diff options
author | Noah Watkins <noahwatkins@gmail.com> | 2013-07-20 18:41:40 -0700 |
---|---|---|
committer | Noah Watkins <noahwatkins@gmail.com> | 2013-09-17 10:37:36 -0700 |
commit | 3b19a30584021c748daf3de6d5e7e6a8c3d97f76 (patch) | |
tree | 62f6c2a07c63e105cf53514627ab8a5441cf4533 | |
parent | ec828682bc7588c904100180fa799b0a23c65725 (diff) | |
download | ceph-3b19a30584021c748daf3de6d5e7e6a8c3d97f76.tar.gz |
inttypes: detect and define missing integer types
Working around missing integer types is pretty easy. For example, the
__u32 family are Linux-specific types, and using these in Ceph
internally is fine because we can typedef them, but the biggest problem
is that they are also used in installed headers. Again, they could be
typedefed in the installed headers, but it isn't clear that we can't
just use standard ints in installed headers.
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | src/client/ioctl.h | 1 | ||||
-rw-r--r-- | src/crush/builder.c | 2 | ||||
-rw-r--r-- | src/crush/crush.c | 1 | ||||
-rw-r--r-- | src/crush/hash.c | 2 | ||||
-rw-r--r-- | src/crush/mapper.c | 1 | ||||
-rw-r--r-- | src/include/buffer.h | 2 | ||||
-rw-r--r-- | src/include/byteorder.h | 2 | ||||
-rw-r--r-- | src/include/ceph_fs.h | 1 | ||||
-rw-r--r-- | src/include/int_types.h | 37 | ||||
-rw-r--r-- | src/include/linux_fiemap.h | 2 | ||||
-rw-r--r-- | src/include/msgr.h | 2 | ||||
-rw-r--r-- | src/include/rados.h | 1 |
13 files changed, 61 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac index b193c85d590..5f36cea8381 100644 --- a/configure.ac +++ b/configure.ac @@ -582,6 +582,20 @@ AC_CHECK_FUNC([pthread_spin_init], LIBS="$saved_LIBS" CFLAGS="$saved_CFLAGS" +AC_CHECK_TYPES(int8_t) +AC_CHECK_TYPES(uint8_t) +AC_CHECK_TYPES(int16_t) +AC_CHECK_TYPES(uint16_t) +AC_CHECK_TYPES(int32_t) +AC_CHECK_TYPES(uint32_t) +AC_CHECK_TYPES(int64_t) +AC_CHECK_TYPES(uint64_t) + +dnl check for Linux types +AC_CHECK_HEADERS([linux/types.h]) +AC_CHECK_TYPES([__u8, __s8, __u16, __s16, __u32, __s32, __u64, __s64, __le16, + __be16, __le32, __be32, __le64, __be64], [], [], [[#include <linux/types.h>]]) + # Checks for typedefs, structures, and compiler characteristics. #AC_HEADER_STDBOOL #AC_C_CONST diff --git a/src/client/ioctl.h b/src/client/ioctl.h index 6744547a201..1f975a5ee0a 100644 --- a/src/client/ioctl.h +++ b/src/client/ioctl.h @@ -2,6 +2,7 @@ #define FS_CEPH_IOCTL_H #include "include/int_types.h" +#include "acconfig.h" #if defined(__linux__) #include <linux/ioctl.h> diff --git a/src/crush/builder.c b/src/crush/builder.c index 9bfde0bd8e2..118ca9519fd 100644 --- a/src/crush/builder.c +++ b/src/crush/builder.c @@ -6,6 +6,8 @@ #include <assert.h> #include <errno.h> +#include "include/inttypes.h" + #include "builder.h" #include "hash.h" diff --git a/src/crush/crush.c b/src/crush/crush.c index 1e83eb866bb..fa835f17b14 100644 --- a/src/crush/crush.c +++ b/src/crush/crush.c @@ -6,6 +6,7 @@ # include <assert.h> # define kfree(x) do { if (x) free(x); } while (0) # define BUG_ON(x) assert(!(x)) +# include "include/inttypes.h" #endif #include "crush.h" diff --git a/src/crush/hash.c b/src/crush/hash.c index 9b15321d783..8f1d31ad36b 100644 --- a/src/crush/hash.c +++ b/src/crush/hash.c @@ -1,5 +1,7 @@ #include "include/int_types.h" +#include "acconfig.h" + #if defined(__linux__) #include <linux/types.h> #elif defined(__FreeBSD__) diff --git a/src/crush/mapper.c b/src/crush/mapper.c index ce23ef7c711..5ffade71861 100644 --- a/src/crush/mapper.c +++ b/src/crush/mapper.c @@ -16,6 +16,7 @@ # define dprintk(args...) /* printf(args) */ # define kmalloc(x, f) malloc(x) # define kfree(x) free(x) +# include "include/inttypes.h" #endif #include "crush.h" diff --git a/src/include/buffer.h b/src/include/buffer.h index 077cf0d9b0b..e17853abe3b 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -24,6 +24,8 @@ #include <stdlib.h> #endif +#include "include/inttypes.h" + #ifndef _XOPEN_SOURCE # define _XOPEN_SOURCE 600 #endif diff --git a/src/include/byteorder.h b/src/include/byteorder.h index 9a39d54543f..c1395d08ce0 100644 --- a/src/include/byteorder.h +++ b/src/include/byteorder.h @@ -17,6 +17,8 @@ #error "Your platform is not yet supported." #endif +#include "include/inttypes.h" + #if defined(__FreeBSD__) || defined(DARWIN) #define __BYTE_ORDER _BYTE_ORDER #define __BIG_ENDIAN _BIG_ENDIAN diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 6c41d14f5da..db7b7693630 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -14,6 +14,7 @@ #include "msgr.h" #include "rados.h" +#include "include/inttypes.h" /* * subprotocol versions. when specific messages types or high-level diff --git a/src/include/int_types.h b/src/include/int_types.h index f290f9d8d23..98220e9a52e 100644 --- a/src/include/int_types.h +++ b/src/include/int_types.h @@ -3,7 +3,7 @@ #include "acconfig.h" -#if defined(__linux__) +#ifdef HAVE_LINUX_TYPES_H #include <linux/types.h> #endif @@ -50,17 +50,41 @@ # endif #endif -#if defined(__FreeBSD__) +#ifdef HAVE_SYS_TYPES_H #include <sys/types.h> +#endif -typedef int8_t __s8; +#ifndef HAVE___U8 typedef uint8_t __u8; -typedef int16_t __s16; +#endif + +#ifndef HAVE___S8 +typedef int8_t __s8; +#endif + +#ifndef HAVE___U16 typedef uint16_t __u16; -typedef int32_t __s32; +#endif + +#ifndef HAVE___S16 +typedef int16_t __s16; +#endif + +#ifndef HAVE___U32 typedef uint32_t __u32; -typedef int64_t __s64; +#endif + +#ifndef HAVE___S32 +typedef int32_t __s32; +#endif + +#ifndef HAVE___U64 typedef uint64_t __u64; +#endif + +#ifndef HAVE___S64 +typedef int64_t __s64; +#endif #define __bitwise__ @@ -72,4 +96,3 @@ typedef __u64 __bitwise__ __le64; typedef __u64 __bitwise__ __be64; #endif -#endif diff --git a/src/include/linux_fiemap.h b/src/include/linux_fiemap.h index 352208b2207..2d40201afd8 100644 --- a/src/include/linux_fiemap.h +++ b/src/include/linux_fiemap.h @@ -18,6 +18,8 @@ #include <sys/types.h> #endif +#include "include/inttypes.h" + struct fiemap_extent { __u64 fe_logical; /* logical offset in bytes for the start of * the extent from the beginning of the file */ diff --git a/src/include/msgr.h b/src/include/msgr.h index 585468270dd..6f9c46660ba 100644 --- a/src/include/msgr.h +++ b/src/include/msgr.h @@ -5,6 +5,8 @@ #include <sys/socket.h> // for struct sockaddr_storage #endif +#include "include/inttypes.h" + /* * Data types for message passing layer used by Ceph. */ diff --git a/src/include/rados.h b/src/include/rados.h index 178c171c445..106349cd9a2 100644 --- a/src/include/rados.h +++ b/src/include/rados.h @@ -7,6 +7,7 @@ */ #include "msgr.h" +#include "include/inttypes.h" /* * fs id |