Subversion Repositories Games.Prince of Persia

Rev

Rev 1 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 8
Line 1... Line 1...
1
/*
1
/*
2
  Simple DirectMedia Layer
2
  Simple DirectMedia Layer
3
  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4
 
4
 
5
  This software is provided 'as-is', without any express or implied
5
  This software is provided 'as-is', without any express or implied
6
  warranty.  In no event will the authors be held liable for any damages
6
  warranty.  In no event will the authors be held liable for any damages
7
  arising from the use of this software.
7
  arising from the use of this software.
8
 
8
 
Line 52... Line 52...
52
typedef unsigned int SDL_TLSID;
52
typedef unsigned int SDL_TLSID;
53
 
53
 
54
/**
54
/**
55
 *  The SDL thread priority.
55
 *  The SDL thread priority.
56
 *
56
 *
57
 *  \note On many systems you require special privileges to set high priority.
57
 *  \note On many systems you require special privileges to set high or time critical priority.
58
 */
58
 */
59
typedef enum {
59
typedef enum {
60
    SDL_THREAD_PRIORITY_LOW,
60
    SDL_THREAD_PRIORITY_LOW,
61
    SDL_THREAD_PRIORITY_NORMAL,
61
    SDL_THREAD_PRIORITY_NORMAL,
62
    SDL_THREAD_PRIORITY_HIGH
62
    SDL_THREAD_PRIORITY_HIGH,
-
 
63
    SDL_THREAD_PRIORITY_TIME_CRITICAL
63
} SDL_ThreadPriority;
64
} SDL_ThreadPriority;
64
 
65
 
65
/**
66
/**
66
 *  The function passed to SDL_CreateThread().
67
 *  The function passed to SDL_CreateThread().
67
 *  It is passed a void* user context parameter and returns an int.
68
 *  It is passed a void* user context parameter and returns an int.
Line 102... Line 103...
102
 */
103
 */
103
extern DECLSPEC SDL_Thread *SDLCALL
104
extern DECLSPEC SDL_Thread *SDLCALL
104
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
105
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
105
                 pfnSDL_CurrentBeginThread pfnBeginThread,
106
                 pfnSDL_CurrentBeginThread pfnBeginThread,
106
                 pfnSDL_CurrentEndThread pfnEndThread);
107
                 pfnSDL_CurrentEndThread pfnEndThread);
-
 
108
 
-
 
109
extern DECLSPEC SDL_Thread *SDLCALL
-
 
110
SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
-
 
111
                 const char *name, const size_t stacksize, void *data,
-
 
112
                 pfnSDL_CurrentBeginThread pfnBeginThread,
-
 
113
                 pfnSDL_CurrentEndThread pfnEndThread);
-
 
114
 
107
 
115
 
108
/**
116
/**
109
 *  Create a thread.
117
 *  Create a thread.
110
 */
118
 */
111
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
119
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
112
#undef SDL_CreateThread
120
#undef SDL_CreateThread
113
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
121
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
-
 
122
#undef SDL_CreateThreadWithStackSize
-
 
123
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
114
#else
124
#else
115
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
125
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
-
 
126
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
116
#endif
127
#endif
117
 
128
 
118
#elif defined(__OS2__)
129
#elif defined(__OS2__)
119
/*
130
/*
120
 * just like the windows case above:  We compile SDL2
131
 * just like the windows case above:  We compile SDL2
Line 123... Line 134...
123
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
134
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
124
#ifndef __EMX__
135
#ifndef __EMX__
125
#include <process.h>
136
#include <process.h>
126
#else
137
#else
127
#include <stdlib.h>
138
#include <stdlib.h>
128
#endif
139
#endif
129
typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void * /*arg*/);
140
typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void * /*arg*/);
130
typedef void (*pfnSDL_CurrentEndThread)(void);
141
typedef void (*pfnSDL_CurrentEndThread)(void);
131
extern DECLSPEC SDL_Thread *SDLCALL
142
extern DECLSPEC SDL_Thread *SDLCALL
132
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
143
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
-
 
144
                 pfnSDL_CurrentBeginThread pfnBeginThread,
-
 
145
                 pfnSDL_CurrentEndThread pfnEndThread);
-
 
146
extern DECLSPEC SDL_Thread *SDLCALL
-
 
147
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data,
133
                 pfnSDL_CurrentBeginThread pfnBeginThread,
148
                 pfnSDL_CurrentBeginThread pfnBeginThread,
134
                 pfnSDL_CurrentEndThread pfnEndThread);
149
                 pfnSDL_CurrentEndThread pfnEndThread);
135
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
150
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
136
#undef SDL_CreateThread
151
#undef SDL_CreateThread
137
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
152
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
-
 
153
#undef SDL_CreateThreadWithStackSize
-
 
154
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
138
#else
155
#else
139
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
156
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
-
 
157
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
140
#endif
158
#endif
141
 
159
 
142
#else
160
#else
-
 
161
 
-
 
162
/**
-
 
163
 *  Create a thread with a default stack size.
-
 
164
 *
-
 
165
 *  This is equivalent to calling:
-
 
166
 *  SDL_CreateThreadWithStackSize(fn, name, 0, data);
-
 
167
 */
-
 
168
extern DECLSPEC SDL_Thread *SDLCALL
-
 
169
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
143
 
170
 
144
/**
171
/**
145
 *  Create a thread.
172
 *  Create a thread.
146
 *
173
 *
147
 *   Thread naming is a little complicated: Most systems have very small
174
 *   Thread naming is a little complicated: Most systems have very small
Line 156... Line 183...
156
 *    http://stackoverflow.com/questions/149932/naming-conventions-for-threads
183
 *    http://stackoverflow.com/questions/149932/naming-conventions-for-threads
157
 *
184
 *
158
 *   If a system imposes requirements, SDL will try to munge the string for
185
 *   If a system imposes requirements, SDL will try to munge the string for
159
 *    it (truncate, etc), but the original string contents will be available
186
 *    it (truncate, etc), but the original string contents will be available
160
 *    from SDL_GetThreadName().
187
 *    from SDL_GetThreadName().
-
 
188
 *
-
 
189
 *   The size (in bytes) of the new stack can be specified. Zero means "use
-
 
190
 *    the system default" which might be wildly different between platforms
-
 
191
 *    (x86 Linux generally defaults to eight megabytes, an embedded device
-
 
192
 *    might be a few kilobytes instead).
-
 
193
 *
-
 
194
 *   In SDL 2.1, stacksize will be folded into the original SDL_CreateThread
-
 
195
 *    function.
161
 */
196
 */
162
extern DECLSPEC SDL_Thread *SDLCALL
197
extern DECLSPEC SDL_Thread *SDLCALL
163
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
198
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data);
164
 
199
 
165
#endif
200
#endif
166
 
201
 
167
/**
202
/**
168
 * Get the thread name, as it was specified in SDL_CreateThread().
203
 * Get the thread name, as it was specified in SDL_CreateThread().