| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 |
| 11 | 11 |
| 12 #ifndef _PTHREAD_EMULATION | 12 #ifndef _PTHREAD_EMULATION |
| 13 #define _PTHREAD_EMULATION | 13 #define _PTHREAD_EMULATION |
| 14 | 14 |
| 15 #define VPXINFINITE 10000 /* 10second. */ | |
| 16 | |
| 17 #if CONFIG_OS_SUPPORT && CONFIG_MULTITHREAD | 15 #if CONFIG_OS_SUPPORT && CONFIG_MULTITHREAD |
| 18 | 16 |
| 19 /* Thread management macros */ | 17 /* Thread management macros */ |
| 20 #ifdef _WIN32 | 18 #ifdef _WIN32 |
| 21 /* Win32 */ | 19 /* Win32 */ |
| 22 #define _WIN32_WINNT 0x500 /* WINBASE.H - Enable signal_object_and_wait */ | 20 #define _WIN32_WINNT 0x500 /* WINBASE.H - Enable signal_object_and_wait */ |
| 23 #include <process.h> | 21 #include <process.h> |
| 24 #include <windows.h> | 22 #include <windows.h> |
| 25 #define THREAD_FUNCTION DWORD WINAPI | 23 #define THREAD_FUNCTION DWORD WINAPI |
| 26 #define THREAD_FUNCTION_RETURN DWORD | 24 #define THREAD_FUNCTION_RETURN DWORD |
| 27 #define THREAD_SPECIFIC_INDEX DWORD | 25 #define THREAD_SPECIFIC_INDEX DWORD |
| 28 #define pthread_t HANDLE | 26 #define pthread_t HANDLE |
| 29 #define pthread_attr_t DWORD | 27 #define pthread_attr_t DWORD |
| 30 #define pthread_create(thhandle,attr,thfunc,tharg) (int)((*thhandle=(HANDLE)_beg
inthreadex(NULL,0,(unsigned int (__stdcall *)(void *))thfunc,tharg,0,NULL))==NUL
L) | 28 #define pthread_create(thhandle,attr,thfunc,tharg) (int)((*thhandle=(HANDLE)_beg
inthreadex(NULL,0,(unsigned int (__stdcall *)(void *))thfunc,tharg,0,NULL))==NUL
L) |
| 31 #define pthread_join(thread, result) ((WaitForSingleObject((thread),VPXINFINITE)
!=WAIT_OBJECT_0) || !CloseHandle(thread)) | 29 #define pthread_join(thread, result) ((WaitForSingleObject((thread),INFINITE)!=W
AIT_OBJECT_0) || !CloseHandle(thread)) |
| 32 #define pthread_detach(thread) if(thread!=NULL)CloseHandle(thread) | 30 #define pthread_detach(thread) if(thread!=NULL)CloseHandle(thread) |
| 33 #define thread_sleep(nms) Sleep(nms) | 31 #define thread_sleep(nms) Sleep(nms) |
| 34 #define pthread_cancel(thread) terminate_thread(thread,0) | 32 #define pthread_cancel(thread) terminate_thread(thread,0) |
| 35 #define ts_key_create(ts_key, destructor) {ts_key = TlsAlloc();}; | 33 #define ts_key_create(ts_key, destructor) {ts_key = TlsAlloc();}; |
| 36 #define pthread_getspecific(ts_key) TlsGetValue(ts_key) | 34 #define pthread_getspecific(ts_key) TlsGetValue(ts_key) |
| 37 #define pthread_setspecific(ts_key, value) TlsSetValue(ts_key, (void *)value) | 35 #define pthread_setspecific(ts_key, value) TlsSetValue(ts_key, (void *)value) |
| 38 #define pthread_self() GetCurrentThreadId() | 36 #define pthread_self() GetCurrentThreadId() |
| 39 #else | 37 #else |
| 40 #ifdef __APPLE__ | 38 #ifdef __APPLE__ |
| 41 #include <mach/mach_init.h> | 39 #include <mach/mach_init.h> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 54 #define THREAD_FUNCTION void * | 52 #define THREAD_FUNCTION void * |
| 55 #define THREAD_FUNCTION_RETURN void * | 53 #define THREAD_FUNCTION_RETURN void * |
| 56 #define THREAD_SPECIFIC_INDEX pthread_key_t | 54 #define THREAD_SPECIFIC_INDEX pthread_key_t |
| 57 #define ts_key_create(ts_key, destructor) pthread_key_create (&(ts_key), destruc
tor); | 55 #define ts_key_create(ts_key, destructor) pthread_key_create (&(ts_key), destruc
tor); |
| 58 #endif | 56 #endif |
| 59 | 57 |
| 60 /* Syncrhronization macros: Win32 and Pthreads */ | 58 /* Syncrhronization macros: Win32 and Pthreads */ |
| 61 #ifdef _WIN32 | 59 #ifdef _WIN32 |
| 62 #define sem_t HANDLE | 60 #define sem_t HANDLE |
| 63 #define pause(voidpara) __asm PAUSE | 61 #define pause(voidpara) __asm PAUSE |
| 64 #define sem_init(sem, sem_attr1, sem_init_value) (int)((*sem = CreateEvent(NULL,
FALSE,FALSE,NULL))==NULL) | 62 #define sem_init(sem, sem_attr1, sem_init_value) (int)((*sem = CreateSemaphore(N
ULL,0,32768,NULL))==NULL) |
| 65 #define sem_wait(sem) (int)(WAIT_OBJECT_0 != WaitForSingleObject(*sem,VPXINFINIT
E)) | 63 #define sem_wait(sem) (int)(WAIT_OBJECT_0 != WaitForSingleObject(*sem,INFINITE)) |
| 66 #define sem_post(sem) SetEvent(*sem) | 64 #define sem_post(sem) ReleaseSemaphore(*sem,1,NULL) |
| 67 #define sem_destroy(sem) if(*sem)((int)(CloseHandle(*sem))==TRUE) | 65 #define sem_destroy(sem) if(*sem)((int)(CloseHandle(*sem))==TRUE) |
| 68 #define thread_sleep(nms) Sleep(nms) | 66 #define thread_sleep(nms) Sleep(nms) |
| 69 | 67 |
| 70 #else | 68 #else |
| 71 | 69 |
| 72 #ifdef __APPLE__ | 70 #ifdef __APPLE__ |
| 73 #define sem_t semaphore_t | 71 #define sem_t semaphore_t |
| 74 #define sem_init(X,Y,Z) semaphore_create(mach_task_self(), X, SYNC_POLICY_FIFO,
Z) | 72 #define sem_init(X,Y,Z) semaphore_create(mach_task_self(), X, SYNC_POLICY_FIFO,
Z) |
| 75 #define sem_wait(sem) (semaphore_wait(*sem) ) | 73 #define sem_wait(sem) (semaphore_wait(*sem) ) |
| 76 #define sem_post(sem) semaphore_signal(*sem) | 74 #define sem_post(sem) semaphore_signal(*sem) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 87 | 85 |
| 88 #if ARCH_X86 || ARCH_X86_64 | 86 #if ARCH_X86 || ARCH_X86_64 |
| 89 #include "vpx_ports/x86.h" | 87 #include "vpx_ports/x86.h" |
| 90 #else | 88 #else |
| 91 #define x86_pause_hint() | 89 #define x86_pause_hint() |
| 92 #endif | 90 #endif |
| 93 | 91 |
| 94 #endif /* CONFIG_OS_SUPPORT && CONFIG_MULTITHREAD */ | 92 #endif /* CONFIG_OS_SUPPORT && CONFIG_MULTITHREAD */ |
| 95 | 93 |
| 96 #endif | 94 #endif |
| OLD | NEW |