[Glibc-bsd-commits] r4806 - trunk/glibc-ports
Petr Salinger
ps-guest at alioth.debian.org
Sun Jul 28 14:47:57 UTC 2013
Author: ps-guest
Date: 2013-07-28 14:47:57 +0000 (Sun, 28 Jul 2013)
New Revision: 4806
Added:
trunk/glibc-ports/218_ipc.diff
Log:
ipc changes for 2.18
Added: trunk/glibc-ports/218_ipc.diff
===================================================================
--- trunk/glibc-ports/218_ipc.diff (rev 0)
+++ trunk/glibc-ports/218_ipc.diff 2013-07-28 14:47:57 UTC (rev 4806)
@@ -0,0 +1,612 @@
+Index: sys/syscall.h
+===================================================================
+--- sys/syscall.h (revision 4805)
++++ sys/syscall.h (working copy)
+@@ -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
+Index: syscalls.list
+===================================================================
+--- syscalls.list (revision 4805)
++++ syscalls.list (working copy)
+@@ -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
+@@ -170,7 +170,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
+Index: shmctl.c
+===================================================================
+--- shmctl.c (revision 0)
++++ shmctl.c (revision 0)
+@@ -0,0 +1,91 @@
++/* Copyright (C) 2013 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, see
++ <http://www.gnu.org/licenses/>. */
++
++#include <errno.h>
++#include <sys/shm.h>
++#include <ipc_priv.h>
++
++#include <sysdep.h>
++#include <string.h>
++#include <sys/syscall.h>
++#include <bits/wordsize.h>
++#include <shlib-compat.h>
++
++#include <kernel-features.h>
++
++/* Provide operations to control over shared memory segments. */
++extern int __syscall_shmctl (int shmid, int cmd, struct shmid_ds *buf);
++libc_hidden_proto (__syscall_shmctl)
++
++
++int
++__new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
++{
++ return INLINE_SYSCALL (shmctl, 3, shmid, cmd, buf);
++}
++versioned_symbol (libc, __new_shmctl, shmctl, GLIBC_2_18);
++
++#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_18)
++struct shmid_ds_old {
++ struct ipc_perm_old shm_perm; /* operation permission structure */
++ int shm_segsz; /* size of segment in bytes */
++ pid_t shm_lpid; /* process ID of last shared memory op */
++ pid_t shm_cpid; /* process ID of creator */
++ unsigned short 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; /* sysv stupidity */
++};
++
++int
++attribute_compat_text_section
++__old_shmctl (int shmid, int cmd, struct shmid_ds_old *buf)
++{
++ struct shmid_ds newbuf;
++ int rv;
++
++ if (cmd == IPC_SET)
++ {
++ ipc_perm_old2new(&(buf->shm_perm), &(newbuf.shm_perm));
++ newbuf.shm_segsz = buf->shm_segsz;
++ newbuf.shm_lpid = buf->shm_lpid;
++ newbuf.shm_cpid = buf->shm_cpid;
++ newbuf.shm_nattch= buf->shm_nattch;
++ newbuf.shm_atime = buf->shm_atime;
++ newbuf.shm_dtime = buf->shm_dtime;
++ newbuf.shm_ctime = buf->shm_ctime;
++ }
++
++ rv = __new_shmctl (shmid, cmd, &newbuf);
++
++ if ((rv != -1) && (cmd == IPC_STAT))
++ {
++ ipc_perm_new2old(&(newbuf.shm_perm), &(buf->shm_perm));
++ buf->shm_segsz = newbuf.shm_segsz;
++ buf->shm_lpid = newbuf.shm_lpid;
++ buf->shm_cpid = newbuf.shm_cpid;
++ buf->shm_nattch= newbuf.shm_nattch;
++ buf->shm_atime = newbuf.shm_atime;
++ buf->shm_dtime = newbuf.shm_dtime;
++ buf->shm_ctime = newbuf.shm_ctime;
++ }
++
++ return rv;
++}
++compat_symbol (libc, __old_shmctl, shmctl, GLIBC_2_0);
++#endif
+Index: Makefile
+===================================================================
+--- Makefile (revision 4805)
++++ Makefile (working copy)
+@@ -89,7 +89,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)
+Index: msgctl.c
+===================================================================
+--- msgctl.c (revision 0)
++++ msgctl.c (revision 0)
+@@ -0,0 +1,104 @@
++/* Copyright (C) 2013 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, see
++ <http://www.gnu.org/licenses/>. */
++
++#include <errno.h>
++#include <sys/msg.h>
++#include <ipc_priv.h>
++
++#include <sysdep.h>
++#include <string.h>
++#include <sys/syscall.h>
++#include <bits/wordsize.h>
++#include <shlib-compat.h>
++
++#include <kernel-features.h>
++
++/* Provide operations to control over shared memory segments. */
++
++extern int __syscall_msgctl(int msqid, int cmd, struct msqid_ds *buf);
++libc_hidden_proto (__syscall_msgctl)
++
++int
++__new_msgctl(int msqid, int cmd, struct msqid_ds *buf)
++{
++ return INLINE_SYSCALL (msgctl, 3, msqid, cmd, buf);
++}
++versioned_symbol (libc, __new_msgctl, msgctl, GLIBC_2_18);
++
++#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_18)
++struct msqid_ds_old
++{
++ struct ipc_perm_old 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];
++};
++
++int
++attribute_compat_text_section
++__old_msgctl(int msqid, int cmd, struct msqid_ds_old *buf)
++{
++ struct msqid_ds newbuf;
++ int rv;
++
++ if (cmd == IPC_SET)
++ {
++ ipc_perm_old2new(&(buf->msg_perm), &(newbuf.msg_perm));
++ newbuf.__msg_first = buf->__msg_first;
++ newbuf.__msg_last = buf->__msg_first;
++ newbuf.__msg_cbytes = buf->__msg_cbytes;
++ newbuf.msg_qnum = buf->msg_qnum;
++ newbuf.msg_qbytes = buf->msg_qbytes;
++ newbuf.msg_lspid = buf->msg_lspid;
++ newbuf.msg_lrpid = buf->msg_lrpid;
++ newbuf.msg_stime = buf->msg_stime;
++ newbuf.msg_rtime = buf->msg_rtime;
++ newbuf.msg_ctime = buf->msg_ctime;
++ }
++
++ rv = __new_msgctl (msqid, cmd, &newbuf);
++
++ if ((rv != -1) && (cmd == IPC_STAT))
++ {
++ ipc_perm_new2old(&(newbuf.msg_perm), &(buf->msg_perm));
++ buf->__msg_first = newbuf.__msg_first;
++ buf->__msg_last = newbuf.__msg_first;
++ buf->__msg_cbytes = newbuf.__msg_cbytes;
++ buf->msg_qnum = newbuf.msg_qnum;
++ buf->msg_qbytes = newbuf.msg_qbytes;
++ buf->msg_lspid = newbuf.msg_lspid;
++ buf->msg_lrpid = newbuf.msg_lrpid;
++ buf->msg_stime = newbuf.msg_stime;
++ buf->msg_rtime = newbuf.msg_rtime;
++ buf->msg_ctime = newbuf.msg_ctime;
++ }
++
++ return rv;
++}
++compat_symbol (libc, __old_msgctl, msgctl, GLIBC_2_0);
++#endif
+Index: Versions
+===================================================================
+--- Versions (revision 4805)
++++ Versions (working copy)
+@@ -98,6 +98,11 @@
+ jail_get;
+ jail_set;
+ }
++ GLIBC_2.18 {
++ msgctl;
++ semctl;
++ shmctl;
++ }
+ GLIBC_PRIVATE {
+ # needed by libpthread.
+ __clone; __libc_fork; __libc_sigaction; __kernel_getosreldate;
+Index: ipc_priv.h
+===================================================================
+--- ipc_priv.h (revision 0)
++++ ipc_priv.h (revision 0)
+@@ -0,0 +1,53 @@
++/*
++ Copyright (C) 2013 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. */
++
++struct ipc_perm_old
++ {
++ __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;
++ };
++
++static inline void
++ipc_perm_old2new(const struct ipc_perm_old *in, struct ipc_perm *out)
++{
++ out->cuid = in->cuid;
++ out->cgid = in->cgid;
++ out->uid = in->uid;
++ out->gid = in->gid;
++ out->mode = in->mode;
++ out->__seq = in->__seq;
++ out->__key = in->__key;
++}
++
++static inline void
++ipc_perm_new2old(const struct ipc_perm *in, struct ipc_perm_old *out)
++{
++ out->cuid = in->cuid;
++ out->cgid = in->cgid;
++ out->uid = in->uid;
++ out->gid = in->gid;
++ out->mode = in->mode;
++ out->__seq = in->__seq;
++ out->__key = in->__key;
++}
+Index: bits/shm.h
+===================================================================
+--- bits/shm.h (revision 4805)
++++ bits/shm.h (working copy)
+@@ -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
+Index: bits/sem.h
+===================================================================
+--- bits/sem.h (revision 4805)
++++ bits/sem.h (working copy)
+@@ -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'.
+
+Index: bits/msq.h
+===================================================================
+--- bits/msq.h (revision 4805)
++++ bits/msq.h (working copy)
+@@ -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
+Index: bits/ipc.h
+===================================================================
+--- bits/ipc.h (revision 4805)
++++ bits/ipc.h (working copy)
+@@ -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 */
++};
+Index: semctl.c
+===================================================================
+--- semctl.c (revision 4805)
++++ semctl.c (working copy)
+@@ -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
More information about the Glibc-bsd-commits
mailing list