View Issue Details

IDProjectCategoryView StatusLast Update
0000554LDMud 3.3Portabilitypublic2008-07-18 15:30
Reporterzesstra Assigned Tozesstra  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Platformx86_64OSMacOS XOS Version10.5.x
Product Version3.3 
Fixed in Version3.3.717 
Summary0000554: port.h should use stdint.h, inttypes.h and stdbool.h if available
Descriptionstdint.h (required by C99) makes several interesting types available, among them intptr_t which is exactly what we need to p_int. If these headers are available on a system, port.h should use them and otherwise fall back to the current scheme for determining the correct types.
Additionally, port.h should define the system-dependent prefix for printing p_int (e.g. a long int needs 'l' as prefix: %ld), which is on some systems available from inttypes.h. This prefix can then be used in sprintf.c (s. 0000528)
TagsNo tags attached.

Relationships

related to 0000556 new Change code which assumes that p_int and mp_int are always a long. 
child of 0000528 resolvedzesstra sprintf() fails to print int values larger than 2^32 - 1 correctly 

Activities

zesstra

2008-07-13 14:17

administrator   ~0000726

I worked a little on port.h and autoconf this weekend and prepared a little patch.

Changes to autoconf:
* removed check for values.h from configure.in and not used HAVE_VALUES from port.h - obsoleted by limits+float.h (was TODO)
* removed self-written check for ANSI-C89 compliant compiler and used AC_PROG_CC_STDC.
* removed self-written checks for uint32_t, ssize_t, size_t, off_t, long long and added the corresponding autoconf macros
* removed obsolete AC_HEADER_STDC
* added checks for C99 datatypes: (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t, (u)inptr_t, (u)intmax_t.
* added size checks for intptr_t, intmax_t, long long
* added some checks for compiler charactestics: stringenize operator in preprocessor, typeof. (check for restrict due to problems with mk_func.c still disabled)
* added header check for stdbool.h
* changed obsolete AC_CONFIG_HEADER to AC_CONFIG_HEADERS

Changes to port.h
* fixed PHINT_MIN, PHINT_MAX and PHUINT_MAX in port.h. If SIZEOF_CHAR_P == 4 they were defined to SHORT_MAX, SHORT_MIN, USHORT_MAX, which should be SHRT_MIN, SHRT_MAX, USHRT_MAX.
* fixed selection of ph_int (short is not guaranteed to be 2 bytes)
* use inttypes.h and stdint.h if available.
* use stdbool.h and _Bool for our own Bool if available.
* removed own typedef for ssize_t as autoconf will provide is with a suitable ssize_t if the standard headers don't have one, which is anyway very unlikely.
* added PRI_PINT_PREFIX containing a length prefix used in sprintf.c for calling the system sprintf() and MAX_PRI_PINT_PREFIX_LENGTH for buffer allocation in sprintf.c

After the changes I found some inconsistent declarations (int/Bool), which I changed in SVN yesterday.

zesstra

2008-07-14 18:23

administrator   ~0000727

Tests on glibc based ILP32 platforms showed a problem with the patch from yesterday:
warning: format '%ld' expects type 'long int', but argument 3 has type 'p_i
nt'
The problem is, that on these systems intptr_t is typedef'ed to int instead of long, but the format specifier ist hard-coded. This version of the patch includes a hack which avoids to use intptr_t on systems where sizeof(int)==sizeof(char*) so that we don't use a intptr_t which may be typedef'ed to int. This hack has to be removed once bug 0000556 is resolved.

Additionally this introduces defines to the correct format specifiers for sprintf() & Co for p_(u)int, ph_(u)int and mp_(u)int which will be needed for resolving 0000556. (There might still some format specifiers missing.)

2008-07-14 18:23

 

port.diff (19,476 bytes)   
Index: src/port.h
===================================================================
--- src/port.h	(Revision 2387)
+++ src/port.h	(Arbeitskopie)
@@ -87,12 +87,7 @@
 #if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
 #    include <memory.h>
 #endif
-#if 0
-/* TODO: Obsoleted by limits.h+floats.h - remove this and the config check */
-#ifdef HAVE_VALUES_H
-#    include <values.h>
-#endif
-#endif
+
 #ifdef HAVE_STDLIB_H
 #    include <stdlib.h>
 #endif
@@ -121,36 +116,7 @@
 #    include <sys/param.h>
 #endif
 
-
 /*------------------------------------------------------------------
- * Limits for less-standard integral types:
- *
- *   LONGLONG_MIN, LONGLONG_MAX, ULONGLONG_MAX
- * TODO: Add SIZEOF_SIZET to configure, and SIZET_limits here.
- * TODO:: Then use SIZET_limits in smalloc::smalloc().
- */
-
-#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
-#    if defined(LONG_LONG_MAX)
-#        define LONGLONG_MIN   LONG_LONG_MIN
-#        define LONGLONG_MAX   LONG_LONG_MAX
-#        define ULONGLONG_MAX  ULONG_LONG_MAX
-#    elif SIZEOF_LONG_LONG == 8
-#        define LONGLONG_MIN   (-9223372036854775807LL - 1)
-#        define LONGLONG_MAX   (9223372036854775807LL)
-#        define ULONGLONG_MAX  (0xffffffffffffffffULL)
-#    elif SIZEOF_LONG_LONG == SIZEOF_LONG
-#        define LONGLONG_MIN   LONG_MIN
-#        define LONGLONG_MAX   LONG_MAX
-#        define ULONGLONG_MAX  ULONG_MAX
-#    elif SIZEOF_LONG_LONG == SIZEOF_INT
-#        define LONGLONG_MIN   INT_MIN
-#        define LONGLONG_MAX   INT_MAX
-#        define ULONGLONG_MAX  UINT_MAX
-#    endif
-#endif
-
-/*------------------------------------------------------------------
  * Define some macros:
  *   CHAR_BIT     number of bits in a char, if not defined already.
  *   TODO: Lookup what ISO-C says about this.
@@ -209,6 +175,8 @@
 
 #define VARPROT(proto,like,form,var) proto FORMATDEBUG(like,form,var)
 
+// TODO: autoconf defines inline to some suitable keyword if the compiler does
+// not understand inline itself. Just use inline in code?
 #if defined(HAS_INLINE) && !defined(NO_INLINES)
 #    define INLINE inline
      /* configure made sure that 'inline' expands to the proper attribute */
@@ -234,103 +202,257 @@
 #define MSDOS_FS
 #endif
 
+/*------------------------------------------------------------------
+ * Test for C99-compatible data types
+ * TODO: check if we can remove these checks once (if?) we require a C99
+ * compliant build environment.
+ */
+#if defined(HAVE_INTTYPES_H)
+    /* C99 compliant inttypes.h. */
+#   include <inttypes.h>
+#endif
+#if defined(HAVE_STDINT_H)
+    /* C99 compliant stdint.h available
+     * Usually it gets included also in inttypes.h, but it doesn't hurt to
+     * include it specifically. */
+#   include <stdint.h>
+#endif
 
+/* If stdint.h or inttypes.h don't have int8_t, int16_t, int32_t, int64_t,
+ * uint8_t, uint16_t, uint32_t, uint64_t, intmax_t, uintmax_t, intptr_t,
+ * or uintmax_t, autoconf will have them defined to a suitable type now.
+ * If Autoconf did not find suitable types, there is probably no sense in
+ * searching them ourself.
+ */
+#if !defined(HAVE_INTPTR_T) && !defined(intptr_t)
+    /* If there is no intptr_t in stdint.h and autoconf did not find a
+     * suitable type, we're out of luck (because in this case we are unlikely
+     * to find one). */
+#   error Cannot find an integer type with same size as a pointer
+    Thats it.
+#endif
+#if !defined(INT32_MAX) && !defined(int32_t)
+#   error Cannot find an integer type with exactly 32 bits.
+    Thats it.
+#endif
+
+/* If mode_t, off_t, pid_t, size_t or ssize_t are not defined by the standard
+ * headers on this system, autoconf will have them defined as well.
+ */
+
+
 /*------------------------------------------------------------------
+ * Limits for less-standard integral types:
+ *
+ *   LONGLONG_MIN, LONGLONG_MAX, ULONGLONG_MAX
+ * TODO: Add SIZEOF_SIZET to configure, and SIZET_limits here.
+ * TODO:: Then use SIZET_limits in smalloc::smalloc().
+ */
+#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
+#    if defined(LONG_LONG_MAX)
+#        define LONGLONG_MIN   LONG_LONG_MIN
+#        define LONGLONG_MAX   LONG_LONG_MAX
+#        define ULONGLONG_MAX  ULONG_LONG_MAX
+#    elif SIZEOF_LONG_LONG == 8
+#        define LONGLONG_MIN   (-9223372036854775807LL - 1)
+#        define LONGLONG_MAX   (9223372036854775807LL)
+#        define ULONGLONG_MAX  (0xffffffffffffffffULL)
+#    elif SIZEOF_LONG_LONG == SIZEOF_LONG
+#        define LONGLONG_MIN   LONG_MIN
+#        define LONGLONG_MAX   LONG_MAX
+#        define ULONGLONG_MAX  ULONG_MAX
+#    elif SIZEOF_LONG_LONG == SIZEOF_INT
+#        define LONGLONG_MIN   INT_MIN
+#        define LONGLONG_MAX   INT_MAX
+#        define ULONGLONG_MAX  UINT_MAX
+#    endif
+#endif
+
+/*------------------------------------------------------------------
  * Integral types:
- *   Bool, SBool, CBool: boolean type, sized as int/short/char.
+ *   Bool, SBool, CBool: boolean type, sized as _Bool or int, short, char.
  *   p_int  : an integer that has the same size as a pointer
  *   ph_int : an integer that has half the size of a pointer
  *   mp_int : an integer that has at least the size of a pointer
  *   int32  : an integer with 32 bits
  *   PTRTYPE: a type to use with constant pointer arithmetic.
  * The unsigned versions use 'uint' instead of 'int'.
+ * Additionally to the type themselves we define format specifiers for
+ * printing our types with sprintf() and scanning them with sscanf().
  * Changes here must be reflected in my-limits.h .
- * TODO: Add a type 'u/schar', '(u/s)int8' and '(u/s)int16'., unless not already
- * TODO:: defined by STDC.
- * TODO: inttypes.h, stdint.h, limits.h have many interesting types...
+ * Additional integral types from stdint.h/inttypes.h are available (s. above)
+ * TODO: check, if it is feasible to use the C99 data types instead of our own
+ * TODO::names in the future.
  */
 
 /* p_int : an integer that has the same size as a pointer */
-#define SIZEOF_PINT SIZEOF_CHAR_P
-
-#if SIZEOF_LONG == SIZEOF_CHAR_P
-     typedef long                p_int;
-     typedef unsigned long       p_uint;
-#    define PINT_MIN  LONG_MIN
-#    define PINT_MAX  LONG_MAX
-#    define PUINT_MAX ULONG_MAX
-
-#elif SIZEOF_INT == SIZEOF_CHAR_P
-     typedef int                 p_int;
-     typedef unsigned int        p_uint;
-#    define PINT_MIN  INT_MIN
-#    define PINT_MAX  INT_MAX
-#    define PUINT_MAX UINT_MAX
-
-#elif defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == SIZEOF_CHAR_P
-     typedef long long           p_int;
-     typedef unsigned long long  p_uint;
-#    define PINT_MIN  LONGLONG_MIN
-#    define PINT_MAX  LONGLONG_MAX
-#    define PUINT_MAX ULONGLONG_MAX
-
+#if defined(HAVE_INTPTR_T) && SIZEOF_INT != SIZEOF_CHAR_P
+    /* just use intptr_t 
+     * BUT! glibc on ILP32 platforms unfortunately defines intptr_t as int,
+     * not as long. While this doesn't change things in principle, because they
+     * have equal size, gcc will output a bunch of warnings on
+     * sprintf("%ld",p_int) because %ld is the wrong format specifier for int.
+     * Therefore this little hack, which uses intptr_t for the time being
+     * only if sizeof(int) != sizeof(char*) (because then intptr_t cannot be
+     * an int). As it is not guaranteed that p_int will alway be a long or
+     * have the size of a long, this %ld for outputting p_int are anyway a
+     * problem.
+     * TODO: As soon, as all the %ld for p_int are replaced, this hack should
+     * TODO::be removed!
+     */
+    typedef intptr_t                 p_int;
+    typedef uintptr_t                p_uint;
+#   define PINT_MIN  INTPTR_MIN
+#   define PINT_MAX  INTPTR_MAX
+#   define PUINT_MAX UINTPTR_MAX
+#   define SIZEOF_PINT SIZEOF_INTPTR_T
+#   define PRIdPINT  PRIdPTR
+#   define PRIuPINT  PRIuPTR
+#   define PRIxPINT  PRIxPTR
+#   ifdef __PRIPTR_PREFIX
+#       define PRI_PINT_PREFIX __PRIPTR_PREFIX
+#   else
+    /* ugly - it is a pity that the format specifiers are standardized but not
+     * the length modifier. But we need one for sprintf.c. *sigh* */
+#       if SIZEOF_INTPTR_T == SIZEOF_LONG
+#           define PRI_PINT_PREFIX "l"
+#       elif SIZEOF_INTPTR_T == SIZEOF_INT
+#           define PRI_PINT_PREFIX
+#       elif HAVE_LONG_LONG && SIZEOF_INTPTR_T == SIZEOF_LONG
+#           define PRI_PINT_PREFIX "ll"
+#       else
+#           error Could not find a length modifier for intptr_t.
+            Thats it.
+#       endif
+#   endif
 #else
-#error cannot find an integer type with same size as a pointer
-Thats it.
+  /* autoconf will have some type defined to intptr_t, but it won't define the
+   * limits and we won't have SIZEOF_INTPTR_T available. Therefore we have to
+   * search ourselves the old way. 
+   * TODO: remove once C99 support is required */
+#   define SIZEOF_PINT SIZEOF_CHAR_P
+#   if SIZEOF_LONG == SIZEOF_CHAR_P
+        typedef long                p_int;
+        typedef unsigned long       p_uint;
+#       define PINT_MIN  LONG_MIN
+#       define PINT_MAX  LONG_MAX
+#       define PUINT_MAX ULONG_MAX
+#       define PRI_PINT_PREFIX "l"
+#   elif SIZEOF_INT == SIZEOF_CHAR_P
+        typedef int                 p_int;
+        typedef unsigned int        p_uint;
+#       define PINT_MIN  INT_MIN
+#       define PINT_MAX  INT_MAX
+#       define PUINT_MAX UINT_MAX
+#       define PRI_PINT_PREFIX
+#   elif defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == SIZEOF_CHAR_P
+        typedef long long           p_int;
+        typedef unsigned long long  p_uint;
+#       define PINT_MIN  LONGLONG_MIN
+#       define PINT_MAX  LONGLONG_MAX
+#       define PUINT_MAX ULONGLONG_MAX
+#       define PRI_PINT_PREFIX "ll"
+#   else
+        /* nearly impossible (s. intptr_t check above, but better safe than
+         * sorry. */
+#       error cannot find an integer type with same size as a pointer
+        Thats it.
+#   endif
+#   define PRIdPINT  PRI_PINT_PREFIX "d"
+#   define PRIuPINT  PRI_PINT_PREFIX "u"
+#   define PRIxPINT  PRI_PINT_PREFIX "x"
+#endif // HAVE_INTPTR_T
+/* Maximum length PRI_PINT_PREFIX can be (given as strlen, without terminating
+ * 0). If it is longer, a buffer in sprintf.c will overflow. This will be
+ * checked in main() during driver startup. 
+ * TODO: allocate format string buffer in sprintf.c dynamically or use
+ * TODO::variable length arrays (C99) and remove this here.*/
+#ifdef PRI_PINT_PREFIX
+#define MAX_PRI_PINT_PREFIX_LENGTH 2
+#else
+#define MAX_PRI_PINT_PREFIX_LENGTH 0
 #endif
 
-/* ph_int : an integer that has half the size of a pointer */
+/* ph_int : an integer that has half the size of a pointer.
+ * Unfortuntately C99 has nothing like this and therefore we have to find our
+ * own.
+ */
 #if SIZEOF_CHAR_P == SIZEOF_INT * 2
      typedef int                 ph_int;
      typedef unsigned int        ph_uint;
 #    define PHINT_MIN  INT_MIN
 #    define PHINT_MAX  INT_MAX
 #    define PHUINT_MAX UINT_MAX
-
+#    define PRI_PHINT_PREFIX
+#elif SIZEOF_CHAR_P == SIZEOF_SHORT * 2
+     typedef short               ph_int;
+     typedef unsigned short      ph_uint;
+#    define PHINT_MIN  SHRT_MIN
+#    define PHINT_MAX  SHRT_MAX
+#    define PHUINT_MAX USHRT_MAX
+#    define PRI_PHINT_PREFIX "h"
+#elif SIZEOF_CHAR_P == SIZEOF_LONG * 2
+     typedef long                 ph_int;
+     typedef unsigned long        ph_uint;
+#    define PHINT_MIN  LONG_MIN
+#    define PHINT_MAX  LONG_MAX
+#    define PHUINT_MAX ULONG_MAX
+#    define PRI_PHINT_PREFIX "l"
 #else
-#    if SIZEOF_CHAR_P == 4
-/* short is assumed to be always 2 bytes. */
-/* TODO: This is a dangerous assumption. */
-         typedef short               ph_int;
-         typedef unsigned short      ph_uint;
-#        define PHINT_MIN  SHORT_MIN
-#        define PHINT_MAX  SHORT_MAX
-#        define PHUINT_MAX USHORT_MAX
-#    endif
+#    error Cannot find an integer of half the size of a pointer.
+     Thats it.
 #endif
+#define PRIdPHINT  PRI_PHINT_PREFIX "d"
+#define PRIuPHINT  PRI_PHINT_PREFIX "u"
+#define PRIxPHINT  PRI_PHINT_PREFIX "x"
 
-/* mp_int : an integer that has at least the size of a pointer */
+/* mp_int : an integer that has at least the size of a pointer 
+ TODO: maybe use intmax_t intstead? */
 typedef p_int        mp_int;
-typedef p_uint        mp_uint;
+typedef p_uint       mp_uint;
 #define MPINT_MIN  PINT_MIN
 #define MPINT_MAX  PINT_MAX
 #define MPUINT_MAX PUINT_MAX
+#define PRIdMPINT  PRIdPINT
+#define PRIuMPINT  PRIuPINT
+#define PRIxMPINT  PRIxPINT
 
 #ifndef __BEOS__
-/* int32 : an integer with 32 bits. */
-/* TODO: Add a configuration check for 'int32' typedef */
-#    if SIZEOF_LONG == 4
-#        if !defined(_AIX)
-typedef long                int32;
-#        endif
-typedef unsigned long       uint32;
-#    else
-#        if SIZEOF_INT == 4
-typedef int                 int32;
-typedef unsigned int        uint32;
-#        endif
-#    endif
+/* int32 : an integer with 32 bits.
+   TODO: just use (u)int32_t instead of (u)int32. */
+typedef int32_t   int32;
+typedef uint32_t  uint32;
 #endif /* __BEOS__ */
 
+
+/* type to use with constant pointer arithmetic. */
+#define PTRTYPE char *
+
+
 /* Boolean datatype and values */
-
-typedef int    Bool;  /* naming it 'bool' clashes on some machines... */
+#ifdef HAVE_STDBOOL_H
+#   include <stdbool.h>
+#else
+#   ifndef HAVE__BOOL
+        /* _Bool is not available - typedef our own with int. 
+         * naming it 'bool' clashes on some machines... */
+        typedef int    _Bool;
+#   endif
+    /* define true and false as stdbool.h does. */
+#   define false 0
+#   define true 1
+#   define __bool_true_false_are_defined 1
+#endif // HAVE_STDBOOL_H
+/* _Bool looks strange and we anyway used Bool until now. */
+typedef _Bool Bool;
+/* TODO: check if these two can be merged with Bool */
 typedef short SBool;
 typedef char  CBool;
 
-#define MY_TRUE  (1)
-#define MY_FALSE (0)
+#define MY_TRUE  (true)
+#define MY_FALSE (false)
 
+
 /* TODO: This should go into my-malloc.h? */
 #ifdef FREE_RETURNS_VOID
 #    define FREE_RETURN_TYPE void
@@ -340,17 +462,11 @@
 #    define FREE_RETURN return 1;
 #endif
 
-#define PTRTYPE char *
 
-
 /*------------------------------------------------------------------
  * Provide functions, types and defines missing from the system headers.
  */
 
-#ifndef HAVE_SSIZE_T
-typedef signed long ssize_t;
-#endif
-
 #ifndef HAVE_MEMCPY
 /* The following 'implementation' is suitable for throwing away a value,
    but not to using it; the cast to return int is likely to show a warning
Index: src/autoconf/configure.in
===================================================================
--- src/autoconf/configure.in	(Revision 2387)
+++ src/autoconf/configure.in	(Arbeitskopie)
@@ -528,24 +528,67 @@
 # Restore the CFLAGS
 CFLAGS=$save_cflags
 
-dnl check for ANSI-C  (for compiling LDMUD project)
-dnl TODO: check for 'c89' if CC="cc" and 'cc' not ANSI-C
-dnl
-AC_TRY_COMPILE([
-#ifndef __STDC__
-#error need STDC
-guarantee an compiling error here...
-#endif
-],,
-:,
-AC_MSG_ERROR(You need an ANSI-C compiler! sorry..)
-)
+# check for ANSI-C  (for compiling LDMUD project)
+AC_PROG_CC_STDC
+if test "${ac_cv_prog_cc_stdc}" = no; then
+  AC_MSG_ERROR(You need an ANSI-C89 or ISO-C (C99) compiler! sorry..)
+fi
 
 
-dnl Checking for programs
+# does the compile have an inline keyword?
+AC_C_INLINE
+if test "x$ac_cv_c_inline" != "xno"; then
+  AC_DEFINE(HAS_INLINE)
+fi
 
+# does the compile have an restrict keyword?
+# temporarily deactivated because it introduces an #if defined x into
+# machine.h and mkfunc.c can't deal with 'defined' without parentheses.
+#AC_C_RESTRICT
+
+# does the compile have an typeof keyword?
+AC_C_TYPEOF
+
+# does the preprocessor support the stringenizing operator?
+AC_C_STRINGIZE
+
+# check for some types
+AC_TYPE_INT8_T
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INTMAX_T
+AC_TYPE_INTPTR_T
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_UINTMAX_T
+AC_TYPE_UINTPTR_T
+AC_TYPE_LONG_LONG_INT
+AC_TYPE_UNSIGNED_LONG_LONG_INT
+AC_TYPE_LONG_DOUBLE
+AC_TYPE_LONG_DOUBLE_WIDER
+AC_TYPE_SSIZE_T
+AC_TYPE_SIZE_T
+AC_TYPE_OFF_T
+AC_TYPE_MODE_T
+AC_TYPE_PID_T
+AC_TYPE_SIGNAL
+
+# Check some sizes
+AC_CHECK_SIZEOF(char *)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+AC_CHECK_SIZEOF(intptr_t)
+AC_CHECK_SIZEOF(intmax_t)
+
+
+# Checking for programs
 AC_PROG_INSTALL
-AC_CONFIG_HEADER(machine.h)
+AC_CONFIG_HEADERS(machine.h)
 AC_CHECK_PROGS(YACC, byacc "bison -y", yacc)
 AC_PROG_CPP
 
@@ -568,19 +611,23 @@
 [ EXTRA_CFLAGS="${EXTRA_CFLAGS} -DMSWIN" ])
 
 dnl Checking for headers
+AC_HEADER_STDBOOL
+AC_CHECK_HEADERS(sys/rusage.h sys/time.h unistd.h stdlib.h libc.h memory.h)
+AC_CHECK_HEADERS(string.h bstring.h netdb.h crypt.h sys/param.h sys/termios.h)
 
-AC_HEADER_STDC
-AC_CHECK_HEADERS(sys/rusage.h sys/time.h unistd.h stdlib.h libc.h memory.h)
-AC_CHECK_HEADERS(values.h string.h bstring.h netdb.h crypt.h sys/param.h sys/termios.h)
 dnl extra check for <limits.h>; must be there!
 AC_CHECK_HEADERS(limits.h)
 AC_HEADER_DIRENT
 
-AC_CHECK_SIZEOF(char *)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(long)
 
+dnl check for some functions
+AC_FUNC_MKTIME
+AC_FUNC_ALLOCA
+AC_CHECK_FUNCS(fchmod getrusage bzero memset memcpy memmem strdup strcspn)
+AC_CHECK_FUNCS(strchr strrchr getcwd memmove sysconf gettimeofday wait3 waitpid)
+AC_CHECK_FUNCS(fcntl getdomainname poll strtoul trunc)
+
+
 AC_CACHE_CHECK(for needed malloc() alignment,lp_cv_sys_malloc_align,
 AC_TRY_COMPILE([struct ts {double d; char *p; double e;};
 int i = 96/(sizeof(struct ts)-20);
@@ -589,46 +636,7 @@
 lp_cv_sys_malloc_align=4))
 AC_DEFINE_UNQUOTED(MALLOC_ALIGN,$lp_cv_sys_malloc_align)
 
-AC_CACHE_CHECK(for uint32_t and friends,lp_cv_inttypes,
-AC_TRY_COMPILE([#include <sys/types.h>
-uint32_t i;],,
-lp_cv_inttypes=yes,
-lp_cv_inttypes=no))
-if test $lp_cv_inttypes = yes; then
-  AC_DEFINE(HAVE_INTTYPES)
-fi
 
-AC_CACHE_CHECK(for ssize_t,lp_cv_type_ssize_t,
-AC_TRY_COMPILE([#include <sys/types.h>
-ssize_t i;],,
-lp_cv_type_ssize_t=yes,
-lp_cv_type_ssize_t=no))
-if test $lp_cv_type_ssize_t = yes; then
-  AC_DEFINE(HAVE_SSIZE_T)
-fi
-
-AC_CHECK_SIZEOF(long long) dnl Also checks for the existance
-if test $ac_cv_type_long_long = yes; then
-  AC_DEFINE(HAVE_LONG_LONG)
-fi
-
-AC_CACHE_CHECK(for bool,lp_cv_type_bool,
-AC_TRY_COMPILE([bool b;],,
-lp_cv_type_bool=yes,
-lp_cv_type_bool=no))
-if test $lp_cv_type_bool = yes; then
-  AC_DEFINE(HAVE_BOOL)
-fi
-
-AC_C_INLINE
-if test "x$ac_cv_c_inline" != "xno"; then
-  AC_DEFINE(HAS_INLINE)
-fi
-
-AC_TYPE_SIZE_T
-AC_TYPE_PID_T
-AC_TYPE_SIGNAL
-
 if test "x$ac_cv_type_signal" = "xvoid"; then
   cat >> confdefs.h <<EOF
 #define RETSIGTYPE_VOID 1
@@ -694,13 +702,7 @@
 
 fi
 
-# --- Check for functions ---
 
-AC_FUNC_ALLOCA
-AC_CHECK_FUNCS(fchmod getrusage bzero memset memcpy memmem strdup strcspn)
-AC_CHECK_FUNCS(strchr strrchr getcwd memmove sysconf gettimeofday wait3 waitpid)
-AC_CHECK_FUNCS(fcntl getdomainname poll strtoul trunc)
-
 AC_CACHE_CHECK(if inet_ntoa() ok,lp_cv_func_inet_ntoa_ok,
 AC_TRY_RUN([
 #include <sys/types.h> /* needed for netinet/in.h */
@@ -2411,6 +2413,8 @@
 SAVE_CFLAGS="${CFLAGS}"
 CFLAGS=''
 for TESTFLAG in '' -static -Bstatic -n; do
+
+
 AC_MSG_CHECKING(malloc redefinition with linking flag ${TESTFLAG})
 LIBS="${SAVE_LIBS} ${TESTFLAG}"
 cat > conftest.data <<EOF
port.diff (19,476 bytes)   

zesstra

2008-07-17 15:04

administrator   ~0000747

Are there some more issues with the current version? (On platforms I have available, there are right now no problems, Im aware of.) I would like to use the printing format specifiers, the question is, if these changes are acceptable for now... If not, I would add only the the format specifiers to the current port.h for the time being.

zesstra

2008-07-18 15:30

administrator   ~0000749

I applied the latest patch and additionally the corresponding defines for the sscanf() format specifiers (which happen to be identical right now). This closes this for now.
Once we got rid of all the hard-coded sprintf("%ld",(m)p_int) we should remove the hack which prevents intptr_t being used on systems where sizeof(int)==sizeof(char*).
And at some point in the future we should decide if we start to require a C99 compliant build environment and get rid of quite a lot checks in port.h (e.g. in 3.5).

Issue History

Date Modified Username Field Change
2008-07-12 18:17 zesstra New Issue
2008-07-12 18:17 zesstra Status new => assigned
2008-07-12 18:17 zesstra Assigned To => zesstra
2008-07-12 18:17 zesstra Relationship added child of 0000528
2008-07-13 14:03 zesstra File Added: port.diff
2008-07-13 14:17 zesstra Note Added: 0000726
2008-07-14 16:16 zesstra Relationship added related to 0000556
2008-07-14 18:23 zesstra Note Added: 0000727
2008-07-14 18:23 zesstra File Deleted: port.diff
2008-07-14 18:23 zesstra File Added: port.diff
2008-07-17 15:04 zesstra Note Added: 0000747
2008-07-18 15:30 zesstra Status assigned => resolved
2008-07-18 15:30 zesstra Fixed in Version => 3.3.717
2008-07-18 15:30 zesstra Resolution open => fixed
2008-07-18 15:30 zesstra Note Added: 0000749