[Glibc-bsd-commits] r5047 - in trunk/glibc-ports/kfreebsd: . bits sys

Petr Salinger ps-guest at alioth.debian.org
Sun Oct 13 10:33:30 UTC 2013


Author: ps-guest
Date: 2013-10-13 10:33:29 +0000 (Sun, 13 Oct 2013)
New Revision: 5047

Modified:
   trunk/glibc-ports/kfreebsd/Makefile
   trunk/glibc-ports/kfreebsd/Versions
   trunk/glibc-ports/kfreebsd/bits/ipc.h
   trunk/glibc-ports/kfreebsd/bits/msq.h
   trunk/glibc-ports/kfreebsd/bits/sem.h
   trunk/glibc-ports/kfreebsd/bits/shm.h
   trunk/glibc-ports/kfreebsd/semctl.c
   trunk/glibc-ports/kfreebsd/sys/syscall.h
   trunk/glibc-ports/kfreebsd/syscalls.list
Log:
migrate to contemporary ipc interfaces


Modified: trunk/glibc-ports/kfreebsd/Makefile
===================================================================
--- trunk/glibc-ports/kfreebsd/Makefile	2013-10-13 10:31:09 UTC (rev 5046)
+++ trunk/glibc-ports/kfreebsd/Makefile	2013-10-13 10:33:29 UTC (rev 5047)
@@ -90,7 +90,7 @@
 sysdep_routines += sys_fork sys_execve sys_sigaction sys_close sys_fcntl
 sysdep_routines += sys_clock_getres sys_clock_gettime sys_clock_settime
 sysdep_routines += sys_ktimer_create sys_ktimer_gettime sys_ktimer_settime sys_ktimer_getoverrun sys_ktimer_delete
-sysdep_routines += sys_semctl
+sysdep_routines += sys_semctl sys_shmctl sys_msgctl
 endif
 
 ifeq ($(subdir),posix)

Modified: trunk/glibc-ports/kfreebsd/Versions
===================================================================
--- trunk/glibc-ports/kfreebsd/Versions	2013-10-13 10:31:09 UTC (rev 5046)
+++ trunk/glibc-ports/kfreebsd/Versions	2013-10-13 10:33:29 UTC (rev 5047)
@@ -99,6 +99,9 @@
     jail_set;
   }
   GLIBC_2.18 {
+    msgctl;
+    semctl;
+    shmctl;
     #errlist-compat 97
     _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
   }

Modified: trunk/glibc-ports/kfreebsd/bits/ipc.h
===================================================================
--- trunk/glibc-ports/kfreebsd/bits/ipc.h	2013-10-13 10:31:09 UTC (rev 5046)
+++ trunk/glibc-ports/kfreebsd/bits/ipc.h	2013-10-13 10:33:29 UTC (rev 5047)
@@ -33,7 +33,7 @@
 #define IPC_STAT	2		/* get `ipc_perm' options */
 
 /* Special key values.  */
-#define IPC_PRIVATE	((key_t) 0)	/* private key */
+#define IPC_PRIVATE	((__key_t) 0)	/* private key */
 
 #ifdef __USE_BSD
 /* Common mode bits.  */
@@ -45,12 +45,12 @@
 
 /* Data structure used to pass permission information to IPC operations.  */
 struct ipc_perm
-  {
-    __uint16_t /* yuck! */ cuid;	/* creator's user ID */
-    __uint16_t /* yuck! */ cgid;	/* creator's group ID */
-    __uint16_t /* yuck! */ uid;		/* owner's user ID */
-    __uint16_t /* yuck! */ gid;		/* owner's group ID */
-    __mode_t mode;			/* read/write permission */
-    __uint16_t __seq;
-    __key_t __key;
-  };
+{
+    __uid_t		cuid;	/* creator user id */
+    __gid_t		cgid;	/* creator group id */
+    __uid_t		uid;	/* user id */
+    __gid_t		gid;	/* group id */
+    __mode_t		mode;	/* r/w permission */
+    __uint16_t		__seq;	/* sequence # (to generate unique ipcid) */
+    __key_t		__key;	/* user specified msg/sem/shm key */
+};

Modified: trunk/glibc-ports/kfreebsd/bits/msq.h
===================================================================
--- trunk/glibc-ports/kfreebsd/bits/msq.h	2013-10-13 10:31:09 UTC (rev 5046)
+++ trunk/glibc-ports/kfreebsd/bits/msq.h	2013-10-13 10:33:29 UTC (rev 5047)
@@ -34,21 +34,17 @@
    The type `struct __msg' is opaque.  */
 struct msqid_ds
 {
-  struct ipc_perm msg_perm;	/* structure describing operation permission */
-  void *__msg_first;
-  void *__msg_last;
-  msglen_t __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() */
-  __time_t msg_stime;		/* time of last msgsnd command */
-  long __unused1;
-  __time_t msg_rtime;		/* time of last msgrcv command */
-  long __unused2;
-  __time_t msg_ctime;		/* time of last change */
-  long __unused3;
-  long __unused4[4];
+	struct	ipc_perm msg_perm;	/* msg queue permission bits */
+	void *__msg_first;		/* first message in the queue */
+	void *__msg_last;		/* last message in the queue */
+	msglen_t __msg_cbytes;	/* number of bytes in use on the queue */
+	msgqnum_t msg_qnum;	/* number of msgs in the queue */
+	msglen_t msg_qbytes;	/* max # of bytes on the queue */
+	__pid_t	msg_lspid;	/* pid of last msgsnd() */
+	__pid_t	msg_lrpid;	/* pid of last msgrcv() */
+	__time_t msg_stime;	/* time of last msgsnd() */
+	__time_t msg_rtime;	/* time of last msgrcv() */
+	__time_t msg_ctime;	/* time of last msgctl() */
 };
 
 #ifdef __USE_MISC

Modified: trunk/glibc-ports/kfreebsd/bits/sem.h
===================================================================
--- trunk/glibc-ports/kfreebsd/bits/sem.h	2013-10-13 10:31:09 UTC (rev 5046)
+++ trunk/glibc-ports/kfreebsd/bits/sem.h	2013-10-13 10:33:29 UTC (rev 5047)
@@ -41,18 +41,16 @@
 
 
 /* Data structure describing a set of semaphores.  */
-struct semid_ds
+struct semid_ds 
 {
-  struct ipc_perm sem_perm;		/* operation permission struct */
-  void *__sem_base;
-  unsigned short int sem_nsems;		/* number of semaphores in set */
-  __time_t sem_otime;			/* last semop() time */
-  long __unused1;
-  __time_t sem_ctime;			/* last time changed by semctl() */
-  long __unused2;
-  long __unused3[4];
+    struct ipc_perm	sem_perm;	/* operation permission struct */
+    void		*__sem_base;	/* pointer to first semaphore in set */
+    unsigned short	sem_nsems;	/* number of sems in set */
+    __time_t		sem_otime;	/* last operation time */
+    __time_t		sem_ctime;	/* last change time */
+    					/* Times measured in secs since */
+    					/* 00:00:00 GMT, Jan. 1, 1970 */
 };
-
 /* The user should define a union like the following to use it for arguments
    for `semctl'.
 

Modified: trunk/glibc-ports/kfreebsd/bits/shm.h
===================================================================
--- trunk/glibc-ports/kfreebsd/bits/shm.h	2013-10-13 10:31:09 UTC (rev 5046)
+++ trunk/glibc-ports/kfreebsd/bits/shm.h	2013-10-13 10:33:29 UTC (rev 5047)
@@ -44,20 +44,19 @@
 
 
 /* Type to count number of attaches.  */
-typedef unsigned short int shmatt_t;
+typedef int shmatt_t;
 
 /* Data structure describing a set of semaphores.  */
 struct shmid_ds
   {
     struct ipc_perm shm_perm;		/* operation permission struct */
-    int shm_segsz;			/* size of segment in bytes */
+    size_t shm_segsz;			/* size of segment in bytes */
     __pid_t shm_lpid;			/* pid of last shmop */
     __pid_t shm_cpid;			/* pid of creator */
     shmatt_t shm_nattch;		/* number of current attaches */
     __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() */
-    void *__shm_internal;
   };
 
 #ifdef __USE_MISC

Modified: trunk/glibc-ports/kfreebsd/semctl.c
===================================================================
--- trunk/glibc-ports/kfreebsd/semctl.c	2013-10-13 10:31:09 UTC (rev 5046)
+++ trunk/glibc-ports/kfreebsd/semctl.c	2013-10-13 10:33:29 UTC (rev 5047)
@@ -49,7 +49,15 @@
 #include <stdarg.h> /* va_list */
 #include <stdlib.h> /* NULL */
 #include <unistd.h>
+#include <ipc_priv.h>
 
+#include <sysdep.h>
+#include <string.h>
+#include <sys/syscall.h>
+#include <bits/wordsize.h>
+#include <shlib-compat.h>
+
+
 /* union semun from FreeBSD <sys/sem.h> */
 /*
  * semctl's arg parameter structure
@@ -58,6 +66,7 @@
 {
   int val;			/* value for SETVAL */
   struct semid_ds *buf;		/* buffer for IPC_STAT & IPC_SET */
+  struct semid_ds_old *oldbuf;	/* buffer for IPC_STAT & IPC_SET */
   unsigned short *array;	/* array for GETALL & SETALL */
 };
 
@@ -66,24 +75,101 @@
 libc_hidden_proto (__syscall_semctl)
 
 int
-semctl (int semid, int semnum, int cmd, ...)
+__new_semctl (int semid, int semnum, int cmd, ...)
 {
-  va_list ap;
-  union semun semun;
-  union semun *semun_ptr;
+    va_list ap;
+    union semun semun;
+    union semun *semun_ptr;
 
-  va_start (ap, cmd);
-  if (cmd == IPC_SET || cmd == IPC_STAT || cmd == GETALL
-      || cmd == SETVAL || cmd == SETALL)
+    va_start (ap, cmd);
+    switch (cmd) 
     {
-      semun = va_arg (ap, union semun);
-      semun_ptr = &semun;
+        case SEM_STAT:
+        case IPC_SET: 
+        case IPC_STAT: 
+        case GETALL:
+        case SETVAL:  
+        case SETALL:
+            semun = va_arg (ap, union semun);
+            semun_ptr = &semun;
+        break;
+        default:                                                  
+            semun_ptr = NULL;
     }
-  else
+    va_end (ap);
+    return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd, semun_ptr);
+}
+versioned_symbol (libc, __new_semctl, semctl, GLIBC_2_18);
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_18)
+
+struct semid_ds_old
+{
+  struct ipc_perm_old sem_perm;		/* operation permission struct */
+  void *__sem_base;
+  unsigned short int sem_nsems;		/* number of semaphores in set */
+  __time_t sem_otime;			/* last semop() time */
+  long __unused1;
+  __time_t sem_ctime;			/* last time changed by semctl() */
+  long __unused2;
+  long __unused3[4];
+};
+
+int
+attribute_compat_text_section
+__old_semctl (int semid, int semnum, int cmd, ...)
+{
+    struct semid_ds newbuf;
+    struct semid_ds_old *buf;
+    int rv;
+
+    va_list ap;
+    union semun semun;
+    union semun *semun_ptr;
+
+    va_start (ap, cmd);
+    switch (cmd) 
     {
-      semun_ptr = NULL;
+        case SEM_STAT:
+        case IPC_SET: 
+        case IPC_STAT:
+            semun = va_arg (ap, union semun);
+            buf = semun.oldbuf;
+            semun.buf = &newbuf;
+	    semun_ptr = &semun;
+	break;
+        case GETALL:
+        case SETVAL:  
+        case SETALL:
+            semun = va_arg (ap, union semun);
+	    semun_ptr = &semun;
+        break;
+        default:                                                  
+            semun_ptr = NULL;
     }
-  va_end (ap);
-
-  return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd, semun_ptr);
+    va_end (ap);
+  
+    if (cmd == IPC_SET)
+    {
+        ipc_perm_old2new(&(buf->sem_perm), &(newbuf.sem_perm));
+        newbuf.__sem_base = buf->__sem_base;
+        newbuf.sem_nsems  = buf->sem_nsems;
+        newbuf.sem_otime  = buf->sem_otime;
+        newbuf.sem_ctime  = buf->sem_ctime;
+    }
+    
+    rv = INLINE_SYSCALL (semctl, 4, semid, semnum, cmd, semun_ptr);
+    
+    if ((rv != -1) && ((cmd == IPC_STAT) || (cmd == SEM_STAT)))
+    {
+        ipc_perm_new2old(&(newbuf.sem_perm), &(buf->sem_perm));
+        buf->__sem_base = newbuf.__sem_base;
+        buf->sem_nsems  = newbuf.sem_nsems;
+        buf->sem_otime  = newbuf.sem_otime;
+        buf->sem_ctime  = newbuf.sem_ctime;
+    }
+        
+    return rv;
 }
+compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
+#endif

Modified: trunk/glibc-ports/kfreebsd/sys/syscall.h
===================================================================
--- trunk/glibc-ports/kfreebsd/sys/syscall.h	2013-10-13 10:31:09 UTC (rev 5046)
+++ trunk/glibc-ports/kfreebsd/sys/syscall.h	2013-10-13 10:33:29 UTC (rev 5047)
@@ -434,8 +434,8 @@
 #define	SYS_jail_remove	508
 #define	SYS_closefrom	509
 #define	SYS___semctl	510
-#define	SYS_msgctl	SYS_freebsd7_msgctl
-#define	SYS_shmctl	SYS_freebsd7_shmctl
+#define	SYS_msgctl	511
+#define	SYS_shmctl	512
 #define	SYS_lpathconf	513
 #define	SYS_cap_new	514
 #define	SYS_cap_rights_get	515
@@ -471,7 +471,7 @@
 #define SYS_sysctl	SYS___sysctl
 #define SYS_getcwd	SYS___getcwd
 #define SYS_setugid	SYS___setugid
-#define SYS_semctl	SYS_freebsd7___semctl
+#define SYS_semctl	SYS___semctl
 
 #define SYS_acl_get_file	SYS___acl_get_file
 #define SYS_acl_set_file	SYS___acl_set_file

Modified: trunk/glibc-ports/kfreebsd/syscalls.list
===================================================================
--- trunk/glibc-ports/kfreebsd/syscalls.list	2013-10-13 10:31:09 UTC (rev 5046)
+++ trunk/glibc-ports/kfreebsd/syscalls.list	2013-10-13 10:33:29 UTC (rev 5047)
@@ -108,7 +108,7 @@
 modnext			-	modnext			i:i		modnext
 modstat			-	modstat			i:ip		modstat
 mount			-	mount			i:ssiP		mount
-msgctl			-	msgctl			i:iip		msgctl
+sys_msgctl		-	msgctl			i:iip		__syscall_msgctl
 msgget			-	msgget			i:ii		msgget
 msgrcv			-	msgrcv			Ci:ibnii	__libc_msgrcv msgrcv
 msgsnd			-	msgsnd			Ci:ibni		__libc_msgsnd msgsnd
@@ -171,7 +171,7 @@
 shm_open		-	shm_open		i:sii		shm_open
 shm_unlink		-	shm_unlink		i:s		shm_unlink
 shmat			-	shmat			i:iai		shmat
-shmctl			-	shmctl			i:iip		shmctl
+sys_shmctl		-	shmctl			i:iip		__syscall_shmctl
 shmdt			-	shmdt			i:a		shmdt
 shmget			-	shmget			i:iii		shmget
 sys_sigaction		-	sigaction		i:ipp		__syscall_sigaction




More information about the Glibc-bsd-commits mailing list