This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] 2.3.39+ IPC for glibc 2.2


Hi!

This is the initial cut of 2.3.39 IPC for glibc 2.2.
I haven't been able to test it much besides compilation so far.
This version of *ctl functions cannot set some internal cache of whether new
IPC is present or not, amybe we should copy those three files to linux/i386/
as well and use there __libc_missing_32bit_uids to determine which one
should it try. That variable would have to go to 3 states though, and if
none of the 32bit uid syscalls have been invoked yet, then it would try
getuid32 or some other fast syscall to see whether it is in or not.

2000-01-17  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/unix/sysv/linux/bits/ipc.h: New file.
	* sysdeps/unix/sysv/linux/bits/sem.h: New file.
	* sysdeps/unix/sysv/linux/bits/shm.h: New file.
	* sysdeps/unix/sysv/linux/bits/msg.h: New file.
	* sysdeps/unix/sysv/linux/bits/alpha/ipc.h: Update for new ipc.
	* sysdeps/unix/sysv/linux/bits/alpha/sem.h: New file.
	* sysdeps/unix/sysv/linux/bits/alpha/shm.h: New file.
	* sysdeps/unix/sysv/linux/bits/alpha/msg.h: New file.
	* sysdeps/unix/sysv/linux/bits/sparc/ipc.h: New file.
	* sysdeps/unix/sysv/linux/bits/sparc/sem.h: New file.
	* sysdeps/unix/sysv/linux/bits/sparc/shm.h: New file.
	* sysdeps/unix/sysv/linux/bits/sparc/msg.h: New file.

	* sysdeps/unix/sysv/linux/msgctl.c (__old_msgctl):
	Renamed from msgctl.
	(__new_msgctl): New function.
	* sysdeps/unix/sysv/linux/semctl.c (__old_semctl):
	Renamed from semctl.
	(__new_semctl): New function.
	* sysdeps/unix/sysv/linux/shmctl.c (__old_shmctl):
	Renamed from shmctl.
	(__new_shmctl): New function.

	* sysdeps/unix/sysv/linux/msgget.c: Define __LIBC_IPC_INTERNAL.
	* sysdeps/unix/sysv/linux/msgrcv.c: Likewise.
	* sysdeps/unix/sysv/linux/semget.c: Likewise.
	* sysdeps/unix/sysv/linux/msgsnd.c: Likewise.
	* sysdeps/unix/sysv/linux/semop.c: Likewise.
	* sysdeps/unix/sysv/linux/shmat.c: Likewise.
	* sysdeps/unix/sysv/linux/shmdt.c: Likewise.
	* sysdeps/unix/sysv/linux/shmget.c: Likewise.

	* sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c: New file.
	* sysdeps/unix/sysv/linux/sparc/sparc64/msgctl.c: New file.
	* sysdeps/unix/sysv/linux/sparc/sparc64/shmctl.c: New file.

	* sysdeps/unix/sysv/linux/Versions: Add msgctl, semctl, shmctl.

--- libc/sysdeps/unix/sysv/linux/alpha/bits/msq.h.jj	Mon Jan 17 09:18:45 2000
+++ libc/sysdeps/unix/sysv/linux/alpha/bits/msq.h	Mon Jan 17 11:46:58 2000
@@ -0,0 +1,89 @@
+/* Copyright (C) 1995, 1996, 1997, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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 <sys/types.h>
+
+/* Define options for message queue functions.  */
+#define MSG_NOERROR	010000	/* no error if message is too big */
+#define MSG_EXCEPT	020000	/* recv any msg except of specified type */
+
+
+/* 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 */
+  __time_t msg_rtime;		/* time of last msgrcv command */
+  __time_t msg_ctime;		/* time of last change */
+  unsigned long __msg_cbytes;	/* current number of bytes on queue */
+  unsigned long msg_qnum;	/* number of messages currently on queue */
+  unsigned long 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 __unused1;
+  unsigned long __unused2;
+};
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_msqid_ds
+{
+  struct __old_ipc_perm msg_perm;	/* structure describing operation permission */
+  struct msg *__msg_first;		/* pointer to first message on queue */
+  struct msg *__msg_last;		/* pointer to last message on queue */
+  __time_t msg_stime;			/* time of last msgsnd command */
+  __time_t msg_rtime;			/* time of last msgrcv command */
+  __time_t msg_ctime;			/* time of last change */
+  struct wait_queue *__wwait;		/* ??? */
+  struct wait_queue *__rwait;		/* ??? */
+  unsigned short int __msg_cbytes;	/* current number of bytes on queue */
+  unsigned short int msg_qnum;		/* number of messages currently on queue */
+  unsigned short int msg_qbytes;	/* max number of bytes allowed on queue */
+  __ipc_pid_t msg_lspid;		/* pid of last msgsnd() */
+  __ipc_pid_t msg_lrpid;		/* pid of last msgrcv() */
+};
+
+#endif
+
+#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 */
--- libc/sysdeps/unix/sysv/linux/alpha/bits/sem.h.jj	Mon Jan 17 09:18:50 2000
+++ libc/sysdeps/unix/sysv/linux/alpha/bits/sem.h	Mon Jan 17 11:48:20 2000
@@ -0,0 +1,101 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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 */
+  __time_t sem_ctime;			/* last time changed by semctl() */
+  unsigned long sem_nsems;		/* number of semaphores in set */
+  unsigned long __unused1;
+  unsigned long __unused2;
+};
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_semid_ds
+{
+  struct __old_ipc_perm sem_perm;	/* operation permission struct */
+  __time_t sem_otime;			/* last semop() time */
+  __time_t sem_ctime;			/* last time changed by semctl() */
+  struct sem *__sembase;		/* ptr to first semaphore in array */
+  struct sem_queue *__sem_pending;	/* pending operations */
+  struct sem_queue *__sem_pending_last; /* last pending operation */
+  struct sem_undo *__undo;		/* ondo requests on this array */
+  unsigned short int sem_nsems;		/* number of semaphores in set */
+};
+
+#endif
+
+/* 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 */
--- libc/sysdeps/unix/sysv/linux/alpha/bits/shm.h.jj	Mon Jan 17 09:18:09 2000
+++ libc/sysdeps/unix/sysv/linux/alpha/bits/shm.h	Mon Jan 17 11:49:05 2000
@@ -0,0 +1,115 @@
+/* Copyright (C) 1995, 1996, 1997, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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 <sys/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) */
+
+
+/* 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() */
+    __time_t shm_dtime;			/* time of last shmdt() */
+    __time_t shm_ctime;			/* time of last change by shmctl() */
+    pid_t shm_cpid;			/* pid of creator */
+    pid_t shm_lpid;			/* pid of last shmop */
+    unsigned long shm_nattch;		/* number of current attaches */
+    unsigned long __unused1;
+    unsigned long __unused2;
+  };
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_shmid_ds
+  {
+    struct __old_ipc_perm shm_perm;	/* operation permission struct */
+    int shm_segsz;			/* size of segment in bytes */
+    __time_t shm_atime;			/* time of last shmat() */
+    __time_t shm_dtime;			/* time of last shmdt() */
+    __time_t shm_ctime;			/* time of last change by shmctl() */
+    __ipc_pid_t shm_cpid;		/* pid of creator */
+    __ipc_pid_t shm_lpid;		/* pid of last shmop */
+    unsigned short int shm_nattch;	/* number of current attaches */
+    unsigned short int __shm_npages;	/* size of segment (pages) */
+    unsigned long int *__shm_pages;	/* array of ptrs to frames -> SHMMAX */
+    struct vm_area_struct *__attaches;	/* descriptors for attaches */
+  };
+
+#endif
+
+#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 shmmax;
+    unsigned long shmmin;
+    unsigned long shmmni;
+    unsigned long shmseg;
+    unsigned long shmall;
+    unsigned long __unused1;
+    unsigned long __unused2;
+    unsigned long __unused3;
+    unsigned long __unused4;
+  };
+
+struct	__old_shminfo
+  {
+    int shmmax;
+    int shmmin;
+    int shmmni;
+    int shmseg;
+    int shmall;
+  };
+
+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 */
--- libc/sysdeps/unix/sysv/linux/alpha/bits/ipc.h.jj	Wed Aug 18 09:40:30 1999
+++ libc/sysdeps/unix/sysv/linux/alpha/bits/ipc.h	Mon Jan 17 13:26:43 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 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
@@ -47,9 +47,23 @@ struct ipc_perm
     unsigned int cgid;			/* Creator's group ID.  */
     unsigned int mode;			/* Read/write permission.  */
     unsigned short int __seq;		/* Sequence number.  */
+    unsigned short __pad1;
+    unsigned long __unused1;
+    unsigned long __unused2;
   };
 
+#ifdef __LIBC_IPC_INTERNAL
 
+struct __old_ipc_perm
+  {
+    __key_t __key;			/* Key.  */
+    unsigned int uid;			/* Owner's user ID.  */
+    unsigned int gid;			/* Owner's group ID.  */
+    unsigned int cuid;			/* Creator's user ID.  */
+    unsigned int cgid;			/* Creator's group ID.  */
+    unsigned int mode;			/* Read/write permission.  */
+    unsigned short int __seq;		/* Sequence number.  */
+  };
 
 __BEGIN_DECLS
 
@@ -71,3 +85,5 @@ __END_DECLS
 #define IPCOP_shmdt	22
 #define IPCOP_shmget	23
 #define IPCOP_shmctl	24
+
+#endif
--- libc/sysdeps/unix/sysv/linux/bits/sem.h.jj	Mon Jan 17 09:18:50 2000
+++ libc/sysdeps/unix/sysv/linux/bits/sem.h	Mon Jan 17 10:17:07 2000
@@ -0,0 +1,103 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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 __unused1;
+  __time_t sem_ctime;			/* last time changed by semctl() */
+  unsigned long __unused2;
+  unsigned long sem_nsems;		/* number of semaphores in set */
+  unsigned long __unused3;
+  unsigned long __unused4;
+};
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_semid_ds
+{
+  struct __old_ipc_perm sem_perm;	/* operation permission struct */
+  __time_t sem_otime;			/* last semop() time */
+  __time_t sem_ctime;			/* last time changed by semctl() */
+  struct sem *__sembase;		/* ptr to first semaphore in array */
+  struct sem_queue *__sem_pending;	/* pending operations */
+  struct sem_queue *__sem_pending_last; /* last pending operation */
+  struct sem_undo *__undo;		/* ondo requests on this array */
+  unsigned short int sem_nsems;		/* number of semaphores in set */
+};
+
+#endif
+
+/* 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 */
--- libc/sysdeps/unix/sysv/linux/bits/shm.h.jj	Mon Jan 17 09:18:09 2000
+++ libc/sysdeps/unix/sysv/linux/bits/shm.h	Mon Jan 17 10:17:28 2000
@@ -0,0 +1,118 @@
+/* Copyright (C) 1995, 1996, 1997, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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 <sys/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) */
+
+
+/* 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() */
+    unsigned long __unused1;
+    __time_t shm_dtime;			/* time of last shmdt() */
+    unsigned long __unused2;
+    __time_t shm_ctime;			/* time of last change by shmctl() */
+    unsigned long __unused3;
+    pid_t shm_cpid;			/* pid of creator */
+    pid_t shm_lpid;			/* pid of last shmop */
+    unsigned long shm_nattch;		/* number of current attaches */
+    unsigned long __unused4;
+    unsigned long __unused5;
+  };
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_shmid_ds
+  {
+    struct __old_ipc_perm shm_perm;	/* operation permission struct */
+    int shm_segsz;			/* size of segment in bytes */
+    __time_t shm_atime;			/* time of last shmat() */
+    __time_t shm_dtime;			/* time of last shmdt() */
+    __time_t shm_ctime;			/* time of last change by shmctl() */
+    __ipc_pid_t shm_cpid;		/* pid of creator */
+    __ipc_pid_t shm_lpid;		/* pid of last shmop */
+    unsigned short int shm_nattch;	/* number of current attaches */
+    unsigned short int __shm_npages;	/* size of segment (pages) */
+    unsigned long int *__shm_pages;	/* array of ptrs to frames -> SHMMAX */
+    struct vm_area_struct *__attaches;	/* descriptors for attaches */
+  };
+
+#endif
+
+#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 shmmax;
+    unsigned long shmmin;
+    unsigned long shmmni;
+    unsigned long shmseg;
+    unsigned long shmall;
+    unsigned long __unused1;
+    unsigned long __unused2;
+    unsigned long __unused3;
+    unsigned long __unused4;
+  };
+
+struct	__old_shminfo
+  {
+    int shmmax;
+    int shmmin;
+    int shmmni;
+    int shmseg;
+    int shmall;
+  };
+
+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 */
--- libc/sysdeps/unix/sysv/linux/bits/ipc.h.jj	Mon Jan 17 09:18:42 2000
+++ libc/sysdeps/unix/sysv/linux/bits/ipc.h	Mon Jan 17 13:25:43 2000
@@ -0,0 +1,93 @@
+/* Copyright (C) 1995-1999, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _SYS_IPC_H
+# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Mode bits for `msgget', `semget', and `shmget'.  */
+#define IPC_CREAT	01000		/* Create key if key does not exist. */
+#define IPC_EXCL	02000		/* Fail if key exists.  */
+#define IPC_NOWAIT	04000		/* Return error on wait.  */
+
+/* Control commands for `msgctl', `semctl', and `shmctl'.  */
+#define IPC_RMID	0		/* Remove identifier.  */
+#define IPC_SET		1		/* Set `ipc_perm' options.  */
+#define IPC_STAT	2		/* Get `ipc_perm' options.  */
+#define IPC_INFO	3		/* See ipcs.  */
+
+/* Special key values.  */
+#define IPC_PRIVATE	((__key_t) 0)	/* Private key.  */
+
+#define __IPC_64	0x100
+
+
+/* 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;
+    unsigned long	__unused1;
+    unsigned long	__unused2;
+  };
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_ipc_perm
+  {
+    __key_t __key;			/* Key.  */
+    unsigned short int uid;		/* Owner's user ID.  */
+    unsigned short int gid;		/* Owner's group ID.  */
+    unsigned short int cuid;		/* Creator's user ID.  */
+    unsigned short int cgid;		/* Creator's group ID.  */
+    unsigned short int mode;		/* Read/write permission.  */
+    unsigned short int __seq;		/* Sequence number.  */
+  };
+
+__BEGIN_DECLS
+
+/* The actual system call: all functions are multiplexed by this.  */
+extern int __syscall_ipc (int __call, int __first, int __second,
+			  int __third, void *__ptr);
+
+__END_DECLS
+
+
+/* The codes for the functions to use the multiplexer `__syscall_ipc'.  */
+#define IPCOP_semop	 1
+#define IPCOP_semget	 2
+#define IPCOP_semctl	 3
+#define IPCOP_msgsnd	11
+#define IPCOP_msgrcv	12
+#define IPCOP_msgget	13
+#define IPCOP_msgctl	14
+#define IPCOP_shmat	21
+#define IPCOP_shmdt	22
+#define IPCOP_shmget	23
+#define IPCOP_shmctl	24
+
+#endif /* __LIBC_IPC_INTERNAL */
--- libc/sysdeps/unix/sysv/linux/bits/msq.h.jj	Mon Jan 17 09:18:45 2000
+++ libc/sysdeps/unix/sysv/linux/bits/msq.h	Mon Jan 17 11:10:13 2000
@@ -0,0 +1,92 @@
+/* Copyright (C) 1995, 1996, 1997, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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 <sys/types.h>
+
+/* Define options for message queue functions.  */
+#define MSG_NOERROR	010000	/* no error if message is too big */
+#define MSG_EXCEPT	020000	/* recv any msg except of specified type */
+
+
+/* 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 */
+  unsigned long __unused1;
+  __time_t msg_rtime;		/* time of last msgrcv command */
+  unsigned long __unused2;
+  __time_t msg_ctime;		/* time of last change */
+  unsigned long __unused3;
+  unsigned long __msg_cbytes;	/* current number of bytes on queue */
+  unsigned long msg_qnum;	/* number of messages currently on queue */
+  unsigned long 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 __unused4;
+  unsigned long __unused5;
+};
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_msqid_ds
+{
+  struct __old_ipc_perm msg_perm;	/* structure describing operation permission */
+  struct msg *__msg_first;		/* pointer to first message on queue */
+  struct msg *__msg_last;		/* pointer to last message on queue */
+  __time_t msg_stime;			/* time of last msgsnd command */
+  __time_t msg_rtime;			/* time of last msgrcv command */
+  __time_t msg_ctime;			/* time of last change */
+  struct wait_queue *__wwait;		/* ??? */
+  struct wait_queue *__rwait;		/* ??? */
+  unsigned short int __msg_cbytes;	/* current number of bytes on queue */
+  unsigned short int msg_qnum;		/* number of messages currently on queue */
+  unsigned short int msg_qbytes;	/* max number of bytes allowed on queue */
+  __ipc_pid_t msg_lspid;		/* pid of last msgsnd() */
+  __ipc_pid_t msg_lrpid;		/* pid of last msgrcv() */
+};
+
+#endif
+
+#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 */
--- libc/sysdeps/unix/sysv/linux/sparc/bits/msq.h.jj	Mon Jan 17 09:18:45 2000
+++ libc/sysdeps/unix/sysv/linux/sparc/bits/msq.h	Mon Jan 17 11:59:02 2000
@@ -0,0 +1,99 @@
+/* Copyright (C) 1995, 1996, 1997, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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 <sys/types.h>
+#include <bits/wordsize.h>
+
+/* Define options for message queue functions.  */
+#define MSG_NOERROR	010000	/* no error if message is too big */
+#define MSG_EXCEPT	020000	/* recv any msg except of specified type */
+
+
+/* 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 */
+#if __WORDSIZE == 32
+  unsigned int __pad1;
+#endif
+  __time_t msg_stime;		/* time of last msgsnd command */
+#if __WORDSIZE == 32
+  unsigned int __pad2;
+#endif
+  __time_t msg_rtime;		/* time of last msgrcv command */
+#if __WORDSIZE == 32
+  unsigned int __pad3;
+#endif
+  __time_t msg_ctime;		/* time of last change */
+  unsigned long __msg_cbytes;	/* current number of bytes on queue */
+  unsigned long msg_qnum;	/* number of messages currently on queue */
+  unsigned long 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 __unused1;
+  unsigned long __unused2;
+};
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_msqid_ds
+{
+  struct __old_ipc_perm msg_perm;	/* structure describing operation permission */
+  struct msg *__msg_first;		/* pointer to first message on queue */
+  struct msg *__msg_last;		/* pointer to last message on queue */
+  __time_t msg_stime;			/* time of last msgsnd command */
+  __time_t msg_rtime;			/* time of last msgrcv command */
+  __time_t msg_ctime;			/* time of last change */
+  struct wait_queue *__wwait;		/* ??? */
+  struct wait_queue *__rwait;		/* ??? */
+  unsigned short int __msg_cbytes;	/* current number of bytes on queue */
+  unsigned short int msg_qnum;		/* number of messages currently on queue */
+  unsigned short int msg_qbytes;	/* max number of bytes allowed on queue */
+  __ipc_pid_t msg_lspid;		/* pid of last msgsnd() */
+  __ipc_pid_t msg_lrpid;		/* pid of last msgrcv() */
+};
+
+#endif
+
+#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 */
--- libc/sysdeps/unix/sysv/linux/sparc/bits/ipc.h.jj	Mon Jan 17 09:18:42 2000
+++ libc/sysdeps/unix/sysv/linux/sparc/bits/ipc.h	Mon Jan 17 13:26:22 2000
@@ -0,0 +1,99 @@
+/* Copyright (C) 1995-1999, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _SYS_IPC_H
+# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
+#endif
+
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+/* Mode bits for `msgget', `semget', and `shmget'.  */
+#define IPC_CREAT	01000		/* Create key if key does not exist. */
+#define IPC_EXCL	02000		/* Fail if key exists.  */
+#define IPC_NOWAIT	04000		/* Return error on wait.  */
+
+/* Control commands for `msgctl', `semctl', and `shmctl'.  */
+#define IPC_RMID	0		/* Remove identifier.  */
+#define IPC_SET		1		/* Set `ipc_perm' options.  */
+#define IPC_STAT	2		/* Get `ipc_perm' options.  */
+#define IPC_INFO	3		/* See ipcs.  */
+
+/* Special key values.  */
+#define IPC_PRIVATE	((__key_t) 0)	/* Private key.  */
+
+#define __IPC_64	0x100
+
+
+/* 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.  */
+#if __WORDSIZE == 32
+    unsigned short int	__pad1;
+    unsigned short int	mode;			/* Read/write permission.  */
+    unsigned short int	__pad2;
+#else
+    unsigned int	mode;			/* Read/write permission.  */
+    unsigned short int	__pad1;
+#endif    
+    unsigned short int	__seq;			/* Sequence number.  */
+    unsigned long long	__unused1;
+    unsigned long long	__unused2;
+  };
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_ipc_perm
+  {
+    __key_t __key;			/* Key.  */
+    unsigned short int uid;		/* Owner's user ID.  */
+    unsigned short int gid;		/* Owner's group ID.  */
+    unsigned short int cuid;		/* Creator's user ID.  */
+    unsigned short int cgid;		/* Creator's group ID.  */
+    unsigned short int mode;		/* Read/write permission.  */
+    unsigned short int __seq;		/* Sequence number.  */
+  };
+
+__BEGIN_DECLS
+
+/* The actual system call: all functions are multiplexed by this.  */
+extern int __syscall_ipc (int __call, int __first, int __second,
+			  int __third, void *__ptr);
+
+__END_DECLS
+
+
+/* The codes for the functions to use the multiplexer `__syscall_ipc'.  */
+#define IPCOP_semop	 1
+#define IPCOP_semget	 2
+#define IPCOP_semctl	 3
+#define IPCOP_msgsnd	11
+#define IPCOP_msgrcv	12
+#define IPCOP_msgget	13
+#define IPCOP_msgctl	14
+#define IPCOP_shmat	21
+#define IPCOP_shmdt	22
+#define IPCOP_shmget	23
+#define IPCOP_shmctl	24
+
+#endif /* __LIBC_IPC_INTERNAL */
--- libc/sysdeps/unix/sysv/linux/sparc/bits/sem.h.jj	Mon Jan 17 09:18:50 2000
+++ libc/sysdeps/unix/sysv/linux/sparc/bits/sem.h	Mon Jan 17 12:02:39 2000
@@ -0,0 +1,108 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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>
+#include <bits/wordsize.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 */
+#if __WORDSIZE == 32
+  unsigned int __pad1;
+#endif  
+  __time_t sem_otime;			/* last semop() time */
+#if __WORDSIZE == 32
+  unsigned int __pad2;
+#endif  
+  __time_t sem_ctime;			/* last time changed by semctl() */
+  unsigned long sem_nsems;		/* number of semaphores in set */
+  unsigned long __unused1;
+  unsigned long __unused2;
+};
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_semid_ds
+{
+  struct __old_ipc_perm sem_perm;	/* operation permission struct */
+  __time_t sem_otime;			/* last semop() time */
+  __time_t sem_ctime;			/* last time changed by semctl() */
+  struct sem *__sembase;		/* ptr to first semaphore in array */
+  struct sem_queue *__sem_pending;	/* pending operations */
+  struct sem_queue *__sem_pending_last; /* last pending operation */
+  struct sem_undo *__undo;		/* ondo requests on this array */
+  unsigned short int sem_nsems;		/* number of semaphores in set */
+};
+
+#endif
+
+/* 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 */
--- libc/sysdeps/unix/sysv/linux/sparc/bits/shm.h.jj	Mon Jan 17 09:18:09 2000
+++ libc/sysdeps/unix/sysv/linux/sparc/bits/shm.h	Mon Jan 17 12:04:45 2000
@@ -0,0 +1,125 @@
+/* Copyright (C) 1995, 1996, 1997, 2000 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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 <sys/types.h>
+#include <bits/wordsize.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) */
+
+
+/* Data structure describing a set of semaphores.  */
+struct shmid_ds
+  {
+    struct ipc_perm shm_perm;		/* operation permission struct */
+#if __WORDSIZE == 32
+    unsigned int __pad1;
+#endif
+    __time_t shm_atime;			/* time of last shmat() */
+#if __WORDSIZE == 32
+    unsigned int __pad2;
+#endif
+    __time_t shm_dtime;			/* time of last shmdt() */
+#if __WORDSIZE == 32
+    unsigned int __pad3;
+#endif
+    __time_t shm_ctime;			/* time of last change by shmctl() */
+    size_t shm_segsz;			/* size of segment in bytes */
+    pid_t shm_cpid;			/* pid of creator */
+    pid_t shm_lpid;			/* pid of last shmop */
+    unsigned long shm_nattch;		/* number of current attaches */
+    unsigned long __unused1;
+    unsigned long __unused2;
+  };
+
+#ifdef __LIBC_IPC_INTERNAL
+
+struct __old_shmid_ds
+  {
+    struct __old_ipc_perm shm_perm;	/* operation permission struct */
+    int shm_segsz;			/* size of segment in bytes */
+    __time_t shm_atime;			/* time of last shmat() */
+    __time_t shm_dtime;			/* time of last shmdt() */
+    __time_t shm_ctime;			/* time of last change by shmctl() */
+    __ipc_pid_t shm_cpid;		/* pid of creator */
+    __ipc_pid_t shm_lpid;		/* pid of last shmop */
+    unsigned short int shm_nattch;	/* number of current attaches */
+    unsigned short int __shm_npages;	/* size of segment (pages) */
+    unsigned long int *__shm_pages;	/* array of ptrs to frames -> SHMMAX */
+    struct vm_area_struct *__attaches;	/* descriptors for attaches */
+  };
+
+#endif
+
+#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 shmmax;
+    unsigned long shmmin;
+    unsigned long shmmni;
+    unsigned long shmseg;
+    unsigned long shmall;
+    unsigned long __unused1;
+    unsigned long __unused2;
+    unsigned long __unused3;
+    unsigned long __unused4;
+  };
+
+struct	__old_shminfo
+  {
+    int shmmax;
+    int shmmin;
+    int shmmni;
+    int shmseg;
+    int shmall;
+  };
+
+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 */
--- libc/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c.jj	Mon Jan 17 12:11:17 2000
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c	Mon Jan 17 12:06:29 2000
@@ -0,0 +1,54 @@
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <stdarg.h>
+#include <sys/sem.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Define a `union semun' suitable for Linux here.  */
+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 */
+};
+
+
+/* Return identifier for array of NSEMS semaphores associated with
+   KEY.  */
+
+int
+semctl (int semid, int semnum, int cmd, ...)
+{
+  union semun arg;
+  va_list ap;
+
+  va_start (ap, cmd);
+
+  /* Get the argument.  */
+  arg = va_arg (ap, union semun);
+
+  va_end (ap);
+
+  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
+}
--- libc/sysdeps/unix/sysv/linux/sparc/sparc64/msgctl.c.jj	Mon Jan 17 12:11:17 2000
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/msgctl.c	Mon Jan 17 12:06:42 2000
@@ -0,0 +1,36 @@
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <sys/msg.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Allows to control internal state and destruction of message queue
+   objects.  */
+
+int
+msgctl (msqid, cmd, buf)
+     int msqid;
+     int cmd;
+     struct msqid_ds *buf;
+{
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
+}
--- libc/sysdeps/unix/sysv/linux/sparc/sparc64/shmctl.c.jj	Mon Jan 17 12:11:17 2000
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/shmctl.c	Mon Jan 17 12:06:35 2000
@@ -0,0 +1,35 @@
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <sys/shm.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Provide operations to control over shared memory segments.  */
+
+int
+shmctl (shmid, cmd, buf)
+     int shmid;
+     int cmd;
+     struct shmid_ds *buf;
+{
+  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
+}
--- libc/sysdeps/unix/sysv/linux/msgget.c.jj	Tue Dec 15 17:45:05 1998
+++ libc/sysdeps/unix/sysv/linux/msgget.c	Mon Jan 17 10:21:01 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
 
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/msg.h>
 #include <stdlib.h>		/* for definition of NULL */
--- libc/sysdeps/unix/sysv/linux/msgctl.c.jj	Tue Dec 15 17:45:04 1998
+++ libc/sysdeps/unix/sysv/linux/msgctl.c	Mon Jan 17 13:08:54 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
 
@@ -17,20 +17,95 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/msg.h>
 
 #include <sysdep.h>
+#include <string.h>
 #include <sys/syscall.h>
 
+#include "kernel-features.h"
+
 /* Allows to control internal state and destruction of message queue
    objects.  */
+int __old_msgctl (int, int, struct __old_msqid_ds *);
+int __new_msgctl (int, int, struct msqid_ds *);
 
 int
-msgctl (msqid, cmd, buf)
-     int msqid;
-     int cmd;
-     struct msqid_ds *buf;
+__old_msgctl (int msqid, int cmd, struct __old_msqid_ds *buf)
 {
   return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
 }
+
+int
+__new_msgctl (int msqid, int cmd, struct msqid_ds *buf)
+{
+#if __ASSUME_32BITUIDS > 0
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf);
+#else
+  switch (cmd) {
+    case MSG_STAT:
+    case IPC_STAT:
+    case IPC_SET:
+      break;
+    default:
+      return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
+  }
+
+  {
+    int save_errno = errno, result;
+    struct __old_msqid_ds old;
+
+    /* Unfortunately there is no way how to find out for sure whether
+       we should use old or new msgctl.  */
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf);
+    if (result != -1 || errno != EINVAL)
+      return result;
+
+    __set_errno(save_errno);
+    if (cmd == IPC_SET)
+      {
+	old.msg_perm.uid = buf->msg_perm.uid;
+	old.msg_perm.gid = buf->msg_perm.gid;
+	old.msg_perm.mode = buf->msg_perm.mode;
+	old.msg_qbytes = buf->msg_qbytes;
+	if (old.msg_perm.uid != buf->msg_perm.uid ||
+	    old.msg_perm.gid != buf->msg_perm.gid ||
+	    old.msg_qbytes != buf->msg_qbytes)
+	  {
+	    __set_errno (EINVAL);
+	    return -1;
+	  }
+      }
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, &old);
+    if (result != -1 && cmd != IPC_SET)
+      {
+	memset(buf, 0, sizeof(*buf));
+	buf->msg_perm.__key = old.msg_perm.__key;
+	buf->msg_perm.uid = old.msg_perm.uid;
+	buf->msg_perm.gid = old.msg_perm.gid;
+	buf->msg_perm.cuid = old.msg_perm.cuid;
+	buf->msg_perm.cgid = old.msg_perm.cgid;
+	buf->msg_perm.mode = old.msg_perm.mode;
+	buf->msg_perm.__seq = old.msg_perm.__seq;
+	buf->msg_stime = old.msg_stime;
+	buf->msg_rtime = old.msg_rtime;
+	buf->msg_ctime = old.msg_ctime;
+	buf->__msg_cbytes = old.__msg_cbytes;
+	buf->msg_qnum = old.msg_qnum;
+	buf->msg_qbytes = old.msg_qbytes;
+	buf->msg_lspid = old.msg_lspid;
+	buf->msg_lrpid = old.msg_lrpid;
+      }
+    return result;
+  }
+#endif
+}
+
+#if defined PIC && DO_VERSIONING
+default_symbol_version (__new_msgctl, msgctl, GLIBC_2.2);
+symbol_version (__old_msgctl, msgctl, GLIBC_2.0);
+#else
+weak_alias (__new_msgctl, msgctl);
+#endif
--- libc/sysdeps/unix/sysv/linux/msgrcv.c.jj	Tue Dec 15 17:45:06 1998
+++ libc/sysdeps/unix/sysv/linux/msgrcv.c	Mon Jan 17 10:21:26 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
 
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/msg.h>
 
--- libc/sysdeps/unix/sysv/linux/semctl.c.jj	Fri Sep 17 18:58:06 1999
+++ libc/sysdeps/unix/sysv/linux/semctl.c	Mon Jan 17 13:34:22 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
 
@@ -17,13 +17,17 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <stdarg.h>
 #include <sys/sem.h>
 
 #include <sysdep.h>
+#include <string.h>
 #include <sys/syscall.h>
 
+#include "kernel-features.h"
+
 /* Define a `union semun' suitable for Linux here.  */
 union semun
 {
@@ -36,9 +40,11 @@ union semun
 
 /* Return identifier for array of NSEMS semaphores associated with
    KEY.  */
+int __old_semctl (int semid, int semnum, int cmd, ...);
+int __new_semctl (int semid, int semnum, int cmd, ...);
 
 int
-semctl (int semid, int semnum, int cmd, ...)
+__old_semctl (int semid, int semnum, int cmd, ...)
 {
   union semun arg;
   va_list ap;
@@ -52,3 +58,81 @@ semctl (int semid, int semnum, int cmd, 
 
   return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
 }
+
+int
+__new_semctl (int semid, int semnum, int cmd, ...)
+{
+  union semun arg;
+  va_list ap;
+
+  va_start (ap, cmd);
+
+  /* Get the argument.  */
+  arg = va_arg (ap, union semun);
+
+  va_end (ap);
+
+#if __ASSUME_32BITUIDS > 0
+  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64, &arg);
+#else
+  switch (cmd) {
+    case SEM_STAT:
+    case IPC_STAT:
+    case IPC_SET:
+      break;
+    default:
+      return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
+  }
+
+  {
+    int save_errno = errno, result;
+    struct __old_semid_ds old;
+    struct semid_ds *buf;
+
+    /* Unfortunately there is no way how to find out for sure whether
+       we should use old or new semctl.  */
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64, &arg);
+    if (result != -1 || errno != EINVAL)
+      return result;
+
+    __set_errno(save_errno);
+    buf = arg.buf;
+    arg.buf = (struct semid_ds *)&old;
+    if (cmd == IPC_SET)
+      {
+	old.sem_perm.uid = buf->sem_perm.uid;
+	old.sem_perm.gid = buf->sem_perm.gid;
+	old.sem_perm.mode = buf->sem_perm.mode;
+	if (old.sem_perm.uid != buf->sem_perm.uid ||
+	    old.sem_perm.gid != buf->sem_perm.gid)
+	  {
+	    __set_errno (EINVAL);
+	    return -1;
+	  }
+      }
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
+    if (result != -1 && cmd != IPC_SET)
+      {
+	memset(buf, 0, sizeof(*buf));
+	buf->sem_perm.__key = old.sem_perm.__key;
+	buf->sem_perm.uid = old.sem_perm.uid;
+	buf->sem_perm.gid = old.sem_perm.gid;
+	buf->sem_perm.cuid = old.sem_perm.cuid;
+	buf->sem_perm.cgid = old.sem_perm.cgid;
+	buf->sem_perm.mode = old.sem_perm.mode;
+	buf->sem_perm.__seq = old.sem_perm.__seq;
+	buf->sem_otime = old.sem_otime;
+	buf->sem_ctime = old.sem_ctime;
+	buf->sem_nsems = old.sem_nsems;
+      }
+    return result;
+  }
+#endif
+}
+
+#if defined PIC && DO_VERSIONING
+default_symbol_version (__new_semctl, semctl, GLIBC_2.2);
+symbol_version (__old_semctl, semctl, GLIBC_2.0);
+#else
+weak_alias (__new_semctl, semctl);
+#endif
--- libc/sysdeps/unix/sysv/linux/semget.c.jj	Tue Dec 15 17:45:09 1998
+++ libc/sysdeps/unix/sysv/linux/semget.c	Mon Jan 17 10:21:51 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
 
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/sem.h>
 #include <stdlib.h>		/* for definition of NULL */
--- libc/sysdeps/unix/sysv/linux/msgsnd.c.jj	Wed Aug 18 09:39:00 1999
+++ libc/sysdeps/unix/sysv/linux/msgsnd.c	Mon Jan 17 13:33:46 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, August 1995.
 
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/msg.h>
 
@@ -30,5 +31,5 @@ msgsnd (msqid, msgp, msgsz, msgflg)
      size_t msgsz;
      int msgflg;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz, msgflg, msgp);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz, msgflg, (void *)msgp);
 }
--- libc/sysdeps/unix/sysv/linux/semop.c.jj	Wed Aug 18 09:39:25 1999
+++ libc/sysdeps/unix/sysv/linux/semop.c	Mon Jan 17 10:19:01 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, August 1995.
 
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/sem.h>
 
--- libc/sysdeps/unix/sysv/linux/Versions.jj	Fri Dec 10 15:15:34 1999
+++ libc/sysdeps/unix/sysv/linux/Versions	Mon Jan 17 12:14:34 2000
@@ -82,4 +82,8 @@ libc {
     # u*
     umount2;
   }
+  GLIBC_2.2 {
+    # ipc ctl interface change.
+    semctl; shmctl; msgctl;
+  }
 }
--- libc/sysdeps/unix/sysv/linux/shmat.c.jj	Wed Jul 14 17:12:03 1999
+++ libc/sysdeps/unix/sysv/linux/shmat.c	Mon Jan 17 10:22:23 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
 
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/shm.h>
 
--- libc/sysdeps/unix/sysv/linux/shmctl.c.jj	Tue Dec 15 17:45:12 1998
+++ libc/sysdeps/unix/sysv/linux/shmctl.c	Mon Jan 17 13:16:21 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
 
@@ -17,19 +17,109 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/shm.h>
 
 #include <sysdep.h>
+#include <string.h>
 #include <sys/syscall.h>
+#include <bits/wordsize.h>
+
+#include "kernel-features.h"
 
 /* Provide operations to control over shared memory segments.  */
+int __old_shmctl (int, int, struct __old_shmid_ds *);
+int __new_shmctl (int, int, struct shmid_ds *);
 
 int
-shmctl (shmid, cmd, buf)
-     int shmid;
-     int cmd;
-     struct shmid_ds *buf;
+__old_shmctl (int shmid, int cmd, struct __old_shmid_ds *buf)
 {
   return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
 }
+
+int
+__new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
+{
+#if __ASSUME_32BITUIDS > 0
+  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf);
+#else
+  switch (cmd) {
+    case SHM_STAT:
+    case IPC_STAT:
+    case IPC_SET:
+#if __WORDSIZE != 32
+    case IPC_INFO:
+#endif
+      break;
+    default:
+      return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
+  }
+
+  {
+    int save_errno = errno, result;
+    struct __old_shmid_ds old;
+
+    /* Unfortunately there is no way how to find out for sure whether
+       we should use old or new shmctl.  */
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf);
+    if (result != -1 || errno != EINVAL)
+      return result;
+
+    __set_errno(save_errno);
+    if (cmd == IPC_SET)
+      {
+	old.shm_perm.uid = buf->shm_perm.uid;
+	old.shm_perm.gid = buf->shm_perm.gid;
+	old.shm_perm.mode = buf->shm_perm.mode;
+	if (old.shm_perm.uid != buf->shm_perm.uid ||
+	    old.shm_perm.gid != buf->shm_perm.gid)
+	  {
+	    __set_errno (EINVAL);
+	    return -1;
+	  }
+      }
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, &old);
+    if (result != -1 && (cmd == SHM_STAT || cmd == IPC_STAT))
+      {
+	memset(buf, 0, sizeof(*buf));
+	buf->shm_perm.__key = old.shm_perm.__key;
+	buf->shm_perm.uid = old.shm_perm.uid;
+	buf->shm_perm.gid = old.shm_perm.gid;
+	buf->shm_perm.cuid = old.shm_perm.cuid;
+	buf->shm_perm.cgid = old.shm_perm.cgid;
+	buf->shm_perm.mode = old.shm_perm.mode;
+	buf->shm_perm.__seq = old.shm_perm.__seq;
+	buf->shm_atime = old.shm_atime;
+	buf->shm_dtime = old.shm_dtime;
+	buf->shm_ctime = old.shm_ctime;
+	buf->shm_segsz = old.shm_segsz;
+	buf->shm_nattch = old.shm_nattch;
+	buf->shm_cpid = old.shm_cpid;
+	buf->shm_lpid = old.shm_lpid;
+      }
+#if __WORDSIZE != 32
+    else if (result != -1 && cmd == IPC_INFO)
+      {
+	struct __old_shminfo *oldi = (struct __old_shminfo *)&old;
+	struct shminfo *i = (struct shminfo *)buf;
+
+	memset(i, 0, sizeof(*i));
+	i->shmmax = oldi->shmmax;
+	i->shmmin = oldi->shmmin;
+	i->shmmni = oldi->shmmni;
+	i->shmseg = oldi->shmseg;
+	i->shmall = oldi->shmall;
+      }
+#endif
+    return result;
+  }
+#endif
+}
+
+#if defined PIC && DO_VERSIONING
+default_symbol_version (__new_shmctl, shmctl, GLIBC_2.2);
+symbol_version (__old_shmctl, shmctl, GLIBC_2.0);
+#else
+weak_alias (__new_shmctl, shmctl);
+#endif
--- libc/sysdeps/unix/sysv/linux/shmdt.c.jj	Tue Dec 15 17:45:13 1998
+++ libc/sysdeps/unix/sysv/linux/shmdt.c	Mon Jan 17 10:22:57 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
 
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/shm.h>
 
--- libc/sysdeps/unix/sysv/linux/shmget.c.jj	Wed Aug 18 09:39:34 1999
+++ libc/sysdeps/unix/sysv/linux/shmget.c	Mon Jan 17 10:23:15 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, August 1995.
 
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define __LIBC_IPC_INTERNAL
 #include <errno.h>
 #include <sys/shm.h>
 #include <stdlib.h>		/* for definition of NULL */

Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.39 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]