about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2002-03-04 13:40:44 +0000
committerAndreas Jaeger <aj@suse.de>2002-03-04 13:40:44 +0000
commit76d81302250475cbca24bb3d257a446b044bc343 (patch)
tree203aa32e7087871cbd119b51fa4f31b63ef3606f
parenta06bb7ce8829e123c996c50302b557af803bd1de (diff)
downloadglibc-76d81302250475cbca24bb3d257a446b044bc343.tar.gz
glibc-76d81302250475cbca24bb3d257a446b044bc343.tar.xz
glibc-76d81302250475cbca24bb3d257a446b044bc343.zip
Update.
2002-03-04  Andreas Jaeger  <aj@suse.de>

	* sysdeps/unix/sysv/linux/kernel-features.h: Add defines for
	x86-64.

	* sysdeps/unix/sysv/linux/x86_64/bits/socket.h: New.

	* sysdeps/unix/sysv/linux/x86_64/bits/sigcontext.h: New.

	* sysdeps/unix/sysv/linux/x86_64/bits/shm.h: New.

	* sysdeps/x86_64/bits/setjmp.h: New.

	* sysdeps/unix/sysv/linux/x86_64/bits/sem.h: New.

	* sysdeps/unix/sysv/linux/x86_64/bits/resource.h: New.

	* sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h: Add compatibilty
	for x86.
	* sysdeps/unix/sysv/linux/x86_64/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/bits/types.h: Likewise.

2002-02-28  Bo Thorsen  <bo@suse.de>

	* sysdeps/unix/sysv/linux/x86_64/bits/stat.h: Merge with i386
	version.
-rw-r--r--ChangeLog27
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h29
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/bits/msq.h83
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/bits/resource.h209
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/bits/sem.h87
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/bits/shm.h99
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/bits/sigcontext.h139
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/bits/socket.h321
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/bits/stat.h73
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/bits/types.h61
-rw-r--r--sysdeps/x86_64/bits/setjmp.h51
11 files changed, 1152 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index a350421dcd..57fa1223e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2002-03-04  Andreas Jaeger  <aj@suse.de>
+
+	* sysdeps/unix/sysv/linux/kernel-features.h: Add defines for
+	x86-64.
+
+	* sysdeps/unix/sysv/linux/x86_64/bits/socket.h: New.
+
+	* sysdeps/unix/sysv/linux/x86_64/bits/sigcontext.h: New.
+
+	* sysdeps/unix/sysv/linux/x86_64/bits/shm.h: New.
+
+	* sysdeps/x86_64/bits/setjmp.h: New.
+
+	* sysdeps/unix/sysv/linux/x86_64/bits/sem.h: New.
+
+	* sysdeps/unix/sysv/linux/x86_64/bits/resource.h: New.
+
+	* sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h: Add compatibilty
+	for x86.
+	* sysdeps/unix/sysv/linux/x86_64/bits/msq.h: Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/bits/types.h: Likewise.
+
+2002-02-28  Bo Thorsen  <bo@suse.de>
+
+	* sysdeps/unix/sysv/linux/x86_64/bits/stat.h: Merge with i386
+	version.
+
 2002-03-03  Andreas Jaeger  <aj@suse.de>
 
 	* sysdeps/x86_64/bits/wordsize.h: New file.
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h
index bb14a9f560..fda18a7bd0 100644
--- a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h
@@ -1,5 +1,5 @@
 /* O_*, F_*, FD_* bit values for Linux/x86-64.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002 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
@@ -23,6 +23,7 @@
 
 
 #include <sys/types.h>
+#include <bits/wordsize.h>
 
 /* open/fcntl - O_SYNC is only implemented on blocks devices and on files
    located on an ext2 file system */
@@ -56,8 +57,11 @@
 #endif
 
 #ifdef __USE_LARGEFILE64
-/* Not necessary, files are always with 64bit off_t.  */
-# define O_LARGEFILE	0
+# if __WORDSIZE == 64
+#  define O_LARGEFILE	0
+# else
+#  define O_LARGEFILE	0100000
+# endif
 #endif
 
 /* Values for the second argument to `fcntl'.  */
@@ -69,10 +73,15 @@
 #define F_GETLK		5	/* Get record locking info.  */
 #define F_SETLK		6	/* Set record locking info (non-blocking).  */
 #define F_SETLKW	7	/* Set record locking info (blocking).	*/
-#define F_GETLK64	F_GETLK	/* Get record locking info.  */
-#define F_SETLK64	F_SETLK	/* Set record locking info (non-blocking).  */
-#define F_SETLKW64	F_SETLKW /* Set record locking info (blocking).	*/
-
+#if __WORDSIZE == 64
+# define F_GETLK64	F_GETLK	/* Get record locking info.  */
+# define F_SETLK64	F_SETLK	/* Set record locking info (non-blocking).  */
+# define F_SETLKW64	F_SETLKW /* Set record locking info (blocking).	*/
+#else
+#define F_GETLK64	12	/* Get record locking info.  */
+#define F_SETLK64	13	/* Set record locking info (non-blocking).  */
+#define F_SETLKW64	14	/* Set record locking info (blocking).	*/
+#endif
 #if defined __USE_BSD || defined __USE_XOPEN2K
 # define F_SETOWN	8	/* Get owner of socket (receiver of SIGIO).  */
 # define F_GETOWN	9	/* Set owner of socket (receiver of SIGIO).  */
@@ -128,13 +137,17 @@
 # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
 #endif
 
-/* We don't need to support __USE_FILE_OFFSET64.  */
 struct flock
   {
     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
     short int l_whence;	/* Where `l_start' is relative to (like `lseek').  */
+#ifndef __USE_FILE_OFFSET64
     __off_t l_start;	/* Offset where the lock begins.  */
     __off_t l_len;	/* Size of the locked area; zero means until EOF.  */
+#else
+    __off64_t l_start;	/* Offset where the lock begins.  */
+    __off64_t l_len;	/* Size of the locked area; zero means until EOF.  */
+#endif
     __pid_t l_pid;	/* Process holding the lock.  */
   };
 
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/msq.h b/sysdeps/unix/sysv/linux/x86_64/bits/msq.h
new file mode 100644
index 0000000000..422218a5f9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/msq.h
@@ -0,0 +1,83 @@
+/* Copyright (C) 1995, 1996, 1997, 2000, 2002 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 _SYS_MSG_H
+# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
+#endif
+
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+/* Define options for message queue functions.  */
+#define MSG_NOERROR	010000	/* no error if message is too big */
+#ifdef __USE_GNU
+# define MSG_EXCEPT	020000	/* recv any msg except of specified type */
+#endif
+
+/* Types used in the structure definition.  */
+typedef unsigned long int msgqnum_t;
+typedef unsigned long int msglen_t;
+
+/* Structure of record for one message inside the kernel.
+   The type `struct msg' is opaque.  */
+struct msqid_ds
+{
+  struct ipc_perm msg_perm;	/* structure describing operation permission */
+  __time_t msg_stime;		/* time of last msgsnd command */
+#if __WORDSIZE == 32
+  unsigned long int __unused1;
+#endif
+  __time_t msg_rtime;		/* time of last msgrcv command */
+#if __WORDSIZE == 32
+  unsigned long int __unused2;
+#endif
+  __time_t msg_ctime;		/* time of last change */
+#if __WORDSIZE == 32
+  unsigned long int __unused3;
+#endif
+  unsigned long int __msg_cbytes; /* current number of bytes on queue */
+  msgqnum_t msg_qnum;		/* number of messages currently on queue */
+  msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
+  __pid_t msg_lspid;		/* pid of last msgsnd() */
+  __pid_t msg_lrpid;		/* pid of last msgrcv() */
+  unsigned long int __unused4;
+  unsigned long int __unused5;
+};
+
+#ifdef __USE_MISC
+
+# define msg_cbytes	__msg_cbytes
+
+/* ipcs ctl commands */
+# define MSG_STAT 11
+# define MSG_INFO 12
+
+/* buffer for msgctl calls IPC_INFO, MSG_INFO */
+struct msginfo
+  {
+    int msgpool;
+    int msgmap;
+    int msgmax;
+    int msgmnb;
+    int msgmni;
+    int msgssz;
+    int msgtql;
+    unsigned short int msgseg;
+  };
+
+#endif /* __USE_MISC */
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/resource.h b/sysdeps/unix/sysv/linux/x86_64/bits/resource.h
new file mode 100644
index 0000000000..34969c4b55
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/resource.h
@@ -0,0 +1,209 @@
+/* Bit values & structures for resource limits.  Linux/x86-64 version.
+   Copyright (C) 1994,1996,1997,1998,1999,2000,2002 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 _SYS_RESOURCE_H
+# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Transmute defines to enumerations.  The macro re-definitions are
+   necessary because some programs want to test for operating system
+   features with #ifdef RUSAGE_SELF.  In ISO C the reflexive
+   definition is a no-op.  */
+
+/* Kinds of resource limit.  */
+enum __rlimit_resource
+{
+  /* Per-process CPU limit, in seconds.  */
+  RLIMIT_CPU = 0,
+#define RLIMIT_CPU RLIMIT_CPU
+
+  /* Largest file that can be created, in bytes.  */
+  RLIMIT_FSIZE = 1,
+#define	RLIMIT_FSIZE RLIMIT_FSIZE
+
+  /* Maximum size of data segment, in bytes.  */
+  RLIMIT_DATA = 2,
+#define	RLIMIT_DATA RLIMIT_DATA
+
+  /* Maximum size of stack segment, in bytes.  */
+  RLIMIT_STACK = 3,
+#define	RLIMIT_STACK RLIMIT_STACK
+
+  /* Largest core file that can be created, in bytes.  */
+  RLIMIT_CORE = 4,
+#define	RLIMIT_CORE RLIMIT_CORE
+
+  /* Largest resident set size, in bytes.
+     This affects swapping; processes that are exceeding their
+     resident set size will be more likely to have physical memory
+     taken from them.  */
+  RLIMIT_RSS = 5,
+#define	RLIMIT_RSS RLIMIT_RSS
+
+  /* Number of open files.  */
+  RLIMIT_NOFILE = 7,
+  RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same.  */
+#define RLIMIT_NOFILE RLIMIT_NOFILE
+#define RLIMIT_OFILE RLIMIT_OFILE
+
+  /* Address space limit.  */
+  RLIMIT_AS = 9,
+#define RLIMIT_AS RLIMIT_AS
+
+  /* Number of processes.  */
+  RLIMIT_NPROC = 6,
+#define RLIMIT_NPROC RLIMIT_NPROC
+
+  /* Locked-in-memory address space.  */
+  RLIMIT_MEMLOCK = 8,
+#define RLIMIT_MEMLOCK RLIMIT_MEMLOCK
+
+  /* Maximum number of file locks.  */
+  RLIMIT_LOCKS = 10,
+#define RLIMIT_LOCKS RLIMIT_LOCKS
+
+  RLIMIT_NLIMITS = 11,
+  RLIM_NLIMITS = RLIMIT_NLIMITS
+#define RLIMIT_NLIMITS RLIMIT_NLIMITS
+#define RLIM_NLIMITS RLIM_NLIMITS
+};
+
+/* Value to indicate that there is no limit.  */
+#ifndef __USE_FILE_OFFSET64
+# define RLIM_INFINITY ((unsigned long int)(~0UL))
+#else
+# define RLIM_INFINITY 0xffffffffffffffffuLL
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define RLIM64_INFINITY 0xffffffffffffffffuLL
+#endif
+
+/* We can represent all limits.  */
+#define RLIM_SAVED_MAX	RLIM_INFINITY
+#define RLIM_SAVED_CUR	RLIM_INFINITY
+
+
+/* Type for resource quantity measurement.  */
+#ifndef __USE_FILE_OFFSET64
+typedef __rlim_t rlim_t;
+#else
+typedef __rlim64_t rlim_t;
+#endif
+#ifdef __USE_LARGEFILE64
+typedef __rlim64_t rlim64_t;
+#endif
+
+struct rlimit
+  {
+    /* The current (soft) limit.  */
+    rlim_t rlim_cur;
+    /* The hard limit.  */
+    rlim_t rlim_max;
+  };
+
+#ifdef __USE_LARGEFILE64
+struct rlimit64
+  {
+    /* The current (soft) limit.  */
+    rlim64_t rlim_cur;
+    /* The hard limit.  */
+    rlim64_t rlim_max;
+ };
+#endif
+
+/* Whose usage statistics do you want?  */
+enum __rusage_who
+{
+  /* The calling process.  */
+  RUSAGE_SELF = 0,
+#define RUSAGE_SELF RUSAGE_SELF
+
+  /* All of its terminated child processes.  */
+  RUSAGE_CHILDREN = -1,
+#define RUSAGE_CHILDREN RUSAGE_CHILDREN
+
+  /* Both.  */
+  RUSAGE_BOTH = -2
+#define RUSAGE_BOTH RUSAGE_BOTH
+};
+
+#define __need_timeval
+#include <bits/time.h>		/* For `struct timeval'.  */
+
+/* Structure which says how much of each resource has been used.  */
+struct rusage
+  {
+    /* Total amount of user time used.  */
+    struct timeval ru_utime;
+    /* Total amount of system time used.  */
+    struct timeval ru_stime;
+    /* Maximum resident set size (in kilobytes).  */
+    long int ru_maxrss;
+    /* Amount of sharing of text segment memory
+       with other processes (kilobyte-seconds).  */
+    long int ru_ixrss;
+    /* Amount of data segment memory used (kilobyte-seconds).  */
+    long int ru_idrss;
+    /* Amount of stack memory used (kilobyte-seconds).  */
+    long int ru_isrss;
+    /* Number of soft page faults (i.e. those serviced by reclaiming
+       a page from the list of pages awaiting reallocation.  */
+    long int ru_minflt;
+    /* Number of hard page faults (i.e. those that required I/O).  */
+    long int ru_majflt;
+    /* Number of times a process was swapped out of physical memory.  */
+    long int ru_nswap;
+    /* Number of input operations via the file system.  Note: This
+       and `ru_oublock' do not include operations with the cache.  */
+    long int ru_inblock;
+    /* Number of output operations via the file system.  */
+    long int ru_oublock;
+    /* Number of IPC messages sent.  */
+    long int ru_msgsnd;
+    /* Number of IPC messages received.  */
+    long int ru_msgrcv;
+    /* Number of signals delivered.  */
+    long int ru_nsignals;
+    /* Number of voluntary context switches, i.e. because the process
+       gave up the process before it had to (usually to wait for some
+       resource to be available).  */
+    long int ru_nvcsw;
+    /* Number of involuntary context switches, i.e. a higher priority process
+       became runnable or the current process used up its time slice.  */
+    long int ru_nivcsw;
+  };
+
+/* Priority limits.  */
+#define PRIO_MIN	-20	/* Minimum priority a process can have.  */
+#define PRIO_MAX	20	/* Maximum priority a process can have.  */
+
+/* The type of the WHICH argument to `getpriority' and `setpriority',
+   indicating what flavor of entity the WHO argument specifies.  */
+enum __priority_which
+{
+  PRIO_PROCESS = 0,		/* WHO is a process ID.  */
+#define PRIO_PROCESS PRIO_PROCESS
+  PRIO_PGRP = 1,		/* WHO is a process group ID.  */
+#define PRIO_PGRP PRIO_PGRP
+  PRIO_USER = 2			/* WHO is a user ID.  */
+#define PRIO_USER PRIO_USER
+};
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/sem.h b/sysdeps/unix/sysv/linux/x86_64/bits/sem.h
new file mode 100644
index 0000000000..9b1d993ee5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/sem.h
@@ -0,0 +1,87 @@
+/* Copyright (C) 2002 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 _SYS_SEM_H
+# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
+#endif
+
+#include <sys/types.h>
+
+/* Flags for `semop'.  */
+#define SEM_UNDO	0x1000		/* undo the operation on exit */
+
+/* Commands for `semctl'.  */
+#define GETPID		11		/* get sempid */
+#define GETVAL		12		/* get semval */
+#define GETALL		13		/* get all semval's */
+#define GETNCNT		14		/* get semncnt */
+#define GETZCNT		15		/* get semzcnt */
+#define SETVAL		16		/* set semval */
+#define SETALL		17		/* set all semval's */
+
+
+/* Data structure describing a set of semaphores.  */
+struct semid_ds
+{
+  struct ipc_perm sem_perm;		/* operation permission struct */
+  __time_t sem_otime;			/* last semop() time */
+  unsigned long int __unused1;
+  __time_t sem_ctime;			/* last time changed by semctl() */
+  unsigned long int __unused2;
+  unsigned long int sem_nsems;		/* number of semaphores in set */
+  unsigned long int __unused3;
+  unsigned long int __unused4;
+};
+
+/* The user should define a union like the following to use it for arguments
+   for `semctl'.
+
+   union semun
+   {
+     int val;				<= value for SETVAL
+     struct semid_ds *buf;		<= buffer for IPC_STAT & IPC_SET
+     unsigned short int *array;		<= array for GETALL & SETALL
+     struct seminfo *__buf;		<= buffer for IPC_INFO
+   };
+
+   Previous versions of this file used to define this union but this is
+   incorrect.  One can test the macro _SEM_SEMUN_UNDEFINED to see whether
+   one must define the union or not.  */
+#define _SEM_SEMUN_UNDEFINED	1
+
+#ifdef __USE_MISC
+
+/* ipcs ctl cmds */
+# define SEM_STAT 18
+# define SEM_INFO 19
+
+struct  seminfo
+{
+  int semmap;
+  int semmni;
+  int semmns;
+  int semmnu;
+  int semmsl;
+  int semopm;
+  int semume;
+  int semusz;
+  int semvmx;
+  int semaem;
+};
+
+#endif /* __USE_MISC */
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/shm.h b/sysdeps/unix/sysv/linux/x86_64/bits/shm.h
new file mode 100644
index 0000000000..ff1fa7ad0f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/shm.h
@@ -0,0 +1,99 @@
+/* Copyright (C) 1995, 1996, 1997, 2000,2002 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 _SYS_SHM_H
+# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Permission flag for shmget.  */
+#define SHM_R		0400		/* or S_IRUGO from <linux/stat.h> */
+#define SHM_W		0200		/* or S_IWUGO from <linux/stat.h> */
+
+/* Flags for `shmat'.  */
+#define SHM_RDONLY	010000		/* attach read-only else read-write */
+#define SHM_RND		020000		/* round attach address to SHMLBA */
+#define SHM_REMAP	040000		/* take-over region on attach */
+
+/* Commands for `shmctl'.  */
+#define SHM_LOCK	11		/* lock segment (root only) */
+#define SHM_UNLOCK	12		/* unlock segment (root only) */
+
+
+/* Type to count number of attaches.  */
+typedef unsigned long int shmatt_t;
+
+/* Data structure describing a set of semaphores.  */
+struct shmid_ds
+  {
+    struct ipc_perm shm_perm;		/* operation permission struct */
+    size_t shm_segsz;			/* size of segment in bytes */
+    __time_t shm_atime;			/* time of last shmat() */
+#if __WORDSIZE == 32
+    unsigned long int __unused1;
+#endif
+    __time_t shm_dtime;			/* time of last shmdt() */
+#if __WORDSIZE == 32
+    unsigned long int __unused2;
+#endif
+    __time_t shm_ctime;			/* time of last change by shmctl() */
+#if __WORDSIZE == 32
+    unsigned long int __unused3;
+#endif
+    __pid_t shm_cpid;			/* pid of creator */
+    __pid_t shm_lpid;			/* pid of last shmop */
+    shmatt_t shm_nattch;		/* number of current attaches */
+    unsigned long int __unused4;
+    unsigned long int __unused5;
+  };
+
+#ifdef __USE_MISC
+
+/* ipcs ctl commands */
+# define SHM_STAT 	13
+# define SHM_INFO 	14
+
+/* shm_mode upper byte flags */
+# define SHM_DEST	01000	/* segment will be destroyed on last detach */
+# define SHM_LOCKED	02000   /* segment will not be swapped */
+
+struct	shminfo
+  {
+    unsigned long int shmmax;
+    unsigned long int shmmin;
+    unsigned long int shmmni;
+    unsigned long int shmseg;
+    unsigned long int shmall;
+    unsigned long int __unused1;
+    unsigned long int __unused2;
+    unsigned long int __unused3;
+    unsigned long int __unused4;
+  };
+
+struct shm_info
+  {
+    int used_ids;
+    unsigned long int shm_tot;	/* total allocated shm */
+    unsigned long int shm_rss;	/* total resident shm */
+    unsigned long int shm_swp;	/* total swapped shm */
+    unsigned long int swap_attempts;
+    unsigned long int swap_successes;
+  };
+
+#endif /* __USE_MISC */
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/sigcontext.h b/sysdeps/unix/sysv/linux/x86_64/bits/sigcontext.h
new file mode 100644
index 0000000000..3426d8c47e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/sigcontext.h
@@ -0,0 +1,139 @@
+/* Copyright (C) 2002 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_SIGCONTEXT_H
+#define _BITS_SIGCONTEXT_H  1
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+#include <bits/wordsize.h>
+
+struct _fpreg
+{
+  unsigned short significand[4];
+  unsigned short exponent;
+};
+
+struct _fpxreg
+{
+  unsigned short significand[4];
+  unsigned short exponent;
+  unsigned short padding[3];
+};
+
+struct _xmmreg
+{
+  __uint32_t	element[4];
+};
+
+/* This is FXSAVE layout without 64bit prefix thus 32bit
+   compatible. This means that the IP and DPs are only 32bit and are
+   not useful in 64bit space.  */
+struct _fpstate
+{
+  /* Regular FPU environment.  */
+  __uint32_t	cw;
+  __uint32_t		sw;
+  __uint32_t		tag;
+  __uint32_t		ipoff;
+  __uint32_t		cssel;
+  __uint32_t		dataoff;
+  __uint32_t		datasel;
+  struct _fpreg	_st[8];
+  unsigned short status;
+  unsigned short magic;
+
+  /* FXSR FPU environment.  */
+  __uint32_t		_fxsr_env[6];
+  __uint32_t		mxcsr;
+  __uint32_t		reserved;
+  struct _fpxreg _fxsr_st[8];
+  struct _xmmreg _xmm[8];	/* It's actually 16 for x86-64.	 */
+  __uint32_t		padding[56];
+};
+
+
+#if __WORDSIZE == 32
+
+struct sigcontext
+{
+  unsigned short gs, __gsh;
+  unsigned short fs, __fsh;
+  unsigned short es, __esh;
+  unsigned short ds, __dsh;
+  unsigned long edi;
+  unsigned long esi;
+  unsigned long ebp;
+  unsigned long esp;
+  unsigned long ebx;
+  unsigned long edx;
+  unsigned long ecx;
+  unsigned long eax;
+  unsigned long trapno;
+  unsigned long err;
+  unsigned long eip;
+  unsigned short cs, __csh;
+  unsigned long eflags;
+  unsigned long esp_at_signal;
+  unsigned short ss, __ssh;
+  struct _fpstate * fpstate;
+  unsigned long oldmask;
+  unsigned long cr2;
+};
+
+#else
+
+struct sigcontext
+{
+  unsigned short gs, __gsh;
+  unsigned short fs, __fsh;
+  unsigned short es, __esh;
+  unsigned short ds, __dsh;
+  unsigned long r8;
+  unsigned long r9;
+  unsigned long r10;
+  unsigned long r12;
+  unsigned long r13;
+  unsigned long r14;
+  unsigned long r15;
+  unsigned long rdi;
+  unsigned long rsi;
+  unsigned long rbp;
+  unsigned long rbx;
+  unsigned long rdx;
+  unsigned long rax;
+  unsigned long trapno;
+  unsigned long err;
+  unsigned long rip;
+  unsigned short cs, __csh;
+  unsigned int __pad0;
+  unsigned long eflags;
+  unsigned long rsp_at_signal;
+  struct _fpstate * fpstate;
+  unsigned long oldmask;
+  unsigned long cr2;
+  unsigned long r11;
+  unsigned long rcx;
+  unsigned long rsp;
+};
+
+#endif
+
+#endif /* _BITS_SIGCONTEXT_H */
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/socket.h b/sysdeps/unix/sysv/linux/x86_64/bits/socket.h
new file mode 100644
index 0000000000..df3d3f6fe7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/socket.h
@@ -0,0 +1,321 @@
+/* System-specific socket constants and types.  Linux/x86-64 version.
+   Copyright (C) 2002 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_SOCKET_H
+#define __BITS_SOCKET_H
+
+#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
+# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
+#endif
+
+#define	__need_size_t
+#define __need_NULL
+#include <stddef.h>
+
+#include <limits.h>
+#include <sys/types.h>
+
+/* Type for length arguments in socket calls.  */
+#ifndef __socklen_t_defined
+typedef __socklen_t socklen_t;
+# define __socklen_t_defined
+#endif
+
+/* Types of sockets.  */
+enum __socket_type
+{
+  SOCK_STREAM = 1,		/* Sequenced, reliable, connection-based
+				   byte streams.  */
+#define SOCK_STREAM SOCK_STREAM
+  SOCK_DGRAM = 2,		/* Connectionless, unreliable datagrams
+				   of fixed maximum length.  */
+#define SOCK_DGRAM SOCK_DGRAM
+  SOCK_RAW = 3,			/* Raw protocol interface.  */
+#define SOCK_RAW SOCK_RAW
+  SOCK_RDM = 4,			/* Reliably-delivered messages.  */
+#define SOCK_RDM SOCK_RDM
+  SOCK_SEQPACKET = 5,		/* Sequenced, reliable, connection-based,
+				   datagrams of fixed maximum length.  */
+#define SOCK_SEQPACKET SOCK_SEQPACKET
+  SOCK_PACKET = 10		/* Linux specific way of getting packets
+				   at the dev level.  For writing rarp and
+				   other similar things on the user level. */
+#define SOCK_PACKET SOCK_PACKET
+};
+
+/* Protocol families.  */
+#define	PF_UNSPEC	0	/* Unspecified.  */
+#define	PF_LOCAL	1	/* Local to host (pipes and file-domain).  */
+#define	PF_UNIX		PF_LOCAL /* Old BSD name for PF_LOCAL.  */
+#define	PF_FILE		PF_LOCAL /* Another non-standard name for PF_LOCAL.  */
+#define	PF_INET		2	/* IP protocol family.  */
+#define	PF_AX25		3	/* Amateur Radio AX.25.  */
+#define	PF_IPX		4	/* Novell Internet Protocol.  */
+#define	PF_APPLETALK	5	/* Appletalk DDP.  */
+#define	PF_NETROM	6	/* Amateur radio NetROM.  */
+#define	PF_BRIDGE	7	/* Multiprotocol bridge.  */
+#define	PF_ATMPVC	8	/* ATM PVCs.  */
+#define	PF_X25		9	/* Reserved for X.25 project.  */
+#define	PF_INET6	10	/* IP version 6.  */
+#define	PF_ROSE		11	/* Amateur Radio X.25 PLP.  */
+#define	PF_DECnet	12	/* Reserved for DECnet project.  */
+#define	PF_NETBEUI	13	/* Reserved for 802.2LLC project.  */
+#define	PF_SECURITY	14	/* Security callback pseudo AF.  */
+#define	PF_KEY		15	/* PF_KEY key management API.  */
+#define	PF_NETLINK	16
+#define	PF_ROUTE	PF_NETLINK /* Alias to emulate 4.4BSD.  */
+#define	PF_PACKET	17	/* Packet family.  */
+#define	PF_ASH		18	/* Ash.  */
+#define	PF_ECONET	19	/* Acorn Econet.  */
+#define	PF_ATMSVC	20	/* ATM SVCs.  */
+#define	PF_SNA		22	/* Linux SNA Project */
+#define	PF_IRDA		23	/* IRDA sockets.  */
+#define	PF_PPPOX	24	/* PPPoX sockets.  */
+#define	PF_WANPIPE	25	/* Wanpipe API sockets.  */
+#define	PF_BLUETOOTH	31	/* Bluetooth sockets.  */
+#define	PF_MAX		32	/* For now..  */
+
+/* Address families.  */
+#define	AF_UNSPEC	PF_UNSPEC
+#define	AF_LOCAL	PF_LOCAL
+#define	AF_UNIX		PF_UNIX
+#define	AF_FILE		PF_FILE
+#define	AF_INET		PF_INET
+#define	AF_AX25		PF_AX25
+#define	AF_IPX		PF_IPX
+#define	AF_APPLETALK	PF_APPLETALK
+#define	AF_NETROM	PF_NETROM
+#define	AF_BRIDGE	PF_BRIDGE
+#define	AF_ATMPVC	PF_ATMPVC
+#define	AF_X25		PF_X25
+#define	AF_INET6	PF_INET6
+#define	AF_ROSE		PF_ROSE
+#define	AF_DECnet	PF_DECnet
+#define	AF_NETBEUI	PF_NETBEUI
+#define	AF_SECURITY	PF_SECURITY
+#define	AF_KEY		PF_KEY
+#define	AF_NETLINK	PF_NETLINK
+#define	AF_ROUTE	PF_ROUTE
+#define	AF_PACKET	PF_PACKET
+#define	AF_ASH		PF_ASH
+#define	AF_ECONET	PF_ECONET
+#define	AF_ATMSVC	PF_ATMSVC
+#define	AF_SNA		PF_SNA
+#define	AF_IRDA		PF_IRDA
+#define	AF_PPPOX	PF_PPPOX
+#define	AF_WANPIPE	PF_WANPIPE
+#define	AF_BLUETOOTH	PF_BLUETOOTH
+#define	AF_MAX		PF_MAX
+
+/* Socket level values.  Others are defined in the appropriate headers.
+
+   XXX These definitions also should go into the appropriate headers as
+   far as they are available.  */
+#define SOL_RAW		255
+#define SOL_DECNET      261
+#define SOL_X25         262
+#define SOL_PACKET	263
+#define SOL_ATM		264	/* ATM layer (cell level).  */
+#define SOL_AAL		265	/* ATM Adaption Layer (packet level).  */
+#define SOL_IRDA	266
+
+/* Maximum queue length specifiable by listen.  */
+#define SOMAXCONN	128
+
+/* Get the definition of the macro to define the common sockaddr members.  */
+#include <bits/sockaddr.h>
+
+/* Structure describing a generic socket address.  */
+struct sockaddr
+  {
+    __SOCKADDR_COMMON (sa_);	/* Common data: address family and length.  */
+    char sa_data[14];		/* Address data.  */
+  };
+
+
+/* Structure large enough to hold any socket address (with the historical
+   exception of AF_UNIX).  We reserve 128 bytes.  */
+#if ULONG_MAX > 0xffffffff
+# define __ss_aligntype	__uint64_t
+#else
+# define __ss_aligntype	__uint32_t
+#endif
+#define _SS_SIZE	128
+#define _SS_PADSIZE	(_SS_SIZE - (2 * sizeof (__ss_aligntype)))
+
+struct sockaddr_storage
+  {
+    __SOCKADDR_COMMON (ss_);	/* Address family, etc.  */
+    __ss_aligntype __ss_align;	/* Force desired alignment.  */
+    char __ss_padding[_SS_PADSIZE];
+  };
+
+
+/* Bits in the FLAGS argument to `send', `recv', et al.  */
+enum
+  {
+    MSG_OOB		= 0x01,	/* Process out-of-band data.  */
+#define MSG_OOB		MSG_OOB
+    MSG_PEEK		= 0x02,	/* Peek at incoming messages.  */
+#define MSG_PEEK	MSG_PEEK
+    MSG_DONTROUTE	= 0x04,	/* Don't use local routing.  */
+#define MSG_DONTROUTE	MSG_DONTROUTE
+#ifdef __USE_GNU
+    /* DECnet uses a different name.  */
+    MSG_TRYHARD		= MSG_DONTROUTE,
+# define MSG_TRYHARD	MSG_DONTROUTE
+#endif
+    MSG_CTRUNC		= 0x08,	/* Control data lost before delivery.  */
+#define MSG_CTRUNC	MSG_CTRUNC
+    MSG_PROXY		= 0x10,	/* Supply or ask second address.  */
+#define MSG_PROXY	MSG_PROXY
+    MSG_TRUNC		= 0x20,
+#define	MSG_TRUNC	MSG_TRUNC
+    MSG_DONTWAIT	= 0x40, /* Nonblocking IO.  */
+#define	MSG_DONTWAIT	MSG_DONTWAIT
+    MSG_EOR		= 0x80, /* End of record.  */
+#define	MSG_EOR		MSG_EOR
+    MSG_WAITALL		= 0x100, /* Wait for a full request.  */
+#define	MSG_WAITALL	MSG_WAITALL
+    MSG_FIN		= 0x200,
+#define	MSG_FIN		MSG_FIN
+    MSG_SYN		= 0x400,
+#define	MSG_SYN		MSG_SYN
+    MSG_CONFIRM		= 0x800, /* Confirm path validity.  */
+#define	MSG_CONFIRM	MSG_CONFIRM
+    MSG_RST		= 0x1000,
+#define	MSG_RST		MSG_RST
+    MSG_ERRQUEUE	= 0x2000, /* Fetch message from error queue.  */
+#define	MSG_ERRQUEUE	MSG_ERRQUEUE
+    MSG_NOSIGNAL	= 0x4000, /* Do not generate SIGPIPE.  */
+#define	MSG_NOSIGNAL	MSG_NOSIGNAL
+    MSG_MORE		= 0x8000  /* Sender will send more.  */
+#define	MSG_MORE	MSG_MORE
+  };
+
+
+/* Structure describing messages sent by
+   `sendmsg' and received by `recvmsg'.  */
+struct msghdr
+  {
+    void *msg_name;		/* Address to send to/receive from.  */
+    socklen_t msg_namelen;	/* Length of address data.  */
+
+    struct iovec *msg_iov;	/* Vector of data to send/receive into.  */
+#if __WORDSIZE == 32
+    int msg_iovlen;		/* Number of elements in the vector.  */
+
+    void *msg_control;		/* Ancillary data (eg BSD filedesc passing). */
+    socklen_t msg_controllen;	/* Ancillary data buffer length.  */
+#else
+    size_t msg_iovlen;		/* Number of elements in the vector.  */
+
+    void *msg_control;		/* Ancillary data (eg BSD filedesc passing). */
+    size_t msg_controllen;	/* Ancillary data buffer length.  */
+#endif
+    int msg_flags;		/* Flags on received message.  */
+  };
+
+/* Structure used for storage of ancillary data object information.  */
+struct cmsghdr
+  {
+    size_t cmsg_len;		/* Length of data in cmsg_data plus length
+				   of cmsghdr structure.  */
+    int cmsg_level;		/* Originating protocol.  */
+    int cmsg_type;		/* Protocol specific type.  */
+#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
+    __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data.  */
+#endif
+  };
+
+/* Ancillary data object manipulation macros.  */
+#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
+# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
+#else
+# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
+#endif
+#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
+#define CMSG_FIRSTHDR(mhdr) \
+  ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr)		      \
+   ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL)
+#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
+			 & (size_t) ~(sizeof (size_t) - 1))
+#define CMSG_SPACE(len) (CMSG_ALIGN (len) \
+			 + CMSG_ALIGN (sizeof (struct cmsghdr)))
+#define CMSG_LEN(len)   (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+
+extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
+				      struct cmsghdr *__cmsg) __THROW;
+#ifdef __USE_EXTERN_INLINES
+# ifndef _EXTERN_INLINE
+#  define _EXTERN_INLINE extern __inline
+# endif
+_EXTERN_INLINE struct cmsghdr *
+__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg) __THROW
+{
+  if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
+    /* The kernel header does this so there may be a reason.  */
+    return 0;
+
+  __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
+			       + CMSG_ALIGN (__cmsg->cmsg_len));
+  if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
+					+ __mhdr->msg_controllen)
+      || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
+	  > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
+    /* No more entries.  */
+    return 0;
+  return __cmsg;
+}
+#endif	/* Use `extern inline'.  */
+
+/* Socket level message types.  This must match the definitions in
+   <linux/socket.h>.  */
+enum
+  {
+    SCM_RIGHTS = 0x01,		/* Transfer file descriptors.  */
+#define SCM_RIGHTS SCM_RIGHTS
+#ifdef __USE_BSD
+    SCM_CREDENTIALS = 0x02,     /* Credentials passing.  */
+# define SCM_CREDENTIALS SCM_CREDENTIALS
+#endif
+    __SCM_CONNECT = 0x03	/* Data array is `struct scm_connect'.  */
+  };
+
+/* User visible structure for SCM_CREDENTIALS message */
+
+struct ucred
+{
+  pid_t pid;			/* PID of sending process.  */
+  uid_t uid;			/* UID of sending process.  */
+  gid_t gid;			/* GID of sending process.  */
+};
+
+/* Get socket manipulation related informations from kernel headers.  */
+#include <asm/socket.h>
+
+
+/* Structure used to manipulate the SO_LINGER option.  */
+struct linger
+  {
+    int l_onoff;		/* Nonzero to linger on close.  */
+    int l_linger;		/* Time to linger.  */
+  };
+
+#endif	/* bits/socket.h */
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/stat.h b/sysdeps/unix/sysv/linux/x86_64/bits/stat.h
index 818a58b585..8c74b3ff53 100644
--- a/sysdeps/unix/sysv/linux/x86_64/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2001, 2002 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
@@ -25,44 +25,101 @@
 #define _STAT_VER_LINUX		1
 #define _STAT_VER		_STAT_VER_LINUX
 
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX	0
+#if __WORDSIZE == 32
+# define _STAT_VER_SVR4		2
+# define _STAT_VER_LINUX	3
+
+/* i386 versions of the `xmknod' interface.  */
+# define _MKNOD_VER_LINUX	1
+# define _MKNOD_VER_SVR4	2
+# define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits defined below.  */
+#else
+/* x86-64 versions of the `xmknod' interface.  */
+# define _MKNOD_VER_LINUX	0
+#endif
 
 struct stat
   {
     __dev_t st_dev;		/* Device.  */
+#if __WORDSIZE == 32
+    unsigned short int __pad1;
+#endif
+#if __WORDSIZE == 64 || !defined __USE_FILE_OFFSET64
     __ino_t st_ino;		/* File serial number.	*/
+#else
+    __ino_t __st_ino;			/* 32bit file serial number.	*/
+#endif
+#if __WORDSIZE == 32
+    __mode_t st_mode;			/* File mode.  */
+    __nlink_t st_nlink;			/* Link count.  */
+#else
     __nlink_t st_nlink;		/* Link count.  */
     __mode_t st_mode;		/* File mode.  */
+#endif
     __uid_t st_uid;		/* User ID of the file's owner.	*/
     __gid_t st_gid;		/* Group ID of the file's group.*/
+#if __WORDSIZE == 64
     int pad0;
+#endif
     __dev_t st_rdev;		/* Device number, if device.  */
-    __off_t st_size;		/* Size of file, in bytes.  */
+#if __WORDSIZE == 32
+    unsigned short int __pad2;
+#endif
+#if __WORDSIZE == 64 || !defined __USE_FILE_OFFSET64
+    __off_t st_size;			/* Size of file, in bytes.  */
+#else
+    __off64_t st_size;			/* Size of file, in bytes.  */
+#endif
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
-    __blkcnt_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
+#if __WORDSIZE == 64 || !defined __USE_FILE_OFFSET64
+    __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
+#else
+    __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
+#endif
     __time_t st_atime;		/* Time of last access.  */
     long int __reserved0;	/* Reserved for atime.nanoseconds.  */
     __time_t st_mtime;		/* Time of last modification.  */
     long int __reserved1;	/* Reserved for mtime.nanoseconds.  */
     __time_t st_ctime;		/* Time of last status change.  */
     long int __reserved2;	/* Reserved for ctime.nanoseconds.  */
+#if __WORDSIZE == 64
     long int __unused[3];
+#else
+# ifndef __USE_FILE_OFFSET64
+    unsigned long int __unused4;
+    unsigned long int __unused5;
+# else
+    __ino64_t st_ino;			/* File serial number.	*/
+# endif
+#endif
   };
 
 #ifdef __USE_LARGEFILE64
-/* Note stat64 has the same shape as stat.  */
+/* Note stat64 has the same shape as stat for x86-64.  */
 struct stat64
   {
     __dev_t st_dev;		/* Device.  */
+#if __WORDSIZE == 64
     __ino64_t st_ino;		/* File serial number.  */
     __nlink_t st_nlink;		/* Link count.  */
     __mode_t st_mode;		/* File mode.  */
+#else
+    unsigned int __pad1;
+    __ino_t __st_ino;			/* 32bit file serial number.	*/
+    __mode_t st_mode;			/* File mode.  */
+    __nlink_t st_nlink;			/* Link count.  */
+#endif
     __uid_t st_uid;		/* User ID of the file's owner.	*/
     __gid_t st_gid;		/* Group ID of the file's group.*/
+#if __WORDSIZE == 64
     int pad0;
     __dev_t st_rdev;		/* Device number, if device.  */
     __off_t st_size;		/* Size of file, in bytes.  */
+#else
+    __dev_t st_rdev;			/* Device number, if device.  */
+    unsigned int __pad2;
+    __off64_t st_size;			/* Size of file, in bytes.  */
+#endif
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
     __blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
     __time_t st_atime;		/* Time of last access.  */
@@ -71,7 +128,11 @@ struct stat64
     long int __reserved1;	/* Reserved for mtime.nanoseconds.  */
     __time_t st_ctime;		/* Time of last status change.  */
     long int __reserved2;	/* Reserved for ctime.nanoseconds.  */
+#if __WORDSIZE == 64
     long int __unused[3];
+#else
+    __ino64_t st_ino;			/* File serial number.		*/
+#endif
   };
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/types.h b/sysdeps/unix/sysv/linux/x86_64/bits/types.h
index 36eec20111..640a336b17 100644
--- a/sysdeps/unix/sysv/linux/x86_64/bits/types.h
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/types.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2002 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
@@ -27,35 +27,69 @@
 
 #define __need_size_t
 #include <stddef.h>
+#include <bits/wordsize.h>
 
 /* Convenience types.  */
 typedef unsigned char __u_char;
 typedef unsigned short int __u_short;
 typedef unsigned int __u_int;
 typedef unsigned long int __u_long;
+#if __WORDSIZE == 64
 typedef unsigned long int __u_quad_t;
 typedef long int __quad_t;
+#else
+# ifdef __GLIBC_HAVE_LONG_LONG
+__extension__ typedef unsigned long long int __u_quad_t;
+__extension__ typedef long long int __quad_t;
+# else
+typedef struct
+  {
+    long int __val[2];
+  } __quad_t;
+typedef struct
+  {
+    __u_long __val[2];
+  } __u_quad_t;
+# endif
+#endif
 typedef signed char __int8_t;
 typedef unsigned char __uint8_t;
 typedef signed short int __int16_t;
 typedef unsigned short int __uint16_t;
 typedef signed int __int32_t;
 typedef unsigned int __uint32_t;
+#if __WORDSIZE == 64
 typedef signed long int __int64_t;
 typedef unsigned long int __uint64_t;
+#else
+# ifdef __GLIBC_HAVE_LONG_LONG
+__extension__ typedef signed long long int __int64_t;
+__extension__ typedef unsigned long long int __uint64_t;
+# endif
+#endif
 typedef __quad_t *__qaddr_t;
 
 typedef __uint64_t __dev_t;		/* Type of device numbers.  */
 typedef __uint32_t __uid_t;		/* Type of user identifications.  */
 typedef __uint32_t __gid_t;		/* Type of group identifications.  */
+#if __WORDSIZE == 64
 typedef __uint64_t __ino_t;		/* Type of file serial numbers.  */
+#else
+typedef __u_long__ino_t;		/* Type of file serial numbers.  */
+#endif
 typedef __uint64_t __ino64_t;		/*  "" (LFS) */
 typedef __uint32_t __mode_t;		/* Type of file attribute bitmasks.  */
+#if __WORDSIZE == 64
 typedef __uint64_t __nlink_t;		/* Type of file link counts.  */
 typedef __int64_t  __off_t;		/* Type of file sizes and offsets.  */
+#else
+typedef __u_int __nlink_t;		/* Type of file link counts.  */
+typedef long int __off_t;		/* Type of file sizes and offsets.  */
+#endif
 typedef __int64_t  __off64_t;		/*  "" (LFS) */
 typedef __int64_t  __loff_t;		/* Type of file sizes and offsets.  */
 typedef __int32_t  __pid_t;		/* Type of process identifications.  */
+#if __WORDSIZE == 64
 typedef __int64_t  __ssize_t;		/* Type of a byte count, or error.  */
 typedef __uint64_t  __rlim_t;		/* Type of resource counts.  */
 typedef __uint64_t  __rlim64_t;		/*  "" (LFS) */
@@ -66,6 +100,18 @@ typedef __uint64_t __fsblkcnt64_t;	/*  "" (LFS) */
 typedef __uint64_t __fsfilcnt_t;	/* Type to count file system inodes.  */
 typedef __uint64_t __fsfilcnt64_t;	/*  "" (LFS) */
 typedef __uint32_t __id_t;		/* General type for IDs.  */
+#else
+typedef int __ssize_t;			/* Type of a byte count, or error.  */
+typedef __u_long __rlim_t;		/* Type of resource counts.  */
+typedef __u_quad_t __rlim64_t;		/* Type of resource counts (LFS).  */
+typedef long int  __blkcnt_t;		/* Type to count nr disk blocks.  */
+typedef __quad_t  __blkcnt64_t;		/*  "" (LFS) */
+typedef __long __fsblkcnt_t;		/* Type to count file system blocks.  */
+typedef __u_quad_t __fsblkcnt64_t;	/*  "" (LFS) */
+typedef __u_long __fsfilcnt_t;		/* Type to count file system inodes.  */
+typedef __u_quad_t __fsfilcnt64_t;	/*  "" (LFS) */
+typedef __u_int __id_t;			/* General type for ID.  */
+#endif
 
 typedef struct
   {
@@ -89,7 +135,11 @@ typedef int __clockid_t;
 typedef int __timer_t;
 
 /* Used in `struct shmid_ds'.  */
+#if __WORDSIZE == 64
 typedef int __ipc_pid_t;
+#else
+typedef unsigned short int __ipc_pid_t;
+#endif
 
 /* type to represent block size. */
 typedef long int __blksize_t;
@@ -102,11 +152,20 @@ typedef long int __blksize_t;
 #define __FD_SETSIZE	1024
 
 /* Used in XTI.  */
+#if __WORDSIZE == 64
 typedef int __t_scalar_t;
 typedef unsigned int __t_uscalar_t;
+#else
+typedef long int __t_scalar_t;
+typedef unsigned long int __t_uscalar_t;
+#endif
 
 /* Duplicates info from stdint.h but this is used in unistd.h.  */
+#if __WORDSIZE == 64
 typedef long int __intptr_t;
+#else
+typedef int __intptr_t;
+#endif
 
 /* Duplicate info from sys/socket.h.  */
 typedef unsigned int __socklen_t;
diff --git a/sysdeps/x86_64/bits/setjmp.h b/sysdeps/x86_64/bits/setjmp.h
index be39482d09..ba5dd2c112 100644
--- a/sysdeps/x86_64/bits/setjmp.h
+++ b/sysdeps/x86_64/bits/setjmp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2002 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
@@ -22,26 +22,53 @@
 # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
 #endif
 
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+
 /* We only need to save callee-saved registers plus stackpointer and
    program counter.  */
-#if defined __USE_MISC || defined _ASM
-# define JB_RBX	0
-# define JB_RBP	1
-# define JB_R12	2
-# define JB_R13	3
-# define JB_R14	4
-# define JB_R15	5
-# define JB_RSP	6
-# define JB_PC	7
-# define JB_SIZE (8*8)
+# if defined __USE_MISC || defined _ASM
+#  define JB_RBX	0
+#  define JB_RBP	1
+#  define JB_R12	2
+#  define JB_R13	3
+#  define JB_R14	4
+#  define JB_R15	5
+#  define JB_RSP	6
+#  define JB_PC	7
+#  define JB_SIZE (8*8)
+# endif
+
+#else
+
+# if defined __USE_MISC || defined _ASM
+#  define JB_BX	0
+#  define JB_SI	1
+#  define JB_DI	2
+#  define JB_BP	3
+#  define JB_SP	4
+#  define JB_PC	5
+#  define JB_SIZE 24
+# endif
+
 #endif
 
 #ifndef _ASM
 
+# if __WORDSIZE == 64
 typedef long int __jmp_buf[8];
+# else
+typedef int __jmp_buf[6];
+# endif
 
 /* Test if longjmp to JMPBUF would unwind the frame
    containing a local variable at ADDRESS.  */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
+# if __WORDSIZE == 64
+#  define _JMPBUF_UNWINDS(jmpbuf, address) \
   ((void *) (address) < (void *) (jmpbuf)[JB_RSP])
+# else
+#  define _JMPBUF_UNWINDS(jmpbuf, address) \
+  ((void *) (address) < (void *) (jmpbuf)[JB_SP])
+# endif
 #endif