diff --git a/build.zig b/build.zig index e21aa76b..f6a5cf85 100644 --- a/build.zig +++ b/build.zig @@ -7,6 +7,7 @@ pub const ecs = @import("ecs/build.zig"); const freetype = @import("freetype/build.zig"); const sysaudio = @import("sysaudio/build.zig"); const sysjs = @import("sysjs/build.zig"); +const gamemode = @import("gamemode-zig/build.zig"); const Pkg = std.build.Pkg; pub fn build(b: *std.build.Builder) void { @@ -226,6 +227,13 @@ pub const App = struct { exe.addPackage(gpu.pkg); exe.addPackage(glfw.pkg); + if (target.os.tag == .linux) { + exe.addPackage(gamemode.pkg); + // TODO: choose between system lib vs buildlib? + gamemode.link(exe); + // gamemode.buildAndLink(b, exe); + } + break :blk exe; } }; diff --git a/gamemode-zig/build.zig b/gamemode-zig/build.zig new file mode 100644 index 00000000..ef361b4d --- /dev/null +++ b/gamemode-zig/build.zig @@ -0,0 +1,23 @@ +const std = @import("std"); + +pub const pkg = std.build.Pkg{ + .name = "gamemode", + .source = .{ .path = thisDir() ++ "/src/gamemode.zig" }, +}; + +/// Link system library gamemode +pub fn link(exe: *std.build.LibExeObjStep) void { + exe.linkSystemLibrary("gamemode"); +} + +/// TODO: +/// Build and link gamemode +pub fn buildAndLink(b: *std.build.Builder, exe: *std.build.LibExeObjStep) void { + const lib = b.addSharedLibrarySource("gamemode", std.build.FileSource{ .path = thisDir() ++ "/c/client_impl.c" }, .unversioned); + lib.linkLibC(); + exe.linkLibrary(lib); +} + +fn thisDir() []const u8 { + return std.fs.path.dirname(@src().file) orelse "."; +} diff --git a/gamemode-zig/c/client_impl.c b/gamemode-zig/c/client_impl.c new file mode 100644 index 00000000..f53d0635 --- /dev/null +++ b/gamemode-zig/c/client_impl.c @@ -0,0 +1,395 @@ +/* + +Copyright (c) 2017-2019, Feral Interactive +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Feral Interactive nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + */ + +#define _GNU_SOURCE + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// For developmental purposes +#define DO_TRACE 0 + +// D-Bus name, path, iface +#define DAEMON_DBUS_NAME "com.feralinteractive.GameMode" +#define DAEMON_DBUS_PATH "/com/feralinteractive/GameMode" +#define DAEMON_DBUS_IFACE "com.feralinteractive.GameMode" + +#define PORTAL_DBUS_NAME "org.freedesktop.portal.Desktop" +#define PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop" +#define PORTAL_DBUS_IFACE "org.freedesktop.portal.GameMode" + +// Cleanup macros +#define _cleanup_(x) __attribute__((cleanup(x))) +#define _cleanup_bus_ _cleanup_(hop_off_the_bus) +#define _cleanup_msg_ _cleanup_(cleanup_msg) +#define _cleanup_dpc_ _cleanup_(cleanup_pending_call) +#define _cleanup_fds_ _cleanup_(cleanup_fd_array) + +#ifdef NDEBUG +#define DEBUG(...) +#else +#define DEBUG(...) fprintf(stderr, __VA_ARGS__) +#endif + +#if DO_TRACE +#define TRACE(...) fprintf(stderr, __VA_ARGS__) +#else +#define TRACE(...) +#endif + +// Prototypes +static int log_error(const char *fmt, ...) __attribute__((format(printf, 1, 2))); + +// Storage for error strings +static char error_string[512] = { 0 }; + +// memory helpers +static void cleanup_fd_array(int **fdlist) +{ + if (fdlist == NULL || *fdlist == NULL) + return; + + int errsave = errno; + for (int *fd = *fdlist; *fd != -1; fd++) { + TRACE("GM Closing fd %d\n", *fd); + (void)close(*fd); + } + + errno = errsave; + free(*fdlist); +} + +// Allocate a -1 termianted array of ints +static inline int *alloc_fd_array(int n) +{ + int *fds; + + size_t count = (size_t)n + 1; /* -1, terminated */ + fds = (int *)malloc(sizeof(int) * count); + for (size_t i = 0; i < count; i++) + fds[i] = -1; + + return fds; +} + +// Helper to check if we are running inside a flatpak +static int in_flatpak(void) +{ + static int status = -1; + + if (status == -1) { + struct stat sb; + int r; + + r = lstat("/.flatpak-info", &sb); + status = r == 0 && sb.st_size > 0; + } + + return status; +} + +static int log_error(const char *fmt, ...) +{ + va_list args; + int n; + + va_start(args, fmt); + n = vsnprintf(error_string, sizeof(error_string), fmt, args); + va_end(args); + + if (n < 0) + DEBUG("Failed to format error string"); + else if ((size_t)n >= sizeof(error_string)) + DEBUG("Error log overflow"); + + fprintf(stderr, "GameMode ERROR: %s\n", error_string); + + return -1; +} + +static void hop_off_the_bus(DBusConnection **bus) +{ + if (bus == NULL) + return; + + dbus_connection_unref(*bus); +} + +static DBusConnection *hop_on_the_bus(void) +{ + DBusConnection *bus; + DBusError err; + + dbus_error_init(&err); + + bus = dbus_bus_get(DBUS_BUS_SESSION, &err); + + if (bus == NULL) { + log_error("Could not connect to bus: %s", err.message); + dbus_error_free(&err); + } + + return bus; +} + +/* cleanup functions */ +static void cleanup_msg(DBusMessage **msg) +{ + if (msg == NULL || *msg == NULL) + return; + + dbus_message_unref(*msg); +} + +static void cleanup_pending_call(DBusPendingCall **call) +{ + if (call == NULL || *call == NULL) + return; + + dbus_pending_call_unref(*call); +} + +/* internal API */ +static int make_request(DBusConnection *bus, int native, int use_pidfds, const char *method, + pid_t *pids, int npids, DBusError *error) +{ + _cleanup_msg_ DBusMessage *msg = NULL; + _cleanup_dpc_ DBusPendingCall *call = NULL; + _cleanup_fds_ int *fds = NULL; + char action[256] = { + 0, + }; + DBusError err; + DBusMessageIter iter; + int res = -1; + + TRACE("GM: Incoming request: %s, npids: %d, native: %d pifds: %d\n", + method, + npids, + native, + use_pidfds); + + if (use_pidfds) { + fds = alloc_fd_array(npids); + + res = open_pidfds(pids, fds, npids); + if (res != npids) { + dbus_set_error(error, DBUS_ERROR_FAILED, "Could not open pidfd for %d", (int)pids[res]); + return -1; + } + + if (strstr(method, "ByPID")) + snprintf(action, sizeof(action), "%sFd", method); + else + snprintf(action, sizeof(action), "%sByPIDFd", method); + method = action; + } + + TRACE("GM: Making request: %s, npids: %d, native: %d pifds: %d\n", + method, + npids, + native, + use_pidfds); + + // If we are inside a flatpak we need to talk to the portal instead + const char *dest = native ? DAEMON_DBUS_NAME : PORTAL_DBUS_NAME; + const char *path = native ? DAEMON_DBUS_PATH : PORTAL_DBUS_PATH; + const char *iface = native ? DAEMON_DBUS_IFACE : PORTAL_DBUS_IFACE; + + msg = dbus_message_new_method_call(dest, path, iface, method); + + if (!msg) { + dbus_set_error_const(error, DBUS_ERROR_FAILED, "Could not create dbus message"); + return -1; + } + + dbus_message_iter_init_append(msg, &iter); + + for (int i = 0; i < npids; i++) { + dbus_int32_t p; + int type; + + if (use_pidfds) { + type = DBUS_TYPE_UNIX_FD; + p = (dbus_int32_t)fds[i]; + } else { + type = DBUS_TYPE_INT32; + p = (dbus_int32_t)pids[i]; + } + dbus_message_iter_append_basic(&iter, type, &p); + } + + dbus_connection_send_with_reply(bus, msg, &call, -1); + dbus_connection_flush(bus); + dbus_message_unref(msg); + msg = NULL; + + dbus_pending_call_block(call); + msg = dbus_pending_call_steal_reply(call); + + if (msg == NULL) { + dbus_set_error_const(error, DBUS_ERROR_FAILED, "Did not receive a reply"); + return -1; + } + + dbus_error_init(&err); + res = -1; + if (dbus_set_error_from_message(&err, msg)) { + dbus_set_error(error, + err.name, + "Could not call method '%s' on '%s': %s", + method, + dest, + err.message); + } else if (!dbus_message_iter_init(msg, &iter) || + dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32) { + dbus_set_error(error, DBUS_ERROR_INVALID_SIGNATURE, "Failed to parse response"); + } else { + dbus_message_iter_get_basic(&iter, &res); + } + + /* free the local error */ + if (dbus_error_is_set(&err)) + dbus_error_free(&err); + + return res; +} + +static int gamemode_request(const char *method, pid_t for_pid) +{ + _cleanup_bus_ DBusConnection *bus = NULL; + static int use_pidfs = 1; + DBusError err; + pid_t pids[2]; + int npids; + int native; + int res = -1; + + native = !in_flatpak(); + + /* pid[0] is the client, i.e. the game + * pid[1] is the requestor, i.e. this process + * + * we setup the array such that pids[1] will always be a valid + * pid, because if we are going to use the pidfd based API, + * both pids are being sent, even if they are the same + */ + pids[1] = getpid(); + pids[0] = for_pid != 0 ? for_pid : pids[1]; + + TRACE("GM: [%d] request '%s' received (by: %d) [portal: %s]\n", + (int)pids[0], + method, + (int)pids[1], + (native ? "n" : "y")); + + bus = hop_on_the_bus(); + + if (bus == NULL) + return -1; + + dbus_error_init(&err); +retry: + if (for_pid != 0 || use_pidfs) + npids = 2; + else + npids = 1; + + res = make_request(bus, native, use_pidfs, method, pids, npids, &err); + + if (res == -1 && use_pidfs && dbus_error_is_set(&err)) { + TRACE("GM: Request with pidfds failed (%s). Retrying.\n", err.message); + use_pidfs = 0; + dbus_error_free(&err); + goto retry; + } + + if (res == -1 && dbus_error_is_set(&err)) + log_error("D-Bus error: %s", err.message); + + TRACE("GM: [%d] request '%s' done: %d\n", (int)pids[0], method, res); + + if (dbus_error_is_set(&err)) + dbus_error_free(&err); + + return res; +} + +// Get the error string +extern const char *real_gamemode_error_string(void) +{ + return error_string; +} + +// Wrapper to call RegisterGame +extern int real_gamemode_request_start(void) +{ + return gamemode_request("RegisterGame", 0); +} + +// Wrapper to call UnregisterGame +extern int real_gamemode_request_end(void) +{ + return gamemode_request("UnregisterGame", 0); +} + +// Wrapper to call QueryStatus +extern int real_gamemode_query_status(void) +{ + return gamemode_request("QueryStatus", 0); +} + +// Wrapper to call RegisterGameByPID +extern int real_gamemode_request_start_for(pid_t pid) +{ + return gamemode_request("RegisterGameByPID", pid); +} + +// Wrapper to call UnregisterGameByPID +extern int real_gamemode_request_end_for(pid_t pid) +{ + return gamemode_request("UnregisterGameByPID", pid); +} + +// Wrapper to call QueryStatusByPID +extern int real_gamemode_query_status_for(pid_t pid) +{ + return gamemode_request("QueryStatusByPID", pid); +} diff --git a/gamemode-zig/c/client_loader.c b/gamemode-zig/c/client_loader.c new file mode 100644 index 00000000..08c86d06 --- /dev/null +++ b/gamemode-zig/c/client_loader.c @@ -0,0 +1,35 @@ +/* + +Copyright (c) 2017-2019, Feral Interactive +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Feral Interactive nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + */ + +// Simply include the header with GAMEMODE_AUTO set +// This will ensure it calls the functions when it's loaded +#define GAMEMODE_AUTO +#include "gamemode_client.h" diff --git a/gamemode-zig/c/gamemode_client.h b/gamemode-zig/c/gamemode_client.h new file mode 100644 index 00000000..b9f64fe4 --- /dev/null +++ b/gamemode-zig/c/gamemode_client.h @@ -0,0 +1,376 @@ +/* + +Copyright (c) 2017-2019, Feral Interactive +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Feral Interactive nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + */ +#ifndef CLIENT_GAMEMODE_H +#define CLIENT_GAMEMODE_H +/* + * GameMode supports the following client functions + * Requests are refcounted in the daemon + * + * int gamemode_request_start() - Request gamemode starts + * 0 if the request was sent successfully + * -1 if the request failed + * + * int gamemode_request_end() - Request gamemode ends + * 0 if the request was sent successfully + * -1 if the request failed + * + * GAMEMODE_AUTO can be defined to make the above two functions apply during static init and + * destruction, as appropriate. In this configuration, errors will be printed to stderr + * + * int gamemode_query_status() - Query the current status of gamemode + * 0 if gamemode is inactive + * 1 if gamemode is active + * 2 if gamemode is active and this client is registered + * -1 if the query failed + * + * int gamemode_request_start_for(pid_t pid) - Request gamemode starts for another process + * 0 if the request was sent successfully + * -1 if the request failed + * -2 if the request was rejected + * + * int gamemode_request_end_for(pid_t pid) - Request gamemode ends for another process + * 0 if the request was sent successfully + * -1 if the request failed + * -2 if the request was rejected + * + * int gamemode_query_status_for(pid_t pid) - Query status of gamemode for another process + * 0 if gamemode is inactive + * 1 if gamemode is active + * 2 if gamemode is active and this client is registered + * -1 if the query failed + * + * const char* gamemode_error_string() - Get an error string + * returns a string describing any of the above errors + * + * Note: All the above requests can be blocking - dbus requests can and will block while the daemon + * handles the request. It is not recommended to make these calls in performance critical code + */ + +#include +#include + +#include +#include + +#include + +#include + +static char internal_gamemode_client_error_string[512] = { 0 }; + +/** + * Load libgamemode dynamically to dislodge us from most dependencies. + * This allows clients to link and/or use this regardless of runtime. + * See SDL2 for an example of the reasoning behind this in terms of + * dynamic versioning as well. + */ +static volatile int internal_libgamemode_loaded = 1; + +/* Typedefs for the functions to load */ +typedef int (*api_call_return_int)(void); +typedef const char *(*api_call_return_cstring)(void); +typedef int (*api_call_pid_return_int)(pid_t); + +/* Storage for functors */ +static api_call_return_int REAL_internal_gamemode_request_start = NULL; +static api_call_return_int REAL_internal_gamemode_request_end = NULL; +static api_call_return_int REAL_internal_gamemode_query_status = NULL; +static api_call_return_cstring REAL_internal_gamemode_error_string = NULL; +static api_call_pid_return_int REAL_internal_gamemode_request_start_for = NULL; +static api_call_pid_return_int REAL_internal_gamemode_request_end_for = NULL; +static api_call_pid_return_int REAL_internal_gamemode_query_status_for = NULL; + +/** + * Internal helper to perform the symbol binding safely. + * + * Returns 0 on success and -1 on failure + */ +__attribute__((always_inline)) static inline int internal_bind_libgamemode_symbol( + void *handle, const char *name, void **out_func, size_t func_size, bool required) +{ + void *symbol_lookup = NULL; + char *dl_error = NULL; + + /* Safely look up the symbol */ + symbol_lookup = dlsym(handle, name); + dl_error = dlerror(); + if (required && (dl_error || !symbol_lookup)) { + snprintf(internal_gamemode_client_error_string, + sizeof(internal_gamemode_client_error_string), + "dlsym failed - %s", + dl_error); + return -1; + } + + /* Have the symbol correctly, copy it to make it usable */ + memcpy(out_func, &symbol_lookup, func_size); + return 0; +} + +/** + * Loads libgamemode and needed functions + * + * Returns 0 on success and -1 on failure + */ +__attribute__((always_inline)) static inline int internal_load_libgamemode(void) +{ + /* We start at 1, 0 is a success and -1 is a fail */ + if (internal_libgamemode_loaded != 1) { + return internal_libgamemode_loaded; + } + + /* Anonymous struct type to define our bindings */ + struct binding { + const char *name; + void **functor; + size_t func_size; + bool required; + } bindings[] = { + { "real_gamemode_request_start", + (void **)&REAL_internal_gamemode_request_start, + sizeof(REAL_internal_gamemode_request_start), + true }, + { "real_gamemode_request_end", + (void **)&REAL_internal_gamemode_request_end, + sizeof(REAL_internal_gamemode_request_end), + true }, + { "real_gamemode_query_status", + (void **)&REAL_internal_gamemode_query_status, + sizeof(REAL_internal_gamemode_query_status), + false }, + { "real_gamemode_error_string", + (void **)&REAL_internal_gamemode_error_string, + sizeof(REAL_internal_gamemode_error_string), + true }, + { "real_gamemode_request_start_for", + (void **)&REAL_internal_gamemode_request_start_for, + sizeof(REAL_internal_gamemode_request_start_for), + false }, + { "real_gamemode_request_end_for", + (void **)&REAL_internal_gamemode_request_end_for, + sizeof(REAL_internal_gamemode_request_end_for), + false }, + { "real_gamemode_query_status_for", + (void **)&REAL_internal_gamemode_query_status_for, + sizeof(REAL_internal_gamemode_query_status_for), + false }, + }; + + void *libgamemode = NULL; + + /* Try and load libgamemode */ + libgamemode = dlopen("libgamemode.so.0", RTLD_NOW); + if (!libgamemode) { + /* Attempt to load unversioned library for compatibility with older + * versions (as of writing, there are no ABI changes between the two - + * this may need to change if ever ABI-breaking changes are made) */ + libgamemode = dlopen("libgamemode.so", RTLD_NOW); + if (!libgamemode) { + snprintf(internal_gamemode_client_error_string, + sizeof(internal_gamemode_client_error_string), + "dlopen failed - %s", + dlerror()); + internal_libgamemode_loaded = -1; + return -1; + } + } + + /* Attempt to bind all symbols */ + for (size_t i = 0; i < sizeof(bindings) / sizeof(bindings[0]); i++) { + struct binding *binder = &bindings[i]; + + if (internal_bind_libgamemode_symbol(libgamemode, + binder->name, + binder->functor, + binder->func_size, + binder->required)) { + internal_libgamemode_loaded = -1; + return -1; + }; + } + + /* Success */ + internal_libgamemode_loaded = 0; + return 0; +} + +/** + * Redirect to the real libgamemode + */ +__attribute__((always_inline)) static inline const char *gamemode_error_string(void) +{ + /* If we fail to load the system gamemode, or we have an error string already, return our error + * string instead of diverting to the system version */ + if (internal_load_libgamemode() < 0 || internal_gamemode_client_error_string[0] != '\0') { + return internal_gamemode_client_error_string; + } + + /* Assert for static analyser that the function is not NULL */ + assert(REAL_internal_gamemode_error_string != NULL); + + return REAL_internal_gamemode_error_string(); +} + +/** + * Redirect to the real libgamemode + * Allow automatically requesting game mode + * Also prints errors as they happen. + */ +#ifdef GAMEMODE_AUTO +__attribute__((constructor)) +#else +__attribute__((always_inline)) static inline +#endif +int gamemode_request_start(void) +{ + /* Need to load gamemode */ + if (internal_load_libgamemode() < 0) { +#ifdef GAMEMODE_AUTO + fprintf(stderr, "gamemodeauto: %s\n", gamemode_error_string()); +#endif + return -1; + } + + /* Assert for static analyser that the function is not NULL */ + assert(REAL_internal_gamemode_request_start != NULL); + + if (REAL_internal_gamemode_request_start() < 0) { +#ifdef GAMEMODE_AUTO + fprintf(stderr, "gamemodeauto: %s\n", gamemode_error_string()); +#endif + return -1; + } + + return 0; +} + +/* Redirect to the real libgamemode */ +#ifdef GAMEMODE_AUTO +__attribute__((destructor)) +#else +__attribute__((always_inline)) static inline +#endif +int gamemode_request_end(void) +{ + /* Need to load gamemode */ + if (internal_load_libgamemode() < 0) { +#ifdef GAMEMODE_AUTO + fprintf(stderr, "gamemodeauto: %s\n", gamemode_error_string()); +#endif + return -1; + } + + /* Assert for static analyser that the function is not NULL */ + assert(REAL_internal_gamemode_request_end != NULL); + + if (REAL_internal_gamemode_request_end() < 0) { +#ifdef GAMEMODE_AUTO + fprintf(stderr, "gamemodeauto: %s\n", gamemode_error_string()); +#endif + return -1; + } + + return 0; +} + +/* Redirect to the real libgamemode */ +__attribute__((always_inline)) static inline int gamemode_query_status(void) +{ + /* Need to load gamemode */ + if (internal_load_libgamemode() < 0) { + return -1; + } + + if (REAL_internal_gamemode_query_status == NULL) { + snprintf(internal_gamemode_client_error_string, + sizeof(internal_gamemode_client_error_string), + "gamemode_query_status missing (older host?)"); + return -1; + } + + return REAL_internal_gamemode_query_status(); +} + +/* Redirect to the real libgamemode */ +__attribute__((always_inline)) static inline int gamemode_request_start_for(pid_t pid) +{ + /* Need to load gamemode */ + if (internal_load_libgamemode() < 0) { + return -1; + } + + if (REAL_internal_gamemode_request_start_for == NULL) { + snprintf(internal_gamemode_client_error_string, + sizeof(internal_gamemode_client_error_string), + "gamemode_request_start_for missing (older host?)"); + return -1; + } + + return REAL_internal_gamemode_request_start_for(pid); +} + +/* Redirect to the real libgamemode */ +__attribute__((always_inline)) static inline int gamemode_request_end_for(pid_t pid) +{ + /* Need to load gamemode */ + if (internal_load_libgamemode() < 0) { + return -1; + } + + if (REAL_internal_gamemode_request_end_for == NULL) { + snprintf(internal_gamemode_client_error_string, + sizeof(internal_gamemode_client_error_string), + "gamemode_request_end_for missing (older host?)"); + return -1; + } + + return REAL_internal_gamemode_request_end_for(pid); +} + +/* Redirect to the real libgamemode */ +__attribute__((always_inline)) static inline int gamemode_query_status_for(pid_t pid) +{ + /* Need to load gamemode */ + if (internal_load_libgamemode() < 0) { + return -1; + } + + if (REAL_internal_gamemode_query_status_for == NULL) { + snprintf(internal_gamemode_client_error_string, + sizeof(internal_gamemode_client_error_string), + "gamemode_query_status_for missing (older host?)"); + return -1; + } + + return REAL_internal_gamemode_query_status_for(pid); +} + +#endif // CLIENT_GAMEMODE_H diff --git a/gamemode-zig/fetch_upstream.sh b/gamemode-zig/fetch_upstream.sh new file mode 100755 index 00000000..cbd364c8 --- /dev/null +++ b/gamemode-zig/fetch_upstream.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +rm ./c/* +cd ./c +wget "https://github.com/FeralInteractive/gamemode/raw/master/lib/gamemode_client.h" +wget "https://github.com/FeralInteractive/gamemode/raw/master/lib/client_impl.c" +wget "https://github.com/FeralInteractive/gamemode/raw/master/lib/client_loader.c" +cd .. + +# The output from translate-c isn't perfect, so we need this fix +zig translate-c ./c/gamemode_client.h -lc | sed "s#functor\(.*\)@alignCast\(.*\),\(.*\))#functor\1\3#" > ./src/gamemode_client.zig + +rm -r ./zig-cache diff --git a/gamemode-zig/src/gamemode.zig b/gamemode-zig/src/gamemode.zig new file mode 100644 index 00000000..9e9bc487 --- /dev/null +++ b/gamemode-zig/src/gamemode.zig @@ -0,0 +1,76 @@ +//! Note: All the above requests can be blocking - dbus requests can and will block while the daemon +//! handles the request. It is not recommended to make these calls in performance critical code + +pub const c = @import("gamemode_client.zig"); + +pub const GamemodeError = error{ + RequestFailed, + RequestRejected, + QueryFailed, +}; + +pub const GamemodeStatus = enum(c_int) { + Inactive = 0, + Active = 1, + /// Gamemode is active and the client is registered + ActiveAndRegistered = 2, +}; + +/// Request gamemode starts +pub fn requestStart() GamemodeError!void { + if (c.gamemode_request_start() == -1) + return GamemodeError.RequestFailed; +} + +/// Request gamemode ends +pub fn requestEnd() GamemodeError!void { + if (c.gamemode_request_end() == -1) + return GamemodeError.RequestFailed; +} + +/// Query the current status of gamemode +pub fn queryStatus() GamemodeError!GamemodeStatus { + const status = c.gamemode_query_status(); + if (status == -1) + return GamemodeError.QueryFailed; + + return @intToEnum(GamemodeStatus, status); +} + +/// Request gamemode starts for another process +pub fn requestStartFor(pid: c.pid_t) GamemodeError!void { + const res = c.gamemode_request_start_for(pid); + if (res == 0) { + return; + } else if (res == -1) { + return GamemodeError.RequestFailed; + } else if (res == -2) { + return GamemodeError.RequestRejected; + } +} + +/// Request gamemode ends for another process +pub fn requestEndFor(pid: c.pid_t) GamemodeError!void { + const res = c.gamemode_request_end_for(pid); + if (res == 0) { + return; + } else if (res == -1) { + return GamemodeError.RequestFailed; + } else if (res == -2) { + return GamemodeError.RequestRejected; + } +} + +/// Query the current status of gamemode for another process +pub fn queryStatusFor(pid: c.pid_t) GamemodeError!GamemodeStatus { + const status = c.gamemode_query_status_for(pid); + if (status == -1) + return GamemodeError.QueryFailed; + + return @intToEnum(GamemodeStatus, status); +} + +/// Get an error string +pub fn errorString() []const u8 { + return @import("std").mem.sliceTo(c.gamemode_error_string(), 0); +} diff --git a/gamemode-zig/src/gamemode_client.zig b/gamemode-zig/src/gamemode_client.zig new file mode 100644 index 00000000..7dc9527e --- /dev/null +++ b/gamemode-zig/src/gamemode_client.zig @@ -0,0 +1,1650 @@ +pub const __builtin_bswap16 = @import("std").zig.c_builtins.__builtin_bswap16; +pub const __builtin_bswap32 = @import("std").zig.c_builtins.__builtin_bswap32; +pub const __builtin_bswap64 = @import("std").zig.c_builtins.__builtin_bswap64; +pub const __builtin_signbit = @import("std").zig.c_builtins.__builtin_signbit; +pub const __builtin_signbitf = @import("std").zig.c_builtins.__builtin_signbitf; +pub const __builtin_popcount = @import("std").zig.c_builtins.__builtin_popcount; +pub const __builtin_ctz = @import("std").zig.c_builtins.__builtin_ctz; +pub const __builtin_clz = @import("std").zig.c_builtins.__builtin_clz; +pub const __builtin_sqrt = @import("std").zig.c_builtins.__builtin_sqrt; +pub const __builtin_sqrtf = @import("std").zig.c_builtins.__builtin_sqrtf; +pub const __builtin_sin = @import("std").zig.c_builtins.__builtin_sin; +pub const __builtin_sinf = @import("std").zig.c_builtins.__builtin_sinf; +pub const __builtin_cos = @import("std").zig.c_builtins.__builtin_cos; +pub const __builtin_cosf = @import("std").zig.c_builtins.__builtin_cosf; +pub const __builtin_exp = @import("std").zig.c_builtins.__builtin_exp; +pub const __builtin_expf = @import("std").zig.c_builtins.__builtin_expf; +pub const __builtin_exp2 = @import("std").zig.c_builtins.__builtin_exp2; +pub const __builtin_exp2f = @import("std").zig.c_builtins.__builtin_exp2f; +pub const __builtin_log = @import("std").zig.c_builtins.__builtin_log; +pub const __builtin_logf = @import("std").zig.c_builtins.__builtin_logf; +pub const __builtin_log2 = @import("std").zig.c_builtins.__builtin_log2; +pub const __builtin_log2f = @import("std").zig.c_builtins.__builtin_log2f; +pub const __builtin_log10 = @import("std").zig.c_builtins.__builtin_log10; +pub const __builtin_log10f = @import("std").zig.c_builtins.__builtin_log10f; +pub const __builtin_abs = @import("std").zig.c_builtins.__builtin_abs; +pub const __builtin_fabs = @import("std").zig.c_builtins.__builtin_fabs; +pub const __builtin_fabsf = @import("std").zig.c_builtins.__builtin_fabsf; +pub const __builtin_floor = @import("std").zig.c_builtins.__builtin_floor; +pub const __builtin_floorf = @import("std").zig.c_builtins.__builtin_floorf; +pub const __builtin_ceil = @import("std").zig.c_builtins.__builtin_ceil; +pub const __builtin_ceilf = @import("std").zig.c_builtins.__builtin_ceilf; +pub const __builtin_trunc = @import("std").zig.c_builtins.__builtin_trunc; +pub const __builtin_truncf = @import("std").zig.c_builtins.__builtin_truncf; +pub const __builtin_round = @import("std").zig.c_builtins.__builtin_round; +pub const __builtin_roundf = @import("std").zig.c_builtins.__builtin_roundf; +pub const __builtin_strlen = @import("std").zig.c_builtins.__builtin_strlen; +pub const __builtin_strcmp = @import("std").zig.c_builtins.__builtin_strcmp; +pub const __builtin_object_size = @import("std").zig.c_builtins.__builtin_object_size; +pub const __builtin___memset_chk = @import("std").zig.c_builtins.__builtin___memset_chk; +pub const __builtin_memset = @import("std").zig.c_builtins.__builtin_memset; +pub const __builtin___memcpy_chk = @import("std").zig.c_builtins.__builtin___memcpy_chk; +pub const __builtin_memcpy = @import("std").zig.c_builtins.__builtin_memcpy; +pub const __builtin_expect = @import("std").zig.c_builtins.__builtin_expect; +pub const __builtin_nanf = @import("std").zig.c_builtins.__builtin_nanf; +pub const __builtin_huge_valf = @import("std").zig.c_builtins.__builtin_huge_valf; +pub const __builtin_inff = @import("std").zig.c_builtins.__builtin_inff; +pub const __builtin_isnan = @import("std").zig.c_builtins.__builtin_isnan; +pub const __builtin_isinf = @import("std").zig.c_builtins.__builtin_isinf; +pub const __builtin_isinf_sign = @import("std").zig.c_builtins.__builtin_isinf_sign; +pub const __has_builtin = @import("std").zig.c_builtins.__has_builtin; +pub const __builtin_assume = @import("std").zig.c_builtins.__builtin_assume; +pub const __builtin_unreachable = @import("std").zig.c_builtins.__builtin_unreachable; +pub const __builtin_constant_p = @import("std").zig.c_builtins.__builtin_constant_p; +pub const __builtin_mul_overflow = @import("std").zig.c_builtins.__builtin_mul_overflow; +pub const struct___va_list_tag = extern struct { + gp_offset: c_uint, + fp_offset: c_uint, + overflow_arg_area: ?*anyopaque, + reg_save_area: ?*anyopaque, +}; +pub const __builtin_va_list = [1]struct___va_list_tag; +pub const va_list = __builtin_va_list; +pub const __gnuc_va_list = __builtin_va_list; +pub const __u_char = u8; +pub const __u_short = c_ushort; +pub const __u_int = c_uint; +pub const __u_long = c_ulong; +pub const __int8_t = i8; +pub const __uint8_t = u8; +pub const __int16_t = c_short; +pub const __uint16_t = c_ushort; +pub const __int32_t = c_int; +pub const __uint32_t = c_uint; +pub const __int64_t = c_long; +pub const __uint64_t = c_ulong; +pub const __int_least8_t = __int8_t; +pub const __uint_least8_t = __uint8_t; +pub const __int_least16_t = __int16_t; +pub const __uint_least16_t = __uint16_t; +pub const __int_least32_t = __int32_t; +pub const __uint_least32_t = __uint32_t; +pub const __int_least64_t = __int64_t; +pub const __uint_least64_t = __uint64_t; +pub const __quad_t = c_long; +pub const __u_quad_t = c_ulong; +pub const __intmax_t = c_long; +pub const __uintmax_t = c_ulong; +pub const __dev_t = c_ulong; +pub const __uid_t = c_uint; +pub const __gid_t = c_uint; +pub const __ino_t = c_ulong; +pub const __ino64_t = c_ulong; +pub const __mode_t = c_uint; +pub const __nlink_t = c_ulong; +pub const __off_t = c_long; +pub const __off64_t = c_long; +pub const __pid_t = c_int; +pub const __fsid_t = extern struct { + __val: [2]c_int, +}; +pub const __clock_t = c_long; +pub const __rlim_t = c_ulong; +pub const __rlim64_t = c_ulong; +pub const __id_t = c_uint; +pub const __time_t = c_long; +pub const __useconds_t = c_uint; +pub const __suseconds_t = c_long; +pub const __suseconds64_t = c_long; +pub const __daddr_t = c_int; +pub const __key_t = c_int; +pub const __clockid_t = c_int; +pub const __timer_t = ?*anyopaque; +pub const __blksize_t = c_long; +pub const __blkcnt_t = c_long; +pub const __blkcnt64_t = c_long; +pub const __fsblkcnt_t = c_ulong; +pub const __fsblkcnt64_t = c_ulong; +pub const __fsfilcnt_t = c_ulong; +pub const __fsfilcnt64_t = c_ulong; +pub const __fsword_t = c_long; +pub const __ssize_t = c_long; +pub const __syscall_slong_t = c_long; +pub const __syscall_ulong_t = c_ulong; +pub const __loff_t = __off64_t; +pub const __caddr_t = [*c]u8; +pub const __intptr_t = c_long; +pub const __socklen_t = c_uint; +pub const __sig_atomic_t = c_int; +const union_unnamed_1 = extern union { + __wch: c_uint, + __wchb: [4]u8, +}; +pub const __mbstate_t = extern struct { + __count: c_int, + __value: union_unnamed_1, +}; +pub const struct__G_fpos_t = extern struct { + __pos: __off_t, + __state: __mbstate_t, +}; +pub const __fpos_t = struct__G_fpos_t; +pub const struct__G_fpos64_t = extern struct { + __pos: __off64_t, + __state: __mbstate_t, +}; +pub const __fpos64_t = struct__G_fpos64_t; +pub const struct__IO_marker = opaque {}; +pub const _IO_lock_t = anyopaque; +pub const struct__IO_codecvt = opaque {}; +pub const struct__IO_wide_data = opaque {}; +pub const struct__IO_FILE = extern struct { + _flags: c_int, + _IO_read_ptr: [*c]u8, + _IO_read_end: [*c]u8, + _IO_read_base: [*c]u8, + _IO_write_base: [*c]u8, + _IO_write_ptr: [*c]u8, + _IO_write_end: [*c]u8, + _IO_buf_base: [*c]u8, + _IO_buf_end: [*c]u8, + _IO_save_base: [*c]u8, + _IO_backup_base: [*c]u8, + _IO_save_end: [*c]u8, + _markers: ?*struct__IO_marker, + _chain: [*c]struct__IO_FILE, + _fileno: c_int, + _flags2: c_int, + _old_offset: __off_t, + _cur_column: c_ushort, + _vtable_offset: i8, + _shortbuf: [1]u8, + _lock: ?*_IO_lock_t, + _offset: __off64_t, + _codecvt: ?*struct__IO_codecvt, + _wide_data: ?*struct__IO_wide_data, + _freeres_list: [*c]struct__IO_FILE, + _freeres_buf: ?*anyopaque, + __pad5: usize, + _mode: c_int, + _unused2: [20]u8, +}; +pub const __FILE = struct__IO_FILE; +pub const FILE = struct__IO_FILE; +pub const off_t = __off_t; +pub const fpos_t = __fpos_t; +pub extern var stdin: [*c]FILE; +pub extern var stdout: [*c]FILE; +pub extern var stderr: [*c]FILE; +pub extern fn remove(__filename: [*c]const u8) c_int; +pub extern fn rename(__old: [*c]const u8, __new: [*c]const u8) c_int; +pub extern fn renameat(__oldfd: c_int, __old: [*c]const u8, __newfd: c_int, __new: [*c]const u8) c_int; +pub extern fn fclose(__stream: [*c]FILE) c_int; +pub extern fn tmpfile() [*c]FILE; +pub extern fn tmpnam([*c]u8) [*c]u8; +pub extern fn tmpnam_r(__s: [*c]u8) [*c]u8; +pub extern fn tempnam(__dir: [*c]const u8, __pfx: [*c]const u8) [*c]u8; +pub extern fn fflush(__stream: [*c]FILE) c_int; +pub extern fn fflush_unlocked(__stream: [*c]FILE) c_int; +pub extern fn fopen(__filename: [*c]const u8, __modes: [*c]const u8) [*c]FILE; +pub extern fn freopen(noalias __filename: [*c]const u8, noalias __modes: [*c]const u8, noalias __stream: [*c]FILE) [*c]FILE; +pub extern fn fdopen(__fd: c_int, __modes: [*c]const u8) [*c]FILE; +pub extern fn fmemopen(__s: ?*anyopaque, __len: usize, __modes: [*c]const u8) [*c]FILE; +pub extern fn open_memstream(__bufloc: [*c][*c]u8, __sizeloc: [*c]usize) [*c]FILE; +pub extern fn setbuf(noalias __stream: [*c]FILE, noalias __buf: [*c]u8) void; +pub extern fn setvbuf(noalias __stream: [*c]FILE, noalias __buf: [*c]u8, __modes: c_int, __n: usize) c_int; +pub extern fn setbuffer(noalias __stream: [*c]FILE, noalias __buf: [*c]u8, __size: usize) void; +pub extern fn setlinebuf(__stream: [*c]FILE) void; +pub extern fn fprintf(__stream: [*c]FILE, __format: [*c]const u8, ...) c_int; +pub extern fn printf(__format: [*c]const u8, ...) c_int; +pub extern fn sprintf(__s: [*c]u8, __format: [*c]const u8, ...) c_int; +pub extern fn vfprintf(__s: [*c]FILE, __format: [*c]const u8, __arg: [*c]struct___va_list_tag) c_int; +pub extern fn vprintf(__format: [*c]const u8, __arg: [*c]struct___va_list_tag) c_int; +pub extern fn vsprintf(__s: [*c]u8, __format: [*c]const u8, __arg: [*c]struct___va_list_tag) c_int; +pub extern fn snprintf(__s: [*c]u8, __maxlen: c_ulong, __format: [*c]const u8, ...) c_int; +pub extern fn vsnprintf(__s: [*c]u8, __maxlen: c_ulong, __format: [*c]const u8, __arg: [*c]struct___va_list_tag) c_int; +pub extern fn vdprintf(__fd: c_int, noalias __fmt: [*c]const u8, __arg: [*c]struct___va_list_tag) c_int; +pub extern fn dprintf(__fd: c_int, noalias __fmt: [*c]const u8, ...) c_int; +pub extern fn fscanf(noalias __stream: [*c]FILE, noalias __format: [*c]const u8, ...) c_int; +pub extern fn scanf(noalias __format: [*c]const u8, ...) c_int; +pub extern fn sscanf(noalias __s: [*c]const u8, noalias __format: [*c]const u8, ...) c_int; +pub const _Float32 = f32; +pub const _Float64 = f64; +pub const _Float32x = f64; +pub const _Float64x = c_longdouble; +pub extern fn vfscanf(noalias __s: [*c]FILE, noalias __format: [*c]const u8, __arg: [*c]struct___va_list_tag) c_int; +pub extern fn vscanf(noalias __format: [*c]const u8, __arg: [*c]struct___va_list_tag) c_int; +pub extern fn vsscanf(noalias __s: [*c]const u8, noalias __format: [*c]const u8, __arg: [*c]struct___va_list_tag) c_int; +pub extern fn fgetc(__stream: [*c]FILE) c_int; +pub extern fn getc(__stream: [*c]FILE) c_int; +pub extern fn getchar() c_int; +pub extern fn getc_unlocked(__stream: [*c]FILE) c_int; +pub extern fn getchar_unlocked() c_int; +pub extern fn fgetc_unlocked(__stream: [*c]FILE) c_int; +pub extern fn fputc(__c: c_int, __stream: [*c]FILE) c_int; +pub extern fn putc(__c: c_int, __stream: [*c]FILE) c_int; +pub extern fn putchar(__c: c_int) c_int; +pub extern fn fputc_unlocked(__c: c_int, __stream: [*c]FILE) c_int; +pub extern fn putc_unlocked(__c: c_int, __stream: [*c]FILE) c_int; +pub extern fn putchar_unlocked(__c: c_int) c_int; +pub extern fn getw(__stream: [*c]FILE) c_int; +pub extern fn putw(__w: c_int, __stream: [*c]FILE) c_int; +pub extern fn fgets(noalias __s: [*c]u8, __n: c_int, noalias __stream: [*c]FILE) [*c]u8; +pub extern fn __getdelim(noalias __lineptr: [*c][*c]u8, noalias __n: [*c]usize, __delimiter: c_int, noalias __stream: [*c]FILE) __ssize_t; +pub extern fn getdelim(noalias __lineptr: [*c][*c]u8, noalias __n: [*c]usize, __delimiter: c_int, noalias __stream: [*c]FILE) __ssize_t; +pub extern fn getline(noalias __lineptr: [*c][*c]u8, noalias __n: [*c]usize, noalias __stream: [*c]FILE) __ssize_t; +pub extern fn fputs(noalias __s: [*c]const u8, noalias __stream: [*c]FILE) c_int; +pub extern fn puts(__s: [*c]const u8) c_int; +pub extern fn ungetc(__c: c_int, __stream: [*c]FILE) c_int; +pub extern fn fread(__ptr: ?*anyopaque, __size: c_ulong, __n: c_ulong, __stream: [*c]FILE) c_ulong; +pub extern fn fwrite(__ptr: ?*const anyopaque, __size: c_ulong, __n: c_ulong, __s: [*c]FILE) c_ulong; +pub extern fn fread_unlocked(noalias __ptr: ?*anyopaque, __size: usize, __n: usize, noalias __stream: [*c]FILE) usize; +pub extern fn fwrite_unlocked(noalias __ptr: ?*const anyopaque, __size: usize, __n: usize, noalias __stream: [*c]FILE) usize; +pub extern fn fseek(__stream: [*c]FILE, __off: c_long, __whence: c_int) c_int; +pub extern fn ftell(__stream: [*c]FILE) c_long; +pub extern fn rewind(__stream: [*c]FILE) void; +pub extern fn fseeko(__stream: [*c]FILE, __off: __off_t, __whence: c_int) c_int; +pub extern fn ftello(__stream: [*c]FILE) __off_t; +pub extern fn fgetpos(noalias __stream: [*c]FILE, noalias __pos: [*c]fpos_t) c_int; +pub extern fn fsetpos(__stream: [*c]FILE, __pos: [*c]const fpos_t) c_int; +pub extern fn clearerr(__stream: [*c]FILE) void; +pub extern fn feof(__stream: [*c]FILE) c_int; +pub extern fn ferror(__stream: [*c]FILE) c_int; +pub extern fn clearerr_unlocked(__stream: [*c]FILE) void; +pub extern fn feof_unlocked(__stream: [*c]FILE) c_int; +pub extern fn ferror_unlocked(__stream: [*c]FILE) c_int; +pub extern fn perror(__s: [*c]const u8) void; +pub extern fn fileno(__stream: [*c]FILE) c_int; +pub extern fn fileno_unlocked(__stream: [*c]FILE) c_int; +pub extern fn pclose(__stream: [*c]FILE) c_int; +pub extern fn popen(__command: [*c]const u8, __modes: [*c]const u8) [*c]FILE; +pub extern fn ctermid(__s: [*c]u8) [*c]u8; +pub extern fn flockfile(__stream: [*c]FILE) void; +pub extern fn ftrylockfile(__stream: [*c]FILE) c_int; +pub extern fn funlockfile(__stream: [*c]FILE) void; +pub extern fn __uflow([*c]FILE) c_int; +pub extern fn __overflow([*c]FILE, c_int) c_int; +pub extern fn dlopen(__file: [*c]const u8, __mode: c_int) ?*anyopaque; +pub extern fn dlclose(__handle: ?*anyopaque) c_int; +pub extern fn dlsym(noalias __handle: ?*anyopaque, noalias __name: [*c]const u8) ?*anyopaque; +pub extern fn dlerror() [*c]u8; +pub extern fn memcpy(__dest: ?*anyopaque, __src: ?*const anyopaque, __n: c_ulong) ?*anyopaque; +pub extern fn memmove(__dest: ?*anyopaque, __src: ?*const anyopaque, __n: c_ulong) ?*anyopaque; +pub extern fn memccpy(__dest: ?*anyopaque, __src: ?*const anyopaque, __c: c_int, __n: c_ulong) ?*anyopaque; +pub extern fn memset(__s: ?*anyopaque, __c: c_int, __n: c_ulong) ?*anyopaque; +pub extern fn memcmp(__s1: ?*const anyopaque, __s2: ?*const anyopaque, __n: c_ulong) c_int; +pub extern fn memchr(__s: ?*const anyopaque, __c: c_int, __n: c_ulong) ?*anyopaque; +pub extern fn strcpy(__dest: [*c]u8, __src: [*c]const u8) [*c]u8; +pub extern fn strncpy(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) [*c]u8; +pub extern fn strcat(__dest: [*c]u8, __src: [*c]const u8) [*c]u8; +pub extern fn strncat(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) [*c]u8; +pub extern fn strcmp(__s1: [*c]const u8, __s2: [*c]const u8) c_int; +pub extern fn strncmp(__s1: [*c]const u8, __s2: [*c]const u8, __n: c_ulong) c_int; +pub extern fn strcoll(__s1: [*c]const u8, __s2: [*c]const u8) c_int; +pub extern fn strxfrm(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) c_ulong; +pub const struct___locale_data = opaque {}; +pub const struct___locale_struct = extern struct { + __locales: [13]?*struct___locale_data, + __ctype_b: [*c]const c_ushort, + __ctype_tolower: [*c]const c_int, + __ctype_toupper: [*c]const c_int, + __names: [13][*c]const u8, +}; +pub const __locale_t = [*c]struct___locale_struct; +pub const locale_t = __locale_t; +pub extern fn strcoll_l(__s1: [*c]const u8, __s2: [*c]const u8, __l: locale_t) c_int; +pub extern fn strxfrm_l(__dest: [*c]u8, __src: [*c]const u8, __n: usize, __l: locale_t) usize; +pub extern fn strdup(__s: [*c]const u8) [*c]u8; +pub extern fn strndup(__string: [*c]const u8, __n: c_ulong) [*c]u8; +pub extern fn strchr(__s: [*c]const u8, __c: c_int) [*c]u8; +pub extern fn strrchr(__s: [*c]const u8, __c: c_int) [*c]u8; +pub extern fn strcspn(__s: [*c]const u8, __reject: [*c]const u8) c_ulong; +pub extern fn strspn(__s: [*c]const u8, __accept: [*c]const u8) c_ulong; +pub extern fn strpbrk(__s: [*c]const u8, __accept: [*c]const u8) [*c]u8; +pub extern fn strstr(__haystack: [*c]const u8, __needle: [*c]const u8) [*c]u8; +pub extern fn strtok(__s: [*c]u8, __delim: [*c]const u8) [*c]u8; +pub extern fn __strtok_r(noalias __s: [*c]u8, noalias __delim: [*c]const u8, noalias __save_ptr: [*c][*c]u8) [*c]u8; +pub extern fn strtok_r(noalias __s: [*c]u8, noalias __delim: [*c]const u8, noalias __save_ptr: [*c][*c]u8) [*c]u8; +pub extern fn strlen(__s: [*c]const u8) c_ulong; +pub extern fn strnlen(__string: [*c]const u8, __maxlen: usize) usize; +pub extern fn strerror(__errnum: c_int) [*c]u8; +pub extern fn strerror_r(__errnum: c_int, __buf: [*c]u8, __buflen: usize) c_int; +pub extern fn strerror_l(__errnum: c_int, __l: locale_t) [*c]u8; +pub extern fn bcmp(__s1: ?*const anyopaque, __s2: ?*const anyopaque, __n: c_ulong) c_int; +pub extern fn bcopy(__src: ?*const anyopaque, __dest: ?*anyopaque, __n: usize) void; +pub extern fn bzero(__s: ?*anyopaque, __n: c_ulong) void; +pub extern fn index(__s: [*c]const u8, __c: c_int) [*c]u8; +pub extern fn rindex(__s: [*c]const u8, __c: c_int) [*c]u8; +pub extern fn ffs(__i: c_int) c_int; +pub extern fn ffsl(__l: c_long) c_int; +pub extern fn ffsll(__ll: c_longlong) c_int; +pub extern fn strcasecmp(__s1: [*c]const u8, __s2: [*c]const u8) c_int; +pub extern fn strncasecmp(__s1: [*c]const u8, __s2: [*c]const u8, __n: c_ulong) c_int; +pub extern fn strcasecmp_l(__s1: [*c]const u8, __s2: [*c]const u8, __loc: locale_t) c_int; +pub extern fn strncasecmp_l(__s1: [*c]const u8, __s2: [*c]const u8, __n: usize, __loc: locale_t) c_int; +pub extern fn explicit_bzero(__s: ?*anyopaque, __n: usize) void; +pub extern fn strsep(noalias __stringp: [*c][*c]u8, noalias __delim: [*c]const u8) [*c]u8; +pub extern fn strsignal(__sig: c_int) [*c]u8; +pub extern fn __stpcpy(noalias __dest: [*c]u8, noalias __src: [*c]const u8) [*c]u8; +pub extern fn stpcpy(__dest: [*c]u8, __src: [*c]const u8) [*c]u8; +pub extern fn __stpncpy(noalias __dest: [*c]u8, noalias __src: [*c]const u8, __n: usize) [*c]u8; +pub extern fn stpncpy(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) [*c]u8; +pub extern fn __assert_fail(__assertion: [*c]const u8, __file: [*c]const u8, __line: c_uint, __function: [*c]const u8) noreturn; +pub extern fn __assert_perror_fail(__errnum: c_int, __file: [*c]const u8, __line: c_uint, __function: [*c]const u8) noreturn; +pub extern fn __assert(__assertion: [*c]const u8, __file: [*c]const u8, __line: c_int) noreturn; +pub const u_char = __u_char; +pub const u_short = __u_short; +pub const u_int = __u_int; +pub const u_long = __u_long; +pub const quad_t = __quad_t; +pub const u_quad_t = __u_quad_t; +pub const fsid_t = __fsid_t; +pub const loff_t = __loff_t; +pub const ino_t = __ino_t; +pub const dev_t = __dev_t; +pub const gid_t = __gid_t; +pub const mode_t = __mode_t; +pub const nlink_t = __nlink_t; +pub const uid_t = __uid_t; +pub const pid_t = __pid_t; +pub const id_t = __id_t; +pub const daddr_t = __daddr_t; +pub const caddr_t = __caddr_t; +pub const key_t = __key_t; +pub const clock_t = __clock_t; +pub const clockid_t = __clockid_t; +pub const time_t = __time_t; +pub const timer_t = __timer_t; +pub const ulong = c_ulong; +pub const ushort = c_ushort; +pub const uint = c_uint; +pub const u_int8_t = __uint8_t; +pub const u_int16_t = __uint16_t; +pub const u_int32_t = __uint32_t; +pub const u_int64_t = __uint64_t; +pub const register_t = c_long; +pub fn __bswap_16(arg___bsx: __uint16_t) callconv(.C) __uint16_t { + var __bsx = arg___bsx; + return @bitCast(__uint16_t, @truncate(c_short, ((@bitCast(c_int, @as(c_uint, __bsx)) >> @intCast(@import("std").math.Log2Int(c_int), 8)) & @as(c_int, 255)) | ((@bitCast(c_int, @as(c_uint, __bsx)) & @as(c_int, 255)) << @intCast(@import("std").math.Log2Int(c_int), 8)))); +} +pub fn __bswap_32(arg___bsx: __uint32_t) callconv(.C) __uint32_t { + var __bsx = arg___bsx; + return ((((__bsx & @as(c_uint, 4278190080)) >> @intCast(@import("std").math.Log2Int(c_uint), 24)) | ((__bsx & @as(c_uint, 16711680)) >> @intCast(@import("std").math.Log2Int(c_uint), 8))) | ((__bsx & @as(c_uint, 65280)) << @intCast(@import("std").math.Log2Int(c_uint), 8))) | ((__bsx & @as(c_uint, 255)) << @intCast(@import("std").math.Log2Int(c_uint), 24)); +} +pub fn __bswap_64(arg___bsx: __uint64_t) callconv(.C) __uint64_t { + var __bsx = arg___bsx; + return @bitCast(__uint64_t, @truncate(c_ulong, ((((((((@bitCast(c_ulonglong, @as(c_ulonglong, __bsx)) & @as(c_ulonglong, 18374686479671623680)) >> @intCast(@import("std").math.Log2Int(c_ulonglong), 56)) | ((@bitCast(c_ulonglong, @as(c_ulonglong, __bsx)) & @as(c_ulonglong, 71776119061217280)) >> @intCast(@import("std").math.Log2Int(c_ulonglong), 40))) | ((@bitCast(c_ulonglong, @as(c_ulonglong, __bsx)) & @as(c_ulonglong, 280375465082880)) >> @intCast(@import("std").math.Log2Int(c_ulonglong), 24))) | ((@bitCast(c_ulonglong, @as(c_ulonglong, __bsx)) & @as(c_ulonglong, 1095216660480)) >> @intCast(@import("std").math.Log2Int(c_ulonglong), 8))) | ((@bitCast(c_ulonglong, @as(c_ulonglong, __bsx)) & @as(c_ulonglong, 4278190080)) << @intCast(@import("std").math.Log2Int(c_ulonglong), 8))) | ((@bitCast(c_ulonglong, @as(c_ulonglong, __bsx)) & @as(c_ulonglong, 16711680)) << @intCast(@import("std").math.Log2Int(c_ulonglong), 24))) | ((@bitCast(c_ulonglong, @as(c_ulonglong, __bsx)) & @as(c_ulonglong, 65280)) << @intCast(@import("std").math.Log2Int(c_ulonglong), 40))) | ((@bitCast(c_ulonglong, @as(c_ulonglong, __bsx)) & @as(c_ulonglong, 255)) << @intCast(@import("std").math.Log2Int(c_ulonglong), 56)))); +} +pub fn __uint16_identity(arg___x: __uint16_t) callconv(.C) __uint16_t { + var __x = arg___x; + return __x; +} +pub fn __uint32_identity(arg___x: __uint32_t) callconv(.C) __uint32_t { + var __x = arg___x; + return __x; +} +pub fn __uint64_identity(arg___x: __uint64_t) callconv(.C) __uint64_t { + var __x = arg___x; + return __x; +} +pub const __sigset_t = extern struct { + __val: [16]c_ulong, +}; +pub const sigset_t = __sigset_t; +pub const struct_timeval = extern struct { + tv_sec: __time_t, + tv_usec: __suseconds_t, +}; +pub const struct_timespec = extern struct { + tv_sec: __time_t, + tv_nsec: __syscall_slong_t, +}; +pub const suseconds_t = __suseconds_t; +pub const __fd_mask = c_long; +pub const fd_set = extern struct { + __fds_bits: [16]__fd_mask, +}; +pub const fd_mask = __fd_mask; +pub extern fn select(__nfds: c_int, noalias __readfds: [*c]fd_set, noalias __writefds: [*c]fd_set, noalias __exceptfds: [*c]fd_set, noalias __timeout: [*c]struct_timeval) c_int; +pub extern fn pselect(__nfds: c_int, noalias __readfds: [*c]fd_set, noalias __writefds: [*c]fd_set, noalias __exceptfds: [*c]fd_set, noalias __timeout: [*c]const struct_timespec, noalias __sigmask: [*c]const __sigset_t) c_int; +pub const blksize_t = __blksize_t; +pub const blkcnt_t = __blkcnt_t; +pub const fsblkcnt_t = __fsblkcnt_t; +pub const fsfilcnt_t = __fsfilcnt_t; +pub const struct___pthread_internal_list = extern struct { + __prev: [*c]struct___pthread_internal_list, + __next: [*c]struct___pthread_internal_list, +}; +pub const __pthread_list_t = struct___pthread_internal_list; +pub const struct___pthread_internal_slist = extern struct { + __next: [*c]struct___pthread_internal_slist, +}; +pub const __pthread_slist_t = struct___pthread_internal_slist; +pub const struct___pthread_mutex_s = extern struct { + __lock: c_int, + __count: c_uint, + __owner: c_int, + __nusers: c_uint, + __kind: c_int, + __spins: c_short, + __elision: c_short, + __list: __pthread_list_t, +}; +pub const struct___pthread_rwlock_arch_t = extern struct { + __readers: c_uint, + __writers: c_uint, + __wrphase_futex: c_uint, + __writers_futex: c_uint, + __pad3: c_uint, + __pad4: c_uint, + __cur_writer: c_int, + __shared: c_int, + __rwelision: i8, + __pad1: [7]u8, + __pad2: c_ulong, + __flags: c_uint, +}; +const struct_unnamed_3 = extern struct { + __low: c_uint, + __high: c_uint, +}; +const union_unnamed_2 = extern union { + __wseq: c_ulonglong, + __wseq32: struct_unnamed_3, +}; +const struct_unnamed_5 = extern struct { + __low: c_uint, + __high: c_uint, +}; +const union_unnamed_4 = extern union { + __g1_start: c_ulonglong, + __g1_start32: struct_unnamed_5, +}; +pub const struct___pthread_cond_s = extern struct { + unnamed_0: union_unnamed_2, + unnamed_1: union_unnamed_4, + __g_refs: [2]c_uint, + __g_size: [2]c_uint, + __g1_orig_size: c_uint, + __wrefs: c_uint, + __g_signals: [2]c_uint, +}; +pub const __tss_t = c_uint; +pub const __thrd_t = c_ulong; +pub const __once_flag = extern struct { + __data: c_int, +}; +pub const pthread_t = c_ulong; +pub const pthread_mutexattr_t = extern union { + __size: [4]u8, + __align: c_int, +}; +pub const pthread_condattr_t = extern union { + __size: [4]u8, + __align: c_int, +}; +pub const pthread_key_t = c_uint; +pub const pthread_once_t = c_int; +pub const union_pthread_attr_t = extern union { + __size: [56]u8, + __align: c_long, +}; +pub const pthread_attr_t = union_pthread_attr_t; +pub const pthread_mutex_t = extern union { + __data: struct___pthread_mutex_s, + __size: [40]u8, + __align: c_long, +}; +pub const pthread_cond_t = extern union { + __data: struct___pthread_cond_s, + __size: [48]u8, + __align: c_longlong, +}; +pub const pthread_rwlock_t = extern union { + __data: struct___pthread_rwlock_arch_t, + __size: [56]u8, + __align: c_long, +}; +pub const pthread_rwlockattr_t = extern union { + __size: [8]u8, + __align: c_long, +}; +pub const pthread_spinlock_t = c_int; +pub const pthread_barrier_t = extern union { + __size: [32]u8, + __align: c_long, +}; +pub const pthread_barrierattr_t = extern union { + __size: [4]u8, + __align: c_int, +}; +pub var internal_gamemode_client_error_string: [512]u8 = [1]u8{ + 0, +} ++ [1]u8{0} ** 511; +pub var internal_libgamemode_loaded: c_int = 1; +pub const api_call_return_int = ?fn () callconv(.C) c_int; +pub const api_call_return_cstring = ?fn () callconv(.C) [*c]const u8; +pub const api_call_pid_return_int = ?fn (pid_t) callconv(.C) c_int; +pub var REAL_internal_gamemode_request_start: api_call_return_int = null; +pub var REAL_internal_gamemode_request_end: api_call_return_int = null; +pub var REAL_internal_gamemode_query_status: api_call_return_int = null; +pub var REAL_internal_gamemode_error_string: api_call_return_cstring = null; +pub var REAL_internal_gamemode_request_start_for: api_call_pid_return_int = null; +pub var REAL_internal_gamemode_request_end_for: api_call_pid_return_int = null; +pub var REAL_internal_gamemode_query_status_for: api_call_pid_return_int = null; +pub inline fn internal_bind_libgamemode_symbol(arg_handle: ?*anyopaque, arg_name: [*c]const u8, arg_out_func: [*c]?*anyopaque, arg_func_size: usize, arg_required: bool) c_int { + var handle = arg_handle; + var name = arg_name; + var out_func = arg_out_func; + var func_size = arg_func_size; + var required = arg_required; + var symbol_lookup: ?*anyopaque = @intToPtr(?*anyopaque, @as(c_int, 0)); + var dl_error: [*c]u8 = null; + symbol_lookup = dlsym(handle, name); + dl_error = dlerror(); + if ((@as(c_int, @boolToInt(required)) != 0) and ((dl_error != null) or !(symbol_lookup != null))) { + _ = snprintf(@ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), &internal_gamemode_client_error_string)), @sizeOf([512]u8), "dlsym failed - %s", dl_error); + return -@as(c_int, 1); + } + _ = memcpy(@ptrCast(?*anyopaque, out_func), @ptrCast(?*const anyopaque, &symbol_lookup), func_size); + return 0; +} +pub inline fn internal_load_libgamemode() c_int { + if (internal_libgamemode_loaded != @as(c_int, 1)) { + return internal_libgamemode_loaded; + } + const struct_binding = extern struct { + name: [*c]const u8, + functor: [*c]?*anyopaque, + func_size: usize, + required: bool, + }; + var bindings: [7]struct_binding = [7]struct_binding{ + struct_binding{ + .name = "real_gamemode_request_start", + .functor = @ptrCast([*c]?*anyopaque, &REAL_internal_gamemode_request_start), + .func_size = @sizeOf(api_call_return_int), + .required = @as(c_int, 1) != 0, + }, + struct_binding{ + .name = "real_gamemode_request_end", + .functor = @ptrCast([*c]?*anyopaque, &REAL_internal_gamemode_request_end), + .func_size = @sizeOf(api_call_return_int), + .required = @as(c_int, 1) != 0, + }, + struct_binding{ + .name = "real_gamemode_query_status", + .functor = @ptrCast([*c]?*anyopaque, &REAL_internal_gamemode_query_status), + .func_size = @sizeOf(api_call_return_int), + .required = @as(c_int, 0) != 0, + }, + struct_binding{ + .name = "real_gamemode_error_string", + .functor = @ptrCast([*c]?*anyopaque, &REAL_internal_gamemode_error_string), + .func_size = @sizeOf(api_call_return_cstring), + .required = @as(c_int, 1) != 0, + }, + struct_binding{ + .name = "real_gamemode_request_start_for", + .functor = @ptrCast([*c]?*anyopaque, &REAL_internal_gamemode_request_start_for), + .func_size = @sizeOf(api_call_pid_return_int), + .required = @as(c_int, 0) != 0, + }, + struct_binding{ + .name = "real_gamemode_request_end_for", + .functor = @ptrCast([*c]?*anyopaque, &REAL_internal_gamemode_request_end_for), + .func_size = @sizeOf(api_call_pid_return_int), + .required = @as(c_int, 0) != 0, + }, + struct_binding{ + .name = "real_gamemode_query_status_for", + .functor = @ptrCast([*c]?*anyopaque, &REAL_internal_gamemode_query_status_for), + .func_size = @sizeOf(api_call_pid_return_int), + .required = @as(c_int, 0) != 0, + }, + }; + var libgamemode: ?*anyopaque = @intToPtr(?*anyopaque, @as(c_int, 0)); + libgamemode = dlopen("libgamemode.so.0", @as(c_int, 2)); + if (!(libgamemode != null)) { + libgamemode = dlopen("libgamemode.so", @as(c_int, 2)); + if (!(libgamemode != null)) { + _ = snprintf(@ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), &internal_gamemode_client_error_string)), @sizeOf([512]u8), "dlopen failed - %s", dlerror()); + internal_libgamemode_loaded = -@as(c_int, 1); + return -@as(c_int, 1); + } + } + { + var i: usize = 0; + while (i < (@sizeOf([7]struct_binding) / @sizeOf(struct_binding))) : (i +%= 1) { + var binder: [*c]struct_binding = &bindings[i]; + if (internal_bind_libgamemode_symbol(libgamemode, binder.*.name, binder.*.functor, binder.*.func_size, binder.*.required) != 0) { + internal_libgamemode_loaded = -@as(c_int, 1); + return -@as(c_int, 1); + } + } + } + internal_libgamemode_loaded = 0; + return 0; +} +pub inline fn gamemode_error_string() [*c]const u8 { + if ((internal_load_libgamemode() < @as(c_int, 0)) or (@bitCast(c_int, @as(c_uint, internal_gamemode_client_error_string[@intCast(c_uint, @as(c_int, 0))])) != @as(c_int, '\x00'))) { + return @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), &internal_gamemode_client_error_string)); + } + _ = blk: { + _ = @sizeOf(c_int); + break :blk blk_1: { + break :blk_1 if (REAL_internal_gamemode_error_string != @ptrCast(api_call_return_cstring, @alignCast(@import("std").meta.alignment(fn () callconv(.C) [*c]const u8), @intToPtr(?*anyopaque, @as(c_int, 0))))) {} else { + __assert_fail("REAL_internal_gamemode_error_string != NULL", "./c/gamemode_client.h", @bitCast(c_uint, @as(c_int, 237)), "const char *gamemode_error_string(void)"); + }; + }; + }; + return REAL_internal_gamemode_error_string.?(); +} +pub inline fn gamemode_request_start() c_int { + if (internal_load_libgamemode() < @as(c_int, 0)) { + return -@as(c_int, 1); + } + _ = blk: { + _ = @sizeOf(c_int); + break :blk blk_1: { + break :blk_1 if (REAL_internal_gamemode_request_start != @ptrCast(api_call_return_int, @alignCast(@import("std").meta.alignment(fn () callconv(.C) c_int), @intToPtr(?*anyopaque, @as(c_int, 0))))) {} else { + __assert_fail("REAL_internal_gamemode_request_start != NULL", "./c/gamemode_client.h", @bitCast(c_uint, @as(c_int, 263)), "int gamemode_request_start(void)"); + }; + }; + }; + if (REAL_internal_gamemode_request_start.?() < @as(c_int, 0)) { + return -@as(c_int, 1); + } + return 0; +} +pub inline fn gamemode_request_end() c_int { + if (internal_load_libgamemode() < @as(c_int, 0)) { + return -@as(c_int, 1); + } + _ = blk: { + _ = @sizeOf(c_int); + break :blk blk_1: { + break :blk_1 if (REAL_internal_gamemode_request_end != @ptrCast(api_call_return_int, @alignCast(@import("std").meta.alignment(fn () callconv(.C) c_int), @intToPtr(?*anyopaque, @as(c_int, 0))))) {} else { + __assert_fail("REAL_internal_gamemode_request_end != NULL", "./c/gamemode_client.h", @bitCast(c_uint, @as(c_int, 292)), "int gamemode_request_end(void)"); + }; + }; + }; + if (REAL_internal_gamemode_request_end.?() < @as(c_int, 0)) { + return -@as(c_int, 1); + } + return 0; +} +pub inline fn gamemode_query_status() c_int { + if (internal_load_libgamemode() < @as(c_int, 0)) { + return -@as(c_int, 1); + } + if (REAL_internal_gamemode_query_status == @ptrCast(api_call_return_int, @alignCast(@import("std").meta.alignment(fn () callconv(.C) c_int), @intToPtr(?*anyopaque, @as(c_int, 0))))) { + _ = snprintf(@ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), &internal_gamemode_client_error_string)), @sizeOf([512]u8), "gamemode_query_status missing (older host?)"); + return -@as(c_int, 1); + } + return REAL_internal_gamemode_query_status.?(); +} +pub inline fn gamemode_request_start_for(arg_pid: pid_t) c_int { + var pid = arg_pid; + if (internal_load_libgamemode() < @as(c_int, 0)) { + return -@as(c_int, 1); + } + if (REAL_internal_gamemode_request_start_for == @ptrCast(api_call_pid_return_int, @alignCast(@import("std").meta.alignment(fn (pid_t) callconv(.C) c_int), @intToPtr(?*anyopaque, @as(c_int, 0))))) { + _ = snprintf(@ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), &internal_gamemode_client_error_string)), @sizeOf([512]u8), "gamemode_request_start_for missing (older host?)"); + return -@as(c_int, 1); + } + return REAL_internal_gamemode_request_start_for.?(pid); +} +pub inline fn gamemode_request_end_for(arg_pid: pid_t) c_int { + var pid = arg_pid; + if (internal_load_libgamemode() < @as(c_int, 0)) { + return -@as(c_int, 1); + } + if (REAL_internal_gamemode_request_end_for == @ptrCast(api_call_pid_return_int, @alignCast(@import("std").meta.alignment(fn (pid_t) callconv(.C) c_int), @intToPtr(?*anyopaque, @as(c_int, 0))))) { + _ = snprintf(@ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), &internal_gamemode_client_error_string)), @sizeOf([512]u8), "gamemode_request_end_for missing (older host?)"); + return -@as(c_int, 1); + } + return REAL_internal_gamemode_request_end_for.?(pid); +} +pub inline fn gamemode_query_status_for(arg_pid: pid_t) c_int { + var pid = arg_pid; + if (internal_load_libgamemode() < @as(c_int, 0)) { + return -@as(c_int, 1); + } + if (REAL_internal_gamemode_query_status_for == @ptrCast(api_call_pid_return_int, @alignCast(@import("std").meta.alignment(fn (pid_t) callconv(.C) c_int), @intToPtr(?*anyopaque, @as(c_int, 0))))) { + _ = snprintf(@ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), &internal_gamemode_client_error_string)), @sizeOf([512]u8), "gamemode_query_status_for missing (older host?)"); + return -@as(c_int, 1); + } + return REAL_internal_gamemode_query_status_for.?(pid); +} +pub const __INTMAX_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `L`"); // (no file):80:9 +pub const __UINTMAX_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `UL`"); // (no file):86:9 +pub const __INT64_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `L`"); // (no file):169:9 +pub const __UINT32_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `U`"); // (no file):191:9 +pub const __UINT64_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `UL`"); // (no file):199:9 +pub const __seg_gs = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // (no file):329:9 +pub const __seg_fs = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // (no file):330:9 +pub const __GLIBC_USE = @compileError("unable to translate macro: undefined identifier `__GLIBC_USE_`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/features.h:186:9 +pub const __glibc_has_attribute = @compileError("unable to translate macro: undefined identifier `__has_attribute`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:44:10 +pub const __glibc_has_extension = @compileError("unable to translate macro: undefined identifier `__has_extension`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:54:10 +pub const __THROW = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:78:11 +pub const __THROWNL = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:79:11 +pub const __NTH = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:80:11 +pub const __NTHNL = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:81:11 +pub const __CONCAT = @compileError("unable to translate C expr: unexpected token '##'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:123:9 +pub const __STRING = @compileError("unable to translate C expr: unexpected token '#'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:124:9 +pub const __warnattr = @compileError("unable to translate C expr: unexpected token 'Eof'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:158:10 +pub const __errordecl = @compileError("unable to translate C expr: unexpected token 'extern'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:159:10 +pub const __flexarr = @compileError("unable to translate C expr: unexpected token '['"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:167:10 +pub const __REDIRECT = @compileError("unable to translate macro: undefined identifier `__asm__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:198:10 +pub const __REDIRECT_NTH = @compileError("unable to translate macro: undefined identifier `__asm__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:205:11 +pub const __REDIRECT_NTHNL = @compileError("unable to translate macro: undefined identifier `__asm__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:207:11 +pub const __ASMNAME2 = @compileError("unable to translate C expr: unexpected token 'Identifier'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:211:10 +pub const __attribute_malloc__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:232:10 +pub const __attribute_alloc_size__ = @compileError("unable to translate C expr: unexpected token 'Eof'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:243:10 +pub const __attribute_pure__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:250:10 +pub const __attribute_const__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:257:10 +pub const __attribute_maybe_unused__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:263:10 +pub const __attribute_used__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:272:10 +pub const __attribute_noinline__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:273:10 +pub const __attribute_deprecated__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:281:10 +pub const __attribute_deprecated_msg__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:291:10 +pub const __attribute_format_arg__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:304:10 +pub const __attribute_format_strfmon__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:314:10 +pub const __nonnull = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:324:11 +pub const __returns_nonnull = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:337:10 +pub const __attribute_warn_unused_result__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:346:10 +pub const __always_inline = @compileError("unable to translate macro: undefined identifier `__inline`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:364:10 +pub const __attribute_artificial__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:373:10 +pub const __extern_inline = @compileError("unable to translate macro: undefined identifier `__inline`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:391:11 +pub const __extern_always_inline = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:392:11 +pub const __restrict_arr = @compileError("unable to translate macro: undefined identifier `__restrict`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:435:10 +pub const __attribute_copy__ = @compileError("unable to translate C expr: unexpected token 'Eof'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:484:10 +pub const __LDBL_REDIR2_DECL = @compileError("unable to translate C expr: unexpected token 'Eof'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:560:10 +pub const __LDBL_REDIR_DECL = @compileError("unable to translate C expr: unexpected token 'Eof'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:561:10 +pub const __glibc_macro_warning1 = @compileError("unable to translate macro: undefined identifier `_Pragma`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:575:10 +pub const __glibc_macro_warning = @compileError("unable to translate macro: undefined identifier `GCC`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:576:10 +pub const __attr_access = @compileError("unable to translate C expr: unexpected token 'Eof'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:612:11 +pub const __attr_access_none = @compileError("unable to translate C expr: unexpected token 'Eof'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:613:11 +pub const __attr_dealloc = @compileError("unable to translate C expr: unexpected token 'Eof'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:623:10 +pub const __attribute_returns_twice__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/sys/cdefs.h:630:10 +pub const va_start = @compileError("unable to translate macro: undefined identifier `__builtin_va_start`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/include/stdarg.h:17:9 +pub const va_end = @compileError("unable to translate macro: undefined identifier `__builtin_va_end`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/include/stdarg.h:18:9 +pub const va_arg = @compileError("unable to translate macro: undefined identifier `__builtin_va_arg`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/include/stdarg.h:19:9 +pub const __va_copy = @compileError("unable to translate macro: undefined identifier `__builtin_va_copy`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/include/stdarg.h:24:9 +pub const va_copy = @compileError("unable to translate macro: undefined identifier `__builtin_va_copy`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/include/stdarg.h:27:9 +pub const __STD_TYPE = @compileError("unable to translate C expr: unexpected token 'typedef'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/types.h:137:10 +pub const __FSID_T_TYPE = @compileError("unable to translate macro: undefined identifier `__val`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/x86_64-linux-gnu/bits/typesizes.h:73:9 +pub const __getc_unlocked_body = @compileError("TODO postfix inc/dec expr"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/types/struct_FILE.h:102:9 +pub const __putc_unlocked_body = @compileError("TODO postfix inc/dec expr"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/types/struct_FILE.h:106:9 +pub const __CFLOAT32 = @compileError("unable to translate: TODO _Complex"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:149:12 +pub const __CFLOAT64 = @compileError("unable to translate: TODO _Complex"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:160:13 +pub const __CFLOAT32X = @compileError("unable to translate: TODO _Complex"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:169:12 +pub const __CFLOAT64X = @compileError("unable to translate: TODO _Complex"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:178:13 +pub const __builtin_nansf32 = @compileError("unable to translate macro: undefined identifier `__builtin_nansf`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:221:12 +pub const __builtin_huge_valf64 = @compileError("unable to translate macro: undefined identifier `__builtin_huge_val`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:255:13 +pub const __builtin_inff64 = @compileError("unable to translate macro: undefined identifier `__builtin_inf`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:256:13 +pub const __builtin_nanf64 = @compileError("unable to translate macro: undefined identifier `__builtin_nan`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:257:13 +pub const __builtin_nansf64 = @compileError("unable to translate macro: undefined identifier `__builtin_nans`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:258:13 +pub const __builtin_huge_valf32x = @compileError("unable to translate macro: undefined identifier `__builtin_huge_val`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:272:12 +pub const __builtin_inff32x = @compileError("unable to translate macro: undefined identifier `__builtin_inf`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:273:12 +pub const __builtin_nanf32x = @compileError("unable to translate macro: undefined identifier `__builtin_nan`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:274:12 +pub const __builtin_nansf32x = @compileError("unable to translate macro: undefined identifier `__builtin_nans`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:275:12 +pub const __builtin_huge_valf64x = @compileError("unable to translate macro: undefined identifier `__builtin_huge_vall`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:289:13 +pub const __builtin_inff64x = @compileError("unable to translate macro: undefined identifier `__builtin_infl`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:290:13 +pub const __builtin_nanf64x = @compileError("unable to translate macro: undefined identifier `__builtin_nanl`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:291:13 +pub const __builtin_nansf64x = @compileError("unable to translate macro: undefined identifier `__builtin_nansl`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/floatn-common.h:292:13 +pub const __ASSERT_VOID_CAST = @compileError("unable to translate C expr: unexpected token 'Eof'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/assert.h:40:10 +pub const assert = @compileError("unable to translate macro: undefined identifier `__extension__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/assert.h:104:11 +pub const __ASSERT_FUNCTION = @compileError("unable to translate macro: undefined identifier `__extension__`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/assert.h:126:12 +pub const static_assert = @compileError("unable to translate C expr: unexpected token '_Static_assert'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/assert.h:140:10 +pub const __FD_ZERO = @compileError("unable to translate macro: undefined identifier `__i`"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/select.h:25:9 +pub const __FD_SET = @compileError("unable to translate C expr: expected ')' instead got '|='"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/select.h:32:9 +pub const __FD_CLR = @compileError("unable to translate C expr: expected ')' instead got '&='"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/select.h:34:9 +pub const __PTHREAD_MUTEX_INITIALIZER = @compileError("unable to translate C expr: unexpected token '{'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/x86_64-linux-gnu/bits/struct_mutex.h:56:10 +pub const __PTHREAD_RWLOCK_ELISION_EXTRA = @compileError("unable to translate C expr: unexpected token '{'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/x86_64-linux-gnu/bits/struct_rwlock.h:40:11 +pub const __ONCE_FLAG_INIT = @compileError("unable to translate C expr: unexpected token '{'"); // /home/Zargio/zig/0.10.0-dev.3313+cff5d9c80/files/lib/libc/include/generic-glibc/bits/thread-shared-types.h:127:9 +pub const __llvm__ = @as(c_int, 1); +pub const __clang__ = @as(c_int, 1); +pub const __clang_major__ = @as(c_int, 14); +pub const __clang_minor__ = @as(c_int, 0); +pub const __clang_patchlevel__ = @as(c_int, 6); +pub const __clang_version__ = "14.0.6 (git@github.com:ziglang/zig-bootstrap.git dbc902054739800b8c1656dc1fb29571bba074b9)"; +pub const __GNUC__ = @as(c_int, 4); +pub const __GNUC_MINOR__ = @as(c_int, 2); +pub const __GNUC_PATCHLEVEL__ = @as(c_int, 1); +pub const __GXX_ABI_VERSION = @as(c_int, 1002); +pub const __ATOMIC_RELAXED = @as(c_int, 0); +pub const __ATOMIC_CONSUME = @as(c_int, 1); +pub const __ATOMIC_ACQUIRE = @as(c_int, 2); +pub const __ATOMIC_RELEASE = @as(c_int, 3); +pub const __ATOMIC_ACQ_REL = @as(c_int, 4); +pub const __ATOMIC_SEQ_CST = @as(c_int, 5); +pub const __OPENCL_MEMORY_SCOPE_WORK_ITEM = @as(c_int, 0); +pub const __OPENCL_MEMORY_SCOPE_WORK_GROUP = @as(c_int, 1); +pub const __OPENCL_MEMORY_SCOPE_DEVICE = @as(c_int, 2); +pub const __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES = @as(c_int, 3); +pub const __OPENCL_MEMORY_SCOPE_SUB_GROUP = @as(c_int, 4); +pub const __PRAGMA_REDEFINE_EXTNAME = @as(c_int, 1); +pub const __VERSION__ = "Clang 14.0.6 (git@github.com:ziglang/zig-bootstrap.git dbc902054739800b8c1656dc1fb29571bba074b9)"; +pub const __OBJC_BOOL_IS_BOOL = @as(c_int, 0); +pub const __CONSTANT_CFSTRINGS__ = @as(c_int, 1); +pub const __clang_literal_encoding__ = "UTF-8"; +pub const __clang_wide_literal_encoding__ = "UTF-32"; +pub const __ORDER_LITTLE_ENDIAN__ = @as(c_int, 1234); +pub const __ORDER_BIG_ENDIAN__ = @as(c_int, 4321); +pub const __ORDER_PDP_ENDIAN__ = @as(c_int, 3412); +pub const __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__; +pub const __LITTLE_ENDIAN__ = @as(c_int, 1); +pub const _LP64 = @as(c_int, 1); +pub const __LP64__ = @as(c_int, 1); +pub const __CHAR_BIT__ = @as(c_int, 8); +pub const __BOOL_WIDTH__ = @as(c_int, 8); +pub const __SHRT_WIDTH__ = @as(c_int, 16); +pub const __INT_WIDTH__ = @as(c_int, 32); +pub const __LONG_WIDTH__ = @as(c_int, 64); +pub const __LLONG_WIDTH__ = @as(c_int, 64); +pub const __BITINT_MAXWIDTH__ = @as(c_int, 128); +pub const __SCHAR_MAX__ = @as(c_int, 127); +pub const __SHRT_MAX__ = @as(c_int, 32767); +pub const __INT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); +pub const __LONG_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); +pub const __LONG_LONG_MAX__ = @as(c_longlong, 9223372036854775807); +pub const __WCHAR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); +pub const __WCHAR_WIDTH__ = @as(c_int, 32); +pub const __WINT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); +pub const __WINT_WIDTH__ = @as(c_int, 32); +pub const __INTMAX_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); +pub const __INTMAX_WIDTH__ = @as(c_int, 64); +pub const __SIZE_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); +pub const __SIZE_WIDTH__ = @as(c_int, 64); +pub const __UINTMAX_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); +pub const __UINTMAX_WIDTH__ = @as(c_int, 64); +pub const __PTRDIFF_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); +pub const __PTRDIFF_WIDTH__ = @as(c_int, 64); +pub const __INTPTR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); +pub const __INTPTR_WIDTH__ = @as(c_int, 64); +pub const __UINTPTR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); +pub const __UINTPTR_WIDTH__ = @as(c_int, 64); +pub const __SIZEOF_DOUBLE__ = @as(c_int, 8); +pub const __SIZEOF_FLOAT__ = @as(c_int, 4); +pub const __SIZEOF_INT__ = @as(c_int, 4); +pub const __SIZEOF_LONG__ = @as(c_int, 8); +pub const __SIZEOF_LONG_DOUBLE__ = @as(c_int, 16); +pub const __SIZEOF_LONG_LONG__ = @as(c_int, 8); +pub const __SIZEOF_POINTER__ = @as(c_int, 8); +pub const __SIZEOF_SHORT__ = @as(c_int, 2); +pub const __SIZEOF_PTRDIFF_T__ = @as(c_int, 8); +pub const __SIZEOF_SIZE_T__ = @as(c_int, 8); +pub const __SIZEOF_WCHAR_T__ = @as(c_int, 4); +pub const __SIZEOF_WINT_T__ = @as(c_int, 4); +pub const __SIZEOF_INT128__ = @as(c_int, 16); +pub const __INTMAX_TYPE__ = c_long; +pub const __INTMAX_FMTd__ = "ld"; +pub const __INTMAX_FMTi__ = "li"; +pub const __UINTMAX_TYPE__ = c_ulong; +pub const __UINTMAX_FMTo__ = "lo"; +pub const __UINTMAX_FMTu__ = "lu"; +pub const __UINTMAX_FMTx__ = "lx"; +pub const __UINTMAX_FMTX__ = "lX"; +pub const __PTRDIFF_TYPE__ = c_long; +pub const __PTRDIFF_FMTd__ = "ld"; +pub const __PTRDIFF_FMTi__ = "li"; +pub const __INTPTR_TYPE__ = c_long; +pub const __INTPTR_FMTd__ = "ld"; +pub const __INTPTR_FMTi__ = "li"; +pub const __SIZE_TYPE__ = c_ulong; +pub const __SIZE_FMTo__ = "lo"; +pub const __SIZE_FMTu__ = "lu"; +pub const __SIZE_FMTx__ = "lx"; +pub const __SIZE_FMTX__ = "lX"; +pub const __WCHAR_TYPE__ = c_int; +pub const __WINT_TYPE__ = c_uint; +pub const __SIG_ATOMIC_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); +pub const __SIG_ATOMIC_WIDTH__ = @as(c_int, 32); +pub const __CHAR16_TYPE__ = c_ushort; +pub const __CHAR32_TYPE__ = c_uint; +pub const __UINTPTR_TYPE__ = c_ulong; +pub const __UINTPTR_FMTo__ = "lo"; +pub const __UINTPTR_FMTu__ = "lu"; +pub const __UINTPTR_FMTx__ = "lx"; +pub const __UINTPTR_FMTX__ = "lX"; +pub const __FLT_DENORM_MIN__ = @as(f32, 1.40129846e-45); +pub const __FLT_HAS_DENORM__ = @as(c_int, 1); +pub const __FLT_DIG__ = @as(c_int, 6); +pub const __FLT_DECIMAL_DIG__ = @as(c_int, 9); +pub const __FLT_EPSILON__ = @as(f32, 1.19209290e-7); +pub const __FLT_HAS_INFINITY__ = @as(c_int, 1); +pub const __FLT_HAS_QUIET_NAN__ = @as(c_int, 1); +pub const __FLT_MANT_DIG__ = @as(c_int, 24); +pub const __FLT_MAX_10_EXP__ = @as(c_int, 38); +pub const __FLT_MAX_EXP__ = @as(c_int, 128); +pub const __FLT_MAX__ = @as(f32, 3.40282347e+38); +pub const __FLT_MIN_10_EXP__ = -@as(c_int, 37); +pub const __FLT_MIN_EXP__ = -@as(c_int, 125); +pub const __FLT_MIN__ = @as(f32, 1.17549435e-38); +pub const __DBL_DENORM_MIN__ = 4.9406564584124654e-324; +pub const __DBL_HAS_DENORM__ = @as(c_int, 1); +pub const __DBL_DIG__ = @as(c_int, 15); +pub const __DBL_DECIMAL_DIG__ = @as(c_int, 17); +pub const __DBL_EPSILON__ = 2.2204460492503131e-16; +pub const __DBL_HAS_INFINITY__ = @as(c_int, 1); +pub const __DBL_HAS_QUIET_NAN__ = @as(c_int, 1); +pub const __DBL_MANT_DIG__ = @as(c_int, 53); +pub const __DBL_MAX_10_EXP__ = @as(c_int, 308); +pub const __DBL_MAX_EXP__ = @as(c_int, 1024); +pub const __DBL_MAX__ = 1.7976931348623157e+308; +pub const __DBL_MIN_10_EXP__ = -@as(c_int, 307); +pub const __DBL_MIN_EXP__ = -@as(c_int, 1021); +pub const __DBL_MIN__ = 2.2250738585072014e-308; +pub const __LDBL_DENORM_MIN__ = @as(c_longdouble, 3.64519953188247460253e-4951); +pub const __LDBL_HAS_DENORM__ = @as(c_int, 1); +pub const __LDBL_DIG__ = @as(c_int, 18); +pub const __LDBL_DECIMAL_DIG__ = @as(c_int, 21); +pub const __LDBL_EPSILON__ = @as(c_longdouble, 1.08420217248550443401e-19); +pub const __LDBL_HAS_INFINITY__ = @as(c_int, 1); +pub const __LDBL_HAS_QUIET_NAN__ = @as(c_int, 1); +pub const __LDBL_MANT_DIG__ = @as(c_int, 64); +pub const __LDBL_MAX_10_EXP__ = @as(c_int, 4932); +pub const __LDBL_MAX_EXP__ = @as(c_int, 16384); +pub const __LDBL_MAX__ = @as(c_longdouble, 1.18973149535723176502e+4932); +pub const __LDBL_MIN_10_EXP__ = -@as(c_int, 4931); +pub const __LDBL_MIN_EXP__ = -@as(c_int, 16381); +pub const __LDBL_MIN__ = @as(c_longdouble, 3.36210314311209350626e-4932); +pub const __POINTER_WIDTH__ = @as(c_int, 64); +pub const __BIGGEST_ALIGNMENT__ = @as(c_int, 16); +pub const __WINT_UNSIGNED__ = @as(c_int, 1); +pub const __INT8_TYPE__ = i8; +pub const __INT8_FMTd__ = "hhd"; +pub const __INT8_FMTi__ = "hhi"; +pub const __INT8_C_SUFFIX__ = ""; +pub const __INT16_TYPE__ = c_short; +pub const __INT16_FMTd__ = "hd"; +pub const __INT16_FMTi__ = "hi"; +pub const __INT16_C_SUFFIX__ = ""; +pub const __INT32_TYPE__ = c_int; +pub const __INT32_FMTd__ = "d"; +pub const __INT32_FMTi__ = "i"; +pub const __INT32_C_SUFFIX__ = ""; +pub const __INT64_TYPE__ = c_long; +pub const __INT64_FMTd__ = "ld"; +pub const __INT64_FMTi__ = "li"; +pub const __UINT8_TYPE__ = u8; +pub const __UINT8_FMTo__ = "hho"; +pub const __UINT8_FMTu__ = "hhu"; +pub const __UINT8_FMTx__ = "hhx"; +pub const __UINT8_FMTX__ = "hhX"; +pub const __UINT8_C_SUFFIX__ = ""; +pub const __UINT8_MAX__ = @as(c_int, 255); +pub const __INT8_MAX__ = @as(c_int, 127); +pub const __UINT16_TYPE__ = c_ushort; +pub const __UINT16_FMTo__ = "ho"; +pub const __UINT16_FMTu__ = "hu"; +pub const __UINT16_FMTx__ = "hx"; +pub const __UINT16_FMTX__ = "hX"; +pub const __UINT16_C_SUFFIX__ = ""; +pub const __UINT16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); +pub const __INT16_MAX__ = @as(c_int, 32767); +pub const __UINT32_TYPE__ = c_uint; +pub const __UINT32_FMTo__ = "o"; +pub const __UINT32_FMTu__ = "u"; +pub const __UINT32_FMTx__ = "x"; +pub const __UINT32_FMTX__ = "X"; +pub const __UINT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); +pub const __INT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); +pub const __UINT64_TYPE__ = c_ulong; +pub const __UINT64_FMTo__ = "lo"; +pub const __UINT64_FMTu__ = "lu"; +pub const __UINT64_FMTx__ = "lx"; +pub const __UINT64_FMTX__ = "lX"; +pub const __UINT64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); +pub const __INT64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); +pub const __INT_LEAST8_TYPE__ = i8; +pub const __INT_LEAST8_MAX__ = @as(c_int, 127); +pub const __INT_LEAST8_WIDTH__ = @as(c_int, 8); +pub const __INT_LEAST8_FMTd__ = "hhd"; +pub const __INT_LEAST8_FMTi__ = "hhi"; +pub const __UINT_LEAST8_TYPE__ = u8; +pub const __UINT_LEAST8_MAX__ = @as(c_int, 255); +pub const __UINT_LEAST8_FMTo__ = "hho"; +pub const __UINT_LEAST8_FMTu__ = "hhu"; +pub const __UINT_LEAST8_FMTx__ = "hhx"; +pub const __UINT_LEAST8_FMTX__ = "hhX"; +pub const __INT_LEAST16_TYPE__ = c_short; +pub const __INT_LEAST16_MAX__ = @as(c_int, 32767); +pub const __INT_LEAST16_WIDTH__ = @as(c_int, 16); +pub const __INT_LEAST16_FMTd__ = "hd"; +pub const __INT_LEAST16_FMTi__ = "hi"; +pub const __UINT_LEAST16_TYPE__ = c_ushort; +pub const __UINT_LEAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); +pub const __UINT_LEAST16_FMTo__ = "ho"; +pub const __UINT_LEAST16_FMTu__ = "hu"; +pub const __UINT_LEAST16_FMTx__ = "hx"; +pub const __UINT_LEAST16_FMTX__ = "hX"; +pub const __INT_LEAST32_TYPE__ = c_int; +pub const __INT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); +pub const __INT_LEAST32_WIDTH__ = @as(c_int, 32); +pub const __INT_LEAST32_FMTd__ = "d"; +pub const __INT_LEAST32_FMTi__ = "i"; +pub const __UINT_LEAST32_TYPE__ = c_uint; +pub const __UINT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); +pub const __UINT_LEAST32_FMTo__ = "o"; +pub const __UINT_LEAST32_FMTu__ = "u"; +pub const __UINT_LEAST32_FMTx__ = "x"; +pub const __UINT_LEAST32_FMTX__ = "X"; +pub const __INT_LEAST64_TYPE__ = c_long; +pub const __INT_LEAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); +pub const __INT_LEAST64_WIDTH__ = @as(c_int, 64); +pub const __INT_LEAST64_FMTd__ = "ld"; +pub const __INT_LEAST64_FMTi__ = "li"; +pub const __UINT_LEAST64_TYPE__ = c_ulong; +pub const __UINT_LEAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); +pub const __UINT_LEAST64_FMTo__ = "lo"; +pub const __UINT_LEAST64_FMTu__ = "lu"; +pub const __UINT_LEAST64_FMTx__ = "lx"; +pub const __UINT_LEAST64_FMTX__ = "lX"; +pub const __INT_FAST8_TYPE__ = i8; +pub const __INT_FAST8_MAX__ = @as(c_int, 127); +pub const __INT_FAST8_WIDTH__ = @as(c_int, 8); +pub const __INT_FAST8_FMTd__ = "hhd"; +pub const __INT_FAST8_FMTi__ = "hhi"; +pub const __UINT_FAST8_TYPE__ = u8; +pub const __UINT_FAST8_MAX__ = @as(c_int, 255); +pub const __UINT_FAST8_FMTo__ = "hho"; +pub const __UINT_FAST8_FMTu__ = "hhu"; +pub const __UINT_FAST8_FMTx__ = "hhx"; +pub const __UINT_FAST8_FMTX__ = "hhX"; +pub const __INT_FAST16_TYPE__ = c_short; +pub const __INT_FAST16_MAX__ = @as(c_int, 32767); +pub const __INT_FAST16_WIDTH__ = @as(c_int, 16); +pub const __INT_FAST16_FMTd__ = "hd"; +pub const __INT_FAST16_FMTi__ = "hi"; +pub const __UINT_FAST16_TYPE__ = c_ushort; +pub const __UINT_FAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); +pub const __UINT_FAST16_FMTo__ = "ho"; +pub const __UINT_FAST16_FMTu__ = "hu"; +pub const __UINT_FAST16_FMTx__ = "hx"; +pub const __UINT_FAST16_FMTX__ = "hX"; +pub const __INT_FAST32_TYPE__ = c_int; +pub const __INT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); +pub const __INT_FAST32_WIDTH__ = @as(c_int, 32); +pub const __INT_FAST32_FMTd__ = "d"; +pub const __INT_FAST32_FMTi__ = "i"; +pub const __UINT_FAST32_TYPE__ = c_uint; +pub const __UINT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); +pub const __UINT_FAST32_FMTo__ = "o"; +pub const __UINT_FAST32_FMTu__ = "u"; +pub const __UINT_FAST32_FMTx__ = "x"; +pub const __UINT_FAST32_FMTX__ = "X"; +pub const __INT_FAST64_TYPE__ = c_long; +pub const __INT_FAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); +pub const __INT_FAST64_WIDTH__ = @as(c_int, 64); +pub const __INT_FAST64_FMTd__ = "ld"; +pub const __INT_FAST64_FMTi__ = "li"; +pub const __UINT_FAST64_TYPE__ = c_ulong; +pub const __UINT_FAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); +pub const __UINT_FAST64_FMTo__ = "lo"; +pub const __UINT_FAST64_FMTu__ = "lu"; +pub const __UINT_FAST64_FMTx__ = "lx"; +pub const __UINT_FAST64_FMTX__ = "lX"; +pub const __USER_LABEL_PREFIX__ = ""; +pub const __FINITE_MATH_ONLY__ = @as(c_int, 0); +pub const __GNUC_STDC_INLINE__ = @as(c_int, 1); +pub const __GCC_ATOMIC_TEST_AND_SET_TRUEVAL = @as(c_int, 1); +pub const __CLANG_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2); +pub const __CLANG_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2); +pub const __CLANG_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2); +pub const __CLANG_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2); +pub const __CLANG_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2); +pub const __CLANG_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2); +pub const __CLANG_ATOMIC_INT_LOCK_FREE = @as(c_int, 2); +pub const __CLANG_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2); +pub const __CLANG_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2); +pub const __CLANG_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_INT_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2); +pub const __GCC_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2); +pub const __NO_INLINE__ = @as(c_int, 1); +pub const __PIC__ = @as(c_int, 2); +pub const __pic__ = @as(c_int, 2); +pub const __FLT_EVAL_METHOD__ = @as(c_int, 0); +pub const __FLT_RADIX__ = @as(c_int, 2); +pub const __DECIMAL_DIG__ = __LDBL_DECIMAL_DIG__; +pub const __SSP_STRONG__ = @as(c_int, 2); +pub const __GCC_ASM_FLAG_OUTPUTS__ = @as(c_int, 1); +pub const __code_model_small__ = @as(c_int, 1); +pub const __amd64__ = @as(c_int, 1); +pub const __amd64 = @as(c_int, 1); +pub const __x86_64 = @as(c_int, 1); +pub const __x86_64__ = @as(c_int, 1); +pub const __SEG_GS = @as(c_int, 1); +pub const __SEG_FS = @as(c_int, 1); +pub const __znver1 = @as(c_int, 1); +pub const __znver1__ = @as(c_int, 1); +pub const __tune_znver1__ = @as(c_int, 1); +pub const __REGISTER_PREFIX__ = ""; +pub const __NO_MATH_INLINES = @as(c_int, 1); +pub const __AES__ = @as(c_int, 1); +pub const __PCLMUL__ = @as(c_int, 1); +pub const __LAHF_SAHF__ = @as(c_int, 1); +pub const __LZCNT__ = @as(c_int, 1); +pub const __RDRND__ = @as(c_int, 1); +pub const __FSGSBASE__ = @as(c_int, 1); +pub const __BMI__ = @as(c_int, 1); +pub const __BMI2__ = @as(c_int, 1); +pub const __POPCNT__ = @as(c_int, 1); +pub const __PRFCHW__ = @as(c_int, 1); +pub const __RDSEED__ = @as(c_int, 1); +pub const __ADX__ = @as(c_int, 1); +pub const __MWAITX__ = @as(c_int, 1); +pub const __MOVBE__ = @as(c_int, 1); +pub const __SSE4A__ = @as(c_int, 1); +pub const __FMA__ = @as(c_int, 1); +pub const __F16C__ = @as(c_int, 1); +pub const __SHA__ = @as(c_int, 1); +pub const __FXSR__ = @as(c_int, 1); +pub const __XSAVE__ = @as(c_int, 1); +pub const __XSAVEOPT__ = @as(c_int, 1); +pub const __XSAVEC__ = @as(c_int, 1); +pub const __XSAVES__ = @as(c_int, 1); +pub const __CLFLUSHOPT__ = @as(c_int, 1); +pub const __CLZERO__ = @as(c_int, 1); +pub const __CRC32__ = @as(c_int, 1); +pub const __AVX2__ = @as(c_int, 1); +pub const __AVX__ = @as(c_int, 1); +pub const __SSE4_2__ = @as(c_int, 1); +pub const __SSE4_1__ = @as(c_int, 1); +pub const __SSSE3__ = @as(c_int, 1); +pub const __SSE3__ = @as(c_int, 1); +pub const __SSE2__ = @as(c_int, 1); +pub const __SSE2_MATH__ = @as(c_int, 1); +pub const __SSE__ = @as(c_int, 1); +pub const __SSE_MATH__ = @as(c_int, 1); +pub const __MMX__ = @as(c_int, 1); +pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 = @as(c_int, 1); +pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 = @as(c_int, 1); +pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = @as(c_int, 1); +pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = @as(c_int, 1); +pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 = @as(c_int, 1); +pub const __SIZEOF_FLOAT128__ = @as(c_int, 16); +pub const unix = @as(c_int, 1); +pub const __unix = @as(c_int, 1); +pub const __unix__ = @as(c_int, 1); +pub const linux = @as(c_int, 1); +pub const __linux = @as(c_int, 1); +pub const __linux__ = @as(c_int, 1); +pub const __ELF__ = @as(c_int, 1); +pub const __gnu_linux__ = @as(c_int, 1); +pub const __FLOAT128__ = @as(c_int, 1); +pub const __STDC__ = @as(c_int, 1); +pub const __STDC_HOSTED__ = @as(c_int, 1); +pub const __STDC_VERSION__ = @as(c_long, 201710); +pub const __STDC_UTF_16__ = @as(c_int, 1); +pub const __STDC_UTF_32__ = @as(c_int, 1); +pub const __GLIBC_MINOR__ = @as(c_int, 19); +pub const _DEBUG = @as(c_int, 1); +pub const __GCC_HAVE_DWARF2_CFI_ASM = @as(c_int, 1); +pub const CLIENT_GAMEMODE_H = ""; +pub const __STDBOOL_H = ""; +pub const @"bool" = bool; +pub const @"true" = @as(c_int, 1); +pub const @"false" = @as(c_int, 0); +pub const __bool_true_false_are_defined = @as(c_int, 1); +pub const _STDIO_H = @as(c_int, 1); +pub const __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION = ""; +pub const _FEATURES_H = @as(c_int, 1); +pub const __KERNEL_STRICT_NAMES = ""; +pub inline fn __GNUC_PREREQ(maj: anytype, min: anytype) @TypeOf(((__GNUC__ << @as(c_int, 16)) + __GNUC_MINOR__) >= ((maj << @as(c_int, 16)) + min)) { + return ((__GNUC__ << @as(c_int, 16)) + __GNUC_MINOR__) >= ((maj << @as(c_int, 16)) + min); +} +pub inline fn __glibc_clang_prereq(maj: anytype, min: anytype) @TypeOf(((__clang_major__ << @as(c_int, 16)) + __clang_minor__) >= ((maj << @as(c_int, 16)) + min)) { + return ((__clang_major__ << @as(c_int, 16)) + __clang_minor__) >= ((maj << @as(c_int, 16)) + min); +} +pub const _DEFAULT_SOURCE = @as(c_int, 1); +pub const __GLIBC_USE_ISOC2X = @as(c_int, 0); +pub const __USE_ISOC11 = @as(c_int, 1); +pub const __USE_ISOC99 = @as(c_int, 1); +pub const __USE_ISOC95 = @as(c_int, 1); +pub const __USE_POSIX_IMPLICITLY = @as(c_int, 1); +pub const _POSIX_SOURCE = @as(c_int, 1); +pub const _POSIX_C_SOURCE = @as(c_long, 200809); +pub const __USE_POSIX = @as(c_int, 1); +pub const __USE_POSIX2 = @as(c_int, 1); +pub const __USE_POSIX199309 = @as(c_int, 1); +pub const __USE_POSIX199506 = @as(c_int, 1); +pub const __USE_XOPEN2K = @as(c_int, 1); +pub const __USE_XOPEN2K8 = @as(c_int, 1); +pub const _ATFILE_SOURCE = @as(c_int, 1); +pub const __WORDSIZE = @as(c_int, 64); +pub const __WORDSIZE_TIME64_COMPAT32 = @as(c_int, 1); +pub const __SYSCALL_WORDSIZE = @as(c_int, 64); +pub const __TIMESIZE = __WORDSIZE; +pub const __USE_MISC = @as(c_int, 1); +pub const __USE_ATFILE = @as(c_int, 1); +pub const __USE_FORTIFY_LEVEL = @as(c_int, 0); +pub const __GLIBC_USE_DEPRECATED_GETS = @as(c_int, 0); +pub const __GLIBC_USE_DEPRECATED_SCANF = @as(c_int, 0); +pub const _STDC_PREDEF_H = @as(c_int, 1); +pub const __STDC_IEC_559__ = @as(c_int, 1); +pub const __STDC_IEC_559_COMPLEX__ = @as(c_int, 1); +pub const __STDC_ISO_10646__ = @as(c_long, 201706); +pub const __GNU_LIBRARY__ = @as(c_int, 6); +pub const __GLIBC__ = @as(c_int, 2); +pub inline fn __GLIBC_PREREQ(maj: anytype, min: anytype) @TypeOf(((__GLIBC__ << @as(c_int, 16)) + __GLIBC_MINOR__) >= ((maj << @as(c_int, 16)) + min)) { + return ((__GLIBC__ << @as(c_int, 16)) + __GLIBC_MINOR__) >= ((maj << @as(c_int, 16)) + min); +} +pub const _SYS_CDEFS_H = @as(c_int, 1); +pub inline fn __glibc_has_builtin(name: anytype) @TypeOf(__has_builtin(name)) { + return __has_builtin(name); +} +pub const __LEAF = ""; +pub const __LEAF_ATTR = ""; +pub inline fn __P(args: anytype) @TypeOf(args) { + return args; +} +pub inline fn __PMT(args: anytype) @TypeOf(args) { + return args; +} +pub const __ptr_t = ?*anyopaque; +pub const __BEGIN_DECLS = ""; +pub const __END_DECLS = ""; +pub inline fn __bos(ptr: anytype) @TypeOf(__builtin_object_size(ptr, __USE_FORTIFY_LEVEL > @as(c_int, 1))) { + return __builtin_object_size(ptr, __USE_FORTIFY_LEVEL > @as(c_int, 1)); +} +pub inline fn __bos0(ptr: anytype) @TypeOf(__builtin_object_size(ptr, @as(c_int, 0))) { + return __builtin_object_size(ptr, @as(c_int, 0)); +} +pub inline fn __glibc_objsize0(__o: anytype) @TypeOf(__bos0(__o)) { + return __bos0(__o); +} +pub inline fn __glibc_objsize(__o: anytype) @TypeOf(__bos(__o)) { + return __bos(__o); +} +pub const __glibc_c99_flexarr_available = @as(c_int, 1); +pub inline fn __ASMNAME(cname: anytype) @TypeOf(__ASMNAME2(__USER_LABEL_PREFIX__, cname)) { + return __ASMNAME2(__USER_LABEL_PREFIX__, cname); +} +pub const __wur = ""; +pub const __fortify_function = __extern_always_inline ++ __attribute_artificial__; +pub inline fn __glibc_unlikely(cond: anytype) @TypeOf(__builtin_expect(cond, @as(c_int, 0))) { + return __builtin_expect(cond, @as(c_int, 0)); +} +pub inline fn __glibc_likely(cond: anytype) @TypeOf(__builtin_expect(cond, @as(c_int, 1))) { + return __builtin_expect(cond, @as(c_int, 1)); +} +pub const __attribute_nonstring__ = ""; +pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = @as(c_int, 0); +pub inline fn __LDBL_REDIR1(name: anytype, proto: anytype, alias: anytype) @TypeOf(name ++ proto) { + _ = alias; + return name ++ proto; +} +pub inline fn __LDBL_REDIR(name: anytype, proto: anytype) @TypeOf(name ++ proto) { + return name ++ proto; +} +pub inline fn __LDBL_REDIR1_NTH(name: anytype, proto: anytype, alias: anytype) @TypeOf(name ++ proto ++ __THROW) { + _ = alias; + return name ++ proto ++ __THROW; +} +pub inline fn __LDBL_REDIR_NTH(name: anytype, proto: anytype) @TypeOf(name ++ proto ++ __THROW) { + return name ++ proto ++ __THROW; +} +pub inline fn __REDIRECT_LDBL(name: anytype, proto: anytype, alias: anytype) @TypeOf(__REDIRECT(name, proto, alias)) { + return __REDIRECT(name, proto, alias); +} +pub inline fn __REDIRECT_NTH_LDBL(name: anytype, proto: anytype, alias: anytype) @TypeOf(__REDIRECT_NTH(name, proto, alias)) { + return __REDIRECT_NTH(name, proto, alias); +} +pub const __HAVE_GENERIC_SELECTION = @as(c_int, 1); +pub const __attr_dealloc_free = ""; +pub const __stub___compat_bdflush = ""; +pub const __stub_chflags = ""; +pub const __stub_fchflags = ""; +pub const __stub_gtty = ""; +pub const __stub_revoke = ""; +pub const __stub_setlogin = ""; +pub const __stub_sigreturn = ""; +pub const __stub_stty = ""; +pub const __GLIBC_USE_LIB_EXT2 = @as(c_int, 0); +pub const __GLIBC_USE_IEC_60559_BFP_EXT = @as(c_int, 0); +pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X = @as(c_int, 0); +pub const __GLIBC_USE_IEC_60559_EXT = @as(c_int, 0); +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT = @as(c_int, 0); +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = @as(c_int, 0); +pub const __GLIBC_USE_IEC_60559_TYPES_EXT = @as(c_int, 0); +pub const __need_size_t = ""; +pub const __need_NULL = ""; +pub const _SIZE_T = ""; +pub const NULL = @import("std").zig.c_translation.cast(?*anyopaque, @as(c_int, 0)); +pub const __need___va_list = ""; +pub const __STDARG_H = ""; +pub const _VA_LIST = ""; +pub const __GNUC_VA_LIST = @as(c_int, 1); +pub const _BITS_TYPES_H = @as(c_int, 1); +pub const __S16_TYPE = c_short; +pub const __U16_TYPE = c_ushort; +pub const __S32_TYPE = c_int; +pub const __U32_TYPE = c_uint; +pub const __SLONGWORD_TYPE = c_long; +pub const __ULONGWORD_TYPE = c_ulong; +pub const __SQUAD_TYPE = c_long; +pub const __UQUAD_TYPE = c_ulong; +pub const __SWORD_TYPE = c_long; +pub const __UWORD_TYPE = c_ulong; +pub const __SLONG32_TYPE = c_int; +pub const __ULONG32_TYPE = c_uint; +pub const __S64_TYPE = c_long; +pub const __U64_TYPE = c_ulong; +pub const _BITS_TYPESIZES_H = @as(c_int, 1); +pub const __SYSCALL_SLONG_TYPE = __SLONGWORD_TYPE; +pub const __SYSCALL_ULONG_TYPE = __ULONGWORD_TYPE; +pub const __DEV_T_TYPE = __UQUAD_TYPE; +pub const __UID_T_TYPE = __U32_TYPE; +pub const __GID_T_TYPE = __U32_TYPE; +pub const __INO_T_TYPE = __SYSCALL_ULONG_TYPE; +pub const __INO64_T_TYPE = __UQUAD_TYPE; +pub const __MODE_T_TYPE = __U32_TYPE; +pub const __NLINK_T_TYPE = __SYSCALL_ULONG_TYPE; +pub const __FSWORD_T_TYPE = __SYSCALL_SLONG_TYPE; +pub const __OFF_T_TYPE = __SYSCALL_SLONG_TYPE; +pub const __OFF64_T_TYPE = __SQUAD_TYPE; +pub const __PID_T_TYPE = __S32_TYPE; +pub const __RLIM_T_TYPE = __SYSCALL_ULONG_TYPE; +pub const __RLIM64_T_TYPE = __UQUAD_TYPE; +pub const __BLKCNT_T_TYPE = __SYSCALL_SLONG_TYPE; +pub const __BLKCNT64_T_TYPE = __SQUAD_TYPE; +pub const __FSBLKCNT_T_TYPE = __SYSCALL_ULONG_TYPE; +pub const __FSBLKCNT64_T_TYPE = __UQUAD_TYPE; +pub const __FSFILCNT_T_TYPE = __SYSCALL_ULONG_TYPE; +pub const __FSFILCNT64_T_TYPE = __UQUAD_TYPE; +pub const __ID_T_TYPE = __U32_TYPE; +pub const __CLOCK_T_TYPE = __SYSCALL_SLONG_TYPE; +pub const __TIME_T_TYPE = __SYSCALL_SLONG_TYPE; +pub const __USECONDS_T_TYPE = __U32_TYPE; +pub const __SUSECONDS_T_TYPE = __SYSCALL_SLONG_TYPE; +pub const __SUSECONDS64_T_TYPE = __SQUAD_TYPE; +pub const __DADDR_T_TYPE = __S32_TYPE; +pub const __KEY_T_TYPE = __S32_TYPE; +pub const __CLOCKID_T_TYPE = __S32_TYPE; +pub const __TIMER_T_TYPE = ?*anyopaque; +pub const __BLKSIZE_T_TYPE = __SYSCALL_SLONG_TYPE; +pub const __SSIZE_T_TYPE = __SWORD_TYPE; +pub const __CPU_MASK_TYPE = __SYSCALL_ULONG_TYPE; +pub const __OFF_T_MATCHES_OFF64_T = @as(c_int, 1); +pub const __INO_T_MATCHES_INO64_T = @as(c_int, 1); +pub const __RLIM_T_MATCHES_RLIM64_T = @as(c_int, 1); +pub const __STATFS_MATCHES_STATFS64 = @as(c_int, 1); +pub const __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = @as(c_int, 1); +pub const __FD_SETSIZE = @as(c_int, 1024); +pub const _BITS_TIME64_H = @as(c_int, 1); +pub const __TIME64_T_TYPE = __TIME_T_TYPE; +pub const _____fpos_t_defined = @as(c_int, 1); +pub const ____mbstate_t_defined = @as(c_int, 1); +pub const _____fpos64_t_defined = @as(c_int, 1); +pub const ____FILE_defined = @as(c_int, 1); +pub const __FILE_defined = @as(c_int, 1); +pub const __struct_FILE_defined = @as(c_int, 1); +pub const _IO_EOF_SEEN = @as(c_int, 0x0010); +pub inline fn __feof_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_EOF_SEEN) != @as(c_int, 0)) { + return (_fp.*._flags & _IO_EOF_SEEN) != @as(c_int, 0); +} +pub const _IO_ERR_SEEN = @as(c_int, 0x0020); +pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) { + return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0); +} +pub const _IO_USER_LOCK = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8000, .hexadecimal); +pub const _VA_LIST_DEFINED = ""; +pub const __off_t_defined = ""; +pub const __ssize_t_defined = ""; +pub const _IOFBF = @as(c_int, 0); +pub const _IOLBF = @as(c_int, 1); +pub const _IONBF = @as(c_int, 2); +pub const BUFSIZ = @as(c_int, 8192); +pub const EOF = -@as(c_int, 1); +pub const SEEK_SET = @as(c_int, 0); +pub const SEEK_CUR = @as(c_int, 1); +pub const SEEK_END = @as(c_int, 2); +pub const P_tmpdir = "/tmp"; +pub const _BITS_STDIO_LIM_H = @as(c_int, 1); +pub const L_tmpnam = @as(c_int, 20); +pub const TMP_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 238328, .decimal); +pub const FILENAME_MAX = @as(c_int, 4096); +pub const L_ctermid = @as(c_int, 9); +pub const FOPEN_MAX = @as(c_int, 16); +pub const __attr_dealloc_fclose = __attr_dealloc(fclose, @as(c_int, 1)); +pub const _BITS_FLOATN_H = ""; +pub const __HAVE_FLOAT128 = @as(c_int, 0); +pub const __HAVE_DISTINCT_FLOAT128 = @as(c_int, 0); +pub const __HAVE_FLOAT64X = @as(c_int, 1); +pub const __HAVE_FLOAT64X_LONG_DOUBLE = @as(c_int, 1); +pub const _BITS_FLOATN_COMMON_H = ""; +pub const __HAVE_FLOAT16 = @as(c_int, 0); +pub const __HAVE_FLOAT32 = @as(c_int, 1); +pub const __HAVE_FLOAT64 = @as(c_int, 1); +pub const __HAVE_FLOAT32X = @as(c_int, 1); +pub const __HAVE_FLOAT128X = @as(c_int, 0); +pub const __HAVE_DISTINCT_FLOAT16 = __HAVE_FLOAT16; +pub const __HAVE_DISTINCT_FLOAT32 = @as(c_int, 0); +pub const __HAVE_DISTINCT_FLOAT64 = @as(c_int, 0); +pub const __HAVE_DISTINCT_FLOAT32X = @as(c_int, 0); +pub const __HAVE_DISTINCT_FLOAT64X = @as(c_int, 0); +pub const __HAVE_DISTINCT_FLOAT128X = __HAVE_FLOAT128X; +pub const __HAVE_FLOAT128_UNLIKE_LDBL = (__HAVE_DISTINCT_FLOAT128 != 0) and (__LDBL_MANT_DIG__ != @as(c_int, 113)); +pub const __HAVE_FLOATN_NOT_TYPEDEF = @as(c_int, 0); +pub const __f32 = @import("std").zig.c_translation.Macros.F_SUFFIX; +pub inline fn __f64(x: anytype) @TypeOf(x) { + return x; +} +pub inline fn __f32x(x: anytype) @TypeOf(x) { + return x; +} +pub const __f64x = @import("std").zig.c_translation.Macros.L_SUFFIX; +pub inline fn __builtin_huge_valf32() @TypeOf(__builtin_huge_valf()) { + return __builtin_huge_valf(); +} +pub inline fn __builtin_inff32() @TypeOf(__builtin_inff()) { + return __builtin_inff(); +} +pub inline fn __builtin_nanf32(x: anytype) @TypeOf(__builtin_nanf(x)) { + return __builtin_nanf(x); +} +pub const _DLFCN_H = @as(c_int, 1); +pub const RTLD_LAZY = @as(c_int, 0x00001); +pub const RTLD_NOW = @as(c_int, 0x00002); +pub const RTLD_BINDING_MASK = @as(c_int, 0x3); +pub const RTLD_NOLOAD = @as(c_int, 0x00004); +pub const RTLD_DEEPBIND = @as(c_int, 0x00008); +pub const RTLD_GLOBAL = @as(c_int, 0x00100); +pub const RTLD_LOCAL = @as(c_int, 0); +pub const RTLD_NODELETE = @as(c_int, 0x01000); +pub const _STRING_H = @as(c_int, 1); +pub const _BITS_TYPES_LOCALE_T_H = @as(c_int, 1); +pub const _BITS_TYPES___LOCALE_T_H = @as(c_int, 1); +pub const _STRINGS_H = @as(c_int, 1); +pub const _ASSERT_H = @as(c_int, 1); +pub const _SYS_TYPES_H = @as(c_int, 1); +pub const __u_char_defined = ""; +pub const __ino_t_defined = ""; +pub const __dev_t_defined = ""; +pub const __gid_t_defined = ""; +pub const __mode_t_defined = ""; +pub const __nlink_t_defined = ""; +pub const __uid_t_defined = ""; +pub const __pid_t_defined = ""; +pub const __id_t_defined = ""; +pub const __daddr_t_defined = ""; +pub const __key_t_defined = ""; +pub const __clock_t_defined = @as(c_int, 1); +pub const __clockid_t_defined = @as(c_int, 1); +pub const __time_t_defined = @as(c_int, 1); +pub const __timer_t_defined = @as(c_int, 1); +pub const _BITS_STDINT_INTN_H = @as(c_int, 1); +pub const __BIT_TYPES_DEFINED__ = @as(c_int, 1); +pub const _ENDIAN_H = @as(c_int, 1); +pub const _BITS_ENDIAN_H = @as(c_int, 1); +pub const __LITTLE_ENDIAN = @as(c_int, 1234); +pub const __BIG_ENDIAN = @as(c_int, 4321); +pub const __PDP_ENDIAN = @as(c_int, 3412); +pub const _BITS_ENDIANNESS_H = @as(c_int, 1); +pub const __BYTE_ORDER = __LITTLE_ENDIAN; +pub const __FLOAT_WORD_ORDER = __BYTE_ORDER; +pub inline fn __LONG_LONG_PAIR(HI: anytype, LO: anytype) @TypeOf(HI) { + return blk: { + _ = LO; + break :blk HI; + }; +} +pub const LITTLE_ENDIAN = __LITTLE_ENDIAN; +pub const BIG_ENDIAN = __BIG_ENDIAN; +pub const PDP_ENDIAN = __PDP_ENDIAN; +pub const BYTE_ORDER = __BYTE_ORDER; +pub const _BITS_BYTESWAP_H = @as(c_int, 1); +pub inline fn __bswap_constant_16(x: anytype) __uint16_t { + return @import("std").zig.c_translation.cast(__uint16_t, ((x >> @as(c_int, 8)) & @as(c_int, 0xff)) | ((x & @as(c_int, 0xff)) << @as(c_int, 8))); +} +pub inline fn __bswap_constant_32(x: anytype) @TypeOf(((((x & @import("std").zig.c_translation.promoteIntLiteral(c_uint, 0xff000000, .hexadecimal)) >> @as(c_int, 24)) | ((x & @import("std").zig.c_translation.promoteIntLiteral(c_uint, 0x00ff0000, .hexadecimal)) >> @as(c_int, 8))) | ((x & @as(c_uint, 0x0000ff00)) << @as(c_int, 8))) | ((x & @as(c_uint, 0x000000ff)) << @as(c_int, 24))) { + return ((((x & @import("std").zig.c_translation.promoteIntLiteral(c_uint, 0xff000000, .hexadecimal)) >> @as(c_int, 24)) | ((x & @import("std").zig.c_translation.promoteIntLiteral(c_uint, 0x00ff0000, .hexadecimal)) >> @as(c_int, 8))) | ((x & @as(c_uint, 0x0000ff00)) << @as(c_int, 8))) | ((x & @as(c_uint, 0x000000ff)) << @as(c_int, 24)); +} +pub inline fn __bswap_constant_64(x: anytype) @TypeOf(((((((((x & @as(c_ulonglong, 0xff00000000000000)) >> @as(c_int, 56)) | ((x & @as(c_ulonglong, 0x00ff000000000000)) >> @as(c_int, 40))) | ((x & @as(c_ulonglong, 0x0000ff0000000000)) >> @as(c_int, 24))) | ((x & @as(c_ulonglong, 0x000000ff00000000)) >> @as(c_int, 8))) | ((x & @as(c_ulonglong, 0x00000000ff000000)) << @as(c_int, 8))) | ((x & @as(c_ulonglong, 0x0000000000ff0000)) << @as(c_int, 24))) | ((x & @as(c_ulonglong, 0x000000000000ff00)) << @as(c_int, 40))) | ((x & @as(c_ulonglong, 0x00000000000000ff)) << @as(c_int, 56))) { + return ((((((((x & @as(c_ulonglong, 0xff00000000000000)) >> @as(c_int, 56)) | ((x & @as(c_ulonglong, 0x00ff000000000000)) >> @as(c_int, 40))) | ((x & @as(c_ulonglong, 0x0000ff0000000000)) >> @as(c_int, 24))) | ((x & @as(c_ulonglong, 0x000000ff00000000)) >> @as(c_int, 8))) | ((x & @as(c_ulonglong, 0x00000000ff000000)) << @as(c_int, 8))) | ((x & @as(c_ulonglong, 0x0000000000ff0000)) << @as(c_int, 24))) | ((x & @as(c_ulonglong, 0x000000000000ff00)) << @as(c_int, 40))) | ((x & @as(c_ulonglong, 0x00000000000000ff)) << @as(c_int, 56)); +} +pub const _BITS_UINTN_IDENTITY_H = @as(c_int, 1); +pub inline fn htobe16(x: anytype) @TypeOf(__bswap_16(x)) { + return __bswap_16(x); +} +pub inline fn htole16(x: anytype) @TypeOf(__uint16_identity(x)) { + return __uint16_identity(x); +} +pub inline fn be16toh(x: anytype) @TypeOf(__bswap_16(x)) { + return __bswap_16(x); +} +pub inline fn le16toh(x: anytype) @TypeOf(__uint16_identity(x)) { + return __uint16_identity(x); +} +pub inline fn htobe32(x: anytype) @TypeOf(__bswap_32(x)) { + return __bswap_32(x); +} +pub inline fn htole32(x: anytype) @TypeOf(__uint32_identity(x)) { + return __uint32_identity(x); +} +pub inline fn be32toh(x: anytype) @TypeOf(__bswap_32(x)) { + return __bswap_32(x); +} +pub inline fn le32toh(x: anytype) @TypeOf(__uint32_identity(x)) { + return __uint32_identity(x); +} +pub inline fn htobe64(x: anytype) @TypeOf(__bswap_64(x)) { + return __bswap_64(x); +} +pub inline fn htole64(x: anytype) @TypeOf(__uint64_identity(x)) { + return __uint64_identity(x); +} +pub inline fn be64toh(x: anytype) @TypeOf(__bswap_64(x)) { + return __bswap_64(x); +} +pub inline fn le64toh(x: anytype) @TypeOf(__uint64_identity(x)) { + return __uint64_identity(x); +} +pub const _SYS_SELECT_H = @as(c_int, 1); +pub inline fn __FD_ISSET(d: anytype, s: anytype) @TypeOf((__FDS_BITS(s)[__FD_ELT(d)] & __FD_MASK(d)) != @as(c_int, 0)) { + return (__FDS_BITS(s)[__FD_ELT(d)] & __FD_MASK(d)) != @as(c_int, 0); +} +pub const __sigset_t_defined = @as(c_int, 1); +pub const ____sigset_t_defined = ""; +pub const _SIGSET_NWORDS = @as(c_int, 1024) / (@as(c_int, 8) * @import("std").zig.c_translation.sizeof(c_ulong)); +pub const __timeval_defined = @as(c_int, 1); +pub const _STRUCT_TIMESPEC = @as(c_int, 1); +pub const __suseconds_t_defined = ""; +pub const __NFDBITS = @as(c_int, 8) * @import("std").zig.c_translation.cast(c_int, @import("std").zig.c_translation.sizeof(__fd_mask)); +pub inline fn __FD_ELT(d: anytype) @TypeOf(d / __NFDBITS) { + return d / __NFDBITS; +} +pub inline fn __FD_MASK(d: anytype) __fd_mask { + return @import("std").zig.c_translation.cast(__fd_mask, @as(c_ulong, 1) << (d % __NFDBITS)); +} +pub inline fn __FDS_BITS(set: anytype) @TypeOf(set.*.__fds_bits) { + return set.*.__fds_bits; +} +pub const FD_SETSIZE = __FD_SETSIZE; +pub const NFDBITS = __NFDBITS; +pub inline fn FD_SET(fd: anytype, fdsetp: anytype) @TypeOf(__FD_SET(fd, fdsetp)) { + return __FD_SET(fd, fdsetp); +} +pub inline fn FD_CLR(fd: anytype, fdsetp: anytype) @TypeOf(__FD_CLR(fd, fdsetp)) { + return __FD_CLR(fd, fdsetp); +} +pub inline fn FD_ISSET(fd: anytype, fdsetp: anytype) @TypeOf(__FD_ISSET(fd, fdsetp)) { + return __FD_ISSET(fd, fdsetp); +} +pub inline fn FD_ZERO(fdsetp: anytype) @TypeOf(__FD_ZERO(fdsetp)) { + return __FD_ZERO(fdsetp); +} +pub const __blksize_t_defined = ""; +pub const __blkcnt_t_defined = ""; +pub const __fsblkcnt_t_defined = ""; +pub const __fsfilcnt_t_defined = ""; +pub const _BITS_PTHREADTYPES_COMMON_H = @as(c_int, 1); +pub const _THREAD_SHARED_TYPES_H = @as(c_int, 1); +pub const _BITS_PTHREADTYPES_ARCH_H = @as(c_int, 1); +pub const __SIZEOF_PTHREAD_MUTEX_T = @as(c_int, 40); +pub const __SIZEOF_PTHREAD_ATTR_T = @as(c_int, 56); +pub const __SIZEOF_PTHREAD_RWLOCK_T = @as(c_int, 56); +pub const __SIZEOF_PTHREAD_BARRIER_T = @as(c_int, 32); +pub const __SIZEOF_PTHREAD_MUTEXATTR_T = @as(c_int, 4); +pub const __SIZEOF_PTHREAD_COND_T = @as(c_int, 48); +pub const __SIZEOF_PTHREAD_CONDATTR_T = @as(c_int, 4); +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T = @as(c_int, 8); +pub const __SIZEOF_PTHREAD_BARRIERATTR_T = @as(c_int, 4); +pub const __LOCK_ALIGNMENT = ""; +pub const __ONCE_ALIGNMENT = ""; +pub const _THREAD_MUTEX_INTERNAL_H = @as(c_int, 1); +pub const __PTHREAD_MUTEX_HAVE_PREV = @as(c_int, 1); +pub const _RWLOCK_INTERNAL_H = ""; +pub inline fn __PTHREAD_RWLOCK_INITIALIZER(__flags: anytype) @TypeOf(__flags) { + return blk: { + _ = @as(c_int, 0); + _ = @as(c_int, 0); + _ = @as(c_int, 0); + _ = @as(c_int, 0); + _ = @as(c_int, 0); + _ = @as(c_int, 0); + _ = @as(c_int, 0); + _ = @as(c_int, 0); + _ = __PTHREAD_RWLOCK_ELISION_EXTRA; + _ = @as(c_int, 0); + break :blk __flags; + }; +} +pub const __have_pthread_attr_t = @as(c_int, 1); +pub const __va_list_tag = struct___va_list_tag; +pub const _G_fpos_t = struct__G_fpos_t; +pub const _G_fpos64_t = struct__G_fpos64_t; +pub const _IO_marker = struct__IO_marker; +pub const _IO_codecvt = struct__IO_codecvt; +pub const _IO_wide_data = struct__IO_wide_data; +pub const _IO_FILE = struct__IO_FILE; +pub const __locale_data = struct___locale_data; +pub const __locale_struct = struct___locale_struct; +pub const timeval = struct_timeval; +pub const timespec = struct_timespec; +pub const __pthread_internal_list = struct___pthread_internal_list; +pub const __pthread_internal_slist = struct___pthread_internal_slist; +pub const __pthread_mutex_s = struct___pthread_mutex_s; +pub const __pthread_rwlock_arch_t = struct___pthread_rwlock_arch_t; +pub const __pthread_cond_s = struct___pthread_cond_s; diff --git a/src/platform/native.zig b/src/platform/native.zig index 7522f72b..ab10ea98 100644 --- a/src/platform/native.zig +++ b/src/platform/native.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const builtin = @import("builtin"); const glfw = @import("glfw"); const gpu = @import("gpu"); const app_pkg = @import("app"); @@ -44,7 +45,30 @@ pub const Platform = struct { platform: *Platform, }; + fn getEnvVarOwned(allocator: std.mem.Allocator, key: []const u8) error{ OutOfMemory, InvalidUtf8 }!?[]u8 { + return std.process.getEnvVarOwned(allocator, key) catch |err| switch (err) { + error.EnvironmentVariableNotFound => @as(?[]u8, null), + else => |e| e, + }; + } pub fn init(allocator: std.mem.Allocator, core: *Core) !Platform { + if (builtin.os.tag == .linux) { + const gamemode = @import("gamemode"); + const GAMEMODE_ENV = try getEnvVarOwned(allocator, "GAMEMODE"); + if (GAMEMODE_ENV == null) { + gamemode.requestStart() catch |err| { + std.log.err("Gamemode error {} -> {s}", .{ err, gamemode.errorString() }); + }; + } else { + if (!std.ascii.eqlIgnoreCase(GAMEMODE_ENV.?, "off")) { + gamemode.requestStart() catch |err| { + std.log.err("Gamemode error {} -> {s}", .{ err, gamemode.errorString() }); + }; + } + allocator.free(GAMEMODE_ENV.?); + } + } + const options = core.options; const backend_type = try util.detectBackendType(allocator); @@ -214,6 +238,23 @@ pub const Platform = struct { while (platform.events.popFirst()) |ev| { platform.allocator.destroy(ev); } + + if (builtin.os.tag == .linux) { + const gamemode = @import("gamemode"); + const GAMEMODE_ENV = getEnvVarOwned(platform.allocator, "GAMEMODE") catch unreachable; + if (GAMEMODE_ENV == null) { + gamemode.requestEnd() catch |err| { + std.log.err("Gamemode error {} -> {s}", .{ err, gamemode.errorString() }); + }; + } else { + if (!std.ascii.eqlIgnoreCase(GAMEMODE_ENV.?, "off")) { + gamemode.requestEnd() catch |err| { + std.log.err("Gamemode error {} -> {s}", .{ err, gamemode.errorString() }); + }; + } + platform.allocator.free(GAMEMODE_ENV.?); + } + } } fn pushEvent(platform: *Platform, event: structs.Event) void {