gosu 1.3.0 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependencies/SDL/include/SDL.h +108 -14
- data/dependencies/SDL/include/SDL_assert.h +81 -50
- data/dependencies/SDL/include/SDL_atomic.h +135 -35
- data/dependencies/SDL/include/SDL_audio.h +960 -355
- data/dependencies/SDL/include/SDL_bits.h +11 -6
- data/dependencies/SDL/include/SDL_blendmode.h +91 -14
- data/dependencies/SDL/include/SDL_clipboard.h +30 -7
- data/dependencies/SDL/include/SDL_config.h +277 -27
- data/dependencies/SDL/include/SDL_config_android.h +13 -38
- data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
- data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
- data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
- data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
- data/dependencies/SDL/include/SDL_config_psp.h +16 -37
- data/dependencies/SDL/include/SDL_config_windows.h +28 -91
- data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
- data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
- data/dependencies/SDL/include/SDL_copying.h +1 -1
- data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
- data/dependencies/SDL/include/SDL_egl.h +906 -280
- data/dependencies/SDL/include/SDL_endian.h +101 -47
- data/dependencies/SDL/include/SDL_error.h +70 -19
- data/dependencies/SDL/include/SDL_events.h +387 -79
- data/dependencies/SDL/include/SDL_filesystem.h +73 -64
- data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
- data/dependencies/SDL/include/SDL_gesture.h +36 -6
- data/dependencies/SDL/include/SDL_haptic.h +304 -210
- data/dependencies/SDL/include/SDL_hidapi.h +451 -0
- data/dependencies/SDL/include/SDL_hints.h +1286 -897
- data/dependencies/SDL/include/SDL_joystick.h +577 -130
- data/dependencies/SDL/include/SDL_keyboard.h +162 -63
- data/dependencies/SDL/include/SDL_keycode.h +7 -5
- data/dependencies/SDL/include/SDL_loadso.h +42 -8
- data/dependencies/SDL/include/SDL_locale.h +34 -32
- data/dependencies/SDL/include/SDL_log.h +212 -19
- data/dependencies/SDL/include/SDL_main.h +72 -17
- data/dependencies/SDL/include/SDL_messagebox.h +70 -23
- data/dependencies/SDL/include/SDL_metal.h +27 -32
- data/dependencies/SDL/include/SDL_misc.h +19 -15
- data/dependencies/SDL/include/SDL_mouse.h +262 -110
- data/dependencies/SDL/include/SDL_mutex.h +286 -66
- data/dependencies/SDL/include/SDL_name.h +1 -1
- data/dependencies/SDL/include/SDL_opengl.h +1 -1
- data/dependencies/SDL/include/SDL_opengles.h +1 -1
- data/dependencies/SDL/include/SDL_opengles2.h +2 -2
- data/dependencies/SDL/include/SDL_pixels.h +199 -34
- data/dependencies/SDL/include/SDL_platform.h +39 -2
- data/dependencies/SDL/include/SDL_power.h +23 -10
- data/dependencies/SDL/include/SDL_quit.h +1 -1
- data/dependencies/SDL/include/SDL_rect.h +78 -28
- data/dependencies/SDL/include/SDL_render.h +1204 -472
- data/dependencies/SDL/include/SDL_revision.h +2 -2
- data/dependencies/SDL/include/SDL_rwops.h +605 -33
- data/dependencies/SDL/include/SDL_scancode.h +1 -1
- data/dependencies/SDL/include/SDL_sensor.h +76 -42
- data/dependencies/SDL/include/SDL_shape.h +38 -27
- data/dependencies/SDL/include/SDL_stdinc.h +96 -24
- data/dependencies/SDL/include/SDL_surface.h +571 -139
- data/dependencies/SDL/include/SDL_system.h +339 -101
- data/dependencies/SDL/include/SDL_syswm.h +50 -20
- data/dependencies/SDL/include/SDL_test.h +1 -1
- data/dependencies/SDL/include/SDL_test_assert.h +2 -2
- data/dependencies/SDL/include/SDL_test_common.h +23 -6
- data/dependencies/SDL/include/SDL_test_compare.h +1 -1
- data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
- data/dependencies/SDL/include/SDL_test_font.h +3 -3
- data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
- data/dependencies/SDL/include/SDL_test_harness.h +6 -6
- data/dependencies/SDL/include/SDL_test_images.h +1 -1
- data/dependencies/SDL/include/SDL_test_log.h +1 -1
- data/dependencies/SDL/include/SDL_test_md5.h +1 -1
- data/dependencies/SDL/include/SDL_test_memory.h +1 -1
- data/dependencies/SDL/include/SDL_test_random.h +2 -2
- data/dependencies/SDL/include/SDL_thread.h +226 -128
- data/dependencies/SDL/include/SDL_timer.h +129 -22
- data/dependencies/SDL/include/SDL_touch.h +48 -8
- data/dependencies/SDL/include/SDL_types.h +1 -1
- data/dependencies/SDL/include/SDL_version.h +72 -46
- data/dependencies/SDL/include/SDL_video.h +1266 -460
- data/dependencies/SDL/include/SDL_vulkan.h +100 -161
- data/dependencies/SDL/include/begin_code.h +22 -1
- data/dependencies/SDL/include/close_code.h +1 -1
- data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
- data/dependencies/SDL_sound/SDL_sound.c +104 -70
- data/dependencies/SDL_sound/SDL_sound.h +6 -6
- data/dependencies/SDL_sound/SDL_sound_aiff.c +32 -32
- data/dependencies/SDL_sound/SDL_sound_au.c +14 -14
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +6 -7
- data/dependencies/SDL_sound/SDL_sound_flac.c +28 -30
- data/dependencies/SDL_sound/SDL_sound_internal.h +21 -14
- data/dependencies/SDL_sound/SDL_sound_modplug.c +26 -28
- data/dependencies/SDL_sound/SDL_sound_mp3.c +20 -36
- data/dependencies/SDL_sound/SDL_sound_raw.c +15 -16
- data/dependencies/SDL_sound/SDL_sound_shn.c +11 -10
- data/dependencies/SDL_sound/SDL_sound_voc.c +20 -18
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +11 -9
- data/dependencies/SDL_sound/SDL_sound_wav.c +49 -43
- data/dependencies/SDL_sound/dr_flac.h +10925 -4466
- data/dependencies/SDL_sound/dr_mp3.h +2802 -844
- data/dependencies/SDL_sound/libmodplug/fastmix.c +63 -64
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
- data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
- data/dependencies/SDL_sound/libmodplug/load_amf.c +12 -7
- data/dependencies/SDL_sound/libmodplug/load_ams.c +103 -44
- data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
- data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
- data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
- data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
- data/dependencies/SDL_sound/libmodplug/load_it.c +61 -61
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +94 -58
- data/dependencies/SDL_sound/libmodplug/load_med.c +20 -11
- data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +50 -19
- data/dependencies/SDL_sound/libmodplug/load_okt.c +59 -28
- data/dependencies/SDL_sound/libmodplug/load_psm.c +104 -79
- data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
- data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
- data/dependencies/SDL_sound/libmodplug/load_ult.c +4 -3
- data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
- data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
- data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
- data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
- data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
- data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
- data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +32 -19
- data/dependencies/SDL_sound/libmodplug/sndfile.c +76 -160
- data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
- data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
- data/dependencies/SDL_sound/stb_vorbis.h +504 -329
- data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
- data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
- data/dependencies/mojoAL/mojoal.c +4848 -0
- data/dependencies/stb/stb_image.h +208 -73
- data/dependencies/stb/stb_image_write.h +57 -23
- data/dependencies/stb/stb_truetype.h +345 -279
- data/dependencies/utf8proc/utf8proc.c +37 -18
- data/dependencies/utf8proc/utf8proc.h +17 -5
- data/dependencies/utf8proc/utf8proc_data.h +12012 -10089
- data/ext/gosu/extconf.rb +29 -30
- data/include/Gosu/Audio.hpp +70 -85
- data/include/Gosu/Buttons.hpp +103 -103
- data/include/Gosu/Color.hpp +19 -11
- data/include/Gosu/Directories.hpp +31 -24
- data/include/Gosu/Font.hpp +42 -44
- data/include/Gosu/Gosu.hpp +5 -8
- data/include/Gosu/Graphics.hpp +58 -71
- data/include/Gosu/GraphicsBase.hpp +26 -33
- data/include/Gosu/IO.hpp +0 -3
- data/include/Gosu/Image.hpp +56 -62
- data/include/Gosu/ImageData.hpp +23 -27
- data/include/Gosu/Inspection.hpp +1 -4
- data/include/Gosu/Math.hpp +0 -3
- data/include/Gosu/TextInput.hpp +34 -40
- data/include/Gosu/Timing.hpp +2 -8
- data/include/Gosu/Version.hpp +2 -2
- data/include/Gosu/Window.hpp +71 -70
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/compat.rb +24 -37
- data/lib/gosu.rb +2 -2
- data/lib64/SDL2.dll +0 -0
- data/src/Audio.cpp +88 -86
- data/src/AudioFile.hpp +6 -6
- data/src/AudioFileAudioToolbox.cpp +1 -1
- data/src/AudioFileSDLSound.cpp +1 -1
- data/src/AudioImpl.cpp +0 -7
- data/src/AudioImpl.hpp +6 -8
- data/src/BitmapIO.cpp +23 -22
- data/src/BlockAllocator.cpp +2 -1
- data/src/Channel.cpp +22 -20
- data/src/Color.cpp +12 -9
- data/src/DirectoriesApple.cpp +25 -24
- data/src/DirectoriesUnix.cpp +14 -12
- data/src/DirectoriesWin.cpp +26 -30
- data/src/EmptyImageData.hpp +15 -17
- data/src/FileUnix.cpp +1 -1
- data/src/FileWin.cpp +1 -1
- data/src/Font.cpp +59 -54
- data/src/Graphics.cpp +135 -143
- data/src/Image.cpp +41 -47
- data/src/Input.cpp +1 -1
- data/src/InputUIKit.cpp +1 -1
- data/src/LargeImageData.cpp +108 -101
- data/src/LargeImageData.hpp +17 -15
- data/src/Log.hpp +6 -6
- data/src/Macro.cpp +35 -37
- data/src/Macro.hpp +11 -11
- data/src/Math.cpp +8 -1
- data/src/Resolution.cpp +12 -7
- data/src/RubyGosu.cxx +11 -39
- data/src/TexChunk.cpp +50 -41
- data/src/TexChunk.hpp +22 -22
- data/src/Text.cpp +37 -37
- data/src/TextBuilder.cpp +60 -57
- data/src/TextBuilder.hpp +20 -20
- data/src/TextInput.cpp +127 -135
- data/src/TimingApple.cpp +1 -7
- data/src/TimingUnix.cpp +0 -6
- data/src/TimingWin.cpp +0 -6
- data/src/TrueTypeFont.cpp +107 -107
- data/src/TrueTypeFont.hpp +39 -38
- data/src/TrueTypeFontApple.cpp +19 -22
- data/src/TrueTypeFontUnix.cpp +21 -26
- data/src/TrueTypeFontWin.cpp +30 -30
- data/src/Window.cpp +97 -87
- data/src/WindowUIKit.cpp +46 -49
- metadata +7 -17
- data/dependencies/SDL/include/SDL_config_os2.h +0 -188
- data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
- data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
- data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
- data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
- data/dependencies/al_soft/AL/alext.h +0 -585
- data/dependencies/al_soft/AL/efx-creative.h +0 -3
- data/dependencies/al_soft/AL/efx-presets.h +0 -402
- data/dependencies/al_soft/AL/efx.h +0 -762
- data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
- data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
- data/lib/OpenAL32.dll +0 -0
- data/lib64/OpenAL32.dll +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
Simple DirectMedia Layer
|
3
|
-
Copyright (C) 1997-
|
3
|
+
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
4
4
|
|
5
5
|
This software is provided 'as-is', without any express or implied
|
6
6
|
warranty. In no event will the authors be held liable for any damages
|
@@ -35,6 +35,17 @@
|
|
35
35
|
#include "SDL_atomic.h"
|
36
36
|
#include "SDL_mutex.h"
|
37
37
|
|
38
|
+
#if defined(__WIN32__)
|
39
|
+
#include <process.h> /* _beginthreadex() and _endthreadex() */
|
40
|
+
#endif
|
41
|
+
#if defined(__OS2__) /* for _beginthread() and _endthread() */
|
42
|
+
#ifndef __EMX__
|
43
|
+
#include <process.h>
|
44
|
+
#else
|
45
|
+
#include <stdlib.h>
|
46
|
+
#endif
|
47
|
+
#endif
|
48
|
+
|
38
49
|
#include "begin_code.h"
|
39
50
|
/* Set up for C function definitions, even when using C++ */
|
40
51
|
#ifdef __cplusplus
|
@@ -69,11 +80,14 @@ typedef enum {
|
|
69
80
|
} SDL_ThreadPriority;
|
70
81
|
|
71
82
|
/**
|
72
|
-
*
|
73
|
-
*
|
83
|
+
* The function passed to SDL_CreateThread().
|
84
|
+
*
|
85
|
+
* \param data what was passed as `data` to SDL_CreateThread()
|
86
|
+
* \returns a value that can be reported through SDL_WaitThread().
|
74
87
|
*/
|
75
88
|
typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
|
76
89
|
|
90
|
+
|
77
91
|
#if defined(__WIN32__)
|
78
92
|
/**
|
79
93
|
* \file SDL_thread.h
|
@@ -96,7 +110,6 @@ typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
|
|
96
110
|
* library!
|
97
111
|
*/
|
98
112
|
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
99
|
-
#include <process.h> /* _beginthreadex() and _endthreadex() */
|
100
113
|
|
101
114
|
typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread)
|
102
115
|
(void *, unsigned, unsigned (__stdcall *func)(void *),
|
@@ -110,9 +123,6 @@ typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
|
|
110
123
|
#define SDL_endthread _endthreadex
|
111
124
|
#endif
|
112
125
|
|
113
|
-
/**
|
114
|
-
* Create a thread.
|
115
|
-
*/
|
116
126
|
extern DECLSPEC SDL_Thread *SDLCALL
|
117
127
|
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
|
118
128
|
pfnSDL_CurrentBeginThread pfnBeginThread,
|
@@ -125,9 +135,6 @@ SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
|
|
125
135
|
pfnSDL_CurrentEndThread pfnEndThread);
|
126
136
|
|
127
137
|
|
128
|
-
/**
|
129
|
-
* Create a thread.
|
130
|
-
*/
|
131
138
|
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
|
132
139
|
#undef SDL_CreateThread
|
133
140
|
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
|
@@ -145,12 +152,6 @@ SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
|
|
145
152
|
*/
|
146
153
|
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
147
154
|
|
148
|
-
#ifndef __EMX__
|
149
|
-
#include <process.h>
|
150
|
-
#else
|
151
|
-
#include <stdlib.h>
|
152
|
-
#endif
|
153
|
-
|
154
155
|
typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void * /*arg*/);
|
155
156
|
typedef void (*pfnSDL_CurrentEndThread)(void);
|
156
157
|
|
@@ -183,39 +184,71 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const siz
|
|
183
184
|
#else
|
184
185
|
|
185
186
|
/**
|
186
|
-
*
|
187
|
+
* Create a new thread with a default stack size.
|
188
|
+
*
|
189
|
+
* This is equivalent to calling:
|
190
|
+
*
|
191
|
+
* ```c
|
192
|
+
* SDL_CreateThreadWithStackSize(fn, name, 0, data);
|
193
|
+
* ```
|
187
194
|
*
|
188
|
-
*
|
189
|
-
*
|
195
|
+
* \param fn the SDL_ThreadFunction function to call in the new thread
|
196
|
+
* \param name the name of the thread
|
197
|
+
* \param data a pointer that is passed to `fn`
|
198
|
+
* \returns an opaque pointer to the new thread object on success, NULL if the
|
199
|
+
* new thread could not be created; call SDL_GetError() for more
|
200
|
+
* information.
|
201
|
+
*
|
202
|
+
* \since This function is available since SDL 2.0.0.
|
203
|
+
*
|
204
|
+
* \sa SDL_CreateThreadWithStackSize
|
205
|
+
* \sa SDL_WaitThread
|
190
206
|
*/
|
191
207
|
extern DECLSPEC SDL_Thread *SDLCALL
|
192
208
|
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
|
193
209
|
|
194
210
|
/**
|
195
|
-
*
|
196
|
-
*
|
197
|
-
*
|
198
|
-
*
|
199
|
-
*
|
200
|
-
*
|
201
|
-
*
|
202
|
-
*
|
203
|
-
*
|
204
|
-
*
|
205
|
-
*
|
206
|
-
*
|
207
|
-
*
|
208
|
-
*
|
209
|
-
*
|
210
|
-
*
|
211
|
-
*
|
212
|
-
*
|
213
|
-
*
|
214
|
-
*
|
215
|
-
*
|
216
|
-
*
|
217
|
-
*
|
218
|
-
*
|
211
|
+
* Create a new thread with a specific stack size.
|
212
|
+
*
|
213
|
+
* SDL makes an attempt to report `name` to the system, so that debuggers can
|
214
|
+
* display it. Not all platforms support this.
|
215
|
+
*
|
216
|
+
* Thread naming is a little complicated: Most systems have very small limits
|
217
|
+
* for the string length (Haiku has 32 bytes, Linux currently has 16, Visual
|
218
|
+
* C++ 6.0 has _nine_!), and possibly other arbitrary rules. You'll have to
|
219
|
+
* see what happens with your system's debugger. The name should be UTF-8 (but
|
220
|
+
* using the naming limits of C identifiers is a better bet). There are no
|
221
|
+
* requirements for thread naming conventions, so long as the string is
|
222
|
+
* null-terminated UTF-8, but these guidelines are helpful in choosing a name:
|
223
|
+
*
|
224
|
+
* https://stackoverflow.com/questions/149932/naming-conventions-for-threads
|
225
|
+
*
|
226
|
+
* If a system imposes requirements, SDL will try to munge the string for it
|
227
|
+
* (truncate, etc), but the original string contents will be available from
|
228
|
+
* SDL_GetThreadName().
|
229
|
+
*
|
230
|
+
* The size (in bytes) of the new stack can be specified. Zero means "use the
|
231
|
+
* system default" which might be wildly different between platforms. x86
|
232
|
+
* Linux generally defaults to eight megabytes, an embedded device might be a
|
233
|
+
* few kilobytes instead. You generally need to specify a stack that is a
|
234
|
+
* multiple of the system's page size (in many cases, this is 4 kilobytes, but
|
235
|
+
* check your system documentation).
|
236
|
+
*
|
237
|
+
* In SDL 2.1, stack size will be folded into the original SDL_CreateThread
|
238
|
+
* function, but for backwards compatibility, this is currently a separate
|
239
|
+
* function.
|
240
|
+
*
|
241
|
+
* \param fn the SDL_ThreadFunction function to call in the new thread
|
242
|
+
* \param name the name of the thread
|
243
|
+
* \param stacksize the size, in bytes, to allocate for the new thread stack.
|
244
|
+
* \param data a pointer that is passed to `fn`
|
245
|
+
* \returns an opaque pointer to the new thread object on success, NULL if the
|
246
|
+
* new thread could not be created; call SDL_GetError() for more
|
247
|
+
* information.
|
248
|
+
*
|
249
|
+
* \since This function is available since SDL 2.0.9.
|
250
|
+
*
|
251
|
+
* \sa SDL_WaitThread
|
219
252
|
*/
|
220
253
|
extern DECLSPEC SDL_Thread *SDLCALL
|
221
254
|
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data);
|
@@ -223,137 +256,202 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const siz
|
|
223
256
|
#endif
|
224
257
|
|
225
258
|
/**
|
226
|
-
* Get the thread name
|
227
|
-
*
|
228
|
-
*
|
229
|
-
*
|
230
|
-
*
|
259
|
+
* Get the thread name as it was specified in SDL_CreateThread().
|
260
|
+
*
|
261
|
+
* This is internal memory, not to be freed by the caller, and remains valid
|
262
|
+
* until the specified thread is cleaned up by SDL_WaitThread().
|
263
|
+
*
|
264
|
+
* \param thread the thread to query
|
265
|
+
* \returns a pointer to a UTF-8 string that names the specified thread, or
|
266
|
+
* NULL if it doesn't have a name.
|
267
|
+
*
|
268
|
+
* \since This function is available since SDL 2.0.0.
|
269
|
+
*
|
270
|
+
* \sa SDL_CreateThread
|
231
271
|
*/
|
232
272
|
extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread);
|
233
273
|
|
234
274
|
/**
|
235
|
-
*
|
275
|
+
* Get the thread identifier for the current thread.
|
276
|
+
*
|
277
|
+
* This thread identifier is as reported by the underlying operating system.
|
278
|
+
* If SDL is running on a platform that does not support threads the return
|
279
|
+
* value will always be zero.
|
280
|
+
*
|
281
|
+
* This function also returns a valid thread ID when called from the main
|
282
|
+
* thread.
|
283
|
+
*
|
284
|
+
* \returns the ID of the current thread.
|
285
|
+
*
|
286
|
+
* \since This function is available since SDL 2.0.0.
|
287
|
+
*
|
288
|
+
* \sa SDL_GetThreadID
|
236
289
|
*/
|
237
290
|
extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void);
|
238
291
|
|
239
292
|
/**
|
240
|
-
*
|
293
|
+
* Get the thread identifier for the specified thread.
|
294
|
+
*
|
295
|
+
* This thread identifier is as reported by the underlying operating system.
|
296
|
+
* If SDL is running on a platform that does not support threads the return
|
297
|
+
* value will always be zero.
|
298
|
+
*
|
299
|
+
* \param thread the thread to query
|
300
|
+
* \returns the ID of the specified thread, or the ID of the current thread if
|
301
|
+
* `thread` is NULL.
|
241
302
|
*
|
242
|
-
*
|
303
|
+
* \since This function is available since SDL 2.0.0.
|
304
|
+
*
|
305
|
+
* \sa SDL_ThreadID
|
243
306
|
*/
|
244
307
|
extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread);
|
245
308
|
|
246
309
|
/**
|
247
|
-
*
|
310
|
+
* Set the priority for the current thread.
|
311
|
+
*
|
312
|
+
* Note that some platforms will not let you alter the priority (or at least,
|
313
|
+
* promote the thread to a higher priority) at all, and some require you to be
|
314
|
+
* an administrator account. Be prepared for this to fail.
|
315
|
+
*
|
316
|
+
* \param priority the SDL_ThreadPriority to set
|
317
|
+
* \returns 0 on success or a negative error code on failure; call
|
318
|
+
* SDL_GetError() for more information.
|
319
|
+
*
|
320
|
+
* \since This function is available since SDL 2.0.0.
|
248
321
|
*/
|
249
322
|
extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority);
|
250
323
|
|
251
324
|
/**
|
252
|
-
*
|
253
|
-
* remain (as a "zombie") until this function cleans them up. Not doing so
|
254
|
-
* is a resource leak.
|
325
|
+
* Wait for a thread to finish.
|
255
326
|
*
|
256
|
-
*
|
257
|
-
*
|
258
|
-
* As such, only one thread may call SDL_WaitThread() on another.
|
327
|
+
* Threads that haven't been detached will remain (as a "zombie") until this
|
328
|
+
* function cleans them up. Not doing so is a resource leak.
|
259
329
|
*
|
260
|
-
*
|
261
|
-
*
|
330
|
+
* Once a thread has been cleaned up through this function, the SDL_Thread
|
331
|
+
* that references it becomes invalid and should not be referenced again. As
|
332
|
+
* such, only one thread may call SDL_WaitThread() on another.
|
262
333
|
*
|
263
|
-
*
|
264
|
-
*
|
265
|
-
* both, or behavior is undefined.
|
334
|
+
* The return code for the thread function is placed in the area pointed to by
|
335
|
+
* `status`, if `status` is not NULL.
|
266
336
|
*
|
267
|
-
*
|
337
|
+
* You may not wait on a thread that has been used in a call to
|
338
|
+
* SDL_DetachThread(). Use either that function or this one, but not both, or
|
339
|
+
* behavior is undefined.
|
340
|
+
*
|
341
|
+
* It is safe to pass a NULL thread to this function; it is a no-op.
|
342
|
+
*
|
343
|
+
* Note that the thread pointer is freed by this function and is not valid
|
344
|
+
* afterward.
|
345
|
+
*
|
346
|
+
* \param thread the SDL_Thread pointer that was returned from the
|
347
|
+
* SDL_CreateThread() call that started this thread
|
348
|
+
* \param status pointer to an integer that will receive the value returned
|
349
|
+
* from the thread function by its 'return', or NULL to not
|
350
|
+
* receive such value back.
|
351
|
+
*
|
352
|
+
* \since This function is available since SDL 2.0.0.
|
353
|
+
*
|
354
|
+
* \sa SDL_CreateThread
|
355
|
+
* \sa SDL_DetachThread
|
268
356
|
*/
|
269
357
|
extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status);
|
270
358
|
|
271
359
|
/**
|
272
|
-
*
|
273
|
-
*
|
274
|
-
*
|
275
|
-
*
|
276
|
-
*
|
277
|
-
*
|
278
|
-
*
|
279
|
-
*
|
280
|
-
*
|
281
|
-
*
|
282
|
-
*
|
283
|
-
*
|
284
|
-
*
|
285
|
-
*
|
286
|
-
*
|
287
|
-
*
|
288
|
-
*
|
289
|
-
*
|
290
|
-
*
|
291
|
-
*
|
292
|
-
*
|
293
|
-
*
|
294
|
-
*
|
295
|
-
*
|
360
|
+
* Let a thread clean up on exit without intervention.
|
361
|
+
*
|
362
|
+
* A thread may be "detached" to signify that it should not remain until
|
363
|
+
* another thread has called SDL_WaitThread() on it. Detaching a thread is
|
364
|
+
* useful for long-running threads that nothing needs to synchronize with or
|
365
|
+
* further manage. When a detached thread is done, it simply goes away.
|
366
|
+
*
|
367
|
+
* There is no way to recover the return code of a detached thread. If you
|
368
|
+
* need this, don't detach the thread and instead use SDL_WaitThread().
|
369
|
+
*
|
370
|
+
* Once a thread is detached, you should usually assume the SDL_Thread isn't
|
371
|
+
* safe to reference again, as it will become invalid immediately upon the
|
372
|
+
* detached thread's exit, instead of remaining until someone has called
|
373
|
+
* SDL_WaitThread() to finally clean it up. As such, don't detach the same
|
374
|
+
* thread more than once.
|
375
|
+
*
|
376
|
+
* If a thread has already exited when passed to SDL_DetachThread(), it will
|
377
|
+
* stop waiting for a call to SDL_WaitThread() and clean up immediately. It is
|
378
|
+
* not safe to detach a thread that might be used with SDL_WaitThread().
|
379
|
+
*
|
380
|
+
* You may not call SDL_WaitThread() on a thread that has been detached. Use
|
381
|
+
* either that function or this one, but not both, or behavior is undefined.
|
382
|
+
*
|
383
|
+
* It is safe to pass NULL to this function; it is a no-op.
|
384
|
+
*
|
385
|
+
* \param thread the SDL_Thread pointer that was returned from the
|
386
|
+
* SDL_CreateThread() call that started this thread
|
387
|
+
*
|
388
|
+
* \since This function is available since SDL 2.0.2.
|
389
|
+
*
|
390
|
+
* \sa SDL_CreateThread
|
391
|
+
* \sa SDL_WaitThread
|
296
392
|
*/
|
297
393
|
extern DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread * thread);
|
298
394
|
|
299
395
|
/**
|
300
|
-
*
|
301
|
-
*
|
302
|
-
*
|
303
|
-
*
|
304
|
-
*
|
305
|
-
*
|
306
|
-
*
|
307
|
-
*
|
308
|
-
*
|
309
|
-
*
|
310
|
-
*
|
311
|
-
* SDL_AtomicLock(&tls_lock);
|
312
|
-
* if (!thread_local_storage) {
|
313
|
-
* thread_local_storage = SDL_TLSCreate();
|
314
|
-
* }
|
315
|
-
* SDL_AtomicUnlock(&tls_lock);
|
316
|
-
* }
|
317
|
-
* SDL_TLSSet(thread_local_storage, value, 0);
|
318
|
-
* }
|
319
|
-
*
|
320
|
-
* void *GetMyThreadData(void)
|
321
|
-
* {
|
322
|
-
* return SDL_TLSGet(thread_local_storage);
|
323
|
-
* }
|
324
|
-
* \endcode
|
325
|
-
*
|
326
|
-
* \sa SDL_TLSGet()
|
327
|
-
* \sa SDL_TLSSet()
|
396
|
+
* Create a piece of thread-local storage.
|
397
|
+
*
|
398
|
+
* This creates an identifier that is globally visible to all threads but
|
399
|
+
* refers to data that is thread-specific.
|
400
|
+
*
|
401
|
+
* \returns the newly created thread local storage identifier or 0 on error.
|
402
|
+
*
|
403
|
+
* \since This function is available since SDL 2.0.0.
|
404
|
+
*
|
405
|
+
* \sa SDL_TLSGet
|
406
|
+
* \sa SDL_TLSSet
|
328
407
|
*/
|
329
408
|
extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void);
|
330
409
|
|
331
410
|
/**
|
332
|
-
*
|
411
|
+
* Get the current thread's value associated with a thread local storage ID.
|
333
412
|
*
|
334
|
-
*
|
413
|
+
* \param id the thread local storage ID
|
414
|
+
* \returns the value associated with the ID for the current thread or NULL if
|
415
|
+
* no value has been set; call SDL_GetError() for more information.
|
335
416
|
*
|
336
|
-
*
|
417
|
+
* \since This function is available since SDL 2.0.0.
|
337
418
|
*
|
338
|
-
*
|
339
|
-
*
|
419
|
+
* \sa SDL_TLSCreate
|
420
|
+
* \sa SDL_TLSSet
|
340
421
|
*/
|
341
422
|
extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id);
|
342
423
|
|
343
424
|
/**
|
344
|
-
*
|
425
|
+
* Set the current thread's value associated with a thread local storage ID.
|
426
|
+
*
|
427
|
+
* The function prototype for `destructor` is:
|
428
|
+
*
|
429
|
+
* ```c
|
430
|
+
* void destructor(void *value)
|
431
|
+
* ```
|
345
432
|
*
|
346
|
-
*
|
347
|
-
* \param value The value to associate with the ID for the current thread
|
348
|
-
* \param destructor A function called when the thread exits, to free the value.
|
433
|
+
* where its parameter `value` is what was passed as `value` to SDL_TLSSet().
|
349
434
|
*
|
350
|
-
*
|
435
|
+
* \param id the thread local storage ID
|
436
|
+
* \param value the value to associate with the ID for the current thread
|
437
|
+
* \param destructor a function called when the thread exits, to free the
|
438
|
+
* value
|
439
|
+
* \returns 0 on success or a negative error code on failure; call
|
440
|
+
* SDL_GetError() for more information.
|
351
441
|
*
|
352
|
-
*
|
353
|
-
*
|
442
|
+
* \since This function is available since SDL 2.0.0.
|
443
|
+
*
|
444
|
+
* \sa SDL_TLSCreate
|
445
|
+
* \sa SDL_TLSGet
|
354
446
|
*/
|
355
447
|
extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void*));
|
356
448
|
|
449
|
+
/**
|
450
|
+
* Cleanup all TLS data for this thread.
|
451
|
+
*
|
452
|
+
* \since This function is available since SDL 2.0.16.
|
453
|
+
*/
|
454
|
+
extern DECLSPEC void SDLCALL SDL_TLSCleanup(void);
|
357
455
|
|
358
456
|
/* Ends C function definitions when using C++ */
|
359
457
|
#ifdef __cplusplus
|