@@ -431,6 +431,7 @@ enum {FALSE_WIN = 0};
431431#endif
432432#elif cimg_display==3
433433#include <SDL3/SDL.h>
434+ #include <pthread.h>
434435#if cimg_OS==1
435436#include <csignal>
436437#endif
@@ -653,14 +654,21 @@ extern "C" {
653654#include "tinyexr.h"
654655#endif
655656
656- // Try to define cimg_float16.
657+ // Define cimg_float16.
657658#if defined(_HALF_H_) || defined(cimg_use_openexr)
658659#define cimg_float16 half
659660#define cimg_is_float16 1
660661#else
661662#define cimg_is_float16 0
662663#endif
663664
665+ // Define cimg_use_pthread
666+ #if defined(PTHREAD_H) || defined(_PTHREAD_H)
667+ #define cimg_use_pthread 1
668+ #else
669+ #define cimg_use_pthread 0
670+ #endif
671+
664672// Check if min/max/PI macros are defined.
665673//
666674// CImg does not compile if macros 'min', 'max' or 'PI' are defined,
@@ -3252,7 +3260,7 @@ namespace cimg_library {
32523260 XInitThreads();
32533261#endif
32543262 pthread_mutexattr_init(&attr);
3255- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
3263+ pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
32563264 pthread_mutex_init(&mutex_wait_event, &attr);
32573265 pthread_mutex_init(&mutex_lock_display, &attr);
32583266 pthread_cond_init(&wait_event,0);
@@ -3325,7 +3333,7 @@ namespace cimg_library {
33253333 SDL_DisplayID display;
33263334 SDL_ThreadID main_thread_id;
33273335 const SDL_DisplayMode *mode;
3328- SDL_Mutex *mutex_lock_display; //, *mutex_wait_event;
3336+ SDL_Mutex *mutex_lock_display;
33293337
33303338 SDL3_attr():nb_cimg_displays(0),display(0),mode(0),mutex_lock_display(0) {
33313339 bool init_failed = true;
@@ -3375,7 +3383,7 @@ namespace cimg_library {
33753383#endif
33763384
33773385 struct Mutex_attr {
3378- #if cimg_OS==1 && (defined( cimg_use_pthread) || cimg_display ==1)
3386+ #if cimg_OS==1 && cimg_use_pthread==1
33793387 pthread_mutex_t mutex[32];
33803388 Mutex_attr() { for (unsigned int i = 0; i<32; ++i) pthread_mutex_init(&mutex[i],0); }
33813389 void lock(const unsigned int n) { pthread_mutex_lock(&mutex[n]); }
@@ -8150,7 +8158,10 @@ namespace cimg_library {
81508158
81518159 std::fprintf(cimg::output()," > Display type: %s%-13s%s %s('cimg_display'=%d)%s\n",
81528160 cimg::t_bold,
8153- cimg_display==0?"No display":cimg_display==1?"X11":cimg_display==2?"Windows GDI":"Unknown",
8161+ cimg_display==0?"No display":
8162+ cimg_display==1?"X11":
8163+ cimg_display==2?"Windows GDI":
8164+ cimg_display==3?"SDL3":"Unknown",
81548165 cimg::t_normal,cimg::t_green,
81558166 (int)cimg_display,
81568167 cimg::t_normal);
0 commit comments