diff options
| author | Greg Hudson <ghudson@mit.edu> | 2014-02-01 15:20:08 -0500 |
|---|---|---|
| committer | Greg Hudson <ghudson@mit.edu> | 2014-02-26 16:15:19 -0500 |
| commit | 17e205070745e4712d40eed32d92d02edb47009f (patch) | |
| tree | 7b84dc2f536d8c73da8155a186fbbc23c3b88dc1 /src/include | |
| parent | 4c376a3776aed0fb19b761406eaa2e0516ff6735 (diff) | |
| download | krb5-17e205070745e4712d40eed32d92d02edb47009f.tar.gz krb5-17e205070745e4712d40eed32d92d02edb47009f.tar.xz krb5-17e205070745e4712d40eed32d92d02edb47009f.zip | |
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.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/gssrpc/types.hin | 44 | ||||
| -rw-r--r-- | src/include/k5-platform.h | 39 | ||||
| -rw-r--r-- | src/include/k5-plugin.h | 6 | ||||
| -rw-r--r-- | src/include/krb5/krb5.hin | 30 |
4 files changed, 10 insertions, 109 deletions
diff --git a/src/include/gssrpc/types.hin b/src/include/gssrpc/types.hin index 9d3301217..022ab4fa9 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. - */ -@GSSRPC__STDINT_H@ -@GSSRPC__INTTYPES_H@ -/* Define if there is no uint32_t in system headers. */ -@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 8f0ca9f31..537c8add5 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 6ffbdbb71..90809e168 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 8d7a650a2..43b1f08c0 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 |
