Align time types to SUSv3
Jeff Johnston
jjohnstn@redhat.com
Mon Feb 13 18:28:00 GMT 2006
Corinna Vinschen wrote:
> Hi,
>
> according to SUSv3, struct timeval is defined as
>
> struct timeval {
> time_t tv_sec;
> suseconds_t tv_usec;
> };
>
> see http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html
>
> Additionally, useconds_t is defined as an unsigned type, and suseconds_t
> as a signed type, see
> http://www.opengroup.org/onlinepubs/007908799/xsh/systypes.h.html
>
> I'd like to propose the below patch, which alignes newlib to SUSv3.
>
>
Ok, go ahead. It appears this shouldn't cause any problems since time_t
defaults to long and you are making suseconds_t long as well. Linux has
its own headers that defines it as above.
-- Jeff J.
> Corinna
>
>
> * libc/include/sys/time.h (struct timeval): Change member types
> according to SUSv3.
> * libc/include/sys/types.h (useconds_t): Change to unsigned
> according to SUSv3.
> (suseconds_t): Define type.
>
> Index: libc/include/sys/time.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/sys/time.h,v
> retrieving revision 1.9
> diff -u -p -r1.9 time.h
> --- libc/include/sys/time.h 18 Nov 2005 16:08:10 -0000 1.9
> +++ libc/include/sys/time.h 12 Feb 2006 13:03:56 -0000
> @@ -14,8 +14,8 @@ extern "C" {
>
> #ifndef _WINSOCK_H
> struct timeval {
> - long tv_sec;
> - long tv_usec;
> + time_t tv_sec;
> + suseconds_t tv_usec;
> };
>
> struct timezone {
> Index: libc/include/sys/types.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/sys/types.h,v
> retrieving revision 1.22
> diff -u -p -r1.22 types.h
> --- libc/include/sys/types.h 8 Dec 2005 19:45:43 -0000 1.22
> +++ libc/include/sys/types.h 12 Feb 2006 13:03:56 -0000
> @@ -262,7 +262,8 @@ typedef _TIMER_T_ timer_t;
> #define __timer_t_defined
> #endif
>
> -typedef long useconds_t;
> +typedef unsigned long useconds_t;
> +typedef long suseconds_t;
>
> #include <sys/features.h>
>
>
More information about the Newlib
mailing list