summaryrefslogtreecommitdiffstats
path: root/include/arch/win32/apr_arch_misc.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-12 04:59:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-12 04:59:58 +0000
commitb8d375bcb1f462d5af5d1f480b32d7b0038417f6 (patch)
tree93d48ade79cc9d5892f17ff41c33753be6bb0879 /include/arch/win32/apr_arch_misc.h
parentAdding upstream version 1.7.2. (diff)
downloadapr-upstream.tar.xz
apr-upstream.zip
Adding upstream version 1.7.5.upstream/1.7.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/arch/win32/apr_arch_misc.h')
-rw-r--r--include/arch/win32/apr_arch_misc.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/include/arch/win32/apr_arch_misc.h b/include/arch/win32/apr_arch_misc.h
index 4dbe899..3cc91b0 100644
--- a/include/arch/win32/apr_arch_misc.h
+++ b/include/arch/win32/apr_arch_misc.h
@@ -198,15 +198,16 @@ FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal);
*/
#define APR_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \
typedef rettype (calltype *apr_winapi_fpt_##fn) args; \
- static apr_winapi_fpt_##fn apr_winapi_pfn_##fn = NULL; \
- static int apr_winapi_chk_##fn = 0; \
+ static volatile apr_winapi_fpt_##fn apr_winapi_pfn_##fn = (apr_winapi_fpt_##fn) (ULONG_PTR) (-1); \
static APR_INLINE int apr_winapi_ld_##fn(void) \
- { if (apr_winapi_pfn_##fn) return 1; \
- if (apr_winapi_chk_##fn ++) return 0; \
- if (!apr_winapi_pfn_##fn) \
- apr_winapi_pfn_##fn = (apr_winapi_fpt_##fn) \
- apr_load_dll_func(lib, #fn, ord); \
- if (apr_winapi_pfn_##fn) return 1; else return 0; }; \
+ { \
+ apr_winapi_fpt_##fn cached_func = apr_winapi_pfn_##fn; \
+ if (cached_func == (apr_winapi_fpt_##fn) (ULONG_PTR) (-1)) { \
+ cached_func = (apr_winapi_fpt_##fn) apr_load_dll_func(lib, #fn, ord); \
+ /* Pointer-sized writes are atomic on Windows. */ \
+ apr_winapi_pfn_##fn = cached_func; \
+ } \
+ if (cached_func) return 1; else return 0; }; \
static APR_INLINE rettype apr_winapi_##fn args \
{ if (apr_winapi_ld_##fn()) \
return (*(apr_winapi_pfn_##fn)) names; \