Use C99 stdint.h types instead of custom types in the uuid library.

This commit is contained in:
Theodore Ts'o 2004-04-03 10:20:26 -05:00
parent 13be1fff00
commit 2625803ecf
15 changed files with 63 additions and 42 deletions

View File

@ -1,3 +1,7 @@
2004-04-03 Theodore Ts'o <tytso@mit.edu>
* configure.in: Add test for stdint.h
2004-03-19 Theodore Ts'o <tytso@mit.edu>
* configure.in: Add tests for sa_len in struct sockaddr and test

2
configure vendored
View File

@ -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

View File

@ -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.

View File

@ -1,3 +1,8 @@
2004-04-03 Theodore Ts'o <tytso@mit.edu>
* blkid_types.h.in: Remove check for _UUID_TYPES since uuid_types.h
is no longer used.
2004-03-21 Theodore Ts'o <tytso@mit.edu>
* getsize.c (blkid_get_dev_size): Don't close the file descriptor

View File

@ -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;

View File

@ -1,3 +1,8 @@
2004-04-03 Theodore Ts'o <tytso@mit.edu>
* ext2_types.h.in: Remove check for _UUID_TYPES since uuid_types.h
is no longer used.
2004-03-08 Theodore Ts'o <tytso@mit.edu>
* getsize.c (ext2fs_get_device_size): Only use the BLKGETSIZE64

View File

@ -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;

View File

@ -1,3 +1,8 @@
2004-04-03 Theodore Ts'o <tytso@mit.edu>
* 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 <tytso@mit.edu>
* gen_uuid.c (get_node_id): Clean up AF_LINK #ifdef's for Darwin.

View File

@ -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; \

View File

@ -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);

View File

@ -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;

View File

@ -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++;

View File

@ -32,8 +32,12 @@
* %End-Header%
*/
#include <sys/types.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#include <uuid/uuid_types.h>
#endif
#include <sys/types.h>
#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];
};

View File

@ -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;

View File

@ -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