uxtheme: Add stub for AllowDarkModeForWindow.
[wine.git] / libs / fluidsynth / glib.h
blob722173d825ad7655da4df50859ee15c65b8dee96
1 /*
2 * Copyright 2023 RĂ©mi Bernon for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stddef.h>
20 #include <stdarg.h>
21 #include <stdio.h>
23 #include <windef.h>
24 #include <winbase.h>
25 #include <winsock.h>
27 #include <stdint.h>
28 #include <stdlib.h>
29 #include <math.h>
31 #define GLIB_CHECK_VERSION(x, y, z) ((x) < GLIB_MAJOR_VERSION || ((x) == GLIB_MAJOR_VERSION && (y) <= GLIB_MINOR_VERSION))
32 #define GLIB_MAJOR_VERSION 2
33 #define GLIB_MINOR_VERSION 54
35 #define G_BYTE_ORDER 1234
36 #define G_BIG_ENDIAN 4321
37 #define GINT32_FROM_LE(val) ((INT32)(val))
38 #define GINT16_FROM_LE(val) ((INT16)(val))
40 #define G_UNLIKELY(expr) (expr)
41 #define G_LIKELY(expr) (expr)
43 #define g_return_val_if_fail( cond, val ) do { if (!(cond)) return (val); } while (0)
45 typedef void *gpointer;
46 typedef gpointer (*GThreadFunc)( gpointer data );
48 typedef struct _stat64 GStatBuf;
49 #define g_stat _stat64
51 typedef struct
53 const char *message;
54 } GError;
56 typedef struct
58 LONG ref;
59 HANDLE handle;
60 GThreadFunc func;
61 gpointer data;
62 } GThread;
64 extern int g_vsnprintf( char *buffer, size_t size, const char *format, va_list args ) __WINE_CRT_PRINTF_ATTR(3, 0);
65 extern int g_snprintf( char *buffer, size_t size, const char *format, ... ) __WINE_CRT_PRINTF_ATTR(3, 4);
67 extern double g_get_monotonic_time(void);
68 extern void g_usleep( unsigned int micros );
70 extern GThread *g_thread_try_new( const char *name, GThreadFunc func, gpointer data, GError **err );
71 extern void g_thread_unref( GThread *thread );
72 extern void g_thread_join( GThread *thread );
73 extern void g_clear_error( GError **error );
75 #define G_FILE_TEST_EXISTS 1
76 #define G_FILE_TEST_IS_REGULAR 2
78 extern int g_file_test( const char *path, int test );
80 #define g_new( type, count ) calloc( (count), sizeof(type) )
81 static void g_free( void *ptr ) { free( ptr ); }
83 typedef SRWLOCK GMutex;
84 static void g_mutex_init( GMutex *mutex ) {}
85 static void g_mutex_clear( GMutex *mutex ) {}
86 static void g_mutex_lock( GMutex *mutex ) { AcquireSRWLockExclusive( mutex ); }
87 static void g_mutex_unlock( GMutex *mutex ) { ReleaseSRWLockExclusive( mutex ); }
89 typedef CRITICAL_SECTION GRecMutex;
90 static void g_rec_mutex_init( GRecMutex *mutex ) { InitializeCriticalSection( mutex ); }
91 static void g_rec_mutex_clear( GRecMutex *mutex ) { DeleteCriticalSection( mutex ); }
92 static void g_rec_mutex_lock( GRecMutex *mutex ) { EnterCriticalSection( mutex ); }
93 static void g_rec_mutex_unlock( GRecMutex *mutex ) { LeaveCriticalSection( mutex ); }
95 typedef CONDITION_VARIABLE GCond;
96 static void g_cond_init( GCond *cond ) {}
97 static void g_cond_clear( GCond *cond ) {}
98 static void g_cond_signal( GCond *cond ) { WakeConditionVariable( cond ); }
99 static void g_cond_broadcast( GCond *cond ) { WakeAllConditionVariable( cond ); }
100 static void g_cond_wait( GCond *cond, GMutex *mutex ) { SleepConditionVariableSRW( cond, mutex, INFINITE, 0 ); }
102 static void g_atomic_int_inc( int *ptr ) { InterlockedIncrement( (LONG *)ptr ); }
103 static int g_atomic_int_add( int *ptr, int val ) { return InterlockedAdd( (LONG *)ptr, val ) - 1; }
104 static int g_atomic_int_get( int *ptr ) { return ReadAcquire( (LONG *)ptr ); }
105 static void g_atomic_int_set( int *ptr, int val ) { InterlockedExchange( (LONG *)ptr, val ); }
106 static int g_atomic_int_dec_and_test( int *ptr, int val ) { return !InterlockedAdd( (LONG *)ptr, -val ); }
107 static int g_atomic_int_compare_and_exchange( int *ptr, int cmp, int val ) { return InterlockedCompareExchange( (LONG *)ptr, val, cmp ) == cmp; }