/* * q_stdinc.h - includes the minimum necessary stdc headers, * defines common and / or missing types. * * NOTE: for net stuff use net_sys.h, * for byte order use q_endian.h, * for math stuff use mathlib.h, * for locale-insensitive ctype.h functions use q_ctype.h. * * Copyright (C) 1996-1997 Id Software, Inc. * Copyright (C) 2007-2011 O.Sezer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef spingle__q_stdinc_h #define spingle__q_stdinc_h #include "arch_def.h" #include #include #include #include #include #include #include #include #include #include #if !PLATFORM_IS(WINDOWS) #include #endif _Static_assert(sizeof(float) == 4, "float not correct size"); /* make sure enums are the size of ints for structure packing */ enum dummy_enum { dummy_value }; _Static_assert(sizeof(enum dummy_enum) == sizeof(int32_t), "enum not sizeof(int32_t)"); typedef uint8_t byte; /* math */ typedef float vec_t; typedef vec_t vec3_t[3]; typedef vec_t vec4_t[4]; typedef vec_t vec5_t[5]; /* MAX_OSPATH (max length of a filesystem pathname, i.e. PATH_MAX) * Note: See GNU Hurd and others' notes about brokenness of this: * http://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html * http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html */ #if !defined(PATH_MAX) /* equivalent values? */ #if defined(MAXPATHLEN) #define PATH_MAX MAXPATHLEN #elif defined(_MAX_PATH) #define PATH_MAX _MAX_PATH #elif defined(MAX_PATH) #define PATH_MAX MAX_PATH #else #error "no PATH_MAX available" #endif #endif #define MAX_OSPATH PATH_MAX /* function attributes, etc */ #if PLATFORM_IS_GNUC #define FUNC_PRINTF(x,y) __attribute__((__format__(__printf__,x,y))) #else #define FUNC_PRINTF(x,y) #endif /* argument format attributes for function pointers are supported for gcc >= 3.1 */ #if PLATFORM_IS_GNUC >= 3 #define FUNCP_PRINTF FUNC_PRINTF #else #define FUNCP_PRINTF(x,y) #endif #define arraysizeof(a) (sizeof(a) / sizeof(*a)) #define strsizeof(a) (sizeof(a) - 1) #endif