diff options
Diffstat (limited to 'include/arch/win32')
-rw-r--r-- | include/arch/win32/apr_arch_misc.h | 17 | ||||
-rw-r--r-- | include/arch/win32/apr_private.h | 2 |
2 files changed, 10 insertions, 9 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; \ diff --git a/include/arch/win32/apr_private.h b/include/arch/win32/apr_private.h index c631ad4..ba0c4d3 100644 --- a/include/arch/win32/apr_private.h +++ b/include/arch/win32/apr_private.h @@ -169,7 +169,7 @@ APR_DECLARE_DATA int errno; /* * Include common private declarations. */ -#include "../apr_private_common.h" +#include "arch/apr_private_common.h" #endif /*APR_PRIVATE_H*/ #endif /*WIN32*/ |