From 459aa6b42f88d77403682e7b467c6df6d8a80f88 Mon Sep 17 00:00:00 2001 From: Mathis Rosenhauer Date: Fri, 7 Oct 2016 12:26:07 +0200 Subject: Add gcc visibility only for API functions --- configure.ac | 3 +-- src/CMakeLists.txt | 4 ++-- src/Makefile.am | 2 ++ src/decode.c | 2 +- src/decode.h | 2 ++ src/encode.c | 2 +- src/encode.h | 2 ++ src/libaec.h | 30 +++++++++++++++--------------- src/sz_compat.c | 3 +-- src/szlib.h | 18 ++++++++++-------- 10 files changed, 37 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index c044112..eeea8f7 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_CONFIG_SRCDIR([src/libaec.h]) AC_CONFIG_HEADERS(config/config.h) LT_INIT - +gl_VISIBILITY AM_INIT_AUTOMAKE # Checks for programs. @@ -35,5 +35,4 @@ AM_EXTRA_RECURSIVE_TARGETS([bench benc bdec]) AC_CONFIG_FILES([Makefile \ src/Makefile \ tests/Makefile]) - AC_OUTPUT diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 66a04b1..08d03b0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,8 +10,8 @@ SET_TARGET_PROPERTIES(sz PROPERTIES TARGET_LINK_LIBRARIES(sz aec) IF(WIN32 AND BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES (aec PROPERTIES DEFINE_SYMBOL "AECDLL_EXPORTS") - SET_TARGET_PROPERTIES (sz PROPERTIES DEFINE_SYMBOL "AECDLL_EXPORTS") + SET_TARGET_PROPERTIES (aec PROPERTIES DEFINE_SYMBOL "BUILDING_LIBAEC") + SET_TARGET_PROPERTIES (sz PROPERTIES DEFINE_SYMBOL "BUILDING_LIBAEC") SET_TARGET_PROPERTIES(sz PROPERTIES OUTPUT_NAME "szip") ENDIF(WIN32 AND BUILD_SHARED_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index 0374d91..7e2cd69 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,5 @@ +AM_CFLAGS = @CFLAG_VISIBILITY@ +AM_CPPFLAGS = -DBUILDING_LIBAEC lib_LTLIBRARIES = libaec.la libsz.la libaec_la_SOURCES = encode.c encode_accessors.c decode.c \ encode.h encode_accessors.h decode.h diff --git a/src/decode.c b/src/decode.c index 886228b..edb5af1 100644 --- a/src/decode.c +++ b/src/decode.c @@ -52,8 +52,8 @@ #include #include -#include "libaec.h" #include "decode.h" +#include "libaec.h" #if HAVE_BSR64 # include diff --git a/src/decode.h b/src/decode.h index 57622b3..8a45547 100644 --- a/src/decode.h +++ b/src/decode.h @@ -63,6 +63,8 @@ #define MIN(a, b) (((a) < (b))? (a): (b)) +struct aec_stream; + struct internal_state { int (*mode)(struct aec_stream *); diff --git a/src/encode.c b/src/encode.c index 5c0a745..d0b1659 100644 --- a/src/encode.c +++ b/src/encode.c @@ -52,9 +52,9 @@ #include #include -#include "libaec.h" #include "encode.h" #include "encode_accessors.h" +#include "libaec.h" static int m_get_block(struct aec_stream *strm); diff --git a/src/encode.h b/src/encode.h index 750acba..1485941 100644 --- a/src/encode.h +++ b/src/encode.h @@ -68,6 +68,8 @@ /* Marker for Remainder Of Segment condition in zero block encoding */ #define ROS -1 +struct aec_stream; + struct internal_state { int (*mode)(struct aec_stream *); uint32_t (*get_sample)(struct aec_stream *); diff --git a/src/libaec.h b/src/libaec.h index d554776..bb399d9 100644 --- a/src/libaec.h +++ b/src/libaec.h @@ -52,14 +52,14 @@ #include -#if _WIN32 -# ifdef AECDLL_EXPORTS -# define AEC_SCOPE __declspec(dllexport) -# else -# define AEC_SCOPE extern __declspec(dllimport) -# endif +#if BUILDING_LIBAEC && HAVE_VISIBILITY +# define LIBAEC_DLL_EXPORTED __attribute__((__visibility__("default"))) +#elif BUILDING_LIBAEC && defined _MSC_VER +# define LIBAEC_DLL_EXPORTED __declspec(dllexport) +#elif defined _MSC_VER +# define LIBAEC_DLL_EXPORTED __declspec(dllimport) #else -# define AEC_SCOPE extern +# define LIBAEC_DLL_EXPORTED #endif struct internal_state; @@ -151,18 +151,18 @@ struct aec_stream { /*********************************************/ /* Streaming encoding and decoding functions */ /*********************************************/ -AEC_SCOPE int aec_encode_init(struct aec_stream *strm); -AEC_SCOPE int aec_encode(struct aec_stream *strm, int flush); -AEC_SCOPE int aec_encode_end(struct aec_stream *strm); +LIBAEC_DLL_EXPORTED int aec_encode_init(struct aec_stream *strm); +LIBAEC_DLL_EXPORTED int aec_encode(struct aec_stream *strm, int flush); +LIBAEC_DLL_EXPORTED int aec_encode_end(struct aec_stream *strm); -AEC_SCOPE int aec_decode_init(struct aec_stream *strm); -AEC_SCOPE int aec_decode(struct aec_stream *strm, int flush); -AEC_SCOPE int aec_decode_end(struct aec_stream *strm); +LIBAEC_DLL_EXPORTED int aec_decode_init(struct aec_stream *strm); +LIBAEC_DLL_EXPORTED int aec_decode(struct aec_stream *strm, int flush); +LIBAEC_DLL_EXPORTED int aec_decode_end(struct aec_stream *strm); /***************************************************************/ /* Utility functions for encoding or decoding a memory buffer. */ /***************************************************************/ -AEC_SCOPE int aec_buffer_encode(struct aec_stream *strm); -AEC_SCOPE int aec_buffer_decode(struct aec_stream *strm); +LIBAEC_DLL_EXPORTED int aec_buffer_encode(struct aec_stream *strm); +LIBAEC_DLL_EXPORTED int aec_buffer_decode(struct aec_stream *strm); #endif /* LIBAEC_H */ diff --git a/src/sz_compat.c b/src/sz_compat.c index 75fb820..f06c697 100644 --- a/src/sz_compat.c +++ b/src/sz_compat.c @@ -1,11 +1,10 @@ #include #include #include -#include "szlib.h" - #if HAVE_CONFIG_H # include #endif +#include "szlib.h" #define NOPTS 129 #define MIN(a, b) (((a) < (b))? (a): (b)) diff --git a/src/szlib.h b/src/szlib.h index 88480b5..c22362a 100644 --- a/src/szlib.h +++ b/src/szlib.h @@ -31,13 +31,15 @@ typedef struct SZ_com_t_s int pixels_per_scanline; } SZ_com_t; -AEC_SCOPE int SZ_BufftoBuffCompress(void *dest, size_t *destLen, - const void *source, size_t sourceLen, - SZ_com_t *param); -AEC_SCOPE int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, - const void *source, size_t sourceLen, - SZ_com_t *param); - -AEC_SCOPE int SZ_encoder_enabled(void); +LIBAEC_DLL_EXPORTED int SZ_BufftoBuffCompress( + void *dest, size_t *destLen, + const void *source, size_t sourceLen, + SZ_com_t *param); +LIBAEC_DLL_EXPORTED int SZ_BufftoBuffDecompress( + void *dest, size_t *destLen, + const void *source, size_t sourceLen, + SZ_com_t *param); + +LIBAEC_DLL_EXPORTED int SZ_encoder_enabled(void); #endif /* SZLIB_H */ -- cgit v1.2.3