VirtualBox

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

Last change on this file since 32375 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 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
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
104#ifdef __cplusplus
105}
106#endif
107
108#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