From cc5140e3a1e338b59c760a7f3cb9f601e68904fc Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 24 Dec 2011 10:04:33 +0900 Subject: [PATCH] Move min/max/bound and field_offset into better locations. min/max bound into mathlib.h (they /are/ math functions, after all) and field_offset into qtypes.h. --- hw/source/master.c | 1 + include/QF/mathlib.h | 10 ++++++++++ include/QF/qtypes.h | 3 +++ include/compat.h | 13 ------------- libs/console/complete.c | 1 + libs/console/inputline.c | 1 + libs/gamecode/engine/pr_debug.c | 1 + libs/ruamoko/rua_obj.c | 1 + libs/util/hash.c | 2 ++ libs/util/quakefs.c | 1 + libs/util/sys.c | 1 + libs/util/zone.c | 1 + libs/video/renderer/gl/gl_textures.c | 1 + libs/video/targets/vid.c | 1 + libs/video/targets/vid_common_sw.c | 1 + libs/video/targets/vid_common_sw32.c | 1 + tools/bsp2img/bsp2img.c | 1 + tools/qflight/source/options.c | 1 + 18 files changed, 29 insertions(+), 13 deletions(-) diff --git a/hw/source/master.c b/hw/source/master.c index 6cdcf4e4c..ef63366f4 100644 --- a/hw/source/master.c +++ b/hw/source/master.c @@ -14,6 +14,7 @@ #include "QF/console.h" #include "QF/cvar.h" #include "QF/idparse.h" +#include "QF/mathlib.h" #include "QF/msg.h" #include "QF/plugin.h" #include "QF/qargs.h" diff --git a/include/QF/mathlib.h b/include/QF/mathlib.h index 9604da15a..ec6e2adae 100644 --- a/include/QF/mathlib.h +++ b/include/QF/mathlib.h @@ -37,6 +37,16 @@ #include #include "QF/qtypes.h" +#ifndef max +# define max(a,b) ((a) > (b) ? (a) : (b)) +#endif +#ifndef min +# define min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef bound +# define bound(a,b,c) (max(a, min(b, c))) +#endif + #ifndef M_PI # define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h #endif diff --git a/include/QF/qtypes.h b/include/QF/qtypes.h index 8402a5bd9..d4e34128b 100644 --- a/include/QF/qtypes.h +++ b/include/QF/qtypes.h @@ -42,6 +42,9 @@ # undef msg_t #endif +#undef field_offset +#define field_offset(type,field) ((size_t)&(((type *)0)->field)) + #define MAX_QPATH 64 #ifndef _DEF_BYTE_ diff --git a/include/compat.h b/include/compat.h index a9a1052f1..8d0c7c2aa 100644 --- a/include/compat.h +++ b/include/compat.h @@ -38,16 +38,6 @@ #include - -#ifndef max -# define max(a,b) ((a) > (b) ? (a) : (b)) -#endif -#ifndef min -# define min(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef bound -# define bound(a,b,c) (max(a, min(b, c))) -#endif /* This fixes warnings when compiling with -pedantic */ #if defined(__GNUC__) && !defined(inline) # define inline __inline__ @@ -110,7 +100,4 @@ size_t strnlen (const char *str, size_t len); # include "qstring.h" #endif -#undef field_offset -#define field_offset(type,field) ((size_t)&(((type *)0)->field)) - #endif // __compat_h diff --git a/libs/console/complete.c b/libs/console/complete.c index d0038985a..59aaedea5 100644 --- a/libs/console/complete.c +++ b/libs/console/complete.c @@ -44,6 +44,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/cmd.h" #include "QF/console.h" #include "QF/cvar.h" +#include "QF/mathlib.h" #include "QF/plugin.h" #include "QF/sys.h" #include "QF/va.h" diff --git a/libs/console/inputline.c b/libs/console/inputline.c index 94c2cc2ef..8d6685e4e 100644 --- a/libs/console/inputline.c +++ b/libs/console/inputline.c @@ -45,6 +45,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/cmd.h" #include "QF/console.h" #include "QF/keys.h" +#include "QF/mathlib.h" #include "compat.h" diff --git a/libs/gamecode/engine/pr_debug.c b/libs/gamecode/engine/pr_debug.c index 654269ff3..8799974e8 100644 --- a/libs/gamecode/engine/pr_debug.c +++ b/libs/gamecode/engine/pr_debug.c @@ -47,6 +47,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/cvar.h" #include "QF/dstring.h" #include "QF/hash.h" +#include "QF/mathlib.h" #include "QF/pr_debug.h" #include "QF/progs.h" #include "QF/qendian.h" diff --git a/libs/ruamoko/rua_obj.c b/libs/ruamoko/rua_obj.c index fc81e4bb8..52595329f 100644 --- a/libs/ruamoko/rua_obj.c +++ b/libs/ruamoko/rua_obj.c @@ -48,6 +48,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/cvar.h" #include "QF/dstring.h" #include "QF/hash.h" +#include "QF/mathlib.h" #include "QF/pr_obj.h" #include "QF/progs.h" #include "QF/ruamoko.h" diff --git a/libs/util/hash.c b/libs/util/hash.c index 8e8155e87..4854c439b 100644 --- a/libs/util/hash.c +++ b/libs/util/hash.c @@ -42,6 +42,8 @@ static __attribute__ ((used)) const char rcsid[] = #include // should be sys/types.h, but bc is stupid #include "QF/hash.h" +#include "QF/qtypes.h" +#include "QF/mathlib.h" #include "QF/sys.h" #include "compat.h" diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index 4206eebc6..7cc811433 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -80,6 +80,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/cvar.h" #include "QF/dstring.h" #include "QF/hash.h" +#include "QF/mathlib.h" #include "QF/pak.h" #include "QF/pakfile.h" #include "QF/qargs.h" diff --git a/libs/util/sys.c b/libs/util/sys.c index ca98118be..d3967b4a1 100644 --- a/libs/util/sys.c +++ b/libs/util/sys.c @@ -78,6 +78,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/cmd.h" #include "QF/cvar.h" #include "QF/dstring.h" +#include "QF/mathlib.h" #include "QF/sys.h" #include "QF/quakefs.h" #include "QF/va.h" diff --git a/libs/util/zone.c b/libs/util/zone.c index dc46017c8..8d5a1ba8b 100644 --- a/libs/util/zone.c +++ b/libs/util/zone.c @@ -43,6 +43,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/cmd.h" #include "QF/cvar.h" +#include "QF/mathlib.h" #include "QF/qargs.h" #include "QF/sys.h" #include "QF/zone.h" diff --git a/libs/video/renderer/gl/gl_textures.c b/libs/video/renderer/gl/gl_textures.c index 2cf9101d9..ba69b2f59 100644 --- a/libs/video/renderer/gl/gl_textures.c +++ b/libs/video/renderer/gl/gl_textures.c @@ -45,6 +45,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/crc.h" #include "QF/cvar.h" #include "QF/draw.h" +#include "QF/mathlib.h" #include "QF/sys.h" #include "QF/vid.h" #include "QF/GL/defines.h" diff --git a/libs/video/targets/vid.c b/libs/video/targets/vid.c index dcc83f2d3..f2689f7ce 100644 --- a/libs/video/targets/vid.c +++ b/libs/video/targets/vid.c @@ -41,6 +41,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/console.h" #include "QF/cvar.h" +#include "QF/mathlib.h" #include "QF/qargs.h" #include "QF/sys.h" #include "QF/va.h" diff --git a/libs/video/targets/vid_common_sw.c b/libs/video/targets/vid_common_sw.c index b51f3cab5..c00b48fab 100644 --- a/libs/video/targets/vid_common_sw.c +++ b/libs/video/targets/vid_common_sw.c @@ -35,6 +35,7 @@ static __attribute__ ((used)) const char rcsid[] = #include #include "QF/console.h" +#include "QF/mathlib.h" #include "QF/sys.h" #include "QF/vid.h" diff --git a/libs/video/targets/vid_common_sw32.c b/libs/video/targets/vid_common_sw32.c index 90d1542d9..d794d0d95 100644 --- a/libs/video/targets/vid_common_sw32.c +++ b/libs/video/targets/vid_common_sw32.c @@ -33,6 +33,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/console.h" #include "QF/cvar.h" +#include "QF/mathlib.h" #include "QF/qargs.h" #include "QF/sys.h" #include "QF/va.h" diff --git a/tools/bsp2img/bsp2img.c b/tools/bsp2img/bsp2img.c index eade1f831..a7d72f35a 100644 --- a/tools/bsp2img/bsp2img.c +++ b/tools/bsp2img/bsp2img.c @@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "QF/bspfile.h" #include "QF/cmd.h" #include "QF/cvar.h" +#include "QF/mathlib.h" #include "QF/pcx.h" #include "QF/png.h" #include "QF/quakefs.h" diff --git a/tools/qflight/source/options.c b/tools/qflight/source/options.c index 635337472..8c6a31688 100644 --- a/tools/qflight/source/options.c +++ b/tools/qflight/source/options.c @@ -42,6 +42,7 @@ static __attribute__ ((used)) const char rcsid[] = #include #include "QF/dstring.h" +#include "QF/mathlib.h" #include "QF/qtypes.h" #include "compat.h"