From 41c803093e7108f16bfb4cc7e2c41c52104c73c2 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Tue, 29 Sep 2015 13:57:13 +0200 Subject: [PATCH 1/1] Mark some internal symbols as hidden on ELF in xbt They are not exported and can avoid the GOT and PLT indirections. --- include/xbt/base.h | 6 ++++++ src/portable.h | 5 +++-- src/xbt/dict_private.h | 15 ++++++++------- src/xbt/ex_interface.h | 3 ++- src/xbt/graph_private.h | 6 ++++-- src/xbt/mmalloc/mmprivate.h | 11 ++++++----- src/xbt/setset_private.h | 11 ++++++----- 7 files changed, 35 insertions(+), 22 deletions(-) diff --git a/include/xbt/base.h b/include/xbt/base.h index c1ef5aeba9..6120dabec4 100644 --- a/include/xbt/base.h +++ b/include/xbt/base.h @@ -246,6 +246,12 @@ #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; diff --git a/src/portable.h b/src/portable.h index 5aca5446e3..d09a1dfc08 100644 --- a/src/portable.h +++ b/src/portable.h @@ -11,6 +11,7 @@ #define SIMGRID_PORTABLE_H #include "internal_config.h" +#include "xbt/base.h" #include "xbt/misc.h" #ifdef _XBT_WIN32 # include @@ -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 diff --git a/src/xbt/dict_private.h b/src/xbt/dict_private.h index 34eb4d0388..7db9869605 100644 --- a/src/xbt/dict_private.h +++ b/src/xbt/dict_private.h @@ -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_ */ diff --git a/src/xbt/ex_interface.h b/src/xbt/ex_interface.h index 4f510f6815..cef5284762 100644 --- a/src/xbt/ex_interface.h +++ b/src/xbt/ex_interface.h @@ -11,9 +11,10 @@ #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_ */ diff --git a/src/xbt/graph_private.h b/src/xbt/graph_private.h index 819a11fc39..aa85f249ff 100644 --- a/src/xbt/graph_private.h +++ b/src/xbt/graph_private.h @@ -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 */ diff --git a/src/xbt/mmalloc/mmprivate.h b/src/xbt/mmalloc/mmprivate.h index cb488ac8fa..12441e7e6d 100644 --- a/src/xbt/mmalloc/mmprivate.h +++ b/src/xbt/mmalloc/mmprivate.h @@ -14,6 +14,7 @@ #ifndef __MMPRIVATE_H #define __MMPRIVATE_H 1 +#include #include #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() diff --git a/src/xbt/setset_private.h b/src/xbt/setset_private.h index 128db6364f..3099ed18d5 100644 --- a/src/xbt/setset_private.h +++ b/src/xbt/setset_private.h @@ -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); -- 2.20.1