diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-11-16 16:25:31 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-11-16 17:26:22 +0100 |
commit | c75fbe4d97c17d2e0ca48bcd72eb5551dbf7a6f4 (patch) | |
tree | 7a7b9c4817de507acf626a7bd9cc798ac12f308c /lib | |
parent | 2b2988bd9c6bb706614252dbab7c3d1e531f48a3 (diff) | |
download | gnutls-c75fbe4d97c17d2e0ca48bcd72eb5551dbf7a6f4.tar.gz |
Added GNUTLS_SKIP_GLOBAL_INIT macro to allow programs skip implicit global initialization
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gnutls_global.c | 12 | ||||
-rw-r--r-- | lib/includes/gnutls/gnutls.h.in | 5 | ||||
-rw-r--r-- | lib/libgnutls.map | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c index 0fc50db196..0d02aabe6b 100644 --- a/lib/gnutls_global.c +++ b/lib/gnutls_global.c @@ -51,6 +51,12 @@ # define _DESTRUCTOR __attribute__((destructor)) #endif +int __attribute__((weak)) gnutls_global_init_skip(void); +int gnutls_global_init_skip(void) +{ + return 0; +} + /* created by asn1c */ extern const ASN1_ARRAY_TYPE gnutls_asn1_tab[]; extern const ASN1_ARRAY_TYPE pkix_asn1_tab[]; @@ -456,6 +462,9 @@ static void _CONSTRUCTOR lib_init(void) int ret; const char *e; + if (gnutls_global_init_skip() != 0) + return; + e = getenv("GNUTLS_NO_EXPLICIT_INIT"); if (e != NULL) { ret = atoi(e); @@ -474,6 +483,9 @@ static void _DESTRUCTOR lib_deinit(void) { const char *e; + if (gnutls_global_init_skip() != 0) + return; + e = getenv("GNUTLS_NO_EXPLICIT_INIT"); if (e != NULL) { int ret = atoi(e); diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index a224035fd1..20ce79b4e9 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -73,6 +73,11 @@ extern "C" { # define _SYM_EXPORT #endif +/* Use the following definition globally in your program to disable + * implicit initialization of gnutls. */ +#define GNUTLS_SKIP_GLOBAL_INIT int gnutls_global_init_skip(void); \ + int gnutls_global_init_skip(void) {return 1;} + /** * gnutls_cipher_algorithm_t: * @GNUTLS_CIPHER_UNKNOWN: Unknown algorithm. diff --git a/lib/libgnutls.map b/lib/libgnutls.map index 841f1468a1..1d7cd5d3fa 100644 --- a/lib/libgnutls.map +++ b/lib/libgnutls.map @@ -1059,6 +1059,7 @@ GNUTLS_3_4 gnutls_pkcs11_copy_pubkey; gnutls_x509_crt_set_subject_unique_id; gnutls_x509_crt_set_issuer_unique_id; + gnutls_global_init_skip; local: *; }; |