diff options
author | tma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-12-05 17:32:54 +0000 |
---|---|---|
committer | tma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-12-05 17:32:54 +0000 |
commit | 1fa5872b59f24cb05e82c4124ddb455834dd9f37 (patch) | |
tree | eb835a752c2915f487b9d1d33e5e4e322b4dd45a /code | |
parent | 5da02a4301441953f1b20d10e7cbbc3e8498d959 (diff) | |
download | ioquake3-aero-1fa5872b59f24cb05e82c4124ddb455834dd9f37.tar.gz ioquake3-aero-1fa5872b59f24cb05e82c4124ddb455834dd9f37.zip |
* Replaced ALIGN macro with PAD
* Moved ALIGN16 macro from tr_local.h to ALIGN in q_shared.h
git-svn-id: svn://svn.icculus.org/quake3/trunk@417 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code')
-rw-r--r-- | code/botlib/be_aas_route.c | 5 | ||||
-rw-r--r-- | code/botlib/be_ai_chat.c | 8 | ||||
-rw-r--r-- | code/client/snd_codec_wav.c | 2 | ||||
-rw-r--r-- | code/qcommon/common.c | 4 | ||||
-rw-r--r-- | code/qcommon/q_shared.h | 8 | ||||
-rw-r--r-- | code/renderer/tr_local.h | 22 |
6 files changed, 25 insertions, 24 deletions
diff --git a/code/botlib/be_aas_route.c b/code/botlib/be_aas_route.c index de8cc03..e31202b 100644 --- a/code/botlib/be_aas_route.c +++ b/code/botlib/be_aas_route.c @@ -521,7 +521,8 @@ void AAS_CalculateAreaTravelTimes(void) // size += settings->numreachableareas * sizeof(unsigned short *); // - size += settings->numreachableareas * ALIGN(revreach->numlinks) * sizeof(unsigned short); + size += settings->numreachableareas * + PAD(revreach->numlinks, sizeof(long)) * sizeof(unsigned short); } //end for //allocate memory for the area travel times ptr = (char *) GetClearedMemory(size); @@ -541,7 +542,7 @@ void AAS_CalculateAreaTravelTimes(void) for (l = 0; l < settings->numreachableareas; l++) { aasworld.areatraveltimes[i][l] = (unsigned short *) ptr; - ptr += ALIGN(revreach->numlinks) * sizeof(unsigned short); + ptr += PAD(revreach->numlinks, sizeof(long)) * sizeof(unsigned short); //reachability link reach = &aasworld.reachability[settings->firstreachablearea + l]; // diff --git a/code/botlib/be_ai_chat.c b/code/botlib/be_ai_chat.c index c71df9a..d61e11e 100644 --- a/code/botlib/be_ai_chat.c +++ b/code/botlib/be_ai_chat.c @@ -690,7 +690,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename) return NULL; } //end if len = strlen(token.string) + 1; - len = ALIGN(len); + len = PAD(len, sizeof(long)); size += sizeof(bot_synonym_t) + len; if (pass) { @@ -989,7 +989,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename) return NULL; } //end if len = strlen(token.string) + 1; - len = ALIGN(len); + len = PAD(len, sizeof(long)); size += sizeof(bot_randomlist_t) + len; if (pass) { @@ -1020,7 +1020,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename) return NULL; } //end if len = strlen(chatmessagestring) + 1; - len = ALIGN(len); + len = PAD(len, sizeof(long)); size += sizeof(bot_randomstring_t) + len; if (pass) { @@ -2123,7 +2123,7 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname) return NULL; } //end if len = strlen(chatmessagestring) + 1; - len = ALIGN(len); + len = PAD(len, sizeof(long)); if (pass) { chatmessage = (bot_chatmessage_t *) ptr; diff --git a/code/client/snd_codec_wav.c b/code/client/snd_codec_wav.c index fde6a17..a60f3da 100644 --- a/code/client/snd_codec_wav.c +++ b/code/client/snd_codec_wav.c @@ -91,7 +91,7 @@ static int S_FindRIFFChunk( fileHandle_t f, char *chunk ) { if( !Q_strncmp( name, chunk, 4 ) ) return len; - len = (len + 1 ) & ~1; // pad to word boundary + len = PAD( len, 2 ); // Not the right chunk - skip it FS_Seek( f, len, FS_SEEK_CUR ); diff --git a/code/qcommon/common.c b/code/qcommon/common.c index 3839f7b..b9de067 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -929,7 +929,7 @@ void *Z_TagMalloc( int size, int tag ) { // size += sizeof(memblock_t); // account for size of block header size += 4; // space for memory trash tester - size = ALIGN(size); // align to 32/64 bit boundary + size = PAD(size, sizeof(long)); // align to 32/64 bit boundary base = rover = zone->rover; start = base->prev; @@ -1746,7 +1746,7 @@ void *Hunk_AllocateTempMemory( int size ) { Hunk_SwapBanks(); - size = ALIGN(size) + sizeof( hunkHeader_t ); + size = PAD(size, sizeof(long)) + sizeof( hunkHeader_t ); if ( hunk_temp->temp + hunk_permanent->permanent + size > s_hunkTotal ) { Com_Error( ERR_DROP, "Hunk_AllocateTempMemory: failed on %i", size ); diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 45bd046..d6c69dc 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -111,7 +111,13 @@ typedef int sfxHandle_t; typedef int fileHandle_t; typedef int clipHandle_t; -#define ALIGN(x) ((x+sizeof(long)-1) & ~(sizeof(long)-1)) +#define PAD(x,y) (((x)+(y)-1) & ~((y)-1)) + +#ifdef __GNUC__ +#define ALIGN(x) __attribute__((aligned(x))) +#else +#define ALIGN(x) +#endif #ifndef NULL #define NULL ((void *)0) diff --git a/code/renderer/tr_local.h b/code/renderer/tr_local.h index 646cc6f..865128f 100644 --- a/code/renderer/tr_local.h +++ b/code/renderer/tr_local.h @@ -1274,24 +1274,18 @@ typedef struct stageVars } stageVars_t; -#ifdef __GNUC__ -#define ALIGN16 __attribute__((aligned(16))) -#else -#define ALIGN16 -#endif - typedef struct shaderCommands_s { - glIndex_t indexes[SHADER_MAX_INDEXES] ALIGN16; - vec4_t xyz[SHADER_MAX_VERTEXES] ALIGN16; - vec4_t normal[SHADER_MAX_VERTEXES] ALIGN16; - vec2_t texCoords[SHADER_MAX_VERTEXES][2] ALIGN16; - color4ub_t vertexColors[SHADER_MAX_VERTEXES] ALIGN16; - int vertexDlightBits[SHADER_MAX_VERTEXES] ALIGN16; + glIndex_t indexes[SHADER_MAX_INDEXES] ALIGN(16); + vec4_t xyz[SHADER_MAX_VERTEXES] ALIGN(16); + vec4_t normal[SHADER_MAX_VERTEXES] ALIGN(16); + vec2_t texCoords[SHADER_MAX_VERTEXES][2] ALIGN(16); + color4ub_t vertexColors[SHADER_MAX_VERTEXES] ALIGN(16); + int vertexDlightBits[SHADER_MAX_VERTEXES] ALIGN(16); - stageVars_t svars ALIGN16; + stageVars_t svars ALIGN(16); - color4ub_t constantColor255[SHADER_MAX_VERTEXES] ALIGN16; + color4ub_t constantColor255[SHADER_MAX_VERTEXES] ALIGN(16); shader_t *shader; float shaderTime; |