Path: blob/a-new-beginning/SharedDependencies/Sources/glib/include/glib.h
2 views
#ifndef GLIB_SHIM_H1#define GLIB_SHIM_H23#include <stdint.h>4#include <stdbool.h>5#include <signal.h>6#include <stdio.h>7#include <stdarg.h>8#include <string.h>9#include <stddef.h>1011#if defined(WIN32) || defined(_WIN32) || defined(_MSC_VER)12#define G_OS_WIN32 113#endif1415#define G_LITTLE_ENDIAN 016#define G_BIG_ENDIAN 117#define G_BYTE_ORDER G_LITTLE_ENDIAN1819#define GUINT16_FROM_BE(n) ntohs(n)20#define GUINT16_TO_BE(n) htons(n)21#define GUINT32_FROM_BE(n) ntohl(n)22#define GUINT32_TO_BE(n) htonl(n)2324#define GINT16_TO_BE(n) (int16_t) htons(n)25#define GINT16_FROM_BE(n) (int16_t) ntohs(n)26#define GINT32_TO_BE(n) (int32_t) htonl(n)27#define GINT32_FROM_BE(n) (int32_t) ntohl(n)2829#define G_N_ELEMENTS(arr) (sizeof(arr) / sizeof(arr[0]))3031#define G_GNUC_PRINTF(x, y)3233#define GLIB_CHECK_VERSION(x, y, z) 134#define G_STATIC_ASSERT(...)35#define g_assert assert36#define G_UNLIKELY(x) __builtin_expect(x, 0)3738#define g_return_if_fail(expr) \39do { \40if (!(expr)) \41return; \42} while (false)4344#define g_return_val_if_fail(expr, val) \45do { \46if (!(expr)) \47return (val); \48} while (false)4950#define g_warn_if_reached() \51do { \52g_warning("g_warn_if_reached: Reached " __FILE__ ":%d", __LINE__); \53} while (false)545556#define g_warn_if_fail(expr) \57do { \58if (!(expr)) \59g_warning("g_warn_if_fail: Expression '" #expr "' failed at " __FILE__ ":%d", __LINE__); \60} while (false)6162#define g_assert_not_reached() \63do { \64assert(false && "g_assert_not_reached"); \65__builtin_unreachable(); \66} while (false)6768#define GLIB_SIZEOF_VOID_P 869#ifndef MAX70#define MAX(a, b) (a > b ? a : b)71#endif72#ifndef MIN73#define MIN(a, b) (a < b ? a : b)74#endif7576#ifndef TRUE77#define TRUE true78#endif79#ifndef FALSE80#define FALSE false81#endif8283typedef bool gboolean;84typedef char gchar;85typedef int gint;86typedef size_t gsize;87typedef void* gpointer;8889//RSTSLIRP90#define g_debug(format, ...) //printf("[" G_LOG_DOMAIN ": debug] " format, ##__VA_ARGS__)91#define g_warning(format, ...) //printf("[" G_LOG_DOMAIN ": warning] " format, ##__VA_ARGS__)92#define g_error(format, ...) //printf("[" G_LOG_DOMAIN ": error] " format, ##__VA_ARGS__)93#define g_critical(format, ...) //printf("[" G_LOG_DOMAIN ": critical] " format, ##__VA_ARGS__)9495#define g_new(type, count) (type*) (count > 0 ? malloc(sizeof(type) * count) : NULL)96#define g_new0(type, count) (type*) (count > 0 ? calloc(count, sizeof(type)) : NULL)9798#define g_malloc malloc99#define g_malloc0(size) calloc(1, size)100#define g_realloc realloc101#define g_free free102103#define g_getenv(var) getenv(var)104105typedef struct GString {106gchar* str;107gsize len;108gsize allocated_len;109} GString;110111typedef gchar** GStrv;112113GString* g_string_new(gchar* initial);114gchar* g_string_free(GString* string, gboolean free_segment);115void g_string_append_printf(GString* gstr, const gchar* format, ...);116gchar* g_strstr_len(const gchar* haystack, int len, const gchar* needle);117gchar* g_strdup(const gchar* str);118#ifdef _MSC_VER119#define g_ascii_strcasecmp(a, b) stricmp(a, b)120#else121#define g_ascii_strcasecmp(a, b) strcasecmp(a, b)122#endif123124#define g_str_has_prefix(str, pfx) (strncmp(str, pfx, strlen(pfx)) == 0)125#define g_snprintf snprintf126#define g_vsnprintf vsnprintf127128gint g_strv_length(GStrv strings);129void g_strfreev(GStrv strings);130131typedef uint32_t GRand;132gint g_rand_int_range(GRand* grand, gint min, gint max);133GRand* g_rand_new();134void g_rand_free(GRand* rand);135136typedef struct GError {137const gchar* message;138} GError;139140void g_error_free(GError* error);141#define g_strerror(err) strerror(err)142143typedef void (*GSpawnChildSetupFunc)(gpointer ptr);144typedef enum GSpawnFlags {145G_SPAWN_SEARCH_PATH146} GSpawnFlags;147148typedef gint GPid;149150gboolean g_shell_parse_argv(const gchar* command_line, gint* argcp, gchar*** argvp, GError** error);151152gboolean g_spawn_async_with_fds(const gchar *working_directory, gchar **argv,153gchar **envp, GSpawnFlags flags,154GSpawnChildSetupFunc child_setup,155gpointer user_data, GPid *child_pid, gint stdin_fd,156gint stdout_fd, gint stderr_fd, GError **error);157158typedef struct { gchar* key; int value; } GDebugKey;159#define g_parse_debug_string(str, keys, nkeys) 0160161162#endif163164165