include/SDL_thread.h
changeset 1895 c121d94672cb
parent 1850 d5d3a6fe05a1
child 2049 5f6550e5184f
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
    21 */
    21 */
    22 
    22 
    23 #ifndef _SDL_thread_h
    23 #ifndef _SDL_thread_h
    24 #define _SDL_thread_h
    24 #define _SDL_thread_h
    25 
    25 
    26 /* Header for the SDL thread management routines 
    26 /**
    27 
    27  * \file SDL_thread.h
    28 	These are independent of the other SDL routines.
    28  *
    29 */
    29  * Header for the SDL thread management routines 
       
    30  */
    30 
    31 
    31 #include "SDL_stdinc.h"
    32 #include "SDL_stdinc.h"
    32 #include "SDL_error.h"
    33 #include "SDL_error.h"
    33 
    34 
    34 /* Thread synchronization primitives */
    35 /* Thread synchronization primitives */
    35 #include "SDL_mutex.h"
    36 #include "SDL_mutex.h"
    36 
    37 
    37 #include "begin_code.h"
    38 #include "begin_code.h"
    38 /* Set up for C function definitions, even when using C++ */
    39 /* Set up for C function definitions, even when using C++ */
    39 #ifdef __cplusplus
    40 #ifdef __cplusplus
       
    41 /* *INDENT-OFF* */
    40 extern "C" {
    42 extern "C" {
       
    43 /* *INDENT-ON* */
    41 #endif
    44 #endif
    42 
    45 
    43 /* The SDL thread structure, defined in SDL_thread.c */
    46 /* The SDL thread structure, defined in SDL_thread.c */
    44 struct SDL_Thread;
    47 struct SDL_Thread;
    45 typedef struct SDL_Thread SDL_Thread;
    48 typedef struct SDL_Thread SDL_Thread;
    59    So, in short:
    62    So, in short:
    60    Always use the _beginthread() and _endthread() of the calling runtime library!
    63    Always use the _beginthread() and _endthread() of the calling runtime library!
    61 */
    64 */
    62 #define SDL_PASSED_BEGINTHREAD_ENDTHREAD
    65 #define SDL_PASSED_BEGINTHREAD_ENDTHREAD
    63 #ifndef _WIN32_WCE
    66 #ifndef _WIN32_WCE
    64 #include <process.h> /* This has _beginthread() and _endthread() defined! */
    67 #include <process.h>            /* This has _beginthread() and _endthread() defined! */
    65 #endif
    68 #endif
    66 
    69 
    67 #ifdef __OS2__
    70 #ifdef __OS2__
    68 typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg); 
    71 typedef int (*pfnSDL_CurrentBeginThread) (void (*func) (void *), void *,
    69 typedef void (*pfnSDL_CurrentEndThread)(void);
    72                                           unsigned, void *arg);
       
    73 typedef void (*pfnSDL_CurrentEndThread) (void);
    70 #elif __GNUC__
    74 #elif __GNUC__
    71 typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
    75 typedef unsigned long (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
    72         unsigned (__stdcall *func)(void *), void *arg, 
    76                                                              unsigned
    73         unsigned, unsigned *threadID);
    77                                                              (__stdcall *
    74 typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
    78                                                               func) (void *),
       
    79                                                              void *arg,
       
    80                                                              unsigned,
       
    81                                                              unsigned
       
    82                                                              *threadID);
       
    83 typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
    75 #else
    84 #else
    76 typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
    85 typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
    77         unsigned (__stdcall *func)(void *), void *arg, 
    86                                                         unsigned (__stdcall *
    78         unsigned, unsigned *threadID);
    87                                                                   func) (void
    79 typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
    88                                                                          *),
       
    89                                                         void *arg, unsigned,
       
    90                                                         unsigned *threadID);
       
    91 typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
    80 #endif
    92 #endif
    81 
    93 
    82 extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
    94 extern DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int (*fn) (void *),
       
    95                                                      void *data,
       
    96                                                      pfnSDL_CurrentBeginThread
       
    97                                                      pfnBeginThread,
       
    98                                                      pfnSDL_CurrentEndThread
       
    99                                                      pfnEndThread);
    83 
   100 
    84 #ifdef __OS2__
   101 #ifdef __OS2__
    85 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
   102 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
    86 #elif defined(_WIN32_WCE)
   103 #elif defined(_WIN32_WCE)
    87 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
   104 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
    88 #else
   105 #else
    89 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
   106 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
    90 #endif
   107 #endif
    91 #else
   108 #else
    92 extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
   109 extern DECLSPEC SDL_Thread *SDLCALL
       
   110 SDL_CreateThread(int (SDLCALL * fn) (void *), void *data);
    93 #endif
   111 #endif
    94 
   112 
    95 /* Get the 32-bit thread identifier for the current thread */
   113 /* Get the 32-bit thread identifier for the current thread */
    96 extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void);
   114 extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void);
    97 
   115 
    98 /* Get the 32-bit thread identifier for the specified thread,
   116 /* Get the 32-bit thread identifier for the specified thread,
    99    equivalent to SDL_ThreadID() if the specified thread is NULL.
   117    equivalent to SDL_ThreadID() if the specified thread is NULL.
   100  */
   118  */
   101 extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread);
   119 extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread * thread);
   102 
   120 
   103 /* Wait for a thread to finish.
   121 /* Wait for a thread to finish.
   104    The return code for the thread function is placed in the area
   122    The return code for the thread function is placed in the area
   105    pointed to by 'status', if 'status' is not NULL.
   123    pointed to by 'status', if 'status' is not NULL.
   106  */
   124  */
   107 extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status);
   125 extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status);
   108 
   126 
   109 /* Forcefully kill a thread without worrying about its state */
   127 /* Forcefully kill a thread without worrying about its state */
   110 extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread);
   128 extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread * thread);
   111 
   129 
   112 
   130 
   113 /* Ends C function definitions when using C++ */
   131 /* Ends C function definitions when using C++ */
   114 #ifdef __cplusplus
   132 #ifdef __cplusplus
       
   133 /* *INDENT-OFF* */
   115 }
   134 }
       
   135 /* *INDENT-ON* */
   116 #endif
   136 #endif
   117 #include "close_code.h"
   137 #include "close_code.h"
   118 
   138 
   119 #endif /* _SDL_thread_h */
   139 #endif /* _SDL_thread_h */
       
   140 
       
   141 /* vi: set ts=4 sw=4 expandtab: */