This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH [3/n]: Add __snseconds_t and __SNSECONDS_T_TYPE
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 15 Mar 2012 12:25:15 -0700
- Subject: PATCH [3/n]: Add __snseconds_t and __SNSECONDS_T_TYPE
Hi,
Linux/x32 uses long long for time_t. timespec has
struct timespec
{
__time_t tv_sec; /* Seconds. */
long int tv_nsec; /* Nanoseconds. */
};
Linux/x32 uses the same timespec as x86-64 inside kernel. That means
tv_nsec must also be 64bit for Linux/x32. However, we don't have
__snseconds_t. This patch defines time_t to 64bit and adds __snseconds_t
similar to __suseconds_t.
Also Linux/x32 uses the same 64bit file system calls as x86-64. This patch
defines all integer types used for file system calls as 64bit integer.
This patch defines __SSYSCALL_LONG_TYPE and __USYSCALL_LONG_TYPE to
replace "long int" in data structure in x32 system calls, which are
identical to x86-64 ones. They are used in system call headr files,
like sysdeps/unix/sysv/linux/x86_64/bits/ipc.h:
/* Data structure used to pass permission information to IPC operations.
* */
struct ipc_perm
{
__key_t __key; /* Key. */
__uid_t uid; /* Owner's user ID. */
__gid_t gid; /* Owner's group ID. */
__uid_t cuid; /* Creator's user ID. */
__gid_t cgid; /* Creator's group ID. */
unsigned short int mode; /* Read/write permission. */
unsigned short int __pad1;
unsigned short int __seq; /* Sequence number. */
unsigned short int __pad2;
__USYSCALL_LONG_TYPE __unused1;
__USYSCALL_LONG_TYPE __unused2;
};
so that x32 struct ipc_perm has the same layout as x86-64 struct
ipc_perm. The althernate is to use "#ifdef" to check x32 and use
long long. __SSYSCALL_LONG_TYPE and __USYSCALL_LONG_TYPE will be used
in
sysdeps/unix/sysv/linux/x86_64/bits/ipc.h
sysdeps/unix/sysv/linux/x86_64/bits/mqueue.h
sysdeps/unix/sysv/linux/x86_64/bits/msq.h
sysdeps/unix/sysv/linux/x86_64/bits/sem.h
sysdeps/unix/sysv/linux/x86_64/bits/shm.h
sysdeps/unix/sysv/linux/x86_64/bits/stat.h
sysdeps/unix/sysv/linux/x86_64/bits/statfs.h
sysdeps/unix/sysv/linux/x86_64/bits/timex.h
sysdeps/unix/sysv/linux/x86_64/sys/msg.h
Thanks.
H.J.
---
2012-03-15 H.J. Lu <hongjiu.lu@intel.com>
* bits/types.h (__snseconds_t): New.
* bits/typesizes.h (__SNSECONDS_T_TYPE): Likewise.
* sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h (__SNSECONDS_T_TYPE):
Likewise.
* sysdeps/unix/sysv/linux/s390/bits/typesizes.h (__SNSECONDS_T_TYPE):
Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h (__SNSECONDS_T_TYPE):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/bits/typesizes.h: New.
* time/time.h (timespec): Use __snseconds_t on tv_nsec.
diff --git a/bits/types.h b/bits/types.h
index a9bf0ad..ae79a6f 100644
--- a/bits/types.h
+++ b/bits/types.h
@@ -148,6 +148,7 @@ __STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */
__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */
__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */
__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */
+__STD_TYPE __SNSECONDS_T_TYPE __snseconds_t; /* Signed count of nanoseconds. */
__STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */
__STD_TYPE __SWBLK_T_TYPE __swblk_t; /* Type of a swap block maybe? */
diff --git a/bits/typesizes.h b/bits/typesizes.h
index e1c5a27..abd9fbe 100644
--- a/bits/typesizes.h
+++ b/bits/typesizes.h
@@ -1,5 +1,6 @@
/* bits/typesizes.h -- underlying types for *_t. Generic version.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2011
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -57,6 +58,7 @@
#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
#define __FSID_T_TYPE struct { int __val[2]; }
#define __SSIZE_T_TYPE __SWORD_TYPE
+#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024
diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h
index 7bde5d5..bca63ed 100644
--- a/sysdeps/mach/hurd/bits/typesizes.h
+++ b/sysdeps/mach/hurd/bits/typesizes.h
@@ -57,6 +57,7 @@
#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
#define __FSID_T_TYPE __UQUAD_TYPE
#define __SSIZE_T_TYPE __SWORD_TYPE
+#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 256
diff --git a/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h b/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
index 6703473..1c763c2 100644
--- a/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
+++ b/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
@@ -57,6 +57,7 @@
#define __BLKSIZE_T_TYPE __U32_TYPE
#define __FSID_T_TYPE struct { int __val[2]; }
#define __SSIZE_T_TYPE __SWORD_TYPE
+#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024
diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
index ee85531..af7021f 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
@@ -63,6 +63,7 @@
/* size_t is unsigned long int on s390 -m31. */
#define __SSIZE_T_TYPE __SLONGWORD_TYPE
#endif
+#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
index 37b7656..bba82b3 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
@@ -57,6 +57,7 @@
#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
#define __FSID_T_TYPE struct { int __val[2]; }
#define __SSIZE_T_TYPE __SWORD_TYPE
+#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86_64/bits/typesizes.h
new file mode 100644
index 0000000..2f41667
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/typesizes.h
@@ -0,0 +1,88 @@
+/* bits/typesizes.h -- underlying types for *_t. X86_64 version.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_TYPES_H
+# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef _BITS_TYPESIZES_H
+#define _BITS_TYPESIZES_H 1
+
+/* See <bits/types.h> for the meaning of these macros. This file exists so
+ that <bits/types.h> need not vary across different GNU platforms. */
+
+/* X32 kernel interface is 64bit. */
+#if defined __x86_64__ && __WORDSIZE == 32
+#define __INO_T_TYPE __UQUAD_TYPE
+#define __NLINK_T_TYPE __UQUAD_TYPE
+#define __OFF_T_TYPE __SQUAD_TYPE
+#define __RLIM_T_TYPE __UQUAD_TYPE
+#define __BLKCNT_T_TYPE __SQUAD_TYPE
+#define __FSFILCNT_T_TYPE __UQUAD_TYPE
+#define __FSBLKCNT_T_TYPE __UQUAD_TYPE
+#define __CLOCK_T_TYPE __SQUAD_TYPE
+#define __TIME_T_TYPE __SQUAD_TYPE
+#define __SUSECONDS_T_TYPE __SQUAD_TYPE
+#define __SNSECONDS_T_TYPE __SQUAD_TYPE
+#define __BLKSIZE_T_TYPE __SQUAD_TYPE
+#define __SSYSCALL_LONG_TYPE __SQUAD_TYPE
+#define __USYSCALL_LONG_TYPE __UQUAD_TYPE
+#else
+#define __INO_T_TYPE __ULONGWORD_TYPE
+#define __NLINK_T_TYPE __UWORD_TYPE
+#define __OFF_T_TYPE __SLONGWORD_TYPE
+#define __RLIM_T_TYPE __ULONGWORD_TYPE
+#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
+#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
+#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
+#define __CLOCK_T_TYPE __SLONGWORD_TYPE
+#define __TIME_T_TYPE __SLONGWORD_TYPE
+#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
+#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE
+#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
+#define __SSYSCALL_LONG_TYPE __SLONGWORD_TYPE
+#define __USYSCALL_LONG_TYPE __ULONGWORD_TYPE
+#endif
+
+#define __DEV_T_TYPE __UQUAD_TYPE
+#define __UID_T_TYPE __U32_TYPE
+#define __GID_T_TYPE __U32_TYPE
+#define __INO64_T_TYPE __UQUAD_TYPE
+#define __MODE_T_TYPE __U32_TYPE
+#define __OFF64_T_TYPE __SQUAD_TYPE
+#define __PID_T_TYPE __S32_TYPE
+#define __RLIM64_T_TYPE __UQUAD_TYPE
+#define __BLKCNT64_T_TYPE __SQUAD_TYPE
+#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
+#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
+#define __ID_T_TYPE __U32_TYPE
+#define __USECONDS_T_TYPE __U32_TYPE
+#define __DADDR_T_TYPE __S32_TYPE
+#define __SWBLK_T_TYPE __SLONGWORD_TYPE
+#define __KEY_T_TYPE __S32_TYPE
+#define __CLOCKID_T_TYPE __S32_TYPE
+#define __TIMER_T_TYPE void *
+#define __FSID_T_TYPE struct { int __val[2]; }
+#define __SSIZE_T_TYPE __SWORD_TYPE
+
+/* Number of descriptors that can fit in an `fd_set'. */
+#define __FD_SETSIZE 1024
+
+
+#endif /* bits/typesizes.h */
diff --git a/time/time.h b/time/time.h
index 775c092..776dc40 100644
--- a/time/time.h
+++ b/time/time.h
@@ -120,7 +120,7 @@ typedef __timer_t timer_t;
struct timespec
{
__time_t tv_sec; /* Seconds. */
- long int tv_nsec; /* Nanoseconds. */
+ __snseconds_t tv_nsec; /* Nanoseconds. */
};
#endif /* timespec not defined and <time.h> or need timespec. */
--
1.7.6.5