comparison src/dmlib.h @ 2586:9807ae37ad69

Require stdbool.h, we require C11 now.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 08 Dec 2022 15:59:22 +0200
parents ef6c826c5b7a
children 0f351e291319
comparison
equal deleted inserted replaced
2585:ef6c826c5b7a 2586:9807ae37ad69
23 #include <stdio.h> 23 #include <stdio.h>
24 #include <stdarg.h> 24 #include <stdarg.h>
25 #include <stdlib.h> 25 #include <stdlib.h>
26 #include <ctype.h> 26 #include <ctype.h>
27 #include <inttypes.h> 27 #include <inttypes.h>
28 #include <stdbool.h>
28 #include <string.h> 29 #include <string.h>
29 30
30 31
31 #ifdef DM_USE_ASSERTS 32 #ifdef DM_USE_ASSERTS
32 # include <assert.h> 33 # include <assert.h>
188 // Resource management defines 189 // Resource management defines
189 #define DMRES_NAME_LEN 32 190 #define DMRES_NAME_LEN 32
190 #define DMRES_RES_FILE "res.txt" // Resource data file 191 #define DMRES_RES_FILE "res.txt" // Resource data file
191 192
192 193
193 /* Define a boolean type
194 */
195 #if !defined(FALSE) && !defined(TRUE) && !defined(BOOL)
196 typedef enum { FALSE = 0, TRUE = 1 } BOOL;
197 #endif
198
199 #ifndef BOOL
200 # ifdef bool
201 # define BOOL bool
202 # else
203 # define BOOL int
204 # endif
205 #endif
206
207
208 /* Math constants 194 /* Math constants
209 */ 195 */
210 #define DM_PI 3.14159265358f 196 #define DM_PI 3.14159265358f
211 #define DM_PI2 6.28318530718f 197 #define DM_PI2 6.28318530718f
212 #define DM_E 2.71828182846f 198 #define DM_E 2.71828182846f
472 char * dm_strdup_vprintf(const char *fmt, va_list args); 458 char * dm_strdup_vprintf(const char *fmt, va_list args);
473 char * dm_strdup_printf(const char *fmt, ...); 459 char * dm_strdup_printf(const char *fmt, ...);
474 460
475 char * dm_strrcasecmp(char *str, const char *needle); 461 char * dm_strrcasecmp(char *str, const char *needle);
476 462
477 BOOL dmGetIntVal(const char *str, unsigned int *value, BOOL *neg); 463 bool dmGetIntVal(const char *str, unsigned int *value, bool *neg);
478 464
479 465
480 /* Mutexes 466 /* Mutexes
481 */ 467 */
482 #ifdef DM_MUTEX_DEBUG 468 #ifdef DM_MUTEX_DEBUG
483 469
484 typedef struct 470 typedef struct
485 { 471 {
486 BOOL used; 472 bool used;
487 Uint32 id; 473 Uint32 id;
488 int state; 474 int state;
489 } DMMutexLock; 475 } DMMutexLock;
490 476
491 typedef struct 477 typedef struct