From 2a66234b147b78017e256d33f5b0389849129f5d Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 29 Jun 2006 05:03:15 +0000 Subject: [PATCH] header reorg (trunk only) Move the new VOID_ARGS and some other argument manipulation stuff from global.h to tradstdc.h where it feels like a better fit. Make the definition of VOID_ARGS more general; it should work nearly everwhere these days even if it is only needed for one configuration. XXXconf.h can redefine it as empty if necessary. For MONST_P and OBJ_P, I left "void*" as is but I'm pretty sure that the lack of space in between the two components was never part of the issue there. (The Ultrix system I used to have access to is long gone. It was chugging along on autopilot, effectively defenseless, at the time a linux box on the same subnet got hacked. It probably would have been shut down for Y2K anyway if it had lasted til then.) --- include/global.h | 56 +------------------------------------ include/tradstdc.h | 69 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 61 insertions(+), 64 deletions(-) diff --git a/include/global.h b/include/global.h index f7a686d49..5a0d755a5 100644 --- a/include/global.h +++ b/include/global.h @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)global.h 3.5 2003/12/13 */ +/* SCCS Id: @(#)global.h 3.5 2006/06/28 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -84,60 +84,6 @@ typedef xchar boolean; /* 0 or 1 */ #define Bitfield(x,n) uchar x #endif -#ifdef UNWIDENED_PROTOTYPES -# define CHAR_P char -# define SCHAR_P schar -# define UCHAR_P uchar -# define XCHAR_P xchar -# define SHORT_P short -#ifndef SKIP_BOOLEAN -# define BOOLEAN_P boolean -#endif -# define ALIGNTYP_P aligntyp -#else -# ifdef WIDENED_PROTOTYPES -# define CHAR_P int -# define SCHAR_P int -# define UCHAR_P int -# define XCHAR_P int -# define SHORT_P int -# define BOOLEAN_P int -# define ALIGNTYP_P int -# endif -#endif -#if defined(ULTRIX_PROTO) && !defined(__STDC__) -/* The ultrix 2.0 and 2.1 compilers (on Ultrix 4.0 and 4.2 respectively) can't - * handle "struct obj *" constructs in prototypes. Their bugs are different, - * but both seem to work if we put "void*" in the prototype instead. This - * gives us minimal prototype checking but avoids the compiler bugs. - * - * OBJ_P and MONST_P should _only_ be used for declaring function pointers. - */ -#define OBJ_P void* -#define MONST_P void* -#else -#define OBJ_P struct obj* -#define MONST_P struct monst* -#endif - -#if defined(WIN32) && defined(_MSC_VER) -/* Microsoft Visual C 2005 (_MSC_VER > 1000) complains if a - * function pointer prototype is - * int x(void); - * via the NDECL macro, but the actual function assigned has a definition - * int x() - * { - * } - * We can quiet this by changing the function definition like so - * int x(VOID_ARGS) - * { - * } - */ -#define VOID_ARGS void -#else -#define VOID_ARGS -#endif - #define SIZE(x) (int)(sizeof(x) / sizeof(x[0])) diff --git a/include/tradstdc.h b/include/tradstdc.h index 66d377d8c..90decdb0d 100644 --- a/include/tradstdc.h +++ b/include/tradstdc.h @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)tradstdc.h 3.5 1993/05/30 */ +/* SCCS Id: @(#)tradstdc.h 3.5 2006/06/28 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -27,14 +27,12 @@ /* Ultrix seems to be in a constant state of flux. This check attempts to * set up ansi compatibility if it wasn't set up correctly by the compiler. */ -#ifdef mips -#define __mips mips -#endif - -#ifdef LANGUAGE_C -#define __LANGUAGE_C LANGUAGE_C -#endif - +# ifdef mips +# define __mips mips +# endif +# ifdef LANGUAGE_C +# define __LANGUAGE_C LANGUAGE_C +# endif #endif /* @@ -129,6 +127,13 @@ # define VDECL(f,p) f() # endif +/* + * Used for definitions of functions which take no arguments to force + * an explicit match with the NDECL prototype. Needed in some cases + * (MS Visual C 2005) for functions called through pointers. + */ +#define VOID_ARGS void + /* generic pointer, always a macro; genericptr_t is usually a typedef */ # define genericptr void * @@ -167,6 +172,8 @@ # define FDECL(f,p) f() # define VDECL(f,p) f() +#define VOID_ARGS /*empty*/ + # if defined(AMIGA) || defined(HPUX) || defined(POSIX_TYPES) || defined(__DECC) || defined(__BORLANDC__) # define genericptr void * # endif @@ -226,6 +233,48 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ # endif #endif +/* These are used for arguments within FDECL/VDECL prototype declarations. + */ +#ifdef UNWIDENED_PROTOTYPES +# define CHAR_P char +# define SCHAR_P schar +# define UCHAR_P uchar +# define XCHAR_P xchar +# define SHORT_P short +# ifndef SKIP_BOOLEAN +# define BOOLEAN_P boolean +# endif +# define ALIGNTYP_P aligntyp +#else +# ifdef WIDENED_PROTOTYPES +# define CHAR_P int +# define SCHAR_P int +# define UCHAR_P int +# define XCHAR_P int +# define SHORT_P int +# define BOOLEAN_P int +# define ALIGNTYP_P int +# else + /* Neither widened nor unwidened prototypes. Argument list expansion + * by FDECL/VDECL always empty; all xxx_P vanish so defs aren't needed. */ +# endif +#endif + +/* OBJ_P and MONST_P should _only_ be used for declaring function pointers. + */ +#if defined(ULTRIX_PROTO) && !defined(__STDC__) +/* The ultrix 2.0 and 2.1 compilers (on Ultrix 4.0 and 4.2 respectively) can't + * handle "struct obj *" constructs in prototypes. Their bugs are different, + * but both seem to work if we put "void*" in the prototype instead. This + * gives us minimal prototype checking but avoids the compiler bugs. + */ +# define OBJ_P void* +# define MONST_P void* +#else +# define OBJ_P struct obj * +# define MONST_P struct monst * +#endif + #if 0 /* The problem below is still the case through 4.0.5F, but the suggested * compiler flags in the Makefiles suppress the nasty messages, so we don't @@ -246,6 +295,8 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ # define NDECL(f) f() # define FDECL(f,p) f() # define VDECL(f,p) f() +# undef VOID_ARGS +# define VOID_ARGS /*empty*/ #endif #endif -- 2.40.0