mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
revise the function attributes usage: do not use the gcc __attribute__
directly, but define proper macros for each attribute we do or may use. also support MSC along the way for example with the noreturn attribute. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1440 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
f13af4d0e5
commit
3cf6946ebd
11 changed files with 62 additions and 48 deletions
|
@ -149,9 +149,8 @@ extern char *q_strlwr (char *str);
|
|||
extern char *q_strupr (char *str);
|
||||
|
||||
/* snprintf, vsnprintf : always use our versions. */
|
||||
extern int q_snprintf (char *str, size_t size, const char *format, ...) __attribute__((__format__(__printf__,3,4)));
|
||||
extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args)
|
||||
__attribute__((__format__(__printf__,3,0)));
|
||||
extern int q_snprintf (char *str, size_t size, const char *format, ...) FUNC_PRINTF(3,4);
|
||||
extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args) FUNC_PRINTF(3,0);
|
||||
|
||||
//============================================================================
|
||||
|
||||
|
@ -188,7 +187,7 @@ const char *COM_FileGetExtension (const char *in); /* doesn't return NULL */
|
|||
void COM_ExtractExtension (const char *in, char *out, size_t outsize);
|
||||
void COM_CreatePath (char *path);
|
||||
|
||||
char *va (const char *format, ...) __attribute__((__format__(__printf__,1,2)));
|
||||
char *va (const char *format, ...) FUNC_PRINTF(1,2);
|
||||
// does a varargs printf into a temp buffer
|
||||
|
||||
|
||||
|
|
|
@ -634,7 +634,7 @@ void Con_SafePrintf (const char *fmt, ...)
|
|||
Con_CenterPrintf -- johnfitz -- pad each line with spaces to make it appear centered
|
||||
================
|
||||
*/
|
||||
void Con_CenterPrintf (int linewidth, const char *fmt, ...) __attribute__((__format__(__printf__,2,3)));
|
||||
void Con_CenterPrintf (int linewidth, const char *fmt, ...) FUNC_PRINTF(2,3);
|
||||
void Con_CenterPrintf (int linewidth, const char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
|
|
@ -39,12 +39,12 @@ void Con_DrawCharacter (int cx, int line, int num);
|
|||
void Con_CheckResize (void);
|
||||
void Con_Init (void);
|
||||
void Con_DrawConsole (int lines, qboolean drawinput);
|
||||
void Con_Printf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||
void Con_DWarning (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); //ericw
|
||||
void Con_Warning (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); //johnfitz
|
||||
void Con_DPrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||
void Con_DPrintf2 (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); //johnfitz
|
||||
void Con_SafePrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||
void Con_Printf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void Con_DWarning (const char *fmt, ...) FUNC_PRINTF(1,2); //ericw
|
||||
void Con_Warning (const char *fmt, ...) FUNC_PRINTF(1,2); //johnfitz
|
||||
void Con_DPrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void Con_DPrintf2 (const char *fmt, ...) FUNC_PRINTF(1,2); //johnfitz
|
||||
void Con_SafePrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void Con_DrawNotify (void);
|
||||
void Con_ClearNotify (void);
|
||||
void Con_ToggleConsole_f (void);
|
||||
|
|
|
@ -454,12 +454,13 @@ Host_Status_f
|
|||
*/
|
||||
void Host_Status_f (void)
|
||||
{
|
||||
void (*print_fn) (const char *fmt, ...)
|
||||
FUNCP_PRINTF(1,2);
|
||||
client_t *client;
|
||||
int seconds;
|
||||
int minutes;
|
||||
int hours = 0;
|
||||
int j;
|
||||
void (*print_fn) (const char *fmt, ...) __fp_attribute__((__format__(__printf__,1,2)));
|
||||
|
||||
if (cmd_source == src_command)
|
||||
{
|
||||
|
|
|
@ -103,19 +103,6 @@ float anglemod(float a)
|
|||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
BOPS_Error
|
||||
|
||||
Split out like this for ASM to call.
|
||||
==================
|
||||
*/
|
||||
void BOPS_Error (void) __attribute__((__noreturn__));
|
||||
void BOPS_Error (void)
|
||||
{
|
||||
Sys_Error ("BoxOnPlaneSide: Bad signbits");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
|
@ -179,7 +166,7 @@ int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
|
|||
break;
|
||||
default:
|
||||
dist1 = dist2 = 0; // shut up compiler
|
||||
BOPS_Error ();
|
||||
Sys_Error ("BoxOnPlaneSide: Bad signbits");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,7 @@ static void NET_Ban_f (void)
|
|||
{
|
||||
char addrStr [32];
|
||||
char maskStr [32];
|
||||
void (*print_fn)(const char *fmt, ...)
|
||||
__fp_attribute__((__format__(__printf__,1,2)));
|
||||
void (*print_fn)(const char *fmt, ...) FUNCP_PRINTF(1,2);
|
||||
|
||||
if (cmd_source == src_command)
|
||||
{
|
||||
|
|
|
@ -130,7 +130,7 @@ extern int pr_xstatement;
|
|||
|
||||
extern unsigned short pr_crc;
|
||||
|
||||
void PR_RunError (const char *error, ...) __attribute__((__format__(__printf__,1,2), __noreturn__));
|
||||
FUNC_NORETURN void PR_RunError (const char *error, ...) FUNC_PRINTF(1,2);
|
||||
|
||||
void ED_PrintEdicts (void);
|
||||
void ED_PrintNum (int ent);
|
||||
|
|
|
@ -184,17 +184,46 @@ typedef int ssize_t;
|
|||
|
||||
/*==========================================================================*/
|
||||
|
||||
#if !defined(__GNUC__)
|
||||
#define __attribute__(x)
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
/* argument format attributes for function
|
||||
* pointers are supported for gcc >= 3.1
|
||||
*/
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0))
|
||||
#define __fp_attribute__ __attribute__
|
||||
#if defined(__GNUC__)
|
||||
#define FUNC_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
|
||||
#else
|
||||
#define __fp_attribute__(x)
|
||||
#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
|
||||
|
||||
/* function optimize attribute is added starting with gcc 4.4.0 */
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 3))
|
||||
#define FUNC_NO_OPTIMIZE __attribute__((__optimize__("0")))
|
||||
#else
|
||||
#define FUNC_NO_OPTIMIZE
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define FUNC_NORETURN __attribute__((__noreturn__))
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
#define FUNC_NORETURN __declspec(noreturn)
|
||||
#else
|
||||
#define FUNC_NORETURN
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#define FUNC_NOINLINE __attribute__((__noinline__))
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
#define FUNC_NOINLINE __declspec(noinline)
|
||||
#else
|
||||
#define FUNC_NOINLINE
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
#define FUNC_NOCLONE __attribute__((__noclone__))
|
||||
#else
|
||||
#define FUNC_NOCLONE
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__cplusplus)
|
||||
|
|
|
@ -303,11 +303,11 @@ void Host_InitCommands (void);
|
|||
void Host_Init (void);
|
||||
void Host_Shutdown(void);
|
||||
void Host_Callback_Notify (cvar_t *var); /* callback function for CVAR_NOTIFY */
|
||||
void Host_Error (const char *error, ...) __attribute__((__format__(__printf__,1,2), __noreturn__));
|
||||
void Host_EndGame (const char *message, ...) __attribute__((__format__(__printf__,1,2), __noreturn__));
|
||||
FUNC_NORETURN void Host_Error (const char *error, ...) FUNC_PRINTF(1,2);
|
||||
FUNC_NORETURN void Host_EndGame (const char *message, ...) FUNC_PRINTF(1,2);
|
||||
void Host_Frame (float time);
|
||||
void Host_Quit_f (void);
|
||||
void Host_ClientCommands (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||
void Host_ClientCommands (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void Host_ShutdownServer (qboolean crash);
|
||||
void Host_WriteConfiguration (void);
|
||||
|
||||
|
|
|
@ -211,8 +211,8 @@ void SV_AddUpdates (void);
|
|||
void SV_ClientThink (void);
|
||||
void SV_AddClientToServer (struct qsocket_s *ret);
|
||||
|
||||
void SV_ClientPrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||
void SV_BroadcastPrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||
void SV_ClientPrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void SV_BroadcastPrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
|
||||
void SV_Physics (void);
|
||||
|
||||
|
|
|
@ -45,14 +45,13 @@ void Sys_mkdir (const char *path);
|
|||
//
|
||||
// system IO
|
||||
//
|
||||
void Sys_Error (const char *error, ...) __attribute__((__format__(__printf__,1,2), __noreturn__));
|
||||
FUNC_NORETURN void Sys_Quit (void);
|
||||
FUNC_NORETURN void Sys_Error (const char *error, ...) FUNC_PRINTF(1,2);
|
||||
// an error will cause the entire program to exit
|
||||
|
||||
void Sys_Printf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||
void Sys_Printf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
// send text to the console
|
||||
|
||||
void Sys_Quit (void) __attribute__((__noreturn__));
|
||||
|
||||
double Sys_DoubleTime (void);
|
||||
|
||||
const char *Sys_ConsoleInput (void);
|
||||
|
|
Loading…
Reference in a new issue