[Glibc-bsd-commits] r5048 - trunk/glibc-ports/kfreebsd

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


Author: ps-guest
Date: 2013-10-13 10:37:18 +0000 (Sun, 13 Oct 2013)
New Revision: 5048

Added:
   trunk/glibc-ports/kfreebsd/ipc_priv.h
   trunk/glibc-ports/kfreebsd/msgctl.c
   trunk/glibc-ports/kfreebsd/shmctl.c
Log:
added files for ipc migration


Added: trunk/glibc-ports/kfreebsd/ipc_priv.h
===================================================================
--- trunk/glibc-ports/kfreebsd/ipc_priv.h	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/ipc_priv.h	2013-10-13 10:37:18 UTC (rev 5048)
@@ -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;
+}

Added: trunk/glibc-ports/kfreebsd/msgctl.c
===================================================================
--- trunk/glibc-ports/kfreebsd/msgctl.c	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/msgctl.c	2013-10-13 10:37:18 UTC (rev 5048)
@@ -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

Added: trunk/glibc-ports/kfreebsd/shmctl.c
===================================================================
--- trunk/glibc-ports/kfreebsd/shmctl.c	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/shmctl.c	2013-10-13 10:37:18 UTC (rev 5048)
@@ -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




More information about the Glibc-bsd-commits mailing list