tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Portable type definitions for tools
Hi all,
can you please review the attached patch for configure.ac and friends?
Not included is configure itself as it is 300KB by itself due to the
different version.
The patch does three things:
(a) It uses the normal autoconf macros to find or define if needed
the various fixed size types, [u]intmax_t and [u]intptr_t.
(b) It defines u_int{8,16,32,64}_t to uint{8,16,32,64}_t if the former
don't exist.
(c) Include strtoull, strtoimax and strtoumax if needed.
This should be more portable than the current logic as it will work if
the compiler supports at least the common ways of defining 8-64 bit
types.
Joerg
Index: Makefile
===================================================================
RCS file: /home/joerg/repo/netbsd/src/tools/compat/Makefile,v
retrieving revision 1.51
diff -u -p -r1.51 Makefile
--- Makefile 28 Sep 2007 09:12:49 -0000 1.51
+++ Makefile 10 Sep 2008 14:44:06 -0000
@@ -13,7 +13,8 @@ SRCS= atoll.c basename.c dirname.c fget
setpassent.c setprogname.c sha1.c sha1hl.c sha2.c \
sha256hl.c sha384hl.c sha512hl.c snprintf.c stat_flags.c \
strlcat.c strlcpy.c strmode.c strndup.c strsep.c strsuftoll.c \
- strtoll.c unvis.c vis.c err.c errx.c verr.c verrx.c \
+ strtoll.c strtoull.c strtoimax.c strtoumax.c \
+ unvis.c vis.c err.c errx.c verr.c verrx.c \
vwarn.c vwarnx.c warn.c warnx.c fts.c glob.c efun.c
BUILD_OSTYPE!= uname -s
@@ -27,6 +28,7 @@ CPPFLAGS+= -no-cpp-precomp
# other file ops, on many systems, without changing function names.
CPPFLAGS+= -I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \
+ -I${.CURDIR}/../../common/lib/libc/stdlib \
-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
.PATH: ${.CURDIR}/../../lib/libc/gen \
Index: compat_defs.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/tools/compat/compat_defs.h,v
retrieving revision 1.65
diff -u -p -r1.65 compat_defs.h
--- compat_defs.h 30 Oct 2007 20:23:35 -0000 1.65
+++ compat_defs.h 10 Sep 2008 14:32:42 -0000
@@ -439,6 +439,18 @@ long long strsuftollx(const char *, cons
long long strtoll(const char *, char **, int);
#endif
+#if !HAVE_STRTOULL
+unsigned long long strtoll(const char *, char **, int);
+#endif
+
+#if !HAVE_STRTOIMAX
+intmax_t strtoimax(const char *, char **, int);
+#endif
+
+#if !HAVE_STRTOUMAX
+uintmax_t strtoumax(const char *, char **, int);
+#endif
+
#if !HAVE_USER_FROM_UID
const char *user_from_uid(uid_t, int);
#endif
Index: configure.ac
===================================================================
RCS file: /home/joerg/repo/netbsd/src/tools/compat/configure.ac,v
retrieving revision 1.66
diff -u -p -r1.66 configure.ac
--- configure.ac 19 Oct 2007 15:56:54 -0000 1.66
+++ configure.ac 10 Sep 2008 14:31:33 -0000
@@ -100,28 +100,30 @@ AC_CHECK_TYPE(socklen_t, [AC_DEFINE([HAV
[#include <sys/types.h>
#include <sys/socket.h>])
-dnl XXX - This is UGLY. Need a better way to homogenize the bitsized types,
-dnl including use of compiler primitive types via AC_CHECK_SIZEOF.
-dnl
-define([NB_CHECK_INTTYPE], [
- AC_CHECK_TYPE(uint][$1][_t,, [
- AC_CHECK_TYPE(u_int][$1][_t,
- AC_DEFINE(uint][$1][_t, u_int][$1][_t, \
- [Define if you have u_int][$1][_t, but not
uint][$1][_t.]),
- AC_MSG_ERROR([cannot find a suitable type for
uint][$1][_t]))
- ])
+define([NB_CHECK_LEGACY_INTTYPE], [
AC_CHECK_TYPE(u_int][$1][_t,, [
- AC_CHECK_TYPE(uint][$1][_t,
- AC_DEFINE(u_int][$1][_t, uint][$1][_t, \
- [Define if you have uint][$1][_t, but not
u_int][$1][_t.]),
- AC_MSG_ERROR([cannot find a suitable type for
u_int][$1][_t]))
+ AC_DEFINE(u_int][$1][_t, uint][$1][_t, \
+ [Define u_int][$1][ in terms of uint][$1][_t.]),
])
])
-NB_CHECK_INTTYPE(8)
-NB_CHECK_INTTYPE(16)
-NB_CHECK_INTTYPE(32)
-NB_CHECK_INTTYPE(64)
+AC_TYPE_INT8_T
+AC_TYPE_UINT8_T
+AC_TYPE_INT16_T
+AC_TYPE_UINT16_T
+AC_TYPE_INT32_T
+AC_TYPE_UINT32_T
+AC_TYPE_INT64_T
+AC_TYPE_UINT64_T
+AC_TYPE_INTMAX_T
+AC_TYPE_UINTMAX_T
+AC_TYPE_INTPTR_T
+AC_TYPE_UINTPTR_T
+
+NB_CHECK_LEGACY_INTTYPE(8)
+NB_CHECK_LEGACY_INTTYPE(16)
+NB_CHECK_LEGACY_INTTYPE(32)
+NB_CHECK_LEGACY_INTTYPE(64)
# Struct members.
AC_CHECK_MEMBERS([DIR.dd_fd, DIR.__dd_fd, struct dirent.d_namlen],,,
@@ -150,7 +152,7 @@ AC_CHECK_FUNCS(atoll asprintf asnprintf
mkdtemp poll pread putc_unlocked pwcache_userdb pwcache_groupdb pwrite \
raise_default_signal random setenv \
setgroupent setprogname setpassent snprintf strlcat strlcpy strmode \
- strndup strsep strsuftoll strtoll \
+ strndup strsep strsuftoll strtoll strtoull strtoimax strtoumax \
user_from_uid uid_from_user vasprintf vasnprintf vsnprintf)
AC_CHECK_DECLS([user_from_uid, uid_from_user, pwcache_userdb],,,[
Index: nbtool_config.h.in
===================================================================
RCS file: /home/joerg/repo/netbsd/src/tools/compat/nbtool_config.h.in,v
retrieving revision 1.19
diff -u -p -r1.19 nbtool_config.h.in
--- nbtool_config.h.in 19 Oct 2007 15:56:54 -0000 1.19
+++ nbtool_config.h.in 10 Sep 2008 14:36:29 -0000
@@ -1,6 +1,6 @@
/* nbtool_config.h.in. Generated from configure.ac by autoheader. */
-/* $NetBSD: nbtool_config.h.in,v 1.19 2007/10/19 15:56:54 christos Exp $
*/
+/* $NetBSD: configure.ac,v 1.66 2007/10/19 15:56:54 christos Exp $ */
#ifndef __NETBSD_NBTOOL_CONFIG_H__
#define __NETBSD_NBTOOL_CONFIG_H__
@@ -284,6 +284,12 @@
/* Define to 1 if the system has the type `id_t'. */
#undef HAVE_ID_T
+/* Define to 1 if the system has the type `intmax_t'. */
+#undef HAVE_INTMAX_T
+
+/* Define to 1 if the system has the type `intptr_t'. */
+#undef HAVE_INTPTR_T
+
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@@ -320,6 +326,9 @@
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
+/* Define to 1 if the system has the type `long long int'. */
+#undef HAVE_LONG_LONG_INT
+
/* Define to 1 if you have the `lutimes' function. */
#undef HAVE_LUTIMES
@@ -443,9 +452,18 @@
/* Define to 1 if you have the `strsuftoll' function. */
#undef HAVE_STRSUFTOLL
+/* Define to 1 if you have the `strtoimax' function. */
+#undef HAVE_STRTOIMAX
+
/* Define to 1 if you have the `strtoll' function. */
#undef HAVE_STRTOLL
+/* Define to 1 if you have the `strtoull' function. */
+#undef HAVE_STRTOULL
+
+/* Define to 1 if you have the `strtoumax' function. */
+#undef HAVE_STRTOUMAX
+
/* Define to 1 if `d_namlen' is member of `struct dirent'. */
#undef HAVE_STRUCT_DIRENT_D_NAMLEN
@@ -532,9 +550,18 @@
/* Define to 1 if you have the `uid_from_user' function. */
#undef HAVE_UID_FROM_USER
+/* Define to 1 if the system has the type `uintmax_t'. */
+#undef HAVE_UINTMAX_T
+
+/* Define to 1 if the system has the type `uintptr_t'. */
+#undef HAVE_UINTPTR_T
+
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define to 1 if the system has the type `unsigned long long int'. */
+#undef HAVE_UNSIGNED_LONG_LONG_INT
+
/* Define to 1 if you have the `user_from_uid' function. */
#undef HAVE_USER_FROM_UID
@@ -594,9 +621,13 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Define to 1 if your processor stores words with the most significant byte
- first (like Motorola and SPARC, unlike Intel and VAX). */
-#undef WORDS_BIGENDIAN
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel and VAX). */
+#if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+#elif ! defined __LITTLE_ENDIAN__
+# undef WORDS_BIGENDIAN
+#endif
/* Define for NetBSD headers. */
#undef _POSIX_C_SOURCE
@@ -604,35 +635,86 @@
/* Define for NetBSD headers. */
#undef _POSIX_SOURCE
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+#undef _UINT32_T
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+#undef _UINT64_T
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+#undef _UINT8_T
+
/* Define for NetBSD headers. */
#undef _XOPEN_SOURCE
+/* Define to the type of a signed integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
+#undef int16_t
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+#undef int32_t
+
+/* Define to the type of a signed integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+#undef int64_t
+
+/* Define to the type of a signed integer type of width exactly 8 bits if such
+ a type exists and the standard includes do not define it. */
+#undef int8_t
+
+/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
+ not define. */
+#undef intmax_t
+
+/* Define to the type of a signed integer type wide enough to hold a pointer,
+ if such a type exists, and if the system does not define it. */
+#undef intptr_t
+
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
-/* Define if you have uint16_t, but not u_int16_t. */
+/* Define u_int16 in terms of uint16_t. */
#undef u_int16_t
-/* Define if you have uint32_t, but not u_int32_t. */
+/* Define u_int32 in terms of uint32_t. */
#undef u_int32_t
-/* Define if you have uint64_t, but not u_int64_t. */
+/* Define u_int64 in terms of uint64_t. */
#undef u_int64_t
-/* Define if you have uint8_t, but not u_int8_t. */
+/* Define u_int8 in terms of uint8_t. */
#undef u_int8_t
-/* Define if you have u_int16_t, but not uint16_t. */
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
#undef uint16_t
-/* Define if you have u_int32_t, but not uint32_t. */
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
#undef uint32_t
-/* Define if you have u_int64_t, but not uint64_t. */
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
#undef uint64_t
-/* Define if you have u_int8_t, but not uint8_t. */
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+ such a type exists and the standard includes do not define it. */
#undef uint8_t
+/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
+ do not define. */
+#undef uintmax_t
+
+/* Define to the type of an unsigned integer type wide enough to hold a
+ pointer, if such a type exists, and if the system does not define it. */
+#undef uintptr_t
+
#include "compat_defs.h"
#endif /* !__NETBSD_NBTOOL_CONFIG_H__ */
Home |
Main Index |
Thread Index |
Old Index