| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 */ | 66 */ |
| 67 if(!InterlockedDecrement(&waiters)) | 67 if(!InterlockedDecrement(&waiters)) |
| 68 { | 68 { |
| 69 DeleteCriticalSection(lock); | 69 DeleteCriticalSection(lock); |
| 70 free(lock); | 70 free(lock); |
| 71 lock = NULL; | 71 lock = NULL; |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 #elif CONFIG_MULTITHREAD && defined(__OS2__) |
| 77 #define INCL_DOS |
| 78 #include <os2.h> |
| 79 static void once(void (*func)(void)) |
| 80 { |
| 81 static int done; |
| 82 |
| 83 /* If the initialization is complete, return early. */ |
| 84 if(done) |
| 85 return; |
| 86 |
| 87 /* Causes all other threads in the process to block themselves |
| 88 * and give up their time slice. |
| 89 */ |
| 90 DosEnterCritSec(); |
| 91 |
| 92 if (!done) |
| 93 { |
| 94 func(); |
| 95 done = 1; |
| 96 } |
| 97 |
| 98 /* Restores normal thread dispatching for the current process. */ |
| 99 DosExitCritSec(); |
| 100 } |
| 101 |
| 102 |
| 76 #elif CONFIG_MULTITHREAD && HAVE_PTHREAD_H | 103 #elif CONFIG_MULTITHREAD && HAVE_PTHREAD_H |
| 77 #include <pthread.h> | 104 #include <pthread.h> |
| 78 static void once(void (*func)(void)) | 105 static void once(void (*func)(void)) |
| 79 { | 106 { |
| 80 static pthread_once_t lock = PTHREAD_ONCE_INIT; | 107 static pthread_once_t lock = PTHREAD_ONCE_INIT; |
| 81 pthread_once(&lock, func); | 108 pthread_once(&lock, func); |
| 82 } | 109 } |
| 83 | 110 |
| 84 | 111 |
| 85 #else | 112 #else |
| 86 /* No-op version that performs no synchronization. vp8_rtcd() is idempotent, | 113 /* No-op version that performs no synchronization. vp8_rtcd() is idempotent, |
| 87 * so as long as your platform provides atomic loads/stores of pointers | 114 * so as long as your platform provides atomic loads/stores of pointers |
| 88 * no synchronization is strictly necessary. | 115 * no synchronization is strictly necessary. |
| 89 */ | 116 */ |
| 90 | 117 |
| 91 static void once(void (*func)(void)) | 118 static void once(void (*func)(void)) |
| 92 { | 119 { |
| 93 static int done; | 120 static int done; |
| 94 | 121 |
| 95 if(!done) | 122 if(!done) |
| 96 { | 123 { |
| 97 func(); | 124 func(); |
| 98 done = 1; | 125 done = 1; |
| 99 } | 126 } |
| 100 } | 127 } |
| 101 #endif | 128 #endif |
| 102 | 129 |
| 103 #endif // VPX_PORTS_VPX_ONCE_H_ | 130 #endif // VPX_PORTS_VPX_ONCE_H_ |
| OLD | NEW |