File: PsychConstants.h

package info (click to toggle)
psychtoolbox-3 3.0.9%2Bsvn2579.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 63,408 kB
  • sloc: ansic: 73,310; cpp: 11,139; objc: 3,129; sh: 1,669; python: 382; php: 272; makefile: 172; java: 113
file content (277 lines) | stat: -rwxr-xr-x 8,180 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
        Psychtoolbox2/Source/Common/PsychConstants.h            
  
        AUTHORS:
        Allen.Ingling@nyu.edu           awi 
  
        PLATFORMS:      Mac OS 9   

        HISTORY:
        7/16/02         awi     Split off from PsychProject.h
  
        PROJECTS
        7/16/02         awi     MacOS9 Screen.  

        DESCRIPTION:
        PsychConstants.h defines constants which abstract out platform-specific types.  Note
        That all such abstract types are prefixed with "psych_" as in "psych_uint32".   

        This file also includes platform-specific macros
        
        
         
 

*/

//begin include once 
#ifndef PSYCH_IS_INCLUDED_PsychConstants
#define PSYCH_IS_INCLUDED_PsychConstants

// This is obsolete, as PTBOCTAVE is only defined for Octave-2, which we have
// effectively phased out, but leave it here for documentation:
#if !defined(__cplusplus) && !defined(bool)
#ifdef PTBOCTAVE
typedef unsigned char bool;
#endif
#endif

#define __STDC_LIMIT_MACROS 1

//bring in the standard c and system headers 
#include "PsychIncludes.h"

// Define SIZE_MAX if not defined. Mostly for ancient Windows + R11 builds.
#ifndef SIZE_MAX
#define SIZE_MAX (4294967295U)
#endif

#if PSYCH_LANGUAGE == PSYCH_OCTAVE

// Definitions for constants:
#define mxUINT8_CLASS 0
#define mxDOUBLE_CLASS 1
#define mxLOGICAL_CLASS 2

#endif

#if PSYCH_LANGUAGE == PSYCH_MATLAB | PSYCH_LANGUAGE == PSYCH_OCTAVE
	#undef printf
	#define printf mexPrintf
#endif

//platform dependent macro defines 
#if PSYCH_SYSTEM == PSYCH_WINDOWS
        #define FALSE   0
        #define TRUE    1
#elif PSYCH_SYSTEM == PSYCH_OS9
        #define FALSE   0
        #define TRUE    1
#elif PSYCH_SYSTEM == PSYCH_OSX
        #define FALSE   0
        #define TRUE    1
#elif PSYCH_SYSTEM == PSYCH_LINUX
        #define FALSE   0
        #define TRUE    1
#endif 

#ifndef false
#define false FALSE
#endif

#ifndef true
#define true TRUE
#endif

#ifndef GL_TABLE_TOO_LARGE
#define GL_TABLE_TOO_LARGE   0x8031  
#endif
#ifndef GL_TEXTURE_RECTANGLE_EXT
#define GL_TEXTURE_RECTANGLE_EXT 0x84F5
#endif
#ifndef GL_TEXTURE_RECTANGLE_NV
#define GL_TEXTURE_RECTANGLE_NV  0x84F5
#endif
#ifndef GL_UNSIGNED_INT_8_8_8_8
#define GL_UNSIGNED_INT_8_8_8_8  0x8035
#endif
// Define GL_BGRA as GL_BGRA_EXT aka 0x80E1 if it isn''t defined already
#ifndef GL_BGRA
#define GL_BGRA              0x80E1
#endif
#ifndef GL_UNSIGNED_INT_8_8_8_8_REV
#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
#endif
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
#endif
#ifndef GL_SAMPLES_ARB
#define GL_SAMPLES_ARB   0x80A9
#endif
#ifndef GL_SAMPLE_BUFFERS_ARB
#define GL_SAMPLE_BUFFERS_ARB   0x80A8
#endif
#ifndef GL_TEXTURE_DEPTH
#define GL_TEXTURE_DEPTH 0x8071
#endif

#ifndef PTBOCTAVE3MEX
// mwSize is a new type introduced around Matlab R2006b. Define
// it to be an integer on older Matlab releases and other runtime
// environments: (MX_API_VER is defined in Matlabs matrix.h file)
#ifndef MX_API_VER
	// Old Matlab without Mex API version definition:
	#define SELFMADE_MWSIZE 1
#else
	// Matlab with Mex API prior V7.3 (Release 2006b)?
	#if  MX_API_VER < 0x07030000
		#define SELFMADE_MWSIZE 1
	#endif
#endif
#endif

// Do we need to define mwSize ourselves?
#ifdef SELFMADE_MWSIZE
	typedef int mwSize;
	typedef int mwIndex;
#endif

// Define our own base psych_bool type psych_bool to be an unsigned char,
// i.e., 1 byte per value on each platform:
typedef unsigned char		psych_bool;

//abstract up simple data types. 
#if PSYCH_SYSTEM == PSYCH_LINUX
        typedef int64_t                         psych_int64;
        typedef unsigned long long              psych_uint64;
        typedef unsigned int                    psych_uint32;
        typedef unsigned char                   psych_uint8;
        typedef unsigned short                  psych_uint16;
        typedef GLubyte                         ubyte;          
        #if PSYCH_LANGUAGE == PSYCH_OCTAVE
        typedef psych_bool                      mxLogical;
        #endif
        typedef char                            Str255[256];

        // We don't have Quicktime for Linux, so we provide a little hack to
        // make the compiler happy:
        typedef void*                           CVOpenGLTextureRef;
        typedef int CGDisplayCount;
        // CGDirectDisplayID is typedef'd to a X11 display connection handle:
        typedef Display* CGDirectDisplayID;
        typedef int CGDisplayErr;
        typedef unsigned int CFDictionaryRef;
		
		// Datatype for condition variables:
		typedef pthread_cond_t		psych_condition;		
		// Datatype for Mutex Locks:
		typedef pthread_mutex_t		psych_mutex;
		// Datatype for threads:
		typedef pthread_t			psych_thread;
		typedef pthread_t			psych_threadid;		
#endif

#if PSYCH_SYSTEM == PSYCH_WINDOWS
        typedef LONGLONG						psych_int64;
        typedef ULONGLONG                       psych_uint64;
        typedef DWORD                           psych_uint32;
        typedef BYTE                            psych_uint8;
        typedef WORD                            psych_uint16;
        typedef GLubyte                         ubyte;
		#ifndef PTBOCTAVE3MEX
        #ifndef __cplusplus
        typedef psych_bool                      mxLogical;
        #endif
		#endif

        // The Visual C 6 compiler doesn't know about the __func__ keyword :(
        #define __func__ "UNKNOWN"
        // Matlab 5 doesn't know about mxLOGICAL_CLASS :(
        #define mxLOGICAL_CLASS mxUINT8_CLASS
        #define mxGetLogicals(p) ((PsychNativeBooleanType*)mxGetData((p)))
        mxArray* mxCreateNativeBooleanMatrix3D(size_t m, size_t n, size_t p);

        #if PSYCH_LANGUAGE == PSYCH_MATLAB
		#ifndef TARGET_OS_WIN32 
        #define mxCreateLogicalMatrix(m,n) mxCreateNativeBooleanMatrix3D((m), (n), 1)
		#endif
        #endif

        // Hack to make compiler happy until QT7 Windows supports this:
        typedef void*                           CVOpenGLTextureRef;
        typedef int CGDisplayCount;
        typedef HDC CGDirectDisplayID;
        typedef int CGDisplayErr;
        //typedef unsigned int CFDictionaryRef;

		// Datatype for condition variables:
		typedef HANDLE					psych_condition;		
		// Datatype for Mutex Locks:
		typedef CRITICAL_SECTION		psych_mutex;
		// Datatype for threads:
		typedef struct psych_threadstruct {
			HANDLE				handle;			// Handle to actual thread (NULL == Invalid).
			DWORD				threadId;		// Unique numeric id (0 = Invalid.)
			psych_condition		terminateReq;	// Condition/Event object to signal the request for termination.
			HANDLE				taskHandleMMCS; // Handle to task for MMCSS scheduled thread, NULL otherwise.
		} psych_threadstruct;
		typedef struct psych_threadstruct*	psych_thread;

		typedef psych_uint32		psych_threadid;

#elif PSYCH_SYSTEM == PSYCH_OS9
	typedef unsigned long 			psych_uint32;
	typedef Byte					psych_uint8;
	typedef unsigned short 			psych_uint16;
	typedef GLubyte				ubyte;		

#elif PSYCH_SYSTEM == PSYCH_OSX
        #if PSYCH_LANGUAGE == PSYCH_OCTAVE
        typedef psych_bool			mxLogical;
        #endif

        typedef GLubyte				psych_uint8;
        typedef GLubyte				ubyte;
		typedef UInt16				psych_uint16;
        typedef UInt32				psych_uint32;
        typedef unsigned long long	psych_uint64;
        typedef long long			psych_int64;

		// Datatype for condition variables:
		typedef pthread_cond_t		psych_condition;
		// Datatype for Mutex Locks:	
		typedef pthread_mutex_t		psych_mutex;
		// Datatype for threads:
		typedef pthread_t			psych_thread;
		typedef pthread_t			psych_threadid;
#endif


#if PSYCH_LANGUAGE == PSYCH_MATLAB | PSYCH_LANGUAGE == PSYCH_OCTAVE
	typedef const mxArray CONSTmxArray;
        #define PsychGenericScriptType mxArray
        typedef mxLogical PsychNativeBooleanType; 
#endif

//macros
#if PSYCH_SYSTEM == PSYCH_WINDOWS
	#define EXP  //nothing
	
	// Define snprintf as _snprintf to take Microsoft brain-damage into account:
	#ifndef snprintf
	#define snprintf _snprintf
	#endif
	
	// This didn't work with Matlab5:	#define EXP __declspec(dllexport)
#else
	#define EXP  //nothing
#endif
	
#ifndef APIENTRY
#define APIENTRY
#endif

//end include once
#endif