From 77437920185e6a5ebbfbabfdc170b1d09446c566 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Mon, 3 Jun 2013 20:51:00 +0530 Subject: [PATCH] Make default symbol visibility to hidden with explicit public visibility specified. Add missing static scope to a few more places. --- .gitignore | 1 + Makefile.in | 4 ++-- pcompress.c | 18 +++++++++--------- ppmd_compress.c | 2 +- utils/cpuid.c | 2 +- utils/cpuid.h | 9 ++++----- utils/utils.h | 8 ++++++++ 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index ff8993b..ef57ec0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ files.lst *.o *.so pcompress +libpcompress* Makefile test.log test/datafiles diff --git a/Makefile.in b/Makefile.in index 0a92d9b..4e24006 100644 --- a/Makefile.in +++ b/Makefile.in @@ -215,8 +215,8 @@ DEBUG_CPPFLAGS = $(COMMON_CPPFLAGS) DEBUG_FPTR_FLAG = RELEASE_LINK = g++ -pthread @LIBBSCGEN_OPT@ @EXTRA_OPT_FLAGS@ -fopenmp -fPIC -RELEASE_COMPILE = gcc -c @EXTRA_OPT_FLAGS@ -fPIC -RELEASE_COMPILE_cpp = g++ -c @EXTRA_OPT_FLAGS@ -fPIC +RELEASE_COMPILE = gcc -c @EXTRA_OPT_FLAGS@ -fPIC -fvisibility=hidden +RELEASE_COMPILE_cpp = g++ -c @EXTRA_OPT_FLAGS@ -fPIC -fvisibility=hidden RELEASE_VEC_FLAGS = $(COMMON_VEC_FLAGS) RELEASE_LOOP_OPTFLAGS = $(COMMON_LOOP_OPTFLAGS) RELEASE_CPPFLAGS = $(COMMON_CPPFLAGS) -DNDEBUG diff --git a/pcompress.c b/pcompress.c index f0e661c..d7afe6b 100644 --- a/pcompress.c +++ b/pcompress.c @@ -78,7 +78,7 @@ static void * writer_thread(void *dat); static int init_algo(pc_ctx_t *pctx, const char *algo, int bail); extern uint32_t lzma_crc32(const uint8_t *buf, uint64_t size, uint32_t crc); -void +void DLL_EXPORT usage(pc_ctx_t *pctx) { fprintf(stderr, @@ -686,7 +686,7 @@ cont: */ #define UNCOMP_BAIL err = 1; goto uncomp_done -int +int DLL_EXPORT start_decompress(pc_ctx_t *pctx, const char *filename, const char *to_filename) { char algorithm[ALGO_SZ]; @@ -1689,7 +1689,7 @@ do_cancel: */ #define COMP_BAIL err = 1; goto comp_done -int +int DLL_EXPORT start_compress(pc_ctx_t *pctx, const char *filename, uint64_t chunksize, int level) { struct wdata w; @@ -2516,7 +2516,7 @@ init_algo(pc_ctx_t *pctx, const char *algo, int bail) /* * Pcompress context handling functions. */ -pc_ctx_t * +pc_ctx_t DLL_EXPORT * create_pc_context(void) { pc_ctx_t *ctx = (pc_ctx_t *)malloc(sizeof (pc_ctx_t)); @@ -2537,7 +2537,7 @@ create_pc_context(void) return (ctx); } -void +void DLL_EXPORT destroy_pc_context(pc_ctx_t *pctx) { if (pctx->do_compress) @@ -2549,7 +2549,7 @@ destroy_pc_context(pc_ctx_t *pctx) slab_cleanup(pctx->hide_mem_stats); } -int +int DLL_EXPORT init_pc_context_argstr(pc_ctx_t *pctx, char *args) { int ac; @@ -2568,7 +2568,7 @@ init_pc_context_argstr(pc_ctx_t *pctx, char *args) return (0); } -int +int DLL_EXPORT init_pc_context(pc_ctx_t *pctx, int argc, char *argv[]) { int opt, num_rem, err, my_optind; @@ -2859,7 +2859,7 @@ init_pc_context(pc_ctx_t *pctx, int argc, char *argv[]) return (0); } -int +int DLL_EXPORT start_pcompress(pc_ctx_t *pctx) { int err; @@ -2877,7 +2877,7 @@ start_pcompress(pc_ctx_t *pctx) /* * Setter functions for various parameters in the context. */ -void +void DLL_EXPORT pc_set_userpw(pc_ctx_t *pctx, unsigned char *pwdata, int pwlen) { pctx->user_pw = pwdata; diff --git a/ppmd_compress.c b/ppmd_compress.c index 8d0e74f..e2cd618 100644 --- a/ppmd_compress.c +++ b/ppmd_compress.c @@ -34,7 +34,7 @@ /* * PPMd model order to working set memory size mappings. */ -unsigned int ppmd8_mem_sz[] = { +static unsigned int ppmd8_mem_sz[] = { (16 << 20), (16 << 20), (32 << 20), diff --git a/utils/cpuid.c b/utils/cpuid.c index 3fe06c7..6a927b3 100644 --- a/utils/cpuid.c +++ b/utils/cpuid.c @@ -62,7 +62,7 @@ #define XOP_FLAG 0x800 #define AES_FLAG 0x2000000 -void +static void exec_cpuid(uint32_t *regs) { #ifdef __GNUC__ diff --git a/utils/cpuid.h b/utils/cpuid.h index 643839e..26edbdf 100644 --- a/utils/cpuid.h +++ b/utils/cpuid.h @@ -14,10 +14,10 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. - * If not, see . + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. + * If not, see . * * moinakg@belenix.org, http://moinakg.wordpress.com/ */ @@ -93,7 +93,6 @@ struct cpu_raw_data_t { char vendor_str[VENDOR_STR_MAX]; }; -void exec_cpuid(uint32_t *regs); void cpuid_get_raw_data(struct cpu_raw_data_t* data); void cpuid_basic_identify(processor_info_t *pc); diff --git a/utils/utils.h b/utils/utils.h index 96f257b..3786940 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -134,6 +134,14 @@ typedef int32_t bsize_t; # endif #endif +#ifdef __GNUC__ +#define DLL_EXPORT __attribute__ ((visibility ("default"))) +#define DLL_LOCAL __attribute__ ((visibility ("hidden"))) +#else +#define DLL_EXPORT +#define DLL_LOCAL +#endif + #define ISP2(x) ((x != 0) && ((x & (~x + 1)) == x)) #ifdef DEBUG_STATS