Mercurial > hg > xemacs-beta
changeset 1743:543769b89fed
[xemacs-hg @ 2003-10-14 05:02:57 by james]
New compiler.h contains compiler-specific defines. Use it everywhere.
author | james |
---|---|
date | Tue, 14 Oct 2003 05:03:13 +0000 |
parents | 7f92ee59c996 |
children | e4f996d69637 |
files | lib-src/ChangeLog lib-src/ellcc.c src/ChangeLog src/compiler.h src/dumper.h src/glyphs-eimage.c src/glyphs-gtk.c src/glyphs-msw.c src/glyphs-x.c src/gtk-xemacs.h src/libinterface.h src/lisp.h src/lrecord.h src/process.h src/s/windowsnt.h src/symeval.h src/sysdll.h src/syswindows.h src/text.h |
diffstat | 19 files changed, 319 insertions(+), 328 deletions(-) [+] |
line wrap: on
line diff
--- a/lib-src/ChangeLog Mon Oct 13 18:53:24 2003 +0000 +++ b/lib-src/ChangeLog Tue Oct 14 05:03:13 2003 +0000 @@ -1,3 +1,8 @@ +2003-10-13 Jerry James <james@xemacs.org> + + * ellcc.c: Remove attribute definitions, include new compiler.h + instead, and change existing uses to match new definitions. + 2003-09-26 Steve Youngs <youngs@xemacs.org> * XEmacs 21.5.16 "celeriac" is released.
--- a/lib-src/ellcc.c Mon Oct 13 18:53:24 2003 +0000 +++ b/lib-src/ellcc.c Tue Oct 14 05:03:13 2003 +0000 @@ -78,27 +78,7 @@ #include <emodules.h> #include <ellcc.h> /* Generated files must be included using <...> */ - -#ifndef ATTRIBUTE_MALLOC -# if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__==2 && __GNUC_MINOR__>=96)) -# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) -# else -# define ATTRIBUTE_MALLOC -# endif /* GCC version >= 2.96 */ -#endif /* ATTRIBUTE_MALLOC */ - -#ifdef __GNUC_ -# define ATTRIBUTE_FATAL __attribute__ ((noreturn, format (printf, 1, 2))) -#else -# define ATTRIBUTE_FATAL -#endif /* __GNUC__ */ - -#if defined(__GNUC__) && (__GNUC__ >= 2 || (__GNUC__==2 && __GNUC_MINOR__>=5)) -# define ATTRIBUTE_CONST __attribute__ ((const)) -#else -# define ATTRIBUTE_CONST -#endif - +#include "compiler.h" #ifndef HAVE_SHLIB int @@ -188,7 +168,7 @@ static void *xmalloc (size_t size) ATTRIBUTE_MALLOC; static void *xrealloc (void *ptr, size_t size) ATTRIBUTE_MALLOC; static char *xstrdup (char *) ATTRIBUTE_MALLOC; -static void fatal (char *, ...) ATTRIBUTE_FATAL; +static DECLARE_DOESNT_RETURN (fatal (char *, ...)) PRINTF_ARGS (1, 2); static char ** add_string (char **, char *); static char ** add_to_argv (char **, const char *); static char ** do_compile_mode (void); @@ -467,7 +447,7 @@ } /* Print error message and exit. */ -static void +static DOESNT_RETURN fatal (char *format, ...) { va_list ap;
--- a/src/ChangeLog Mon Oct 13 18:53:24 2003 +0000 +++ b/src/ChangeLog Tue Oct 14 05:03:13 2003 +0000 @@ -1,3 +1,25 @@ +2003-10-13 Jerry James <james@xemacs.org> + + * dumper.h: Use {BEGIN,END}_C_DECLS instead of explicit #ifdef. + * glyphs-eimage.c: Ditto. + * glyphs-gtk.c: Ditto. + * glyphs-msw.c: Ditto. + * glyphs-x.c: Ditto. + * gtk-xemacs.h: Ditto. + * libinterface.h: Ditto. + * lrecord.h: Ditto. + * process.h: Ditto. + * symeval.h: Ditto. + * sysdll.h: Ditto. + * syswindows.h: Ditto. + * text.h: Ditto. + * lisp.h: Ditto. Move basic compiler defines to compiler.h. + Remove redundant definitions. Add MALLOC attribute to xmalloc, + xcalloc, etc. Change attribute uses to match new compiler.h. + * compiler.h: New file containing basic compiler defines from lisp.h. + * s/windowsnt.h (DECLARE_DOESNT_RETURN): Remove definitions now in + compiler.h. + 2003-10-10 Jerry James <james@xemacs.org> * alloc.c (make_compiled_function): Fix C++ breakage introduced by
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/compiler.h Tue Oct 14 05:03:13 2003 +0000 @@ -0,0 +1,212 @@ +/* Compiler-specific definitions for XEmacs. + Copyright (C) 1998-1999, 2003 Free Software Foundation, Inc. + Copyright (C) 1994 Richard Mlynarik. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: not in FSF. */ + +/* Authorship: + + NOT_REACHED, DOESNT_RETURN, PRINTF_ARGS by Richard Mlynarik, c. 1994. + RETURN_SANS_WARNING by Martin buchholz, 1998 or 1999. + Many changes and improvements by Jerry James, 2003. + Split out of lisp.h, reorganized, and modernized. + {BEGIN,END}_C_DECLS, NEED_GCC, GCC_VERSION + ATTRIBUTE_MALLOC, ATTRIBUTE_CONST, ATTRIBUTE_PURE, UNUSED_ARG +*/ + +#ifndef INCLUDED_compiler_h +#define INCLUDED_compiler_h + +/* Define min() and max(). (Some compilers put them in strange places that + won't be referenced by include files used by XEmacs, such as 'macros.h' + under Solaris.) */ + +#ifndef min +#define min(a,b) (((a) <= (b)) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +/* Regular C complains about possible clobbering of local vars NOT declared + as volatile if there's a longjmp() in a function. C++ complains if such + vars ARE volatile; or more correctly, sans volatile no problem even when + you longjmp, avec volatile you get unfixable compile errors like + +/src/xemacs/lilfix/src/process-unix.c: In function `void + unix_send_process(Lisp_Object, lstream*)': +/src/xemacs/lilfix/src/process-unix.c:1577: no matching function for call to ` + Lisp_Object::Lisp_Object(volatile Lisp_Object&)' +/src/xemacs/lilfix/src/lisp-union.h:32: candidates are: + Lisp_Object::Lisp_Object(const Lisp_Object&) +*/ + +#ifdef __cplusplus +#define VOLATILE_IF_NOT_CPP +#else +#define VOLATILE_IF_NOT_CPP volatile +#endif + +/* Avoid indentation problems when XEmacs sees the curly braces */ +#ifndef BEGIN_C_DECLS +# ifdef __cplusplus +# define BEGIN_C_DECLS extern "C" { +# define END_C_DECLS } +# else +# define BEGIN_C_DECLS +# define END_C_DECLS +# endif +#endif + +/* Macro simplification for non-GNU compilers */ +#ifndef __GNUC__ +#define __GNUC__ 0 +#define __GNUC_MINOR__ 0 +#define __GNUC_PATCHLEVEL__ 0 +#endif /* __GNUC__ */ + +/* Simplify testing for specific GCC versions. This also works for non-GCC + compilers, where GCC_VERSION is zero. */ +#ifndef NEED_GCC +#define NEED_GCC(major,minor,patch) (major * 1000000 + minor * 1000 + patch) +#endif /* NEED_GCC */ +#ifndef GCC_VERSION +#define GCC_VERSION NEED_GCC (__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#endif /* GCC_VERSION */ + +/* GCC < 2.6.0 could only declare one attribute per function. In that case, + we define DOESNT_RETURN in preference to PRINTF_ARGS, which is only used + for checking args against the string spec. */ +#ifndef PRINTF_ARGS +# if (GCC_VERSION >= NEED_GCC (2, 6, 0)) +# define PRINTF_ARGS(string_index,first_to_check) \ + __attribute__ ((format (printf, string_index, first_to_check))) +# else +# define PRINTF_ARGS(string_index,first_to_check) +# endif /* GNUC */ +#endif + +#ifndef DOESNT_RETURN +# if (GCC_VERSION > NEED_GCC (0, 0, 0)) +# if (GCC_VERSION >= NEED_GCC (2, 5, 0)) +# if (GCC_VERSION < NEED_GCC (3, 0, 0)) + /* GCC 3.2 -O3 issues complaints in Fcommand_loop_1 about no return + statement if we have this definition */ +# define RETURN_NOT_REACHED(value) DO_NOTHING +# endif +# define DOESNT_RETURN void +# define DECLARE_DOESNT_RETURN(decl) void decl __attribute__ ((noreturn)) +# else /* GCC_VERSION < NEED_GCC (2, 5, 0) */ +# define DOESNT_RETURN void volatile +# define DECLARE_DOESNT_RETURN(decl) void volatile decl +# endif /* GCC_VERSION >= NEED_GCC (2, 5, 0) */ +# else /* not gcc */ +# define DOESNT_RETURN void +# define DECLARE_DOESNT_RETURN(decl) void decl +# endif /* GCC_VERSION > NEED_GCC (0, 0, 0) */ +#endif /* DOESNT_RETURN */ + +/* Another try to fix SunPro C compiler warnings */ +/* "end-of-loop code not reached" */ +/* "statement not reached */ +#if defined __SUNPRO_C || defined __USLC__ +#define RETURN_SANS_WARNINGS if (1) return +#define RETURN_NOT_REACHED(value) DO_NOTHING +#endif + +/* More ways to shut up compiler. This works in Fcommand_loop_1(), + where there's an infinite loop in a function returning a Lisp object. +*/ +#if defined (_MSC_VER) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || \ + (defined (DEC_ALPHA) && defined (OSF1)) +#define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS if (0) return Qnil +#else +#define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS DO_NOTHING +#endif + +#ifndef RETURN_NOT_REACHED +#define RETURN_NOT_REACHED(value) return (value) +#endif + +#ifndef RETURN_SANS_WARNINGS +#define RETURN_SANS_WARNINGS return +#endif + +#ifndef DO_NOTHING +#define DO_NOTHING do {} while (0) +#endif + +#ifndef DECLARE_NOTHING +#define DECLARE_NOTHING struct nosuchstruct +#endif + +#ifndef ATTRIBUTE_MALLOC +# if (GCC_VERSION >= NEED_GCC (2, 96, 0)) +# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define ATTRIBUTE_MALLOC +# endif /* GCC_VERSION >= NEED_GCC (2, 96, 0) */ +#endif /* ATTRIBUTE_MALLOC */ + +#ifndef ATTRIBUTE_PURE +# if (GCC_VERSION >= NEED_GCC (2, 96, 0)) +# define ATTRIBUTE_PURE __attribute__ ((pure)) +# else +# define ATTRIBUTE_PURE +# endif /* GCC_VERSION >= NEED_GCC (2, 96, 0) */ +#endif /* ATTRIBUTE_PURE */ + +#ifndef ATTRIBUTE_CONST +# if (GCC_VERSION >= NEED_GCC (2, 5, 0)) +# define ATTRIBUTE_CONST __attribute__ ((const)) +# define CONST_FUNC +# else +# define ATTRIBUTE_CONST +# define CONST_FUNC const +# endif /* GCC_VERSION >= NEED_GCC (2, 5, 0) */ +#endif /* ATTRIBUTE_CONST */ + +/* Unused declarations; g++ doesn't support this. */ +#ifndef UNUSED_ARG +# if defined(__GNUC__) && !defined(__cplusplus) +# define UNUSED_ARG __attribute__ ((unused)) +# else +# define UNUSED_ARG +# endif +#endif /* ATTRIBUTE_UNUSED */ + +#ifdef DEBUG_XEMACS +#define REGISTER +#define register +#else +#define REGISTER register +#endif + +#if defined(HAVE_MS_WINDOWS) && defined(HAVE_SHLIB) +# ifdef EMACS_MODULE +# define MODULE_API __declspec(dllimport) +# else +# define MODULE_API __declspec(dllexport) +# endif +#else +# define MODULE_API +#endif + +#endif /* INCLUDED_compiler_h */
--- a/src/dumper.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/dumper.h Tue Oct 14 05:03:13 2003 +0000 @@ -23,9 +23,7 @@ #ifndef INCLUDED_dumper_h #define INCLUDED_dumper_h -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS void pdump_objects_unmark (void); void pdump (void); @@ -34,8 +32,6 @@ extern unsigned int dump_id; extern char *pdump_start, *pdump_end; -#ifdef __cplusplus -} -#endif +END_C_DECLS #endif /* INCLUDED_dumper_h */
--- a/src/glyphs-eimage.c Mon Oct 13 18:53:24 2003 +0000 +++ b/src/glyphs-eimage.c Tue Oct 14 05:03:13 2003 +0000 @@ -61,15 +61,15 @@ #include "sysfile.h" #ifdef HAVE_PNG -#ifdef __cplusplus -extern "C" { -#endif + +BEGIN_C_DECLS + #define message message_ /* Yuck */ #include <png.h> #undef message -#ifdef __cplusplus -} -#endif + +END_C_DECLS + #else #include <setjmp.h> #endif @@ -102,14 +102,12 @@ * JPEG * **********************************************************************/ -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS + #include <jpeglib.h> #include <jerror.h> -#ifdef __cplusplus -} -#endif + +END_C_DECLS /*#define USE_TEMP_FILES_FOR_JPEG_IMAGES 1*/ static void
--- a/src/glyphs-gtk.c Mon Oct 13 18:53:24 2003 +0000 +++ b/src/glyphs-gtk.c Tue Oct 14 05:03:13 2003 +0000 @@ -1376,13 +1376,10 @@ /* We have to define SYSV32 so that compface.h includes string.h instead of strings.h. */ #define SYSV32 -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS #include <compface.h> -#ifdef __cplusplus -} -#endif +END_C_DECLS + /* JMP_BUF cannot be used here because if it doesn't get defined to jmp_buf we end up with a conflicting type error with the definition in compface.h */
--- a/src/glyphs-msw.c Mon Oct 13 18:53:24 2003 +0000 +++ b/src/glyphs-msw.c Tue Oct 14 05:03:13 2003 +0000 @@ -1615,13 +1615,10 @@ /* We have to define SYSV32 so that compface.h includes string.h instead of strings.h. */ #define SYSV32 -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS #include <compface.h> -#ifdef __cplusplus -} -#endif +END_C_DECLS + /* JMP_BUF cannot be used here because if it doesn't get defined to jmp_buf we end up with a conflicting type error with the definition in compface.h */
--- a/src/glyphs-x.c Mon Oct 13 18:53:24 2003 +0000 +++ b/src/glyphs-x.c Tue Oct 14 05:03:13 2003 +0000 @@ -1545,13 +1545,10 @@ /* We have to define SYSV32 so that compface.h includes string.h instead of strings.h. */ #define SYSV32 -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS #include <compface.h> -#ifdef __cplusplus -} -#endif +END_C_DECLS + /* JMP_BUF cannot be used here because if it doesn't get defined to jmp_buf we end up with a conflicting type error with the definition in compface.h */
--- a/src/gtk-xemacs.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/gtk-xemacs.h Tue Oct 14 05:03:13 2003 +0000 @@ -15,9 +15,7 @@ #include <gdk/gdk.h> #include <gtk/gtkfixed.h> -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +BEGIN_C_DECLS #define GTK_XEMACS(obj) GTK_CHECK_CAST (obj, gtk_xemacs_get_type (), GtkXEmacs) #define GTK_XEMACS_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_xemacs_get_type (), GtkXEmacsClass) @@ -41,8 +39,6 @@ guint gtk_xemacs_get_type (void); GtkWidget *gtk_xemacs_new (struct frame *f); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +END_C_DECLS #endif /* __GTK_XEMACS_H__ */
--- a/src/libinterface.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/libinterface.h Tue Oct 14 05:03:13 2003 +0000 @@ -28,9 +28,7 @@ #endif /* HAVE_GIF */ #ifdef HAVE_PNG -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS #define message message_ /* Yuck */ /* See comment in libinterface.c for the following */ #define PNG_EXPORT(type, symbol) type XCDECL symbol @@ -38,9 +36,7 @@ #define ZEXPORTVA XCDECL #include <png.h> #undef message -#ifdef __cplusplus -} -#endif +END_C_DECLS #endif /* HAVE_PNG */ /* #### WARNING: Utterly random magic here to prevent namespace conflicts @@ -49,9 +45,7 @@ glyphs-msw.c. For some reason, putting the XPM code after this fixes other problems; don't move it before. --ben */ #if defined (HAVE_JPEG) && !defined (DONT_NEED_JPEG) -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS #ifdef _MSC_VER # ifndef XMD_H /* Yuck! This tricks jpeglib.h into not defining INT32, which is defined @@ -65,9 +59,7 @@ # undef XMD_H #endif #include <jerror.h> -#ifdef __cplusplus -} -#endif +END_C_DECLS boolean XCDECL qxe_jpeg_finish_decompress (j_decompress_ptr cinfo); boolean XCDECL qxe_jpeg_start_decompress (j_decompress_ptr cinfo);
--- a/src/lisp.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/lisp.h Tue Oct 14 05:03:13 2003 +0000 @@ -45,6 +45,9 @@ Various macro-related changes by Martin Buchholz, 1998-1999: LIST_LOOP macros greatly expanded and tortoise-hared; RETURN_SANS_WARNINGS; reworked DEFUN macros; EXFUN macros (???). + Various macro-related changes by Jerry James, 2003: + MODULE_API introduced; + Compiler-specific definitions modernized and moved to compiler.h. */ #ifndef INCLUDED_lisp_h_ @@ -816,127 +819,7 @@ /* ------------------------ basic compiler defines ------------------- */ -/* Also define min() and max(). (Some compilers put them in strange - places that won't be referenced by the above include files, such - as 'macros.h' under Solaris.) */ - -#ifndef min -#define min(a,b) (((a) <= (b)) ? (a) : (b)) -#endif -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -/* Sim, senhor, prefiro toma-lo no cu. - - Regular C complains about possible clobbering of local vars NOT declared - as volatile if there's a longjmp() in a function. C++ complains if such - vars ARE volatile; or more correctly, sans volatile no problem even when - you longjmp, avec volatile you get unfixable compile errors like - -/src/xemacs/lilfix/src/process-unix.c: In function `void - unix_send_process(Lisp_Object, lstream*)': -/src/xemacs/lilfix/src/process-unix.c:1577: no matching function for call to ` - Lisp_Object::Lisp_Object(volatile Lisp_Object&)' -/src/xemacs/lilfix/src/lisp-union.h:32: candidates are: - Lisp_Object::Lisp_Object(const Lisp_Object&) -*/ - -#ifdef __cplusplus -#define VOLATILE_IF_NOT_CPP -#else -#define VOLATILE_IF_NOT_CPP volatile -#endif - -#ifndef PRINTF_ARGS -# if defined (__GNUC__) && (__GNUC__ >= 2) -# define PRINTF_ARGS(string_index,first_to_check) \ - __attribute__ ((format (printf, string_index, first_to_check))) -# else -# define PRINTF_ARGS(string_index,first_to_check) -# endif /* GNUC */ -#endif - -#ifndef DOESNT_RETURN -# if defined __GNUC__ -# if ((__GNUC__ > 2) || (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)) -# if __GNUC__ < 3 - /* GCC 3.2 -O3 issues complaints in Fcommand_loop_1 about no return - statement if we have this definition */ -# define RETURN_NOT_REACHED(value) DO_NOTHING -# endif -# define DOESNT_RETURN void -# define DECLARE_DOESNT_RETURN(decl) \ - extern void decl __attribute__ ((noreturn)) -# define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \ - /* Should be able to state multiple independent __attribute__s, but \ - the losing syntax doesn't work that way, and screws losing cpp */ \ - extern void decl \ - __attribute__ ((noreturn, format (printf, str, idx))) -# else -# define DOESNT_RETURN void volatile -# define DECLARE_DOESNT_RETURN(decl) extern void volatile decl -# define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \ - extern void volatile decl PRINTF_ARGS(str,idx) -# endif /* GNUC 2.5 */ -# else -# define DOESNT_RETURN void -# define DECLARE_DOESNT_RETURN(decl) extern void decl -# define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \ - extern void decl PRINTF_ARGS(str,idx) -# endif /* GNUC */ -#endif - -/* Another try to fix SunPro C compiler warnings */ -/* "end-of-loop code not reached" */ -/* "statement not reached */ -#if defined __SUNPRO_C || defined __USLC__ -#define RETURN_SANS_WARNINGS if (1) return -#define RETURN_NOT_REACHED(value) DO_NOTHING -#endif - -/* More ways to shut up compiler. This works in Fcommand_loop_1(), - where there's an infinite loop in a function returning a Lisp object. -*/ -#if defined (_MSC_VER) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || \ - (defined (DEC_ALPHA) && defined (OSF1)) -#define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS if (0) return Qnil -#else -#define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS DO_NOTHING -#endif - -#ifndef RETURN_NOT_REACHED -#define RETURN_NOT_REACHED(value) return (value) -#endif - -#ifndef RETURN_SANS_WARNINGS -#define RETURN_SANS_WARNINGS return -#endif - -#ifndef DO_NOTHING -#define DO_NOTHING do {} while (0) -#endif - -#ifndef DECLARE_NOTHING -#define DECLARE_NOTHING struct nosuchstruct -#endif - -/*#ifdef DEBUG_XEMACS*/ -#define REGISTER -#define register -/*#else*/ -/*#define REGISTER register*/ -/*#endif*/ - -#if defined(HAVE_MS_WINDOWS) && defined(HAVE_SHLIB) -# ifdef EMACS_MODULE -# define MODULE_API __declspec(dllimport) -# else -# define MODULE_API __declspec(dllexport) -# endif -#else -# define MODULE_API -#endif +#include "compiler.h" /* ------------------------ alignment definitions ------------------- */ @@ -1005,9 +888,7 @@ data of TYPE. */ #define ALIGN_PTR(ptr, type) ((void *) ALIGN_FOR_TYPE ((size_t) (ptr), type)) -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS /* ------------------------ assertions ------------------- */ @@ -1045,16 +926,6 @@ # endif #endif -/* #### - Why the hell do we do this??????????????????????????????? */ -/*#ifdef DEBUG_XEMACS*/ -#define REGISTER -#define register -/*#else*/ -/*#define REGISTER register*/ -/*#endif*/ - - /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit. In particular, it must be large enough to contain a pointer. config.h can override this, e.g. to use `long long' for bigger lisp ints. @@ -1067,30 +938,14 @@ # define SIZEOF_EMACS_INT SIZEOF_VOID_P #endif -#if 0 -#ifdef USE_ASSERTIONS -/* Highly dubious kludge */ -/* (thanks, Jamie, I feel better now -- ben) */ -void assert_failed (const char *, int, const char *); -# define abort() (assert_failed (__FILE__, __LINE__, "abort()")) -# define assert(x) ((x) ? 1 : (assert_failed (__FILE__, __LINE__, #x), 0)) -#else -# ifdef DEBUG_XEMACS -# define assert(x) ((x) ? 1 : ((void) abort (), 0)) -# else -# define assert(x) (1) -# endif -#endif -#endif /* 0 */ - /* ------------------------ simple memory allocation ------------------- */ /* Memory allocation */ void malloc_warning (const char *); -MODULE_API void *xmalloc (Bytecount size); -MODULE_API void *xmalloc_and_zero (Bytecount size); -MODULE_API void *xrealloc (void *, Bytecount size); -MODULE_API char *xstrdup (const char *); +MODULE_API void *xmalloc (Bytecount size) ATTRIBUTE_MALLOC; +MODULE_API void *xmalloc_and_zero (Bytecount size) ATTRIBUTE_MALLOC; +MODULE_API void *xrealloc (void *, Bytecount size) ATTRIBUTE_MALLOC; +MODULE_API char *xstrdup (const char *) ATTRIBUTE_MALLOC; /* generally useful */ #define countof(x) ((int) (sizeof(x)/sizeof((x)[0]))) #define xnew(type) ((type *) xmalloc (sizeof (type))) @@ -1102,7 +957,7 @@ #define alloca_new(type) ((type *) ALLOCA (sizeof (type))) #define alloca_array(type, len) ((type *) ALLOCA ((len) * sizeof (type))) -MODULE_API void *xemacs_c_alloca (unsigned int size); +MODULE_API void *xemacs_c_alloca (unsigned int size) ATTRIBUTE_MALLOC; MODULE_API int record_unwind_protect_freeing (void *ptr); @@ -1675,9 +1530,7 @@ /* OK, you can open them again */ -#ifdef __cplusplus -} -#endif +END_C_DECLS /************************************************************************/ /** Definitions of basic Lisp objects **/ @@ -1685,9 +1538,7 @@ #include "lrecord.h" -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS /*------------------------------ unbound -------------------------------*/ @@ -2838,9 +2689,7 @@ int finish_marking_weak_lists (void); void prune_weak_lists (void); -#ifdef __cplusplus -} -#endif +END_C_DECLS /************************************************************************/ /* Definitions related to the format of text and of characters */ @@ -2968,9 +2817,7 @@ #include "symeval.h" -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS /* `specpdl' is the special binding/unwind-protect stack. @@ -3156,9 +3003,7 @@ extern MODULE_API struct gcpro *gcprolist; -#ifdef __cplusplus -} -#endif +END_C_DECLS /* #### Catching insufficient gcpro: @@ -3226,9 +3071,7 @@ and so some "This function can GC" comments may be inaccurate. */ -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS #ifdef DEBUG_GCPRO @@ -3525,9 +3368,7 @@ int begin_gc_forbidden (void); void end_gc_forbidden (int count); -#ifdef __cplusplus -} -#endif +END_C_DECLS /************************************************************************/ @@ -3553,9 +3394,7 @@ /* Prototypes for all init/syms_of/vars_of initialization functions. */ #include "symsinit.h" -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS /* Defined in abbrev.c */ MODULE_API EXFUN (Fexpand_abbrev, 0); @@ -3920,10 +3759,8 @@ Error_Behavior); Lisp_Object maybe_signal_continuable_error_1 (Lisp_Object, Lisp_Object, Lisp_Object, Error_Behavior); -MODULE_API DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (signal_ferror - (Lisp_Object, - const CIbyte *, - ...), 2, 3); +MODULE_API DECLARE_DOESNT_RETURN (signal_ferror (Lisp_Object, const CIbyte *, + ...)) PRINTF_ARGS(2, 3); void maybe_signal_ferror (Lisp_Object, Lisp_Object, Error_Behavior, const CIbyte *, ...) PRINTF_ARGS (4, 5); Lisp_Object signal_continuable_ferror (Lisp_Object, const CIbyte *, ...) @@ -3943,10 +3780,9 @@ Lisp_Object maybe_signal_continuable_error (Lisp_Object, const CIbyte *, Lisp_Object, Lisp_Object, Error_Behavior); -DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (signal_ferror_with_frob - (Lisp_Object, Lisp_Object, - const CIbyte *, - ...), 3, 4); +DECLARE_DOESNT_RETURN (signal_ferror_with_frob (Lisp_Object, Lisp_Object, + const CIbyte *, ...)) + PRINTF_ARGS(3, 4); void maybe_signal_ferror_with_frob (Lisp_Object, Lisp_Object, Lisp_Object, Error_Behavior, const CIbyte *, ...) PRINTF_ARGS (5, 6); @@ -4028,10 +3864,9 @@ Lisp_Object frob)); DECLARE_DOESNT_RETURN (stack_overflow (const CIbyte *reason, Lisp_Object frob)); -MODULE_API -DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (printing_unreadable_object - (const CIbyte *, - ...), 1, 2); +MODULE_API DECLARE_DOESNT_RETURN (printing_unreadable_object (const CIbyte *, + ...)) + PRINTF_ARGS (1, 2); Lisp_Object signal_void_function_error (Lisp_Object); Lisp_Object signal_invalid_function_error (Lisp_Object); @@ -4600,8 +4435,7 @@ void stdout_out (const CIbyte *, ...) PRINTF_ARGS (1, 2); void external_out (int dest, const CIbyte *fmt, ...) PRINTF_ARGS (2, 3); void debug_out (const CIbyte *, ...) PRINTF_ARGS (1, 2); -DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (fatal (const CIbyte *, - ...), 1, 2); +DECLARE_DOESNT_RETURN (fatal (const CIbyte *, ...)) PRINTF_ARGS(1, 2); /* Internal functions: */ Lisp_Object canonicalize_printcharfun (Lisp_Object printcharfun); @@ -5300,8 +5134,6 @@ extern Lisp_Object Vthis_command_keys, Vunread_command_event; extern Lisp_Object Vx_initial_argv_list; -#ifdef __cplusplus -} -#endif +END_C_DECLS #endif /* INCLUDED_lisp_h_ */
--- a/src/lrecord.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/lrecord.h Tue Oct 14 05:03:13 2003 +0000 @@ -58,9 +58,7 @@ the opaque type. --ben */ -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS struct lrecord_header { @@ -1594,8 +1592,6 @@ #endif /* defined (USE_KKCC) || defined (PDUMP) */ -#ifdef __cplusplus -} -#endif +END_C_DECLS #endif /* INCLUDED_lrecord_h_ */
--- a/src/process.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/process.h Tue Oct 14 05:03:13 2003 +0000 @@ -36,9 +36,7 @@ #else /* not NO_SUBPROCESSES */ -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS /* struct Lisp_Process is defined in procimpl.h; only process-*.c need to know about the guts of it. */ @@ -122,9 +120,7 @@ const char *signal_name (int signum); Lisp_Object canonicalize_host_name (Lisp_Object host); -#ifdef __cplusplus -} -#endif +END_C_DECLS #endif /* not NO_SUBPROCESSES */
--- a/src/s/windowsnt.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/s/windowsnt.h Tue Oct 14 05:03:13 2003 +0000 @@ -242,12 +242,7 @@ /* MSVC 6.0 has a mechanism to declare functions which never return */ #if (_MSC_VER >= 1200) #define DOESNT_RETURN __declspec(noreturn) void -#define DECLARE_DOESNT_RETURN(decl) __declspec(noreturn) extern void decl -#define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \ - __declspec(noreturn) extern void __cdecl decl PRINTF_ARGS(str,idx) -#else -#define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \ - extern void __cdecl decl PRINTF_ARGS(str,idx) +#define DECLARE_DOESNT_RETURN(decl) __declspec(noreturn) extern void XCDECL decl #endif /* MSVC 6.0 */ /* MSVC warnings no-no crap. When adding one to this section,
--- a/src/symeval.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/symeval.h Tue Oct 14 05:03:13 2003 +0000 @@ -27,9 +27,7 @@ #ifndef INCLUDED_symeval_h_ #define INCLUDED_symeval_h_ -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS enum symbol_value_type { @@ -434,8 +432,6 @@ void flush_all_buffer_local_cache (void); -#ifdef __cplusplus -} -#endif +END_C_DECLS #endif /* INCLUDED_symeval_h_ */
--- a/src/sysdll.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/sysdll.h Tue Oct 14 05:03:13 2003 +0000 @@ -22,9 +22,7 @@ #ifndef INCLUDED_sysdll_h_ #define INCLUDED_sysdll_h_ -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS #if defined(WIN32_NATIVE) #define DLLEXPORT __declspec(dllexport) @@ -46,13 +44,11 @@ extern dll_var dll_variable(dll_handle, const CIbyte *); extern Lisp_Object dll_error(dll_handle); -#ifdef __cplusplus -} -#endif - /* More stand-ins ... */ #define Qdll_filename_encoding Qfile_name #define Qdll_function_name_encoding Qnative +END_C_DECLS + #endif /* INCLUDED_sysdll_h_ */
--- a/src/syswindows.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/syswindows.h Tue Oct 14 05:03:13 2003 +0000 @@ -70,18 +70,14 @@ # define _WIN32_IE 0x0400 # endif -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS /* Fucking GCC complains about "no previous prototype" for inline functions. DUH! See DECLARE_INLINE_HEADER. */ extern __inline void *GetCurrentFiber (void); extern __inline void *GetFiberData (void); -#ifdef __cplusplus -} -#endif +END_C_DECLS #endif @@ -851,16 +847,16 @@ /* ------------------------- Filename conversion ------------------------- */ #ifdef CYGWIN -#ifdef __cplusplus -extern "C" { -#endif + +BEGIN_C_DECLS + void cygwin_win32_to_posix_path_list (const char *, char *); int cygwin_win32_to_posix_path_list_buf_size (const char *); void cygwin_posix_to_win32_path_list (const char *, char *); int cygwin_posix_to_win32_path_list_buf_size (const char *); -#ifdef __cplusplus -} -#endif + +END_C_DECLS + #endif #define LOCAL_FILE_FORMAT_TO_TSTR(path, out) \
--- a/src/text.h Mon Oct 13 18:53:24 2003 +0000 +++ b/src/text.h Tue Oct 14 05:03:13 2003 +0000 @@ -45,9 +45,7 @@ char *strupr (char *); #endif -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS /* ---------------------------------------------------------------------- */ /* Super-basic character properties */ @@ -2455,9 +2453,7 @@ #define eilwr(ei) EI_CASECHANGE (ei, 1) #define eiupr(ei) EI_CASECHANGE (ei, 0) -#ifdef __cplusplus -} -#endif +END_C_DECLS /************************************************************************/ @@ -2698,9 +2694,7 @@ }; typedef enum dfc_conversion_type dfc_conversion_type; -#ifdef __cplusplus -extern "C" { -#endif +BEGIN_C_DECLS /* WARNING: These use a static buffer. This can lead to disaster if these functions are not used *very* carefully. Another reason to only use @@ -2909,9 +2903,7 @@ enum new_dfc_src_type type, Lisp_Object codesys); -#ifdef __cplusplus -} -#endif +END_C_DECLS /* Version of EXTERNAL_TO_C_STRING that *RETURNS* the translated string, still in alloca() space. Requires some trickiness to do this, but gets