VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_threads.h@ 61429

最後變更 在這個檔案從61429是 57421,由 vboxsync 提交於 9 年 前

wrong

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 2.5 KB
 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved.
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#ifndef CR_THREADS_H
8#define CR_THREADS_H
9
10#include <iprt/cdefs.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16#include "chromium.h"
17#include "cr_bits.h"
18
19#ifdef WINDOWS
20#define WIN32_LEAN_AND_MEAN
21#include <windows.h>
22#else
23#include <pthread.h>
24#include <semaphore.h>
25#endif
26
27#include "cr_error.h"
28
29#include <iprt/asm.h>
30/*
31 * Handle for Thread-Specific Data
32 */
33typedef struct {
34#ifdef WINDOWS
35 DWORD key;
36#else
37 pthread_key_t key;
38#endif
39 int initMagic;
40} CRtsd;
41
42
43extern DECLEXPORT(void) crInitTSD(CRtsd *tsd);
44extern DECLEXPORT(void) crInitTSDF(CRtsd *tsd, void (*destructor)(void *));
45extern DECLEXPORT(void) crFreeTSD(CRtsd *tsd);
46extern DECLEXPORT(void) crSetTSD(CRtsd *tsd, void *ptr);
47extern DECLEXPORT(void *) crGetTSD(CRtsd *tsd);
48extern DECLEXPORT(unsigned long) crThreadID(void);
49
50
51/* Mutex datatype */
52#ifdef WINDOWS
53typedef CRITICAL_SECTION CRmutex;
54#else
55typedef pthread_mutex_t CRmutex;
56#endif
57
58extern DECLEXPORT(void) crInitMutex(CRmutex *mutex);
59extern DECLEXPORT(void) crFreeMutex(CRmutex *mutex);
60extern DECLEXPORT(void) crLockMutex(CRmutex *mutex);
61extern DECLEXPORT(void) crUnlockMutex(CRmutex *mutex);
62
63
64/* Condition variable datatype */
65#ifdef WINDOWS
66typedef int CRcondition;
67#else
68typedef pthread_cond_t CRcondition;
69#endif
70
71extern DECLEXPORT(void) crInitCondition(CRcondition *cond);
72extern DECLEXPORT(void) crFreeCondition(CRcondition *cond);
73extern DECLEXPORT(void) crWaitCondition(CRcondition *cond, CRmutex *mutex);
74extern DECLEXPORT(void) crSignalCondition(CRcondition *cond);
75
76
77/* Barrier datatype */
78typedef struct {
79 unsigned int count;
80#ifdef WINDOWS
81 HANDLE hEvents[CR_MAX_CONTEXTS];
82#else
83 unsigned int waiting;
84 pthread_cond_t cond;
85 pthread_mutex_t mutex;
86#endif
87} CRbarrier;
88
89extern DECLEXPORT(void) crInitBarrier(CRbarrier *b, unsigned int count);
90extern DECLEXPORT(void) crFreeBarrier(CRbarrier *b);
91extern DECLEXPORT(void) crWaitBarrier(CRbarrier *b);
92
93
94/* Semaphores */
95#ifdef WINDOWS
96 typedef int CRsemaphore;
97#else
98 typedef sem_t CRsemaphore;
99#endif
100
101extern DECLEXPORT(void) crInitSemaphore(CRsemaphore *s, unsigned int count);
102extern DECLEXPORT(void) crWaitSemaphore(CRsemaphore *s);
103extern DECLEXPORT(void) crSignalSemaphore(CRsemaphore *s);
104
105#define VBoxTlsRefGetImpl(_tls) (crGetTSD((CRtsd*)(_tls)))
106#define VBoxTlsRefSetImpl(_tls, _val) (crSetTSD((CRtsd*)(_tls), (_val)))
107#define VBoxTlsRefAssertImpl CRASSERT
108#include <VBox/VBoxVideo3D.h>
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif /* CR_THREADS_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette