Browse Source

Make shm stuff work properly.
-Erik

Eric Andersen 23 years ago
parent
commit
d7aaa51dff
3 changed files with 30 additions and 34 deletions
  1. 8 11
      libc/misc/sysvipc/sem.c
  2. 13 13
      libc/sysdeps/linux/common/bits/ipc.h
  3. 9 10
      libc/sysdeps/linux/common/bits/sem.h

+ 8 - 11
libc/misc/sysvipc/sem.c

@@ -26,13 +26,13 @@
 /* Return identifier for array of NSEMS semaphores associated with
    KEY.  */
 #include <stdarg.h>
-/* Define a `union semun' suitable for Linux here.  */
-union semun
-{
+/* arg for semctl system calls. */
+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 */
+    unsigned short *array;		/* array for GETALL & SETALL */
+    struct seminfo *__buf;		/* buffer for IPC_INFO */
+    void *__pad;
 };
 
 
@@ -41,18 +41,15 @@ union semun
 static inline _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, union semun *, arg);
 #endif
 
-int semctl (int semid, int semnum, int cmd, ...)
+int semctl(int semid, int semnum, int cmd, ...)
 {
     union semun arg;
-    va_list ap;
-
-    va_start (ap, cmd);
+    va_list ap; 
 
     /* Get the argument.  */
+    va_start (ap, cmd);
     arg = va_arg (ap, union semun);
-
     va_end (ap);
-
 #ifdef __NR_semctl
     return __semctl(semid, semnum, cmd, &arg);
 #else

+ 13 - 13
libc/sysdeps/linux/common/bits/ipc.h

@@ -35,22 +35,22 @@
 # define IPC_INFO	3		/* See ipcs.  */
 #endif
 
+/* Type of a SYSV IPC key.  */
+typedef int __kernel_key_t;
+
 /* Special key values.  */
 #define IPC_PRIVATE	((__key_t) 0)	/* Private key.  */
 
 
 /* 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 int __unused1;
-    unsigned long int __unused2;
-  };
+{
+    __kernel_key_t	key;
+    __kernel_uid_t	uid;
+    __kernel_gid_t	gid;
+    __kernel_uid_t	cuid;
+    __kernel_gid_t	cgid;
+    __kernel_mode_t	mode; 
+    unsigned short	seq;
+};
+

+ 9 - 10
libc/sysdeps/linux/common/bits/sem.h

@@ -36,16 +36,15 @@
 
 
 /* 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;
+struct semid_ds {
+    struct ipc_perm	sem_perm;		/* permissions .. see ipc.h */
+    time_t		sem_otime;		/* last semop time */
+    time_t		sem_ctime;		/* last change time */
+    struct sem		*sem_base;		/* ptr to first semaphore in array */
+    struct sem_queue	*sem_pending;		/* pending operations to be processed */
+    struct sem_queue	**sem_pending_last;	/* last pending operation */
+    struct sem_undo	*undo;			/* undo requests on this array */
+    unsigned short	sem_nsems;		/* no. of semaphores in array */
 };
 
 /* The user should define a union like the following to use it for arguments