Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Mark some internal symbols as hidden on ELF in xbt
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 29 Sep 2015 11:57:13 +0000 (13:57 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 1 Oct 2015 09:44:55 +0000 (11:44 +0200)
They are not exported and can avoid the GOT and PLT indirections.

include/xbt/base.h
src/portable.h
src/xbt/dict_private.h
src/xbt/ex_interface.h
src/xbt/graph_private.h
src/xbt/mmalloc/mmprivate.h
src/xbt/setset_private.h

index c1ef5ae..6120dab 100644 (file)
 
 #endif
 
+#ifdef __ELF__
+#define XBT_PRIVATE __attribute__((visibility("hidden")))
+#else
+#define XBT_PRIVATE
+#endif
+
 #ifdef _MSC_VER /* MSVC has no ssize_t, and I fail to use the SSIZE_T declared in BaseTsd.h */
        #if defined(_WIN64)
                typedef __int64 ssize_t;
index 5aca544..d09a1df 100644 (file)
@@ -11,6 +11,7 @@
 #define SIMGRID_PORTABLE_H
 
 #include "internal_config.h"
+#include "xbt/base.h"
 #include "xbt/misc.h"
 #ifdef _XBT_WIN32
 # include <windows.h>
@@ -109,9 +110,9 @@ XBT_PUBLIC(int) vsnprintf(char *, size_t, const char *, va_list);
 
 /* use internal functions when OS provided ones are borken */
 #if defined(HAVE_SNPRINTF) && defined(PREFER_PORTABLE_SNPRINTF)
-extern int portable_snprintf(char *str, size_t str_m, const char *fmt,
+XBT_PRIVATE int portable_snprintf(char *str, size_t str_m, const char *fmt,
                              /*args */ ...);
-extern int portable_vsnprintf(char *str, size_t str_m, const char *fmt,
+XBT_PRIVATE int portable_vsnprintf(char *str, size_t str_m, const char *fmt,
                               va_list ap);
 #define snprintf  portable_snprintf
 #define vsnprintf portable_vsnprintf
index 34eb4d0..7db9869 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef _XBT_DICT_PRIVATE_H__
 #define _XBT_DICT_PRIVATE_H__
 
+#include "xbt/base.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/ex.h"
@@ -36,22 +37,22 @@ typedef struct s_xbt_dict {
 
 typedef struct s_xbt_dict_cursor s_xbt_dict_cursor_t;
 
-extern xbt_mallocator_t dict_elm_mallocator;
-extern void *dict_elm_mallocator_new_f(void);
+extern XBT_PRIVATE xbt_mallocator_t dict_elm_mallocator;
+XBT_PRIVATE void * dict_elm_mallocator_new_f(void);
 #define dict_elm_mallocator_free_f xbt_free_f
 #define dict_elm_mallocator_reset_f ((void_f_pvoid_t)NULL)
 
-extern xbt_mallocator_t dict_het_elm_mallocator;
-extern void *dict_het_elm_mallocator_new_f(void);
+extern XBT_PRIVATE xbt_mallocator_t dict_het_elm_mallocator;
+extern XBT_PRIVATE void * dict_het_elm_mallocator_new_f(void);
 #define dict_het_elm_mallocator_free_f xbt_free_f
 #define dict_het_elm_mallocator_reset_f ((void_f_pvoid_t)NULL)
 
 /*####[ Function prototypes ]################################################*/
-xbt_dictelm_t xbt_dictelm_new(xbt_dict_t dict, const char *key, int key_len,
+XBT_PRIVATE xbt_dictelm_t xbt_dictelm_new(xbt_dict_t dict, const char *key, int key_len,
                               unsigned int hash_code, void *content,
                               void_f_pvoid_t free_f);
-void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element);
-void xbt_dictelm_set_data(xbt_dict_t dict, xbt_dictelm_t element,
+XBT_PRIVATE void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element);
+XBT_PRIVATE void xbt_dictelm_set_data(xbt_dict_t dict, xbt_dictelm_t element,
                           void *data, void_f_pvoid_t free_ctn);
 
 #endif                          /* _XBT_DICT_PRIVATE_H_ */
index 4f510f6..cef5284 100644 (file)
 #ifndef _XBT_EX_INTERFACE_H_
 #define _XBT_EX_INTERFACE_H_
 
+#include "xbt/base.h"
 #include "xbt/ex.h"
 
 /* Change raw libc symbols to file names and line numbers */
-void xbt_ex_setup_backtrace(xbt_ex_t * e);
+XBT_PRIVATE void xbt_ex_setup_backtrace(xbt_ex_t * e);
 
 #endif                          /* _XBT_EX_INTERFACE_H_ */
index 819a11f..aa85f24 100644 (file)
@@ -6,6 +6,8 @@
 
 #ifndef _XBT_GRAPH_PRIVATE_H
 #define _XBT_GRAPH_PRIVATE_H
+
+#include "xbt/base.h"
 #include "xbt/dynar.h"
 #include "xbt/graph.h"
 
@@ -13,9 +15,9 @@
 #define CURRENTLY_EXPLORING 1
 #define ALREADY_EXPLORED 2
 
-void xbt_floyd_algorithm(xbt_graph_t g, double *adj, double *d,
+XBT_PRIVATE void xbt_floyd_algorithm(xbt_graph_t g, double *adj, double *d,
                          xbt_node_t * p);
-void xbt_graph_depth_visit(xbt_graph_t g, xbt_node_t n,
+XBT_PRIVATE void xbt_graph_depth_visit(xbt_graph_t g, xbt_node_t n,
                            xbt_node_t * sorted, int *idx);
 
 #endif                          /* _XBT_GRAPH_PRIVATE_H */
index cb488ac..12441e7 100644 (file)
@@ -14,6 +14,7 @@
 #ifndef __MMPRIVATE_H
 #define __MMPRIVATE_H 1
 
+#include <xbt/base.h>
 #include <xbt/misc.h>
 
 #include "portable.h"
@@ -323,14 +324,14 @@ static inline int mmalloc_get_increment(malloc_info* heapinfo) {
   }
 }
 
-void mmcheck(xbt_mheap_t heap);
+XBT_PRIVATE void mmcheck(xbt_mheap_t heap);
 
-int malloc_use_mmalloc(void);
+XBT_PRIVATE int malloc_use_mmalloc(void);
 
-int mmalloc_exec_using_mm(int argc, const char** argv);
-void mmalloc_ensure_using_mm(int argc, const char** argv);
+XBT_PRIVATE int mmalloc_exec_using_mm(int argc, const char** argv);
+XBT_PRIVATE void mmalloc_ensure_using_mm(int argc, const char** argv);
 
-size_t mmalloc_get_bytes_used_remote(size_t heaplimit, const malloc_info* heapinfo);
+XBT_PRIVATE size_t mmalloc_get_bytes_used_remote(size_t heaplimit, const malloc_info* heapinfo);
 
 SG_END_DECL()
 
index 128db63..3099ed1 100644 (file)
@@ -4,6 +4,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/base.h"
 #include "xbt/dict.h"
 #include "xbt/dynar.h"
 #include "xbt/setset.h"
@@ -44,16 +45,16 @@ typedef struct s_xbt_setset_cursor {
 
 /* Some internal functions */
 
-int bitcount(int);
+XBT_PRIVATE int bitcount(int);
 
 /* Get the object associated to a given index */
-void *_xbt_setset_idx_to_obj(xbt_setset_t setset, unsigned long idx);
+XBT_PRIVATE void *_xbt_setset_idx_to_obj(xbt_setset_t setset, unsigned long idx);
 
 /* Check if the nth bit of an integer is set or not*/
-unsigned int _is_bit_set(unsigned int bit, unsigned int integer);
+XBT_PRIVATE unsigned int _is_bit_set(unsigned int bit, unsigned int integer);
 
 /* Set the nth bit of an array of integers */
-void _set_bit(unsigned int bit, unsigned int *bitmap);
+XBT_PRIVATE void _set_bit(unsigned int bit, unsigned int *bitmap);
 
 /* Unset the nth bit of an array of integers */
-void _unset_bit(unsigned int bit, unsigned int *bitmap);
+XBT_PRIVATE void _unset_bit(unsigned int bit, unsigned int *bitmap);