VirtualBox

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

Last change on this file since 39847 was 39602, checked in by vboxsync, 13 years ago

wine/XPDM: 1. Additional swapchain creation fixes 2. De-libwine'ize wined3d 3. Single context per swapchain 4. wine & crOgl current context sync fixes 5. Proper Get/ReleaseDC handling

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
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 <iprt/asm.h>
28/*
29 * Handle for Thread-Specific Data
30 */
31typedef struct {
32#ifdef WINDOWS
33 DWORD key;
34#else
35 pthread_key_t key;
36#endif
37 int initMagic;
38} CRtsd;
39
40
41extern DECLEXPORT(void) crInitTSD(CRtsd *tsd);
42extern DECLEXPORT(void) crInitTSDF(CRtsd *tsd, void (*destructor)(void *));
43extern DECLEXPORT(void) crFreeTSD(CRtsd *tsd);
44extern DECLEXPORT(void) crSetTSD(CRtsd *tsd, void *ptr);
45extern DECLEXPORT(void *) crGetTSD(CRtsd *tsd);
46extern DECLEXPORT(unsigned long) crThreadID(void);
47
48
49/* Mutex datatype */
50#ifdef WINDOWS
51typedef CRITICAL_SECTION CRmutex;
52#else
53typedef pthread_mutex_t CRmutex;
54#endif
55
56extern DECLEXPORT(void) crInitMutex(CRmutex *mutex);
57extern DECLEXPORT(void) crFreeMutex(CRmutex *mutex);
58extern DECLEXPORT(void) crLockMutex(CRmutex *mutex);
59extern DECLEXPORT(void) crUnlockMutex(CRmutex *mutex);
60
61
62/* Condition variable datatype */
63#ifdef WINDOWS
64typedef int CRcondition;
65#else
66typedef pthread_cond_t CRcondition;
67#endif
68
69extern DECLEXPORT(void) crInitCondition(CRcondition *cond);
70extern DECLEXPORT(void) crFreeCondition(CRcondition *cond);
71extern DECLEXPORT(void) crWaitCondition(CRcondition *cond, CRmutex *mutex);
72extern DECLEXPORT(void) crSignalCondition(CRcondition *cond);
73
74
75/* Barrier datatype */
76typedef struct {
77 unsigned int count;
78#ifdef WINDOWS
79 HANDLE hEvents[CR_MAX_CONTEXTS];
80#else
81 unsigned int waiting;
82 pthread_cond_t cond;
83 pthread_mutex_t mutex;
84#endif
85} CRbarrier;
86
87extern DECLEXPORT(void) crInitBarrier(CRbarrier *b, unsigned int count);
88extern DECLEXPORT(void) crFreeBarrier(CRbarrier *b);
89extern DECLEXPORT(void) crWaitBarrier(CRbarrier *b);
90
91
92/* Semaphores */
93#ifdef WINDOWS
94 typedef int CRsemaphore;
95#else
96 typedef sem_t CRsemaphore;
97#endif
98
99extern DECLEXPORT(void) crInitSemaphore(CRsemaphore *s, unsigned int count);
100extern DECLEXPORT(void) crWaitSemaphore(CRsemaphore *s);
101extern DECLEXPORT(void) crSignalSemaphore(CRsemaphore *s);
102
103#define VBoxTlsRefGetImpl(_tls) (crGetTSD((CRtsd*)(_tls)))
104#define VBoxTlsRefSetImpl(_tls, _val) (crSetTSD((CRtsd*)(_tls), (_val)))
105#define VBoxTlsRefAssertImpl CRASSERT
106#include <VBox/VBoxVideo3D.h>
107
108#ifdef __cplusplus
109}
110#endif
111
112#endif /* CR_THREADS_H */
Note: See TracBrowser for help on using the repository browser.

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