@@ -128,6 +128,89 @@ index 891c5dfd1..9b7b59ab5 100644
128128 {
129129 _gnutls_assert_log("ASSERT: %s[%s]:%d\n", file, func, line);
130130 return val;
131+ diff --git a/lib/global.c b/lib/global.c
132+ index 42d90ee9d..d9290ca69 100644
133+ --- a/lib/global.c
134+ +++ b/lib/global.c
135+ @@ -49,11 +49,12 @@
136+ #ifdef __sun
137+ #pragma fini(lib_deinit)
138+ #pragma init(lib_init)
139+ - #define _CONSTRUCTOR
140+ - #define _DESTRUCTOR
141+ + #define CONSTRUCTOR(f) \
142+ + static void f(void)
143+ #else
144+ - #define _CONSTRUCTOR __attribute__((constructor))
145+ - #define _DESTRUCTOR __attribute__((destructor))
146+ + // this will work for windows or non windows systems
147+ + #define WLB_CONSTRUCTOR_SUPPORT
148+ + #include "../osfixes.h"
149+ #endif
150+
151+ #ifndef _WIN32
152+ @@ -501,7 +502,12 @@ const char *gnutls_check_version(const char *req_version)
153+ return NULL;
154+ }
155+
156+ - static void _CONSTRUCTOR lib_init(void)
157+ +
158+ +
159+ +
160+ +
161+ +
162+ + static void lib_deinit(void)
163+ {
164+ int ret;
165+ const char *e;
166+ @@ -525,29 +531,21 @@ static void _CONSTRUCTOR lib_init(void)
167+ return;
168+ }
169+
170+ - ret = _gnutls_global_init(1);
171+ - if (ret < 0) {
172+ - fprintf(stderr, "Error in GnuTLS initialization: %s\n",
173+ - gnutls_strerror(ret));
174+ - _gnutls_switch_lib_state(LIB_STATE_ERROR);
175+ - }
176+ + _gnutls_global_deinit(1);
177+ }
178+ -
179+ - static void _DESTRUCTOR lib_deinit(void)
180+ + CONSTRUCTOR(lib_init)
181+ {
182+ int ret;
183+ const char *e;
184+ -
185+ if (_gnutls_global_init_skip() != 0)
186+ return;
187+ -
188+ + atexit(lib_deinit);
189+ e = secure_getenv("GNUTLS_NO_IMPLICIT_INIT");
190+ if (e != NULL) {
191+ ret = atoi(e);
192+ if (ret == 1)
193+ return;
194+ }
195+ -
196+ e = secure_getenv("GNUTLS_NO_EXPLICIT_INIT");
197+ if (e != NULL) {
198+ _gnutls_debug_log(
199+ @@ -556,8 +554,12 @@ static void _DESTRUCTOR lib_deinit(void)
200+ if (ret == 1)
201+ return;
202+ }
203+ -
204+ - _gnutls_global_deinit(1);
205+ + ret = _gnutls_global_init(1);
206+ + if (ret < 0) {
207+ + fprintf(stderr, "Error in GnuTLS initialization: %s\n",
208+ + gnutls_strerror(ret));
209+ + _gnutls_switch_lib_state(LIB_STATE_ERROR);
210+ + }
211+ }
212+
213+ static const struct gnutls_library_config_st _gnutls_library_config[] = {
131214diff --git a/lib/x509/verify-high2.c b/lib/x509/verify-high2.c
132215index dc975baeb..208b89d47 100644
133216--- a/lib/x509/verify-high2.c
0 commit comments