diff options
author | Simon Josefsson <simon@josefsson.org> | 2009-03-04 17:38:15 +0100 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2009-03-04 17:38:15 +0100 |
commit | 4844b4ebb0fa4c9c8acf8aaa55deabc69579e0ea (patch) | |
tree | 09b7c0a85c0b4cb269609ac12b31e15ef50ba2f8 /lib | |
parent | d8ec4e76435caa40932c61611be2cedfa811afe3 (diff) | |
download | libtasn1-4844b4ebb0fa4c9c8acf8aaa55deabc69579e0ea.tar.gz libtasn1-4844b4ebb0fa4c9c8acf8aaa55deabc69579e0ea.tar.bz2 libtasn1-4844b4ebb0fa4c9c8acf8aaa55deabc69579e0ea.zip |
Use -fvisibility=hidden and mark public APIs explicitly.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.am | 6 | ||||
-rw-r--r-- | lib/gllib/Makefile.am | 12 | ||||
-rw-r--r-- | lib/glm4/gnulib-cache.m4 | 3 | ||||
-rw-r--r-- | lib/glm4/gnulib-comp.m4 | 2 | ||||
-rw-r--r-- | lib/glm4/visibility.m4 | 52 | ||||
-rw-r--r-- | lib/libtasn1.h | 76 |
6 files changed, 116 insertions, 35 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 10e4ce3..ae1988b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -18,8 +18,8 @@ SUBDIRS = gllib -AM_CFLAGS = $(WARN_CFLAGS) -AM_CPPFLAGS = -I$(builddir)/gllib +AM_CFLAGS = $(WARN_CFLAGS) $(CFLAG_VISIBILITY) +AM_CPPFLAGS = -I$(builddir)/gllib -DASN1_BUILDING include_HEADERS = libtasn1.h @@ -51,4 +51,6 @@ libtasn1_la_LDFLAGS = \ if HAVE_LD_VERSION_SCRIPT libtasn1_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtasn1.map +else +libtasn1_la_LDFLAGS += -export-symbols-regex '^asn1.*' endif diff --git a/lib/gllib/Makefile.am b/lib/gllib/Makefile.am index f1d852e..a045718 100644 --- a/lib/gllib/Makefile.am +++ b/lib/gllib/Makefile.am @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=dummy --lgpl=2 --libtool --macro-prefix=lgl --no-vc-files ld-version-script stdint +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=dummy --lgpl=2 --libtool --macro-prefix=lgl --no-vc-files ld-version-script stdint visibility AUTOMAKE_OPTIONS = 1.5 gnits @@ -87,6 +87,16 @@ EXTRA_DIST += stdint.in.h ## end gnulib module stdint +## begin gnulib module visibility + +# The value of $(CFLAG_VISIBILITY) needs to be added to the CFLAGS for the +# compilation of all sources that make up the library. This line here does it +# only for the gnulib part of it. The developer is responsible for adding +# $(CFLAG_VISIBILITY) to the Makefile.ams of the other portions of the library. +AM_CFLAGS += $(CFLAG_VISIBILITY) + +## end gnulib module visibility + ## begin gnulib module wchar BUILT_SOURCES += $(WCHAR_H) diff --git a/lib/glm4/gnulib-cache.m4 b/lib/glm4/gnulib-cache.m4 index 3c1d474..de4581f 100644 --- a/lib/glm4/gnulib-cache.m4 +++ b/lib/glm4/gnulib-cache.m4 @@ -15,13 +15,14 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=dummy --lgpl=2 --libtool --macro-prefix=lgl --no-vc-files ld-version-script stdint +# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=dummy --lgpl=2 --libtool --macro-prefix=lgl --no-vc-files ld-version-script stdint visibility # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) gl_MODULES([ ld-version-script stdint + visibility ]) gl_AVOID([dummy]) gl_SOURCE_BASE([lib/gllib]) diff --git a/lib/glm4/gnulib-comp.m4 b/lib/glm4/gnulib-comp.m4 index 435a364..79e80fe 100644 --- a/lib/glm4/gnulib-comp.m4 +++ b/lib/glm4/gnulib-comp.m4 @@ -43,6 +43,7 @@ AC_DEFUN([lgl_INIT], gl_LD_VERSION_SCRIPT AC_REQUIRE([gl_MULTIARCH]) gl_STDINT_H + gl_VISIBILITY gl_WCHAR_H m4_ifval(lgl_LIBSOURCES_LIST, [ m4_syscmd([test ! -d ]m4_defn([lgl_LIBSOURCES_DIR])[ || @@ -182,6 +183,7 @@ AC_DEFUN([lgl_FILE_LIST], [ m4/longlong.m4 m4/multiarch.m4 m4/stdint.m4 + m4/visibility.m4 m4/wchar.m4 m4/wint_t.m4 ]) diff --git a/lib/glm4/visibility.m4 b/lib/glm4/visibility.m4 new file mode 100644 index 0000000..70bca56 --- /dev/null +++ b/lib/glm4/visibility.m4 @@ -0,0 +1,52 @@ +# visibility.m4 serial 2 (gettext-0.18) +dnl Copyright (C) 2005, 2008 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Tests whether the compiler supports the command-line option +dnl -fvisibility=hidden and the function and variable attributes +dnl __attribute__((__visibility__("hidden"))) and +dnl __attribute__((__visibility__("default"))). +dnl Does *not* test for __visibility__("protected") - which has tricky +dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on +dnl MacOS X. +dnl Does *not* test for __visibility__("internal") - which has processor +dnl dependent semantics. +dnl Does *not* test for #pragma GCC visibility push(hidden) - which is +dnl "really only recommended for legacy code". +dnl Set the variable CFLAG_VISIBILITY. +dnl Defines and sets the variable HAVE_VISIBILITY. + +AC_DEFUN([gl_VISIBILITY], +[ + AC_REQUIRE([AC_PROG_CC]) + CFLAG_VISIBILITY= + HAVE_VISIBILITY=0 + if test -n "$GCC"; then + AC_MSG_CHECKING([for simple visibility declarations]) + AC_CACHE_VAL([gl_cv_cc_visibility], [ + gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fvisibility=hidden" + AC_TRY_COMPILE( + [extern __attribute__((__visibility__("hidden"))) int hiddenvar; + extern __attribute__((__visibility__("default"))) int exportedvar; + extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); + extern __attribute__((__visibility__("default"))) int exportedfunc (void);], + [], + [gl_cv_cc_visibility=yes], + [gl_cv_cc_visibility=no]) + CFLAGS="$gl_save_CFLAGS"]) + AC_MSG_RESULT([$gl_cv_cc_visibility]) + if test $gl_cv_cc_visibility = yes; then + CFLAG_VISIBILITY="-fvisibility=hidden" + HAVE_VISIBILITY=1 + fi + fi + AC_SUBST([CFLAG_VISIBILITY]) + AC_SUBST([HAVE_VISIBILITY]) + AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], + [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) +]) diff --git a/lib/libtasn1.h b/lib/libtasn1.h index 22a9608..071938a 100644 --- a/lib/libtasn1.h +++ b/lib/libtasn1.h @@ -24,6 +24,18 @@ #ifndef LIBTASN1_H # define LIBTASN1_H +# ifndef ASN1_API +# if defined ASN1_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY +# define ASN1_API __attribute__((__visibility__("default"))) +# elif defined ASN1_BUILDING && defined _MSC_VER && ! defined ASN1_STATIC +# define ASN1_API __declspec(dllexport) +# elif defined _MSC_VER && ! defined ASN1_STATIC +# define ASN1_API __declspec(dllimport) +# else +# define ASN1_API +# endif +# endif + #include <stdio.h> /* for FILE* */ #include <sys/types.h> #include <time.h> @@ -131,106 +143,108 @@ extern "C" asn1_retCode asn1_parser2tree (const char *file_name, ASN1_TYPE * definitions, - char *errorDescription); + char *errorDescription) ASN1_API; asn1_retCode asn1_parser2array (const char *inputFileName, const char *outputFileName, const char *vectorName, - char *errorDescription); + char *errorDescription) ASN1_API; asn1_retCode asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions, - char *errorDescription); + char *errorDescription) ASN1_API; void asn1_print_structure (FILE * out, ASN1_TYPE structure, - const char *name, int mode); + const char *name, int mode) ASN1_API; asn1_retCode asn1_create_element (ASN1_TYPE definitions, const char *source_name, - ASN1_TYPE * element); + ASN1_TYPE * element) ASN1_API; - asn1_retCode asn1_delete_structure (ASN1_TYPE * structure); + asn1_retCode asn1_delete_structure (ASN1_TYPE * structure) ASN1_API; asn1_retCode asn1_delete_element (ASN1_TYPE structure, - const char *element_name); + const char *element_name) ASN1_API; asn1_retCode asn1_write_value (ASN1_TYPE node_root, const char *name, - const void *ivalue, int len); + const void *ivalue, int len) ASN1_API; asn1_retCode asn1_read_value (ASN1_TYPE root, const char *name, - void *ivalue, int *len); + void *ivalue, int *len) ASN1_API; asn1_retCode asn1_number_of_elements (ASN1_TYPE element, const char *name, - int *num); + int *num) ASN1_API; asn1_retCode asn1_der_coding (ASN1_TYPE element, const char *name, - void *ider, int *len, char *ErrorDescription); + void *ider, int *len, + char *ErrorDescription) ASN1_API; asn1_retCode asn1_der_decoding (ASN1_TYPE * element, const void *ider, - int len, char *errorDescription); + int len, char *errorDescription) ASN1_API; asn1_retCode asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, const void *ider, int len, - char *errorDescription); + char *errorDescription) ASN1_API; asn1_retCode asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, const char *name_element, - int *start, int *end); + int *start, int *end) ASN1_API; asn1_retCode asn1_expand_any_defined_by (ASN1_TYPE definitions, - ASN1_TYPE * element); + ASN1_TYPE * element) ASN1_API; asn1_retCode asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element, const char *octetName, - const char *objectName); + const char *objectName) ASN1_API; asn1_retCode asn1_read_tag (ASN1_TYPE root, const char *name, - int *tagValue, int *classValue); + int *tagValue, int *classValue) ASN1_API; const char *asn1_find_structure_from_oid (ASN1_TYPE definitions, - const char *oidValue); + const char *oidValue) ASN1_API; - const char *asn1_check_version (const char *req_version); + const char *asn1_check_version (const char *req_version) ASN1_API; - const char *asn1_strerror (asn1_retCode error); - void asn1_perror (asn1_retCode error); + const char *asn1_strerror (asn1_retCode error) ASN1_API; + void asn1_perror (asn1_retCode error) ASN1_API; /* DER utility functions. */ int asn1_get_tag_der (const unsigned char *der, int der_len, - unsigned char *cls, int *len, unsigned long *tag); + unsigned char *cls, int *len, + unsigned long *tag) ASN1_API; void asn1_octet_der (const unsigned char *str, int str_len, - unsigned char *der, int *der_len); + unsigned char *der, int *der_len) ASN1_API; asn1_retCode asn1_get_octet_der (const unsigned char *der, int der_len, int *ret_len, unsigned char *str, - int str_size, int *str_len); + int str_size, int *str_len) ASN1_API; void asn1_bit_der (const unsigned char *str, int bit_len, - unsigned char *der, int *der_len); + unsigned char *der, int *der_len) ASN1_API; asn1_retCode asn1_get_bit_der (const unsigned char *der, int der_len, int *ret_len, unsigned char *str, - int str_size, int *bit_len); + int str_size, int *bit_len) ASN1_API; signed long asn1_get_length_der (const unsigned char *der, int der_len, - int *len); + int *len) ASN1_API; signed long asn1_get_length_ber (const unsigned char *ber, int ber_len, - int *len); + int *len) ASN1_API; void asn1_length_der (unsigned long int len, unsigned char *ans, - int *ans_len); + int *ans_len) ASN1_API; /* Other utility functions. */ - ASN1_TYPE asn1_find_node (ASN1_TYPE pointer, const char *name); + ASN1_TYPE asn1_find_node (ASN1_TYPE pointer, const char *name) ASN1_API; asn1_retCode asn1_copy_node (ASN1_TYPE dst, const char *dst_name, - ASN1_TYPE src, const char *src_name); + ASN1_TYPE src, const char *src_name) ASN1_API; #ifdef __cplusplus } |