diff options
author | KO Myung-Hun <komh@chollian.net> | 2014-07-26 14:53:59 +0900 |
---|---|---|
committer | James Zern <jzern@google.com> | 2014-07-29 17:36:39 -0700 |
commit | f9f996b3e2012bcc30e5bdf7a2297b4a46016905 (patch) | |
tree | 54b76e5d295ea4dd60caa82551e17dd625c795f5 /vpx_ports | |
parent | 838b53b9fb639917e1566dc1b5d3714d70556e7e (diff) | |
download | libvpx-f9f996b3e2012bcc30e5bdf7a2297b4a46016905.tar libvpx-f9f996b3e2012bcc30e5bdf7a2297b4a46016905.tar.gz libvpx-f9f996b3e2012bcc30e5bdf7a2297b4a46016905.tar.bz2 libvpx-f9f996b3e2012bcc30e5bdf7a2297b4a46016905.zip |
vpx_once: implement once() for OS/2
Change-Id: I9f736f299490464bbdbb6cd24ee6f5b46ad45ec6
Diffstat (limited to 'vpx_ports')
-rw-r--r-- | vpx_ports/vpx_once.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vpx_ports/vpx_once.h b/vpx_ports/vpx_once.h index 182892acf..bd9eebd64 100644 --- a/vpx_ports/vpx_once.h +++ b/vpx_ports/vpx_once.h @@ -73,6 +73,33 @@ static void once(void (*func)(void)) } +#elif CONFIG_MULTITHREAD && defined(__OS2__) +#define INCL_DOS +#include <os2.h> +static void once(void (*func)(void)) +{ + static int done; + + /* If the initialization is complete, return early. */ + if(done) + return; + + /* Causes all other threads in the process to block themselves + * and give up their time slice. + */ + DosEnterCritSec(); + + if (!done) + { + func(); + done = 1; + } + + /* Restores normal thread dispatching for the current process. */ + DosExitCritSec(); +} + + #elif CONFIG_MULTITHREAD && HAVE_PTHREAD_H #include <pthread.h> static void once(void (*func)(void)) |