src/thread/SDL_systhread.h
author Ryan C. Gordon <icculus@icculus.org>
Fri, 01 May 2015 01:12:48 -0400
changeset 9580 d37ef6990bf9
parent 8149 681eb46b8ac4
child 9619 b94b6d0bff0f
permissions -rw-r--r--
checkkeys: Readded the KEYUP event test.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
     2
  Simple DirectMedia Layer
8149
681eb46b8ac4 Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents: 8093
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
     7
  arising from the use of this software.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
    11
  freely, subject to the following restrictions:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5509
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    20
*/
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 7978
diff changeset
    21
#include "../SDL_internal.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    23
/* These are functions that need to be implemented by a port of SDL */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    24
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
    25
#ifndef _SDL_systhread_h
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
    26
#define _SDL_systhread_h
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
    27
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
    28
#include "SDL_thread.h"
7730
e928464b98ec Fixed bug 2076 - OpenGL doesn't work with --disable-threads
Sam Lantinga <slouken@libsdl.org>
parents: 7393
diff changeset
    29
#include "SDL_thread_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    30
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    31
/* This function creates a thread, passing args to SDL_RunThread(),
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    32
   saves a system-dependent thread id in thread->id, and returns 0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    33
   on success.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    34
*/
1471
9fb0eee04dd9 Enabled libc support on Win32, so we don't break binary compatibility in 1.2
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    35
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1471
diff changeset
    36
extern int SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1471
diff changeset
    37
                                pfnSDL_CurrentBeginThread pfnBeginThread,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1471
diff changeset
    38
                                pfnSDL_CurrentEndThread pfnEndThread);
1190
173c063d4f55 OS/2 port!
Ryan C. Gordon <icculus@icculus.org>
parents: 769
diff changeset
    39
#else
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1471
diff changeset
    40
extern int SDL_SYS_CreateThread(SDL_Thread * thread, void *args);
1190
173c063d4f55 OS/2 port!
Ryan C. Gordon <icculus@icculus.org>
parents: 769
diff changeset
    41
#endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    42
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    43
/* This function does any necessary setup in the child thread */
5969
3a041d215edc 1.3 API CHANGE: Add support for naming threads.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    44
extern void SDL_SYS_SetupThread(const char *name);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    45
5509
5b1b4d820d10 The API sets the priority for the current thread, not an arbitrary thread.
Sam Lantinga <slouken@libsdl.org>
parents: 5506
diff changeset
    46
/* This function sets the current thread priority */
5b1b4d820d10 The API sets the priority for the current thread, not an arbitrary thread.
Sam Lantinga <slouken@libsdl.org>
parents: 5506
diff changeset
    47
extern int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority);
5506
82a09d5d0f07 Implemented SDL_SetThreadPriority()
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    48
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    49
/* This function waits for the thread to finish and frees any data
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    50
   allocated by SDL_SYS_CreateThread()
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    51
 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1471
diff changeset
    52
extern void SDL_SYS_WaitThread(SDL_Thread * thread);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    53
7978
70ac84e49797 Added SDL_DetachThread() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 7730
diff changeset
    54
/* Mark thread as cleaned up as soon as it exits, without joining. */
70ac84e49797 Added SDL_DetachThread() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 7730
diff changeset
    55
extern void SDL_SYS_DetachThread(SDL_Thread * thread);
70ac84e49797 Added SDL_DetachThread() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 7730
diff changeset
    56
7393
358696c354a8 Added release/acquire memory barriers to the atomic API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    57
/* Get the thread local storage for this thread */
358696c354a8 Added release/acquire memory barriers to the atomic API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    58
extern SDL_TLSData *SDL_SYS_GetTLSData();
358696c354a8 Added release/acquire memory barriers to the atomic API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    59
358696c354a8 Added release/acquire memory barriers to the atomic API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    60
/* Set the thread local storage for this thread */
358696c354a8 Added release/acquire memory barriers to the atomic API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    61
extern int SDL_SYS_SetTLSData(SDL_TLSData *data);
358696c354a8 Added release/acquire memory barriers to the atomic API
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    62
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
    63
#endif /* _SDL_systhread_h */
3579
3427271a2d75 Added SDL_GetCPUCount() to see how many cores are available.
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    64
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1471
diff changeset
    65
/* vi: set ts=4 sw=4 expandtab: */