VirtualBox

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

Last change on this file since 69474 was 69474, checked in by vboxsync, 7 years ago

*: scm updates - header files should have 'svn:keywords=Id Revision' too (doesn't mean they have to use them).

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