···105105/**
106106 * The SDL thread state.
107107 *
108108- * SDL stores the current state of a thread in an atomic int. The current
109109- * state of a thread can be checked by calling SDL_GetThreadState.
108108+ * The current state of a thread can be checked by calling SDL_GetThreadState.
110109 *
111110 * \since This enum is available since SDL 3.1.3.
112111 *
···114113 */
115114typedef enum SDL_ThreadState
116115{
117117- SDL_THREAD_STATE_ALIVE,
118118- SDL_THREAD_STATE_DETACHED,
119119- SDL_THREAD_STATE_ZOMBIE,
120120- SDL_THREAD_STATE_CLEANED,
116116+ SDL_THREAD_UNKNOWN, /**< The thread is not valid */
117117+ SDL_THREAD_ALIVE, /**< The thread is currently running */
118118+ SDL_THREAD_DETACHED, /**< The thread is detached and can't be waited on */
119119+ SDL_THREAD_COMPLETE, /**< The thread has finished and should be cleaned up with SDL_WaitThread() */
121120} SDL_ThreadState;
122121123122/**
···408407/**
409408 * Wait for a thread to finish.
410409 *
411411- * Threads that haven't been detached will remain (as a "zombie") until this
410410+ * Threads that haven't been detached will remain until this
412411 * function cleans them up. Not doing so is a resource leak.
413412 *
414413 * Once a thread has been cleaned up through this function, the SDL_Thread
415414 * that references it becomes invalid and should not be referenced again. As
416415 * such, only one thread may call SDL_WaitThread() on another.
417416 *
418418- * The return code for the thread function is placed in the area pointed to by
417417+ * The return code from the thread function is placed in the area pointed to by
419418 * `status`, if `status` is not NULL.
420419 *
421420 * You may not wait on a thread that has been used in a call to
···429428 *
430429 * \param thread the SDL_Thread pointer that was returned from the
431430 * SDL_CreateThread() call that started this thread.
432432- * \param status pointer to an integer that will receive the value returned
433433- * from the thread function by its 'return', or NULL to not
434434- * receive such value back.
431431+ * \param status a pointer filled in with the value returned
432432+ * from the thread function by its 'return', or -1 if the thread has been detached or isn't valid, may be NULL.
435433 *
436434 * \since This function is available since SDL 3.1.3.
437435 *
···443441/**
444442 * Get the current state of a thread.
445443 *
446446- * \param thread the thread whose status you want to check.
447447- * \returns the current state of a thread as defined in the SDL_ThreadState
448448- * enum.
444444+ * \param thread the thread to query.
445445+ * \returns the current state of a thread, or SDL_THREAD_UNKNOWN if the thread isn't valid.
449446 *
450447 * \since This function is available since SDL 3.2.0.
451448 *
+3
src/SDL_utils.c
···214214 case SDL_OBJECT_TYPE_HIDAPI_JOYSTICK:
215215 type = "hidapi joystick";
216216 break;
217217+ case SDL_OBJECT_TYPE_THREAD:
218218+ type = "thread";
219219+ break;
217220 default:
218221 type = "unknown object";
219222 break;
···126126 Detached threads can be waited on, but should NOT be cleaned manually
127127 as it would result in a fatal error.
128128 */
129129- if (R_SUCCEEDED(res) && SDL_GetAtomicInt(&thread->state) != SDL_THREAD_STATE_DETACHED) {
129129+ if (R_SUCCEEDED(res) && SDL_GetThreadState(thread) != SDL_THREAD_DETACHED) {
130130 threadFree(thread->handle);
131131 }
132132}