From 2625803ecff90ba8ab60d3c6b83a1ea0c91d2294 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 3 Apr 2004 10:20:26 -0500 Subject: [PATCH] Use C99 stdint.h types instead of custom types in the uuid library. --- ChangeLog | 4 ++++ configure | 2 +- configure.in | 2 +- lib/blkid/ChangeLog | 5 +++++ lib/blkid/blkid_types.h.in | 2 +- lib/ext2fs/ChangeLog | 5 +++++ lib/ext2fs/ext2_types.h.in | 2 +- lib/uuid/ChangeLog | 5 +++++ lib/uuid/Makefile.in | 1 - lib/uuid/gen_uuid.c | 8 ++++---- lib/uuid/pack.c | 2 +- lib/uuid/unpack.c | 4 ++-- lib/uuid/uuidP.h | 16 ++++++++++------ lib/uuid/uuid_time.c | 2 +- lib/uuid/uuid_types.h.in | 45 ++++++++++++++++++++++----------------------- 15 files changed, 63 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4f22b6..26fe6b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-04-03 Theodore Ts'o + + * configure.in: Add test for stdint.h + 2004-03-19 Theodore Ts'o * configure.in: Add tests for sa_len in struct sockaddr and test diff --git a/configure b/configure index 9ef1180..456760d 100644 --- a/configure +++ b/configure @@ -5272,7 +5272,7 @@ test -n "$BUILD_CC" && break done fi -for ac_hdr in stdlib.h unistd.h stdarg.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disk.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h net/if_dl.h netinet/in.h +for ac_hdr in stdlib.h unistd.h stdarg.h stdint.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disk.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h net/if_dl.h netinet/in.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 diff --git a/configure.in b/configure.in index 4d05a1b..04dbd16 100644 --- a/configure.in +++ b/configure.in @@ -586,7 +586,7 @@ if test $cross_compiling = no; then else AC_CHECK_PROGS(BUILD_CC, gcc cc) fi -AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disk.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h net/if_dl.h netinet/in.h) +AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h stdint.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disk.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h net/if_dl.h netinet/in.h) AC_FUNC_VPRINTF dnl Check to see if dirent has member d_reclen. On cygwin those d_reclen dnl is not decleared. diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index 544c0df..cd26bbf 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,3 +1,8 @@ +2004-04-03 Theodore Ts'o + + * blkid_types.h.in: Remove check for _UUID_TYPES since uuid_types.h + is no longer used. + 2004-03-21 Theodore Ts'o * getsize.c (blkid_get_dev_size): Don't close the file descriptor diff --git a/lib/blkid/blkid_types.h.in b/lib/blkid/blkid_types.h.in index 1528407..0fde69f 100644 --- a/lib/blkid/blkid_types.h.in +++ b/lib/blkid/blkid_types.h.in @@ -4,7 +4,7 @@ * also defined the types that we need. */ #if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \ - !defined(_UUID_TYPES) && !defined(_EXT2_TYPES_H)) + !defined(_EXT2_TYPES_H)) #define _BLKID_TYPES_H typedef unsigned char __u8; diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 68bd13b..d2176d6 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,8 @@ +2004-04-03 Theodore Ts'o + + * ext2_types.h.in: Remove check for _UUID_TYPES since uuid_types.h + is no longer used. + 2004-03-08 Theodore Ts'o * getsize.c (ext2fs_get_device_size): Only use the BLKGETSIZE64 diff --git a/lib/ext2fs/ext2_types.h.in b/lib/ext2fs/ext2_types.h.in index 56897dd..a3e16d0 100644 --- a/lib/ext2fs/ext2_types.h.in +++ b/lib/ext2fs/ext2_types.h.in @@ -4,7 +4,7 @@ * also defined the types that we need. */ #if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \ - !defined(_UUID_TYPES) && !defined(_EXT2_TYPES_H)) + !defined(_EXT2_TYPES_H)) #define _EXT2_TYPES_H typedef unsigned char __u8; diff --git a/lib/uuid/ChangeLog b/lib/uuid/ChangeLog index 1529cc3..c7a7c33 100644 --- a/lib/uuid/ChangeLog +++ b/lib/uuid/ChangeLog @@ -1,3 +1,8 @@ +2004-04-03 Theodore Ts'o + + * gen_uuid.c, pack.c, unpack.c, uuid_time.c, uuidP.h, + uuid_types.h.in: Use ANSI C99 types if stdint.h exists. + 2004-03-30 Theodore Ts'o * gen_uuid.c (get_node_id): Clean up AF_LINK #ifdef's for Darwin. diff --git a/lib/uuid/Makefile.in b/lib/uuid/Makefile.in index b36ce7e..ba9326a 100644 --- a/lib/uuid/Makefile.in +++ b/lib/uuid/Makefile.in @@ -130,7 +130,6 @@ install:: all installdirs -$(RANLIB) $(DESTDIR)$(libdir)/libuuid.a $(CHMOD) $(LIBMODE) $(DESTDIR)$(libdir)/libuuid.a $(INSTALL_DATA) $(srcdir)/uuid.h $(DESTDIR)$(includedir)/uuid/uuid.h - $(INSTALL_DATA) uuid_types.h $(DESTDIR)$(includedir)/uuid/uuid_types.h for i in $(SMANPAGES); do \ $(RM) -f $(DESTDIR)$(man3dir)/$$i.gz; \ $(INSTALL_DATA) $$i $(DESTDIR)$(man3dir)/$$i; \ diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c index b58485b..3493649 100644 --- a/lib/uuid/gen_uuid.c +++ b/lib/uuid/gen_uuid.c @@ -219,11 +219,11 @@ static int get_node_id(unsigned char *node_id) /* Assume that the gettimeofday() has microsecond granularity */ #define MAX_ADJUSTMENT 10 -static int get_clock(__u32 *clock_high, __u32 *clock_low, __u16 *ret_clock_seq) +static int get_clock(uint32_t *clock_high, uint32_t *clock_low, uint16_t *ret_clock_seq) { static int adjustment = 0; static struct timeval last = {0, 0}; - static __u16 clock_seq; + static uint16_t clock_seq; struct timeval tv; unsigned long long clock_reg; @@ -266,7 +266,7 @@ void uuid_generate_time(uuid_t out) static unsigned char node_id[6]; static int has_init = 0; struct uuid uu; - __u32 clock_mid; + uint32_t clock_mid; if (!has_init) { if (get_node_id(node_id) <= 0) { @@ -282,7 +282,7 @@ void uuid_generate_time(uuid_t out) } get_clock(&clock_mid, &uu.time_low, &uu.clock_seq); uu.clock_seq |= 0x8000; - uu.time_mid = (__u16) clock_mid; + uu.time_mid = (uint16_t) clock_mid; uu.time_hi_and_version = (clock_mid >> 16) | 0x1000; memcpy(uu.node, node_id, 6); uuid_pack(&uu, out); diff --git a/lib/uuid/pack.c b/lib/uuid/pack.c index 65f72da..348d432 100644 --- a/lib/uuid/pack.c +++ b/lib/uuid/pack.c @@ -37,7 +37,7 @@ void uuid_pack(const struct uuid *uu, uuid_t ptr) { - __u32 tmp; + uint32_t tmp; unsigned char *out = ptr; tmp = uu->time_low; diff --git a/lib/uuid/unpack.c b/lib/uuid/unpack.c index b65cd28..9502fc2 100644 --- a/lib/uuid/unpack.c +++ b/lib/uuid/unpack.c @@ -37,8 +37,8 @@ void uuid_unpack(const uuid_t in, struct uuid *uu) { - const __u8 *ptr = in; - __u32 tmp; + const uint8_t *ptr = in; + uint32_t tmp; tmp = *ptr++; tmp = (tmp << 8) | *ptr++; diff --git a/lib/uuid/uuidP.h b/lib/uuid/uuidP.h index 3da1df2..d207d3a 100644 --- a/lib/uuid/uuidP.h +++ b/lib/uuid/uuidP.h @@ -32,8 +32,12 @@ * %End-Header% */ -#include +#ifdef HAVE_STDINT_H +#include +#else #include +#endif +#include #include "uuid.h" @@ -44,11 +48,11 @@ #define TIME_OFFSET_LOW 0x13814000 struct uuid { - __u32 time_low; - __u16 time_mid; - __u16 time_hi_and_version; - __u16 clock_seq; - __u8 node[6]; + uint32_t time_low; + uint16_t time_mid; + uint16_t time_hi_and_version; + uint16_t clock_seq; + uint8_t node[6]; }; diff --git a/lib/uuid/uuid_time.c b/lib/uuid/uuid_time.c index 8cd833e..d5f992b 100644 --- a/lib/uuid/uuid_time.c +++ b/lib/uuid/uuid_time.c @@ -46,7 +46,7 @@ time_t uuid_time(const uuid_t uu, struct timeval *ret_tv) { struct uuid uuid; - __u32 high; + uint32_t high; struct timeval tv; unsigned long long clock_reg; diff --git a/lib/uuid/uuid_types.h.in b/lib/uuid/uuid_types.h.in index ba67fea..f21ff4e 100644 --- a/lib/uuid/uuid_types.h.in +++ b/lib/uuid/uuid_types.h.in @@ -3,49 +3,48 @@ * everything we need. (cross fingers) Other header files may have * also defined the types that we need. */ -#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \ - !defined(_UUID_TYPES) && !defined(_EXT2_TYPES_H)) -#define _UUID_TYPES_H +#if (!defined(_STDINT_H) && !defined(_UUID_STDINT_H)) +#define _UUID_STDINT_H -typedef unsigned char __u8; -typedef signed char __s8; +typedef unsigned char uint8_t; +typedef signed char int8_t; #if (@SIZEOF_INT@ == 8) -typedef int __s64; -typedef unsigned int __u64; +typedef int int64_t; +typedef unsigned int uint64_t; #elif (@SIZEOF_LONG@ == 8) -typedef long __s64; -typedef unsigned long __u64; +typedef long int64_t; +typedef unsigned long uint64_t; #elif (@SIZEOF_LONG_LONG@ == 8) #if defined(__GNUC__) -typedef __signed__ long long __s64; +typedef __signed__ long long int64_t; #else -typedef signed long long __s64; +typedef signed long long int64_t; #endif -typedef unsigned long long __u64; +typedef unsigned long long uint64_t; #endif #if (@SIZEOF_INT@ == 2) -typedef int __s16; -typedef unsigned int __u16; +typedef int int16_t; +typedef unsigned int uint16_t; #elif (@SIZEOF_SHORT@ == 2) -typedef short __s16; -typedef unsigned short __u16; +typedef short int16_t; +typedef unsigned short uint16_t; #else ?==error: undefined 16 bit type #endif #if (@SIZEOF_INT@ == 4) -typedef int __s32; -typedef unsigned int __u32; +typedef int int32_t; +typedef unsigned int uint32_t; #elif (@SIZEOF_LONG@ == 4) -typedef long __s32; -typedef unsigned long __u32; +typedef long int32_t; +typedef unsigned long uint32_t; #elif (@SIZEOF_SHORT@ == 4) -typedef short __s32; -typedef unsigned short __u32; +typedef short int32_t; +typedef unsigned short uint32_t; #else ?== error: undefined 32 bit type #endif -#endif /* _*_TYPES_H */ +#endif -- 1.8.3.1