Commit f620241d authored by Tom Lane's avatar Tom Lane

Remove overly presumptuous use of __STDC__ in c.h, replacing

it with configure-script tests to see whether const, inline, volatile, etc
work or not.  (Curiously, configure was already doing the work to see if
const and inline were OK, but the results were not getting plugged into
config.h :-(.)
parent 0b874f01
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -583,8 +583,9 @@ dnl ...@@ -583,8 +583,9 @@ dnl
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST AC_C_CONST
AC_TYPE_UID_T
AC_C_INLINE AC_C_INLINE
AC_C_STRINGIZE
AC_TYPE_UID_T
AC_TYPE_MODE_T AC_TYPE_MODE_T
AC_TYPE_OFF_T AC_TYPE_OFF_T
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
...@@ -592,6 +593,18 @@ AC_HEADER_TIME ...@@ -592,6 +593,18 @@ AC_HEADER_TIME
AC_STRUCT_TM AC_STRUCT_TM
AC_STRUCT_TIMEZONE AC_STRUCT_TIMEZONE
AC_MSG_CHECKING(for signed types)
AC_TRY_COMPILE([],
[signed char c; signed short s; signed int i;],
[AC_MSG_RESULT(yes)],
[AC_DEFINE(signed, ) AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for volatile)
AC_TRY_COMPILE([],
[extern volatile int i;],
[AC_MSG_RESULT(yes)],
[AC_DEFINE(volatile, ) AC_MSG_RESULT(no)])
AC_MSG_CHECKING(for type of last arg to accept) AC_MSG_CHECKING(for type of last arg to accept)
AC_TRY_COMPILE([#include <stdlib.h> AC_TRY_COMPILE([#include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: c.h,v 1.53 1999/03/30 01:37:28 momjian Exp $ * $Id: c.h,v 1.54 1999/04/02 05:10:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -19,11 +19,10 @@ ...@@ -19,11 +19,10 @@
* *
* section description * section description
* ------- ------------------------------------------------ * ------- ------------------------------------------------
* 1) bool, true, false, TRUE, FALSE * 1) bool, true, false, TRUE, FALSE, NULL
* 2) __STDC__, non-ansi C definitions: * 2) non-ansi C definitions:
* Pointer typedef, NULL
* cpp magic macros
* type prefixes: const, signed, volatile, inline * type prefixes: const, signed, volatile, inline
* cpp magic macros
* 3) standard system types * 3) standard system types
* 4) datum type * 4) datum type
* 5) IsValid macros for system types * 5) IsValid macros for system types
...@@ -58,7 +57,7 @@ ...@@ -58,7 +57,7 @@
#endif #endif
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* Section 1: bool, true, false, TRUE, FALSE * Section 1: bool, true, false, TRUE, FALSE, NULL
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
/* /*
...@@ -66,13 +65,13 @@ ...@@ -66,13 +65,13 @@
* Boolean value, either true or false. * Boolean value, either true or false.
* *
*/ */
#define false ((char) 0)
#define true ((char) 1)
#ifndef __cplusplus #ifndef __cplusplus
#ifndef bool #ifndef bool
typedef char bool; typedef char bool;
#endif /* ndef bool */ #endif /* ndef bool */
#endif /* not C++ */ #endif /* not C++ */
#define false ((bool) 0)
#define true ((bool) 1)
typedef bool *BoolPtr; typedef bool *BoolPtr;
#ifndef TRUE #ifndef TRUE
...@@ -83,99 +82,43 @@ typedef bool *BoolPtr; ...@@ -83,99 +82,43 @@ typedef bool *BoolPtr;
#define FALSE 0 #define FALSE 0
#endif /* FALSE */ #endif /* FALSE */
/* ----------------------------------------------------------------
* Section 2: __STDC__, non-ansi C definitions:
*
* cpp magic macros
* Pointer typedef, NULL
* type prefixes: const, signed, volatile, inline
* ----------------------------------------------------------------
*/
#ifdef __STDC__ /* ANSI C */
/*
* Pointer
* Variable holding address of any memory resident object.
*/
/*
* XXX Pointer arithmetic is done with this, so it can't be void *
* under "true" ANSI compilers.
*/
typedef char *Pointer;
#ifndef NULL
/* /*
* NULL * NULL
* Null pointer. * Null pointer.
*/ */
#define NULL ((void *) 0)
#endif /* !defined(NULL) */
#define HAVE_ANSI_CPP /* all ANSI C compilers must have this! */
#if defined(NEED_STD_HDRS)
#undef NEED_STD_HDRS /* all ANSI systems must have
* stddef/stdlib */
#endif /* NEED_STD_HDRS */
#else /* !defined(__STDC__) *//* NOT ANSI C */
/*
* Pointer
* Variable containing address of any memory resident object.
*/
typedef char *Pointer;
#ifndef NULL #ifndef NULL
/* #define NULL ((void *) 0)
* NULL
* Null pointer.
*/
#define NULL 0
#endif /* !defined(NULL) */ #endif /* !defined(NULL) */
/* /* ----------------------------------------------------------------
* const * Section 2: non-ansi C definitions:
* Type modifier. Identifies read only variables.
* *
* Example: * type prefixes: const, signed, volatile, inline
* extern const Version RomVersion; * cpp magic macros
*/ * ----------------------------------------------------------------
#ifndef WIN32
#define const /* const */
#endif
/*
* signed
* Type modifier. Identifies signed integral types.
*/ */
#define signed /* signed */
/* /*
* volatile * We used to define const, signed, volatile, and inline as empty
* Type modifier. Identifies variables which may change in ways not * if __STDC__ wasn't defined. Now we let configure test whether
* noticeable by the compiler, e.g. via asynchronous interrupts. * those keywords work; config.h defines them as empty if not.
*
* Example:
* extern volatile unsigned int NumberOfInterrupts;
*/ */
#define volatile /* volatile */
#endif /* !defined(__STDC__) */ /* NOT ANSI C */
/* /*
* CppAsString * CppAsString
* Convert the argument to a string, using the C preprocessor. * Convert the argument to a string, using the C preprocessor.
* CppConcat * CppConcat
* Concatenate two arguments together, using the C preprocessor. * Concatenate two arguments together, using the C preprocessor.
*
* Note: the standard Autoconf macro AC_C_STRINGIZE actually only checks
* whether #identifier works, but if we have that we likely have ## too.
*/ */
#if defined(HAVE_ANSI_CPP) #if defined(HAVE_STRINGIZE)
#define CppAsString(identifier) #identifier #define CppAsString(identifier) #identifier
#define CppConcat(x, y) x##y #define CppConcat(x, y) x##y
#else /* !HAVE_ANSI_CPP */ #else /* !HAVE_STRINGIZE */
#define CppAsString(identifier) "identifier" #define CppAsString(identifier) "identifier"
...@@ -190,39 +133,32 @@ typedef char *Pointer; ...@@ -190,39 +133,32 @@ typedef char *Pointer;
#define _priv_CppIdentity(x)x #define _priv_CppIdentity(x)x
#define CppConcat(x, y) _priv_CppIdentity(x)y #define CppConcat(x, y) _priv_CppIdentity(x)y
#endif /* !HAVE_ANSI_CPP */ #endif /* !HAVE_STRINGIZE */
#ifndef __GNUC__ /* GNU cc */
#endif
#ifndef __GNUC__ /* GNU cc */
#define inline
/* /*
* dummyret is used to set return values in macros that use ?: to make * dummyret is used to set return values in macros that use ?: to make
* assignments. gcc wants these to be void, other compilers like char * assignments. gcc wants these to be void, other compilers like char
*/ */
#define dummyret char #ifdef __GNUC__ /* GNU cc */
#else
#define dummyret void #define dummyret void
#else
#define dummyret char
#endif #endif
#if defined(NEED_STD_HDRS)
/*
* You're doomed. We've removed almost all of our own C library
* extern declarations because they conflict on the different
* systems. You'll have to write your own stdlib.h.
*/
#include "stdlib.h"
#else /* NEED_STD_HDRS */
#include <stddef.h>
#include <stdlib.h>
#endif /* NEED_STD_HDRS */
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* Section 3: standard system types * Section 3: standard system types
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
/*
* Pointer
* Variable holding address of any memory resident object.
*
* XXX Pointer arithmetic is done with this, so it can't be void *
* under "true" ANSI compilers.
*/
typedef char *Pointer;
/* /*
* intN * intN
* Signed integer, EXACTLY N BITS IN SIZE, * Signed integer, EXACTLY N BITS IN SIZE,
......
...@@ -302,6 +302,21 @@ extern void srandom(unsigned int seed); ...@@ -302,6 +302,21 @@ extern void srandom(unsigned int seed);
#undef ALIGNOF_DOUBLE #undef ALIGNOF_DOUBLE
#undef MAXIMUM_ALIGNOF #undef MAXIMUM_ALIGNOF
/* Define const as empty if your compiler doesn't grok const. */
#undef const
/* Define as your compiler's spelling of "inline", or empty if no inline. */
#undef inline
/* Define signed as empty if your compiler doesn't grok "signed char" etc */
#undef signed
/* Define volatile as empty if your compiler doesn't grok volatile. */
#undef volatile
/* Define if your cpp understands the ANSI stringizing operators in macros */
#undef HAVE_STRINGIZE
/* Define as the base type of the last arg to accept */ /* Define as the base type of the last arg to accept */
#undef SOCKET_SIZE_TYPE #undef SOCKET_SIZE_TYPE
......
#define USE_POSIX_TIME #define USE_POSIX_TIME
#define CLASS_CONFLICT #define CLASS_CONFLICT
#define DISABLE_XOPEN_NLS #define DISABLE_XOPEN_NLS
#define HAVE_ANSI_CPP
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
typedef unsigned int slock_t; typedef unsigned int slock_t;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment