diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-10-10 10:45:44 +0300 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-10-10 10:45:44 +0300 |
commit | 9d6873a43d2085e64651ffe9bf343d0dde182e93 (patch) | |
tree | e95b937bf97287debef3066cb5c9631ca180efc1 /compat/w32pthreads.h | |
parent | 89da893c880d872c6615308d3223e755c3fc8dd2 (diff) | |
parent | 2830bce47e2eb29c76202f19017031ddc1f95dd3 (diff) |
Merge commit '2830bce47e2eb29c76202f19017031ddc1f95dd3'
* commit '2830bce47e2eb29c76202f19017031ddc1f95dd3':
w32pthreads: Load dynamically loaded functions on demand
Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'compat/w32pthreads.h')
-rw-r--r-- | compat/w32pthreads.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h index 700a726e87..2aff72ae99 100644 --- a/compat/w32pthreads.h +++ b/compat/w32pthreads.h @@ -168,6 +168,11 @@ static inline int pthread_cond_signal(pthread_cond_t *cond) } #else // _WIN32_WINNT < 0x0600 + +/* atomic init state of dynamically loaded functions */ +static LONG w32thread_init_state = 0; +static av_unused void w32thread_init(void); + /* for pre-Windows 6.0 platforms, define INIT_ONCE struct, * compatible to the one used in the native API */ @@ -208,6 +213,8 @@ static inline void w32thread_once_fallback(LONG volatile *state, void (*init_rou static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) { + w32thread_once_fallback(&w32thread_init_state, w32thread_init); + /* Use native functions on Windows 6.0+ */ if (initonce_begin && initonce_complete) { BOOL pending = FALSE; @@ -244,6 +251,9 @@ static BOOL (WINAPI *cond_wait)(pthread_cond_t *cond, pthread_mutex_t *mutex, static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) { win32_cond_t *win32_cond = NULL; + + w32thread_once_fallback(&w32thread_init_state, w32thread_init); + if (cond_init) { cond_init(cond); return 0; |