File: PsychConstants.h

package info (click to toggle)
psychtoolbox-3 3.0.14.20170103%2Bgit6-g605ff5c.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,044 kB
  • ctags: 69,483
  • sloc: ansic: 167,371; cpp: 11,232; objc: 4,708; sh: 1,875; python: 383; php: 344; makefile: 207; java: 113
file content (181 lines) | stat: -rwxr-xr-x 5,716 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
/*
        Psychtoolbox3/Source/Common/PsychConstants.h            
  
        AUTHORS:
 
        Allen.Ingling@nyu.edu                 awi 
        mario.kleiner@tuebingen.mpg.de        mk
 
        PLATFORMS:      All

        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

#define __STDC_LIMIT_MACROS 1

#if PSYCH_SYSTEM == PSYCH_WINDOWS
// Try to cut down compile time on Windows by only including important headers:
#define WINDOWS_LEAN_AND_MEAN
// Otherwise no math constants like M_PI defined in math.h et al. under MSVC:
#define _USE_MATH_DEFINES

// Some versions of MINGW64 for Windows lack this, causing _putenv_s to be
// undefined.
#ifndef MINGW_HAS_SECURE_API
#define MINGW_HAS_SECURE_API 1
#endif

#endif

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

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

//platform dependent macro defines 
#if PSYCH_SYSTEM == PSYCH_WINDOWS
    // Define snprintf as _snprintf to take Microsoft brain-damage into account:
    #ifndef snprintf
    #define snprintf _snprintf
    #endif

    // MSVC wants _strdup instead of strdup:
    #ifdef _MSC_VER
    #define strdup _strdup
    #endif

#elif PSYCH_SYSTEM == PSYCH_OSX
#elif PSYCH_SYSTEM == PSYCH_LINUX
#endif 

#ifndef FALSE
#define FALSE   0
#define TRUE    1
#endif

#ifndef false
#define false FALSE
#endif

#ifndef true
#define true TRUE
#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 char                            Str255[256];

        // We don't have these types for Linux, so we provide a little hack to
        // make the compiler happy:
        typedef int CGDisplayCount;

        #ifdef PTB_USE_WAYLAND
        // CGDirectDisplayID is typedef'd to a void* connection handle for now:
        typedef void* CGDirectDisplayID;
        #else
        // CGDirectDisplayID is typedef'd to a X11 display connection handle:
        typedef Display* CGDirectDisplayID;
        #endif
        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;

        // The Microsoft Visual C compiler doesn't know about the __func__ keyword, but it knows __FUNCTION__ instead:
        #ifdef _MSC_VER
        #define __func__ __FUNCTION__
        #endif

        // Hack to make compiler happy:
        typedef int CGDisplayCount;
        typedef HDC CGDirectDisplayID;
        typedef int CGDisplayErr;

        // Define missing types on Windows:
        typedef char         Str255[256];
        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_OSX
        typedef UInt8         psych_uint8;
        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
        typedef const mxArray CONSTmxArray;
        #define PsychGenericScriptType mxArray
        typedef mxLogical PsychNativeBooleanType; 
#endif

#define EXP
#ifndef APIENTRY
#define APIENTRY
#endif

//end include once
#endif