/* * 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 __QSTDINC_H #define __QSTDINC_H #include #include #include #include #include #ifndef _WIN32 #include #endif #include #if defined(_MSC_VER) && (_MSC_VER < 1600) #include "msinttypes/stdint.h" #else #include #endif #include #include #include _Static_assert(sizeof(float) == 4, "float not correct size"); _Static_assert(sizeof(int32_t) == 4, "int32_t 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(_WIN32) && defined(_MAX_PATH) #define PATH_MAX _MAX_PATH #elif defined(_WIN32) && defined(MAX_PATH) #define PATH_MAX MAX_PATH #else /* fallback */ #define PATH_MAX 1024 #endif #endif /* PATH_MAX */ #define MAX_OSPATH PATH_MAX /* function attributes, etc */ #if defined(__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 defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)) #define FUNCP_PRINTF FUNC_PRINTF #else #define FUNCP_PRINTF(x,y) #endif #endif /* __QSTDINC_H */