diff --git a/CHANGES b/CHANGES index feff5eb..a70cc89 100644 --- a/CHANGES +++ b/CHANGES @@ -182,6 +182,9 @@ New features: Added AF_VSOCK support with VSOCK-CONNECT and VSOCK-LISTEN addresses. Developed by Stefano Garzarella. +Coding: + Added printf formats for uint16_t etc. + Documentation: Address UDP-RECV does not support option fork. Thanks to Fulvio Scapin for reporting that mistake in docu. diff --git a/compat.h b/compat.h index 99a78ae..3bc010d 100644 --- a/compat.h +++ b/compat.h @@ -94,6 +94,93 @@ typedef int sig_atomic_t; # define SOL_IPV6 IPPROTO_IPV6 #endif +#define F_uint8_t "%hu" +#define F_int8_t "%hd" + +#ifndef F_uint16_t +# if HAVE_BASIC_UINT16_T==0 +# define F_uint16_t "%hu" +# elif HAVE_BASIC_UINT16_T==2 +# define F_uint16_t "%hu" +# elif HAVE_BASIC_UINT16_T==4 +# define F_uint16_t "%u" +# elif HAVE_BASIC_UINT16_T==6 +# define F_uint16_t "%lu" +# else +# error "HAVE_BASIC_UINT16_T is out of range:" HAVE_BASIC_UINT16_T +# endif +#endif + +#ifndef F_uint32_t +# if HAVE_BASIC_UINT32_T==0 +# define F_uint32_t "%hu" +# elif HAVE_BASIC_UINT32_T==2 +# define F_uint32_t "%hu" +# elif HAVE_BASIC_UINT32_T==4 +# define F_uint32_t "%u" +# elif HAVE_BASIC_UINT32_T==6 +# define F_uint32_t "%lu" +# else +# error "HAVE_BASIC_UINT32_T is out of range:" HAVE_BASIC_UINT32_T +# endif +#endif + +#ifndef F_uint64_t +# if HAVE_BASIC_UINT64_T==0 +# define F_uint64_t "%hu" +# elif HAVE_BASIC_UINT64_T==2 +# define F_uint64_t "%hu" +# elif HAVE_BASIC_UINT64_T==4 +# define F_uint64_t "%u" +# elif HAVE_BASIC_UINT64_T==6 +# define F_uint64_t "%lu" +# else +# error "HAVE_BASIC_UINT64_T is out of range:" HAVE_BASIC_UINT64_T +# endif +#endif + +#ifndef F_int16_t +# if HAVE_BASIC_INT16_T==0 +# define F_int16_t "%hd" +# elif HAVE_BASIC_INT16_T==1 +# define F_int16_t "%hd" +# elif HAVE_BASIC_INT16_T==3 +# define F_int16_t "%d" +# elif HAVE_BASIC_INT16_T==5 +# define F_int16_t "%l" +# else +# error "HAVE_BASIC_INT16_T is out of range:" HAVE_BASIC_INT16_T +# endif +#endif + +#ifndef F_int32_t +# if HAVE_BASIC_INT32_T==0 +# define F_int32_t "%hd" +# elif HAVE_BASIC_INT32_T==1 +# define F_int32_t "%hd" +# elif HAVE_BASIC_INT32_T==3 +# define F_int32_t "%d" +# elif HAVE_BASIC_INT32_T==5 +# define F_int32_t "%l" +# else +# error "HAVE_BASIC_INT32_T is out of range:" HAVE_BASIC_INT32_T +# endif +#endif + +#ifndef F_int64_t +# if HAVE_BASIC_INT64_T==0 +# define F_int64_t "%hd" +# elif HAVE_BASIC_INT64_T==1 +# define F_int64_t "%hd" +# elif HAVE_BASIC_INT64_T==3 +# define F_int64_t "%d" +# elif HAVE_BASIC_INT64_T==5 +# define F_int64_t "%l" +# else +# error "HAVE_BASIC_INT64_T is out of range:" HAVE_BASIC_INT64_T +# endif +#endif + /* all unsigned */ #if !defined(HAVE_BASIC_SIZE_T) || !HAVE_BASIC_SIZE_T # undef HAVE_BASIC_SIZE_T @@ -711,6 +798,17 @@ typedef unsigned long T_sigset; # endif #endif +/* basic type of struct timeval tv_usec */ +#ifndef F_tv_usec +# if TYPEOF_STRUCT_TIMEVAL_TV_USEC==1 +# define F_tv_usec "%hu" +# elif TYPEOF_STRUCT_TIMEVAL_TV_USEC==3 +# define F_tv_usec "%u" +# elif TYPEOF_STRUCT_TIMEVAL_TV_USEC==5 +# define F_tv_usec "%lu" +# endif +#endif + /* Cygwin 1.3.22 has the prototypes, but not the type... */ #ifndef HAVE_TYPE_STAT64 # undef HAVE_STAT64 diff --git a/config.h.in b/config.h.in index 08ec477..3b963c6 100644 --- a/config.h.in +++ b/config.h.in @@ -598,6 +598,13 @@ #endif /* 1..short, 3..int, 5..long; 2,4,6..unsigned */ +#undef HAVE_BASIC_UINT16_T +#undef HAVE_BASIC_UINT32_T +#undef HAVE_BASIC_UINT64_T +#undef HAVE_BASIC_INT16_T +#undef HAVE_BASIC_INT32_T +#undef HAVE_BASIC_INT64_T + #undef HAVE_BASIC_SIZE_T #undef HAVE_BASIC_MODE_T #undef HAVE_BASIC_PID_T diff --git a/configure.ac b/configure.ac index b159155..3242dce 100644 --- a/configure.ac +++ b/configure.ac @@ -1844,6 +1844,12 @@ define(AC_TYPEOF_COMPONENT,[ fi ]) +AC_BASIC_TYPE([#include ], uint16_t, HAVE_BASIC_UINT16_T, sc_cv_type_uint16_basic) +AC_BASIC_TYPE([#include ], uint32_t, HAVE_BASIC_UINT32_T, sc_cv_type_uint32_basic) +AC_BASIC_TYPE([#include ], uint64_t, HAVE_BASIC_UINT64_T, sc_cv_type_uint64_basic) +AC_BASIC_TYPE([#include ], int16_t, HAVE_BASIC_INT16_T, sc_cv_type_int16_basic) +AC_BASIC_TYPE([#include ], int32_t, HAVE_BASIC_INT32_T, sc_cv_type_int32_basic) +AC_BASIC_TYPE([#include ], int64_t, HAVE_BASIC_INT64_T, sc_cv_type_int64_basic) AC_BASIC_TYPE([#include ], size_t, HAVE_BASIC_SIZE_T, sc_cv_type_sizet_basic) AC_BASIC_TYPE([#include #include