diff --git a/configure.ac b/configure.ac index a2e586b7c..bbc00a634 100644 --- a/configure.ac +++ b/configure.ac @@ -1312,7 +1312,7 @@ if test "x$optimize" = xyes; then CC_SUB=$3 IFS=" " AC_MSG_RESULT($CCVER) - heavy="-O3 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations" + heavy="-O2 -frename-registers -finline-limit=32000 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations" light="-O2" AC_ARG_ENABLE(strict-aliasing, [ --enable-strict-aliasing enable the -fstrict-aliasing ooption of gcc]) @@ -1472,7 +1472,7 @@ AC_ARG_ENABLE(Werror, dnl We want warnings, lots of warnings... if test "x$GCC" = "xyes"; then if test "x$enable_Werror" $cvs_def_enabled; then - CFLAGS="$CFLAGS -Wall -Werror -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations" + CFLAGS="$CFLAGS -Wall -Werror -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline" else CFLAGS="$CFLAGS -Wall" fi diff --git a/include/QF/mathlib.h b/include/QF/mathlib.h index d9ad65ad1..225f6fb08 100644 --- a/include/QF/mathlib.h +++ b/include/QF/mathlib.h @@ -95,7 +95,6 @@ void _VectorMA (const vec3_t veca, float scale, const vec3_t vecb, void _VectorScale (const vec3_t in, vec_t scale, vec3_t out); void _VectorSubtract (const vec3_t veca, const vec3_t vecb, vec3_t out); void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross); -float VectorNormalize (vec3_t v); // returns vector length vec_t _VectorNormalize (vec3_t v); // returns vector length void VectorInverse (vec3_t v); int Q_log2(int val); @@ -141,6 +140,7 @@ void RotatePointAroundVector (vec3_t dst, const vec3_t axis, extern mplane_t frustum[4]; extern inline qboolean R_CullBox (const vec3_t mins, const vec3_t maxs); extern inline qboolean R_CullSphere (const vec3_t origin, const float radius); +extern inline float VectorNormalize (vec3_t v); // returns vector length #ifndef IMPLEMENT_R_Cull extern inline #endif @@ -173,4 +173,26 @@ R_CullSphere (const vec3_t origin, const float radius) return false; } +#ifndef IMPLEMENT_VectorNormalize +extern inline +#endif +float +VectorNormalize (vec3_t v) +{ + float length; + + length = DotProduct (v, v); + if (length) { + float ilength; + + length = sqrt (length); + ilength = 1.0 / length; + v[0] *= ilength; + v[1] *= ilength; + v[2] *= ilength; + } + + return length; +} + #endif // __mathlib_h diff --git a/libs/gamecode/engine/pr_obj.c b/libs/gamecode/engine/pr_obj.c index 57c9373d8..4bc06d569 100644 --- a/libs/gamecode/engine/pr_obj.c +++ b/libs/gamecode/engine/pr_obj.c @@ -594,7 +594,7 @@ pr_class_pose_as (progs_t *pr) PR_RunError (pr, "%s, not implemented", __FUNCTION__); } -static inline pr_id_t * +static inline pr_id_t * class_create_instance (progs_t *pr, pr_class_t *class) { int size = class->instance_size * sizeof (pr_type_t); diff --git a/libs/models/alias/gl_mesh.c b/libs/models/alias/gl_mesh.c index b38ab6462..d44e890cc 100644 --- a/libs/models/alias/gl_mesh.c +++ b/libs/models/alias/gl_mesh.c @@ -76,7 +76,7 @@ int stripcount; int strip_size; -static void +static inline void alloc_used (int size) { if (size <= used_size) @@ -88,7 +88,7 @@ alloc_used (int size) used_size = size; } -static void +static inline void add_command (int cmd) { if (numcommands + 1 > commands_size) { @@ -100,7 +100,7 @@ add_command (int cmd) commands[numcommands++] = cmd; } -static void +static inline void add_vertex (int vert) { if (numorder + 1 > vertexorder_size) { @@ -112,7 +112,7 @@ add_vertex (int vert) vertexorder[numorder++] = vert; } -static void +static inline void add_strip (int vert, int tri) { if (stripcount + 1 > strip_size) { diff --git a/libs/models/alias/model_alias.c b/libs/models/alias/model_alias.c index 7dccbaf54..100bc3158 100644 --- a/libs/models/alias/model_alias.c +++ b/libs/models/alias/model_alias.c @@ -135,8 +135,7 @@ Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex) void Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator) { - byte *p; - int i, j, len, size, version, numframes, start, end, total; + int i, j, size, version, numframes, start, end, total; dtriangle_t *pintriangles; daliasframetype_t *pframetype; daliasskintype_t *pskintype; @@ -151,8 +150,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator) extra = 1; // extra precision bytes CRC_Init (&crc); - for (len = qfs_filesize, p = buffer; len; len--, p++) - CRC_ProcessByte (&crc, *p); + CRC_ProcessBlock (buffer, &crc, qfs_filesize); start = Hunk_LowMark (); diff --git a/libs/util/mathlib.c b/libs/util/mathlib.c index 0b5ffdfe0..6e2c32b98 100644 --- a/libs/util/mathlib.c +++ b/libs/util/mathlib.c @@ -41,6 +41,7 @@ static __attribute__ ((unused)) const char rcsid[] = #include #define IMPLEMENT_R_Cull +#define IMPLEMENT_VectorNormalize #include "QF/mathlib.h" #include "QF/qtypes.h" @@ -439,25 +440,6 @@ _VectorLength (const vec3_t v) return length; } -float -VectorNormalize (vec3_t v) -{ - float length; - - length = DotProduct (v, v); - if (length) { - float ilength; - - length = sqrt (length); - ilength = 1.0 / length; - v[0] *= ilength; - v[1] *= ilength; - v[2] *= ilength; - } - - return length; -} - vec_t _VectorNormalize (vec3_t v) { diff --git a/libs/util/zone.c b/libs/util/zone.c index d37d1d66d..903856e68 100644 --- a/libs/util/zone.c +++ b/libs/util/zone.c @@ -563,7 +563,6 @@ typedef struct cache_system_s { cache_system_t cache_head; int cache_writelock; -static void *Cache_RealCheck (cache_user_t *c); static cache_system_t *Cache_TryAlloc (int size, qboolean nobottom); static void Cache_RealFree (cache_user_t *c); static void Cache_Profile (void); @@ -652,7 +651,7 @@ Cache_FreeHigh (int new_high_hunk) #endif } -static void +static inline void Cache_UnlinkLRU (cache_system_t * cs) { if (!cs->lru_next || !cs->lru_prev) @@ -664,7 +663,7 @@ Cache_UnlinkLRU (cache_system_t * cs) cs->lru_prev = cs->lru_next = NULL; } -static void +static inline void Cache_MakeLRU (cache_system_t * cs) { if (cs->lru_next || cs->lru_prev) @@ -882,18 +881,7 @@ Cache_RealFree (cache_user_t *c) #endif } -void * -Cache_Check (cache_user_t *c) -{ - void *mem; - - CACHE_WRITE_LOCK; - mem = Cache_RealCheck (c); - CACHE_WRITE_UNLOCK; - return mem; -} - -static void * +static inline void * Cache_RealCheck (cache_user_t *c) { cache_system_t *cs; @@ -910,6 +898,17 @@ Cache_RealCheck (cache_user_t *c) return c->data; } +void * +Cache_Check (cache_user_t *c) +{ + void *mem; + + CACHE_WRITE_LOCK; + mem = Cache_RealCheck (c); + CACHE_WRITE_UNLOCK; + return mem; +} + void * Cache_Alloc (cache_user_t *c, int size, const char *name) { diff --git a/libs/video/renderer/gl/gl_lightmap.c b/libs/video/renderer/gl/gl_lightmap.c index 65e8cf10d..2c5a5540e 100644 --- a/libs/video/renderer/gl/gl_lightmap.c +++ b/libs/video/renderer/gl/gl_lightmap.c @@ -105,7 +105,7 @@ R_RecursiveLightUpdate (mnode_t *node) surf->cached_dlight = true; } -static void +static inline void R_AddDynamicLights_1 (msurface_t *surf) { float dist; @@ -170,7 +170,7 @@ R_AddDynamicLights_1 (msurface_t *surf) } } -static void +static inline void R_AddDynamicLights_3 (msurface_t *surf) { float dist; diff --git a/libs/video/renderer/gl/gl_mod_alias.c b/libs/video/renderer/gl/gl_mod_alias.c index c67e8d5c7..af956173b 100644 --- a/libs/video/renderer/gl/gl_mod_alias.c +++ b/libs/video/renderer/gl/gl_mod_alias.c @@ -91,7 +91,7 @@ float r_avertexnormal_dots[SHADEDOT_QUANT][256] = vec3_t shadevector; -static void +static inline void GL_DrawAliasFrameTri (vert_order_t *vo) { float color[4]; @@ -116,7 +116,7 @@ GL_DrawAliasFrameTri (vert_order_t *vo) qfglEnd(); } -static void +static inline void GL_DrawAliasFrameTri_fb (vert_order_t *vo) { int count; @@ -139,7 +139,7 @@ GL_DrawAliasFrameTri_fb (vert_order_t *vo) qfglEnd(); } -static void +static inline void GL_DrawAliasFrameTriMulti (vert_order_t *vo) { float color[4]; @@ -168,7 +168,7 @@ GL_DrawAliasFrameTriMulti (vert_order_t *vo) qfglEnd (); } -static void +static inline void GL_DrawAliasFrame (vert_order_t *vo) { float color[4]; @@ -208,7 +208,7 @@ GL_DrawAliasFrame (vert_order_t *vo) } } -static void +static inline void GL_DrawAliasFrame_fb (vert_order_t *vo) { int count; @@ -243,7 +243,7 @@ GL_DrawAliasFrame_fb (vert_order_t *vo) } } -static void +static inline void GL_DrawAliasFrameMulti (vert_order_t *vo) { float color[4]; @@ -339,7 +339,7 @@ GL_DrawAliasShadow (aliashdr_t *paliashdr, vert_order_t *vo) } } -static vert_order_t * +static inline vert_order_t * GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e) { float interval; @@ -445,7 +445,7 @@ GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e) return vo; } -static vert_order_t * +static inline vert_order_t * GL_GetAliasFrameVerts (int frame, aliashdr_t *paliashdr, entity_t *e) { float interval; diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index d5f05b5f9..0dc39f266 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -144,7 +144,7 @@ R_RenderFullbrights (void) qfglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } -void +inline void R_RenderBrushPoly (msurface_t *fa) { float *v; @@ -233,7 +233,7 @@ R_DrawWaterSurfaces (void) } } -static void +static inline void DrawTextureChains (void) { int i; diff --git a/libs/video/renderer/gl/gl_skin.c b/libs/video/renderer/gl/gl_skin.c index c3a36f82f..132cb4eef 100644 --- a/libs/video/renderer/gl/gl_skin.c +++ b/libs/video/renderer/gl/gl_skin.c @@ -94,7 +94,7 @@ Skin_Set_Translate (int top, int bottom, void *_dest) } } -static void +static inline void build_skin_8 (byte * original, int tinwidth, int tinheight, unsigned int scaled_width, unsigned int scaled_height, int inwidth, qboolean alpha) @@ -121,7 +121,7 @@ build_skin_8 (byte * original, int tinwidth, int tinheight, alpha); } -static void +static inline void build_skin_32 (byte * original, int tinwidth, int tinheight, unsigned int scaled_width, unsigned int scaled_height, int inwidth, qboolean alpha) diff --git a/libs/video/renderer/r_light.c b/libs/video/renderer/r_light.c index d288f098a..7bf030b67 100644 --- a/libs/video/renderer/r_light.c +++ b/libs/video/renderer/r_light.c @@ -185,7 +185,7 @@ loc0: } } -static void +static inline void real_mark_surfaces (float dist, msurface_t *surf, const vec3_t lightorigin, dlight_t *light, int bit) {