krb5 commit: Assume <stdint.h> and fixed-width types

Greg Hudson ghudson at MIT.EDU
Wed Feb 26 16:32:27 EST 2014


https://github.com/krb5/krb5/commit/17e205070745e4712d40eed32d92d02edb47009f
commit 17e205070745e4712d40eed32d92d02edb47009f
Author: Greg Hudson <ghudson at mit.edu>
Date:   Sat Feb 1 15:20:08 2014 -0500

    Assume <stdint.h> and fixed-width types
    
    Make unconditional use of <stdint.h> and fixed-width types such as
    uint32_t.  k5-plugin.h doesn't use any special integer types, so
    remove the conditional include block there.  Nothing uses
    INT64_FMT/UINT64_FMT, so leave those out of k5-platform.h for now.

 src/configure.in                            |   57 ---------------------------
 src/include/gssrpc/types.hin                |   44 +--------------------
 src/include/k5-platform.h                   |   39 +-----------------
 src/include/k5-plugin.h                     |    6 ---
 src/include/krb5/krb5.hin                   |   30 +++-----------
 src/lib/gssapi/generic/Makefile.in          |    6 ---
 src/lib/gssapi/krb5/Makefile.in             |   16 +-------
 src/lib/gssapi/krb5/gssapi_krb5.hin         |   10 +----
 src/plugins/kdb/db2/libdb2/include/db-int.h |    6 ---
 src/util/profile/prof_init.c                |    6 ---
 src/util/t_array.pm                         |    4 +-
 11 files changed, 15 insertions(+), 209 deletions(-)

diff --git a/src/configure.in b/src/configure.in
index 7dded28..9bc4663 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -755,16 +755,6 @@ AH_BOTTOM([
 #endif /* KRB5_AUTOCONF_H */
 ])
 
-# Not used yet, but let's find out what we've got on the platforms
-# we're working with....
-AC_CHECK_HEADERS(inttypes.h stdint.h)
-AC_CHECK_TYPES([uint32_t, int32_t, uint64_t, int64_t, uint_least32_t, uintptr_t, uintmax_t, long long], , , [
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#elif defined(HAVE_INTTYPES_H)
-# include <inttypes.h>
-#endif
-])
 AC_CHECK_TYPES([struct cmsghdr, struct in_pktinfo, struct in6_pktinfo, struct sockaddr_storage], , , [
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -872,14 +862,6 @@ AC_CHECK_PROG(RUNTEST,runtest,runtest)
 AC_CHECK_PROG(PERL,perl,perl)
 
 # lib/gssapi
-AC_CHECK_HEADER(stdint.h,[
-	include_stdint='awk '\''END{printf("%cinclude <stdint.h>\n", 35);}'\'' < /dev/null'],
-	include_stdint='echo "/* no stdint.h */"')
-AC_SUBST(include_stdint)
-AC_CHECK_HEADER(inttypes.h,[
-	include_inttypes='awk '\''END{printf("%cinclude <inttypes.h>\n", 35);}'\'' < /dev/null'],
-	include_inttypes='echo "/* no inttypes.h */"')
-AC_SUBST(include_inttypes)
 AC_CHECK_HEADER(xom.h,[
 	include_xom='awk '\''END{printf("%cinclude <xom.h>\n", 35);}'\'' < /dev/null'], [
 	include_xom='echo "/* no xom.h */"'])
@@ -965,45 +947,6 @@ fi
 AC_SUBST(GSSRPC__SYS_PARAM_H)
 AC_SUBST(GSSRPC__NETDB_H)
 
-AC_CACHE_CHECK([for uint32_t in sys/types.h],
-  [krb5_cv_header_sys_types_h_uint32_t],
-  [AC_TRY_COMPILE([#include <sys/types.h>],
-      [uint32_t i = 0;],
-      [krb5_cv_header_sys_types_h_uint32_t=yes],
-      [krb5_cv_header_sys_types_h_uint32_t=no])])
-AC_CACHE_CHECK([for uint32_t in stdint.h],
-  [krb5_cv_header_stdint_h_uint32_t],
-  [AC_TRY_COMPILE([#include <stdint.h>],
-      [uint32_t i = 0;],
-      [krb5_cv_header_stdint_h_uint32_t=yes],
-      [krb5_cv_header_stdint_h_uint32_t=no])])
-AC_CACHE_CHECK([for uint32_t in inttypes.h],
-  [krb5_cv_header_inttypes_h_uint32_t],
-  [AC_TRY_COMPILE([#include <inttypes.h>],
-      [uint32_t i = 0;],
-      [krb5_cv_header_inttypes_h_uint32_t=yes],
-      [krb5_cv_header_inttypes_h_uint32_t=no])])
-GSSRPC__STDINT_H='/* #include <stdint.h> */'
-GSSRPC__INTTYPES_H='/* #include <inttypes.h> */'
-GSSRPC__FAKE_UINT32='/* #undef GSSRPC__FAKE_INT32 */'
-if test $krb5_cv_header_sys_types_h_uint32_t = yes; then
-  : # already included sys/types.h
-else
-  if test $krb5_cv_header_stdint_h_uint32_t = yes; then
-    GSSRPC__STDINT_H='#include <stdint.h>'
-  else
-    if test $krb5_cv_header_inttypes_h_uint32_t = yes; then
-      GSSRPC__INTTYPES_H='#include <inttypes.h>'
-    else
-      AC_MSG_WARN([can't find a fixed-width 32-bit type anywhere; faking it])
-      GSSRPC__FAKE_UINT32='#define GSSRPC__FAKE_UINT32 1'
-    fi
-  fi
-fi
-AC_SUBST(GSSRPC__STDINT_H)
-AC_SUBST(GSSRPC__INTTYPES_H)
-AC_SUBST(GSSRPC__FAKE_UINT32)
-
 AC_CACHE_CHECK([for BSD type aliases], [krb5_cv_type_bsdaliases],
   [AC_TRY_COMPILE(
     [#include <sys/types.h>
diff --git a/src/include/gssrpc/types.hin b/src/include/gssrpc/types.hin
index 9d33012..022ab4f 100644
--- a/src/include/gssrpc/types.hin
+++ b/src/include/gssrpc/types.hin
@@ -55,16 +55,7 @@
 #include <netinet/in.h>
 
 #include <stdlib.h>
-
-/*
- * Pull in typedefs for fixed-width integers somehow, if they weren't
- * in sys/types.h.
- */
- at GSSRPC__STDINT_H@
- at GSSRPC__INTTYPES_H@
-/* Define if there is no uint32_t in system headers. */
- at GSSRPC__FAKE_UINT32@
-
+#include <stdint.h>
 #include <limits.h>
 
 #ifndef GSSRPC__BEGIN_DECLS
@@ -83,39 +74,6 @@ GSSRPC__BEGIN_DECLS
 #error "Bytes must be exactly 8 bits."
 #endif
 
-/*
- * If no uint32_t in system headers, fake it by looking for a 32-bit
- * two's-complement type.  Yes, this stomps on POSIX namespace, but if
- * we get here, we're on a system that's far from being
- * POSIX-compliant anyway.
- */
-#if GSSRPC__FAKE_UINT32
-#if (UINT_MAX == 0xffffffffUL) && (INT_MAX == 0x7fffffffL) \
-	&& (INT_MIN == -INT_MAX-1)
-typedef int		int32_t;
-typedef unsigned int	uint32_t;
-#else
-#if (ULONG_MAX == 0xffffffffUL) && (LONG_MAX == 0x7fffffffL) \
-	&& (LONG_MIN == -LONG_MAX-1)
-typedef long		int32_t;
-typedef unsigned long	uint32_t;
-#else
-#if (USHRT_MAX == 0xffffffffUL) && (SHRT_MAX == 0x7fffffffL) \
-	&& (SHRT_MIN == -SHRT_MAX-1)
-typedef short		int32_t;
-typedef unsigned short	uint32_t;
-#else
-#error "Can't fake up uint32_t."
-#endif
-#endif
-#endif
-#endif /* GSSRPC__FAKE_UINT32 */
-
-#if (LONG_MIN != -LONG_MAX-1) || (INT_MIN != -INT_MAX-1) \
-	|| (SHRT_MIN != -SHRT_MAX-1)
-#error "Integer types must be two's-complement."
-#endif
-
 /* Define if we need to fake up some BSD type aliases. */
 #ifndef GSSRPC__BSD_TYPEALIASES	/* Allow application to override. */
 @GSSRPC__BSD_TYPEALIASES@
diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h
index 8f0ca9f..537c8ad 100644
--- a/src/include/k5-platform.h
+++ b/src/include/k5-platform.h
@@ -52,6 +52,7 @@
 #include <assert.h>
 #include <string.h>
 #include <stdarg.h>
+#include <stdint.h>
 #include <limits.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -410,42 +411,13 @@ typedef struct { int error; unsigned char did_run; } k5_init_t;
 
 #endif
 
-
-/* 64-bit support: krb5_ui_8 and krb5_int64.
-
-   This should move to krb5.h eventually, but without the namespace
-   pollution from the autoconf macros.  */
-#if defined(HAVE_STDINT_H) || defined(HAVE_INTTYPES_H)
-# ifdef HAVE_STDINT_H
-#  include <stdint.h>
-# endif
-# ifdef HAVE_INTTYPES_H
-#  include <inttypes.h>
-# endif
-# define INT64_TYPE int64_t
-# define UINT64_TYPE uint64_t
-# define INT64_FMT PRId64
-# define UINT64_FMT PRIu64
-#elif defined(_WIN32)
-# define INT64_TYPE signed __int64
-# define UINT64_TYPE unsigned __int64
-# define INT64_FMT "I64d"
-# define UINT64_FMT "I64u"
-#else /* not Windows, and neither stdint.h nor inttypes.h */
-# define INT64_TYPE signed long long
-# define UINT64_TYPE unsigned long long
-# define INT64_FMT "lld"
-# define UINT64_FMT "llu"
-#endif
+#define INT64_TYPE int64_t
+#define UINT64_TYPE uint64_t
 
 #ifndef SIZE_MAX
 # define SIZE_MAX ((size_t)((size_t)0 - 1))
 #endif
 
-#ifndef UINT64_MAX
-# define UINT64_MAX ((UINT64_TYPE)((UINT64_TYPE)0 - 1))
-#endif
-
 #ifdef _WIN32
 # define SSIZE_MAX ((ssize_t)(SIZE_MAX/2))
 #endif
@@ -743,13 +715,8 @@ load_64_le (const void *cvp)
 #endif
 }
 
-#ifdef _WIN32
-#define UINT16_TYPE unsigned __int16
-#define UINT32_TYPE unsigned __int32
-#else
 #define UINT16_TYPE uint16_t
 #define UINT32_TYPE uint32_t
-#endif
 
 static inline void
 store_16_n (unsigned int val, void *vp)
diff --git a/src/include/k5-plugin.h b/src/include/k5-plugin.h
index 6ffbdbb..90809e1 100644
--- a/src/include/k5-plugin.h
+++ b/src/include/k5-plugin.h
@@ -58,12 +58,6 @@
 #define KRB5_CALLCONV_C
 #endif
 
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#elif defined(HAVE_INTTYPES_H)
-# include <inttypes.h>
-#endif
-
 #include "k5-err.h"
 
 /*
diff --git a/src/include/krb5/krb5.hin b/src/include/krb5/krb5.hin
index 8d7a650..43b1f08 100644
--- a/src/include/krb5/krb5.hin
+++ b/src/include/krb5/krb5.hin
@@ -92,6 +92,7 @@
 #include <stdlib.h>
 #include <limits.h>             /* for *_MAX */
 #include <stdarg.h>
+#include <stdint.h>
 
 #ifndef KRB5INT_BEGIN_DECLS
 #if defined(__cplusplus)
@@ -129,30 +130,11 @@ struct _profile_t;
  * Word-size related definition.
  */
 
-typedef unsigned char   krb5_octet;
-
-#if INT_MAX == 0x7fff
-typedef int     krb5_int16;
-typedef unsigned int    krb5_ui_2;
-#elif SHRT_MAX == 0x7fff
-typedef short   krb5_int16;
-typedef unsigned short  krb5_ui_2;
-#else
-#error undefined 16 bit type
-#endif
-
-#if INT_MAX == 0x7fffffffL
-typedef int     krb5_int32;
-typedef unsigned int    krb5_ui_4;
-#elif LONG_MAX == 0x7fffffffL
-typedef long    krb5_int32;
-typedef unsigned long   krb5_ui_4;
-#elif SHRT_MAX == 0x7fffffffL
-typedef short   krb5_int32;
-typedef unsigned short  krb5_ui_4;
-#else
-#error: undefined 32 bit type
-#endif
+typedef uint8_t krb5_octet;
+typedef int16_t krb5_int16;
+typedef uint16_t krb5_ui_2;
+typedef int32_t krb5_int32;
+typedef uint32_t krb5_ui_4;
 
 #define VALID_INT_BITS    INT_MAX
 #define VALID_UINT_BITS   UINT_MAX
diff --git a/src/lib/gssapi/generic/Makefile.in b/src/lib/gssapi/generic/Makefile.in
index 40c6772..c34cba4 100644
--- a/src/lib/gssapi/generic/Makefile.in
+++ b/src/lib/gssapi/generic/Makefile.in
@@ -42,18 +42,12 @@ gssapi_err_generic.h: gssapi_err_generic.et
 gssapi_err_generic.c: gssapi_err_generic.et
 
 ##DOS##!if 0
-include_stdint=@include_stdint@
-include_inttypes=@include_inttypes@
 include_xom=@include_xom@
-##DOS##include_stdint=rem
-##DOS##include_inttypes=rem
 ##DOS##include_xom=rem
 gssapi.h: gssapi.hin
 	@echo "Creating gssapi.h" ; \
 	h=gss$$$$; $(RM) $$h; \
 	(echo "/* This is the gssapi.h prologue. */"; \
-	$(include_stdint) && \
-	$(include_inttypes) && \
 	$(include_xom) && \
 	echo "/* End of gssapi.h prologue. */"&& \
 	cat $(srcdir)/gssapi.hin )> $$h && \
diff --git a/src/lib/gssapi/krb5/Makefile.in b/src/lib/gssapi/krb5/Makefile.in
index 1e77ea8..3427478 100644
--- a/src/lib/gssapi/krb5/Makefile.in
+++ b/src/lib/gssapi/krb5/Makefile.in
@@ -247,20 +247,8 @@ clean-windows::
 
 generate-files-mac: gssapi_krb5.h error_map.h
 
-##DOS##!if 0
-gssapi_krb5.h: gssapi_krb5.hin
-	@echo "Creating gssapi.h" ; \
-	h=gss$$$$; $(RM) $$h; \
-	(echo "/* This is the gssapi_krb5.h prologue. */"; \
-	$(include_stdint) ; \
-	echo "/* End of gssapi_krb5.h prologue. */"; \
-	cat $(srcdir)/gssapi_krb5.hin )> $$h && \
-	(set -x; $(MV) $$h $@) ; e=$$?; $(RM) $$h; exit $$e
-##DOS##!endif
-##DOS### No prologue needed for Windows, the support is
-##DOS### in gssapi_krb5.hin already.
-##DOS##gssapi_krb5.h: gssapi_krb5.hin
-##DOS##	$(CP) gssapi_krb5.hin gssapi_krb5.h
+gssapi_krb5.h: $(srcdir)/gssapi_krb5.hin
+	$(CP) $(srcdir)/gssapi_krb5.hin $@
 
 install-headers-unix install::
 	@set -x; for f in $(EXPORTED_HEADERS) ; \
diff --git a/src/lib/gssapi/krb5/gssapi_krb5.hin b/src/lib/gssapi/krb5/gssapi_krb5.hin
index 9d124fa..1271f27 100644
--- a/src/lib/gssapi/krb5/gssapi_krb5.hin
+++ b/src/lib/gssapi/krb5/gssapi_krb5.hin
@@ -27,6 +27,7 @@
 #include <gssapi/gssapi.h>
 #include <gssapi/gssapi_ext.h>
 #include <krb5.h>
+#include <stdint.h>
 
 /* C++ friendlyness */
 #ifdef __cplusplus
@@ -92,14 +93,7 @@ GSS_DLLIMP extern const gss_OID_desc krb5_gss_oid_array[];
 #define gss_krb5_nt_machine_uid_name    gss_nt_machine_uid_name
 #define gss_krb5_nt_string_uid_name     gss_nt_string_uid_name
 
-
-#if defined(_WIN32)
-typedef  unsigned __int64 gss_uint64;
-#else /*windows*/
-#include <inttypes.h>
-typedef  uint64_t gss_uint64;
-#endif
-
+typedef uint64_t gss_uint64;
 
 typedef struct gss_krb5_lucid_key {
     OM_uint32       type;           /* key encryption type */
diff --git a/src/plugins/kdb/db2/libdb2/include/db-int.h b/src/plugins/kdb/db2/libdb2/include/db-int.h
index 8329ee3..0dcbf40 100644
--- a/src/plugins/kdb/db2/libdb2/include/db-int.h
+++ b/src/plugins/kdb/db2/libdb2/include/db-int.h
@@ -132,13 +132,7 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include <errno.h>
-#ifdef HAVE_STDINT_H
 #include <stdint.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-/* Tru64 5.1: int8_t is defined here, and stdint.h doesn't exist.  */
-#include <inttypes.h>
-#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/param.h>
diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c
index 4e3d84e..9845a18 100644
--- a/src/util/profile/prof_init.c
+++ b/src/util/profile/prof_init.c
@@ -13,12 +13,6 @@
 #endif
 #include <errno.h>
 
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
 typedef int32_t prof_int32;
 
 /* Create a vtable profile, possibly with a library handle.  The new profile
diff --git a/src/util/t_array.pm b/src/util/t_array.pm
index 4a05ab8..4f1f82b 100644
--- a/src/util/t_array.pm
+++ b/src/util/t_array.pm
@@ -41,9 +41,7 @@ __DATA__
 #include <errno.h>
 #include <limits.h>
 #include <string.h>
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
+#include <stdint.h>
 
 struct <NAME>__header {
     size_t allocated;


More information about the cvs-krb5 mailing list