public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 02/17] Refactor Linux ipc_priv header
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:47   ` Arnd Bergmann
  2016-12-12 13:05   ` Andreas Schwab
  2016-12-12 12:33 ` [PATCH 17/17] Add SYSV shared memory test Adhemerval Zanella
                   ` (16 subsequent siblings)
  17 siblings, 2 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch refactor current ipc_priv.h Linux headers in two directions:

  - Remove cross platform references (for instance alpha including powerpc
    definition) and add required definition for each required port.  The
    idea is to avoid tie one architecture definition with another and make
    platform change independent.

  - Move all common definitions (the ipc syscall commands) on a common
    header, ipc_ops.h.

Since current IPC_64 default now on kernel is 0x100, some architectures
require it to 0 (for instance x86_64) while others continue to use a
non zero default regardless (powerpc).

	* sysdeps/unix/sysv/linux/aarch64/ipc_priv.h: New file.
	* sysdeps/unix/sysv/linux/alpha/ipc_priv.h: Avoid included other arch
	definition and define its own.
	* sysdeps/unix/sysv/linux/ipc_ops.h: New file.
	* sysdeps/unix/sysv/linux/x86_64/ipc_priv.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/ipc_priv.h: Remove file.
	* sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h: New file.
	* sysdeps/unix/sysv/linux/ipc_priv.h: Move ipc syscall operation
	definitions to common header.
	* sysdeps/unix/sysv/linux/powerpc/ipc_priv.h: Use common syscall
	operation from ipc_ops.h.
---
 ChangeLog                                        | 12 +++++++
 sysdeps/unix/sysv/linux/aarch64/ipc_priv.h       | 32 ++++++++++++++++++
 sysdeps/unix/sysv/linux/alpha/ipc_priv.h         | 33 ++++++++++++++++++-
 sysdeps/unix/sysv/linux/ipc_ops.h                | 30 +++++++++++++++++
 sysdeps/unix/sysv/linux/ipc_priv.h               | 23 +++++--------
 sysdeps/unix/sysv/linux/mips/ipc_priv.h          |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h   | 32 ++++++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/ipc_priv.h       | 23 +++++--------
 sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h | 41 ++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/x86_64/ipc_priv.h        | 32 ++++++++++++++++++
 10 files changed, 227 insertions(+), 32 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/ipc_ops.h
 delete mode 100644 sysdeps/unix/sysv/linux/mips/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/ipc_priv.h

diff --git a/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
new file mode 100644
index 0000000..1a31396
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
@@ -0,0 +1,32 @@
+/* Old SysV permission definition for Linux.  AArch64 version.
+   Copyright (C) 2016 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 <sys/ipc.h>  /* For __key_t  */
+
+#define __IPC_64	0x0
+
+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.  */
+};
diff --git a/sysdeps/unix/sysv/linux/alpha/ipc_priv.h b/sysdeps/unix/sysv/linux/alpha/ipc_priv.h
index 67883be..06444fc 100644
--- a/sysdeps/unix/sysv/linux/alpha/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/alpha/ipc_priv.h
@@ -1 +1,32 @@
-#include <sysdeps/unix/sysv/linux/powerpc/ipc_priv.h>
+/* Old SysV permission definition for Linux.  Alpha version.
+   Copyright (C) 2016 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 <sys/ipc.h>  /* For __key_t  */
+
+#define __IPC_64	0x100
+
+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.  */
+};
diff --git a/sysdeps/unix/sysv/linux/ipc_ops.h b/sysdeps/unix/sysv/linux/ipc_ops.h
new file mode 100644
index 0000000..ea3028c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ipc_ops.h
@@ -0,0 +1,30 @@
+/* The codes for the functions to use the ipc syscall multiplexer.
+   Copyright (C) 2016 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/>.  */
+
+#define IPCOP_semop	 	1
+#define IPCOP_semget	 	2
+#define IPCOP_semctl	 	3
+#define IPCOP_semtimedop 	4
+#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
diff --git a/sysdeps/unix/sysv/linux/ipc_priv.h b/sysdeps/unix/sysv/linux/ipc_priv.h
index 7ded463..9b97f00 100644
--- a/sysdeps/unix/sysv/linux/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/ipc_priv.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
+/* Old SysV permission definition for Linux.  Default version.
+   Copyright (C) 1995-2016 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
@@ -15,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>
+#include <sys/ipc.h>  /* For __key_t  */
 
 #define __IPC_64	0x100
 
@@ -30,17 +31,9 @@ struct __old_ipc_perm
   unsigned short int __seq;		/* Sequence number.  */
 };
 
+#define SEMCTL_ARG_ADDRESS(__arg) &__arg.array
 
-/* The codes for the functions to use the ipc syscall multiplexer.  */
-#define IPCOP_semop	 1
-#define IPCOP_semget	 2
-#define IPCOP_semctl	 3
-#define IPCOP_semtimedop 4
-#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
+#define MSGRCV_ARGS(__msgp, __msgtyp) \
+  ((long int []){ (long int) __msgp, __msgtyp })
+
+#include <ipc_ops.h>
diff --git a/sysdeps/unix/sysv/linux/mips/ipc_priv.h b/sysdeps/unix/sysv/linux/mips/ipc_priv.h
deleted file mode 100644
index 67883be..0000000
--- a/sysdeps/unix/sysv/linux/mips/ipc_priv.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/powerpc/ipc_priv.h>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h b/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
new file mode 100644
index 0000000..9f47d89
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
@@ -0,0 +1,32 @@
+/* Old SysV permission definition for Linux.  MIPS64 version.
+   Copyright (C) 2016 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 <sys/ipc.h>
+
+#define __IPC_64	0x100
+
+struct __old_ipc_perm
+{
+  __key_t __key;		/* Key.  */
+  int uid;			/* Owner's user ID.  */
+  int gid;			/* Owner's group ID.  */
+  int cuid;			/* Creator's user ID.  */
+  int cgid;			/* Creator's group ID.  */
+  int mode;			/* Read/write permission.  */
+  unsigned short int __seq;	/* Sequence number.  */
+};
diff --git a/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h b/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
index baae7ab..4f72f58 100644
--- a/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
+/* Old SysV permission definition for Linux.  PowerPC version.
+   Copyright (C) 1995-2016 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
@@ -15,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>
+#include <sys/ipc.h>  /* For __key_t  */
 
 #define __IPC_64	0x100
 
@@ -30,17 +31,9 @@ struct __old_ipc_perm
   unsigned short int __seq;		/* Sequence number.  */
 };
 
+#define SEMCTL_ARG_ADDRESS(__arg) &__arg.array
 
-/* The codes for the functions to use the ipc syscall multiplexer.  */
-#define IPCOP_semop	 1
-#define IPCOP_semget	 2
-#define IPCOP_semctl	 3
-#define IPCOP_semtimedop 4
-#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
+#define MSGRCV_ARGS(__msgp, __msgtyp) \
+  ((long int []){ (long int) __msgp, __msgtyp })
+
+#include <ipc_ops.h>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h b/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
new file mode 100644
index 0000000..386ff8a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
@@ -0,0 +1,41 @@
+/* Old SysV permission definition for Linux.  x86_64 version.
+   Copyright (C) 2016 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 <sys/ipc.h>  /* For __key_t  */
+
+#define __IPC_64	0x0
+
+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.  */
+};
+
+/* SPARC semctl multiplex syscall expects the union pointed address, not
+   the union address itself.  */
+#define SEMCTL_ARG_ADDRESS(__arg) __arg.array
+
+/* Also for msgrcv it does not use the kludge on final 2 arguments.  */
+#define MSGRCV_ARGS(__msgp, __msgtyp) __msgp, __msgtyp
+
+#include <ipc_ops.h>
diff --git a/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h b/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h
new file mode 100644
index 0000000..d39db53
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h
@@ -0,0 +1,32 @@
+/* Old SysV permission definition for Linux.  x86_64 version.
+   Copyright (C) 2016 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 <sys/ipc.h>  /* For __key_t  */
+
+#define __IPC_64	0x0
+
+struct __old_ipc_perm
+{
+  __key_t __key;		/* Key.  */
+  unsigned short uid;		/* Owner's user ID.  */
+  unsigned short gid;		/* Owner's group ID.  */
+  unsigned short cuid;		/* Creator's user ID.  */
+  unsigned short cgid;		/* Creator's group ID.  */
+  unsigned short mode;		/* Read/write permission.  */
+  unsigned short int __seq;	/* Sequence number.  */
+};
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 14/17] Consolidate Linux shmctl implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (13 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 08/17] Consolidate Linux semctl implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 06/17] Use msgget syscall for Linux implementation Adhemerval Zanella
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the shmctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/shmctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
	oldshmctl.
	* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmctl): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (shmctl): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (shmctl): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmctl): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmctl): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmctl): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmctl):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmctl):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmctl): Likewise.
	* sysdeps/unix/sysv/linux/alpha/shmctl.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/shmctl.c: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/shmctl.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/shmctl.c: Use default
	implementation.
	* sysdeps/unix/sysv/linux/shmctl.c (__new_shmctl): Use shmctl syscall
	if it is defined.
---
 ChangeLog                                          | 21 ++++++++
 sysdeps/unix/sysv/linux/alpha/Makefile             |  3 --
 sysdeps/unix/sysv/linux/alpha/shmctl.c             |  1 -
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/shmctl.c               | 34 -------------
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/shmctl.c        |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/shmctl.c       | 17 ++-----
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/shmctl.c                   | 59 ++++++++++------------
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 13 files changed, 53 insertions(+), 89 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/shmctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/shmctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/shmctl.c

diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile
index 386b3fd..4bbe9bf 100644
--- a/sysdeps/unix/sysv/linux/alpha/Makefile
+++ b/sysdeps/unix/sysv/linux/alpha/Makefile
@@ -17,9 +17,6 @@ sysdep_routines += osf_select osf_gettimeofday osf_settimeofday \
 		   osf_getitimer osf_setitimer osf_utimes \
 		   osf_getrusage osf_wait4
 
-# Support old ipc control
-sysdep_routines += oldshmctl
-
 CFLAGS-ioperm.c = -Wa,-mev6
 endif
 
diff --git a/sysdeps/unix/sysv/linux/alpha/shmctl.c b/sysdeps/unix/sysv/linux/alpha/shmctl.c
deleted file mode 100644
index f73ed6f..0000000
--- a/sysdeps/unix/sysv/linux/alpha/shmctl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/arm/shmctl.c>
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 9948d2d..bf9c8ad 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -1,6 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-oldshmctl	EXTRA	shmctl		i:iip	__old_shmctl	shmctl@GLIBC_2.0
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 
diff --git a/sysdeps/unix/sysv/linux/arm/shmctl.c b/sysdeps/unix/sysv/linux/arm/shmctl.c
deleted file mode 100644
index 23c4b8d..0000000
--- a/sysdeps/unix/sysv/linux/arm/shmctl.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 1995-2016 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 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 <sys/syscall.h>
-#include <bits/wordsize.h>
-
-
-int
-__new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
-{
-  return INLINE_SYSCALL (shmctl, 3, shmid, cmd | __IPC_64, buf);
-}
-
-#include <shlib-compat.h>
-versioned_symbol (libc, __new_shmctl, shmctl, GLIBC_2_2);
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index 0df73a9..80244c4 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -2,7 +2,6 @@
 
 # SysV APIs
 shmget		-	shmget		i:iii	__shmget	shmget
-shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 
 # Socket APIs
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index f757f02..d755bfd 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # semaphore and shm system calls
-shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index b0a3a44..90bd870 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -5,7 +5,6 @@ umount2		-	umount		2	__umount2	umount2
 getpriority	-	getpriority	i:ii	__getpriority	getpriority
 
 # semaphore and shm system calls
-shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 
diff --git a/sysdeps/unix/sysv/linux/microblaze/shmctl.c b/sysdeps/unix/sysv/linux/microblaze/shmctl.c
deleted file mode 100644
index f73ed6f..0000000
--- a/sysdeps/unix/sysv/linux/microblaze/shmctl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/arm/shmctl.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/shmctl.c b/sysdeps/unix/sysv/linux/mips/mips64/shmctl.c
index ea0fa94..f835cf8 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/shmctl.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/shmctl.c
@@ -15,18 +15,11 @@
    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 <shlib-compat.h>
 
-int __shmctl (int shmid, int cmd, struct shmid_ds *buf);
+#undef SHLIB_COMPAT
+#define SHLIB_COMPAT(a, b, c) 0
 
-int
-__shmctl (int shmid, int cmd, struct shmid_ds *buf)
-{
-  return INLINE_SYSCALL (shmctl, 3, shmid, cmd | __IPC_64, buf);
-}
+#define DEFAULT_VERSION GLIBC_2_0
 
-#include <shlib-compat.h>
-versioned_symbol (libc, __shmctl, shmctl, GLIBC_2_0);
+#include <./sysdeps/unix/sysv/linux/shmctl.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 40ed7c5..4d478ce 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -1,6 +1,5 @@
 # File name     Caller  Syscall name    # args  Strong name     Weak names
 
 # semaphore and shm system calls
-shmctl          -       shmctl          i:iip   __shmctl        shmctl
 shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
diff --git a/sysdeps/unix/sysv/linux/shmctl.c b/sysdeps/unix/sysv/linux/shmctl.c
index b2caf75..07725fe 100644
--- a/sysdeps/unix/sysv/linux/shmctl.c
+++ b/sysdeps/unix/sysv/linux/shmctl.c
@@ -16,18 +16,34 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
 #include <sys/shm.h>
+#include <stdarg.h>
 #include <ipc_priv.h>
-
 #include <sysdep.h>
-#include <string.h>
-#include <sys/syscall.h>
-#include <bits/wordsize.h>
 #include <shlib-compat.h>
+#include <errno.h>
+
+
+#ifndef DEFAULT_VERSION
+# define DEFAULT_VERSION GLIBC_2_2
+#endif
 
-#include <kernel-features.h>
 
+/* Provide operations to control over shared memory segments.  */
+int
+__new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
+{
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (shmctl, shmid, cmd | __IPC_64, buf);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_shmctl, shmid, cmd | __IPC_64, 0,
+			      buf);
+#endif
+}
+versioned_symbol (libc, __new_shmctl, shmctl, DEFAULT_VERSION);
+
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
 struct __old_shmid_ds
 {
   struct __old_ipc_perm shm_perm;	/* operation permission struct */
@@ -43,36 +59,15 @@ struct __old_shmid_ds
   struct vm_area_struct *__attaches;	/* descriptors for attaches */
 };
 
-struct __old_shminfo
-{
-  int shmmax;
-  int shmmin;
-  int shmmni;
-  int shmseg;
-  int shmall;
-};
-
-/* Provide operations to control over shared memory segments.  */
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
-int __old_shmctl (int, int, struct __old_shmid_ds *);
-#endif
-int __new_shmctl (int, int, struct shmid_ds *);
-
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
 int
 attribute_compat_text_section
 __old_shmctl (int shmid, int cmd, struct __old_shmid_ds *buf)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (shmctl, shmid, cmd, buf);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_shmctl, shmid, cmd, 0, buf);
+#endif
 }
 compat_symbol (libc, __old_shmctl, shmctl, GLIBC_2_0);
 #endif
-
-int
-__new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
-{
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd | __IPC_64, 0,
-			 buf);
-}
-
-versioned_symbol (libc, __new_shmctl, shmctl, GLIBC_2_2);
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 8712bb8..18bd588 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -6,7 +6,6 @@ pread64		-	pread64		Ci:ipii	__libc_pread	__libc_pread64 __pread64 pread64 __prea
 preadv64	-	preadv		Ci:ipii	preadv64	preadv
 pwrite64	-	pwrite64	Ci:ipii	__libc_pwrite	__libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite
 pwritev64	-	pwritev		Ci:ipii	pwritev64	pwritev
-shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 syscall_clock_gettime	EXTRA	clock_gettime	Ei:ip		__syscall_clock_gettime
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 06/17] Use msgget syscall for Linux implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (14 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 14/17] Consolidate Linux shmctl implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 01/17] Add __ASSUME_DIRECT_SYSVIPC_SYSCALL for Linux Adhemerval Zanella
  2016-12-19 18:18 ` Adhemerval Zanella
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch add a direct call to msgget syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgget): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (msgget): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (msgget): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgget): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgget): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (msgget): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (msgget):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgget):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgget): Likewise.
	* sysdeps/unix/sysv/linux/msgget.c (msgget): Use msgget syscall if
	define.
---
 ChangeLog                                          | 14 ++++++++++++++
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/syscalls.list          |  1 -
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/syscalls.list   |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list  |  1 -
 sysdeps/unix/sysv/linux/msgget.c                   | 11 ++++++-----
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 11 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index ced9c10..54c1752 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -1,6 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-msgget		-	msgget		i:ii	__msgget	msgget
 shmat		-	osf_shmat	i:ipi	__shmat		shmat
 oldshmctl	EXTRA	shmctl		i:iip	__old_shmctl	shmctl@GLIBC_2.0
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index 43c464d..4bf4826 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -23,7 +23,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-msgget		-	msgget		i:ii	__msgget	msgget
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index f65598a..ad75223 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # SysV APIs
-msgget		-	msgget		i:ii	__msgget	msgget
 semget		-	semget		i:iii	__semget	semget
 semctl		-	semctl		i:iiii	__semctl	semctl
 semtimedop	-	semtimedop	i:ipip	semtimedop
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index 3fbd81a..da2c9ab 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # semaphore and shm system calls
-msgget		-	msgget		i:ii	__msgget	msgget
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 9edcbe6..8056781 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -5,7 +5,6 @@ umount2		-	umount		2	__umount2	umount2
 getpriority	-	getpriority	i:ii	__getpriority	getpriority
 
 # semaphore and shm system calls
-msgget		-	msgget		i:ii	__msgget	msgget
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index ed715ba..c40bac3 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -8,7 +8,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-msgget          -       msgget          i:ii    __msgget        msgget
 shmat           -       shmat           i:ipi   __shmat         shmat
 shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
index 4c59a33..7c992d7 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -2,7 +2,6 @@
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-msgget		-	msgget		i:ii	__msgget	msgget
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/msgget.c b/sysdeps/unix/sysv/linux/msgget.c
index ef98c75..d487f04 100644
--- a/sysdeps/unix/sysv/linux/msgget.c
+++ b/sysdeps/unix/sysv/linux/msgget.c
@@ -16,13 +16,10 @@
    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 <stdlib.h>		/* for definition of NULL */
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <errno.h>
 
 /* Return descriptor for message queue associated with KEY.  The MSGFLG
    parameter describes how to proceed with clashing of key values.  */
@@ -30,5 +27,9 @@
 int
 msgget (key_t key, int msgflg)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgget, key, msgflg, 0, NULL);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (msgget, key, msgflg);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_msgget, key, msgflg, 0, NULL);
+#endif
 }
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 259bdfc..f23b379 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # semaphore and shm system calls
-msgget		-	msgget		i:ii	__msgget	msgget
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 2d46bb3..75b25a1 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -2,7 +2,6 @@
 
 arch_prctl	EXTRA	arch_prctl	i:ii	__arch_prctl	arch_prctl
 modify_ldt	EXTRA	modify_ldt	i:ipi	__modify_ldt	modify_ldt
-msgget		-	msgget		i:ii	__msgget	msgget
 pread64		-	pread64		Ci:ipii	__libc_pread	__libc_pread64 __pread64 pread64 __pread pread
 preadv64	-	preadv		Ci:ipii	preadv64	preadv
 pwrite64	-	pwrite64	Ci:ipii	__libc_pwrite	__libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 17/17] Add SYSV shared memory test
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
  2016-12-12 12:33 ` [PATCH 02/17] Refactor Linux ipc_priv header Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 07/17] Add SYSV message queue test Adhemerval Zanella
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch adds a simple SYSV shared memory test to check for correct
argument passing on kernel.  The idea is neither to be an extensive
testing nor to check for any specific Linux test.

	* sysvipc/Makefile (tests): Add test-sysvshm.
	* sysvipc/test-sysvshm.c: New file.
---
 ChangeLog              |   3 ++
 sysvipc/Makefile       |   2 +-
 sysvipc/test-sysvshm.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 sysvipc/test-sysvshm.c

diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index 32d64dc..daede74 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -30,7 +30,7 @@ routines := ftok \
 	    semop semget semctl semtimedop \
 	    shmat shmdt shmget shmctl
 
-tests    := test-sysvmsg test-sysvsem
+tests    := test-sysvmsg test-sysvsem test-sysvshm
 
 include ../Rules
 
diff --git a/sysvipc/test-sysvshm.c b/sysvipc/test-sysvshm.c
new file mode 100644
index 0000000..2c197cc
--- /dev/null
+++ b/sysvipc/test-sysvshm.c
@@ -0,0 +1,131 @@
+/* Basic tests for SYSV shared memory functions.
+   Copyright (C) 2016 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 <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#include <support/support.h>
+#include <support/check.h>
+#include <support/temp_file.h>
+
+/* These are for the temporary file we generate.  */
+static char *name;
+static int shmid;
+
+static void
+remove_shm (void)
+{
+  /* Enforce message queue removal in case of early test failure.  
+     Ignore error since the shm may already have being removed.  */
+  shmctl (shmid, IPC_RMID, 0);
+}
+
+static void
+do_prepare (int argc, char *argv[])
+{
+  int fd = create_temp_file ("tst-sysvshm.", &name);
+  if (fd == -1)
+    FAIL_EXIT1 ("cannot create temporary file (errno=%d)", errno);
+}
+
+#define PREPARE do_prepare
+
+/* It is not an extensive test, but rather a functional one aimed to check
+   correct parameter passing on kernel.  */
+
+#define CHECK_EQ(v, k) \
+  if ((v) != (k)) \
+    FAIL_EXIT1("%d != %d", v, k)
+
+#define SHM_MODE 0666
+
+static int
+do_test (void)
+{
+  atexit (remove_shm);
+
+  key_t key = ftok (name, 'G');
+  if (key == -1)
+    FAIL_EXIT1 ("ftok failed");
+
+  long int pgsz = sysconf (_SC_PAGESIZE);
+  if (pgsz == -1)
+    FAIL_EXIT1 ("sysconf (_SC_PAGESIZE) failed (errno = %d)", errno);
+
+  shmid = shmget(key, pgsz, IPC_CREAT | IPC_EXCL | SHM_MODE);
+  if (shmid == -1)
+    {
+      if (errno == ENOSYS)
+	FAIL_UNSUPPORTED ("shmget not supported");
+      FAIL_EXIT1 ("shmget failed (errno=%d)", errno);
+    }
+
+  /* Get shared memory kernel information and do some sanity checks.  */
+  struct shmid_ds shminfo;
+  if (shmctl (shmid, IPC_STAT, &shminfo) == -1)
+    FAIL_EXIT1 ("shmctl with IPC_STAT failed (errno=%d)", errno);
+
+  if (shminfo.shm_perm.__key != key)
+    FAIL_EXIT1 ("shmid_ds::shm_perm::key (%d) != %d",
+		(int) shminfo.shm_perm.__key, (int) key);
+  if (shminfo.shm_perm.mode != SHM_MODE)
+    FAIL_EXIT1 ("shmid_ds::shm_perm::mode (%o) != %o",
+		shminfo.shm_perm.mode, SHM_MODE);
+  if (shminfo.shm_segsz != pgsz)
+    FAIL_EXIT1 ("shmid_ds::shm_segsz (%lu) != %lu",
+		(long unsigned) shminfo.shm_segsz, pgsz);
+
+  /* Attach on shared memory and realize some operations.  */
+  int *shmem = shmat (shmid, NULL, 0);
+  if (shmem == (void*) -1)
+    FAIL_EXIT1 ("shmem failed (errno=%d)", errno);
+
+  shmem[0]   = 0x55555555;
+  shmem[32]  = 0x44444444;
+  shmem[64]  = 0x33333333;
+  shmem[128] = 0x22222222;
+  
+  if (shmdt (shmem) == -1)
+    FAIL_EXIT1 ("shmem failed (errno=%d)", errno);
+
+  shmem = shmat (shmid, NULL, SHM_RDONLY);
+  if (shmem == (void*) -1)
+    FAIL_EXIT1 ("shmem failed (errno=%d)", errno);
+
+  CHECK_EQ (shmem[0],   0x55555555);
+  CHECK_EQ (shmem[32],  0x44444444);
+  CHECK_EQ (shmem[64],  0x33333333);
+  CHECK_EQ (shmem[128], 0x22222222);
+  
+  if (shmdt (shmem) == -1)
+    FAIL_EXIT1 ("shmem failed (errno=%d)", errno);
+
+  /* Finally free up the semnaphore resource.  */
+  if (shmctl (shmid, IPC_RMID, 0) == -1)
+    FAIL_EXIT1 ("semctl failed (errno=%d)", errno);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 03/17] Consolidate Linux msgctl implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (5 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 04/17] Consolidate Linux msgrcv implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 15/17] Use shmdt syscall for linux implementation Adhemerval Zanella
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the msgctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/msgctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
	oldmsgctl.
	* sysdeps/unix/sysv/linux/alpha/msgctl.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/msgctl.c: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/msgctl.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/syscalls.list (oldmsgctl): Remove.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (msgctl): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgctl): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgctl): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgctl):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgctl): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/msgctl.c: Use default
	implementation.
	* sysdeps/unix/sysv/linux/msgctl.c (__new_msgctl): Use msgctl syscall
	if defined.
---
 ChangeLog                                          | 17 ++++++++
 sysdeps/unix/sysv/linux/alpha/Makefile             |  2 +-
 sysdeps/unix/sysv/linux/alpha/msgctl.c             |  1 -
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/msgctl.c               | 33 ----------------
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/msgctl.c        |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/msgctl.c       | 17 +++-----
 sysdeps/unix/sysv/linux/msgctl.c                   | 45 +++++++++++-----------
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 13 files changed, 46 insertions(+), 76 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/msgctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/msgctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/msgctl.c

diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile
index 45941b0..c24dc2e 100644
--- a/sysdeps/unix/sysv/linux/alpha/Makefile
+++ b/sysdeps/unix/sysv/linux/alpha/Makefile
@@ -18,7 +18,7 @@ sysdep_routines += osf_select osf_gettimeofday osf_settimeofday \
 		   osf_getrusage osf_wait4
 
 # Support old ipc control
-sysdep_routines += oldmsgctl oldsemctl oldshmctl
+sysdep_routines += oldsemctl oldshmctl
 
 CFLAGS-ioperm.c = -Wa,-mev6
 endif
diff --git a/sysdeps/unix/sysv/linux/alpha/msgctl.c b/sysdeps/unix/sysv/linux/alpha/msgctl.c
deleted file mode 100644
index d65a5b9..0000000
--- a/sysdeps/unix/sysv/linux/alpha/msgctl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/arm/msgctl.c>
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 0c9efcb..f82c9da 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -1,6 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-oldmsgctl	EXTRA	msgctl		i:iip	__old_msgctl	msgctl@GLIBC_2.0
 msgget		-	msgget		i:ii	__msgget	msgget
 msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
diff --git a/sysdeps/unix/sysv/linux/arm/msgctl.c b/sysdeps/unix/sysv/linux/arm/msgctl.c
deleted file mode 100644
index 83c6744..0000000
--- a/sysdeps/unix/sysv/linux/arm/msgctl.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 1995-2016 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 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 <sys/syscall.h>
-
-
-int
-__new_msgctl (int msqid, int cmd, struct msqid_ds *buf)
-{
-  return INLINE_SYSCALL (msgctl, 3, msqid, cmd | __IPC_64, buf);
-}
-
-#include <shlib-compat.h>
-versioned_symbol (libc, __new_msgctl, msgctl, GLIBC_2_2);
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index 5993ab4..dea452b 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -2,7 +2,6 @@
 
 # SysV APIs
 msgget		-	msgget		i:ii	__msgget	msgget
-msgctl		-	msgctl		i:iip	__msgctl	msgctl
 msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 semget		-	semget		i:iii	__semget	semget
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index a95c3dd..ead0e99 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # semaphore and shm system calls
-msgctl		-	msgctl		i:iip	__msgctl	msgctl
 msgget		-	msgget		i:ii	__msgget	msgget
 msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 68b6c9a..8a66ca9 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -5,7 +5,6 @@ umount2		-	umount		2	__umount2	umount2
 getpriority	-	getpriority	i:ii	__getpriority	getpriority
 
 # semaphore and shm system calls
-msgctl		-	msgctl		i:iip	__msgctl	msgctl
 msgget		-	msgget		i:ii	__msgget	msgget
 msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
diff --git a/sysdeps/unix/sysv/linux/microblaze/msgctl.c b/sysdeps/unix/sysv/linux/microblaze/msgctl.c
deleted file mode 100644
index d65a5b9..0000000
--- a/sysdeps/unix/sysv/linux/microblaze/msgctl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/arm/msgctl.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/msgctl.c b/sysdeps/unix/sysv/linux/mips/mips64/msgctl.c
index c4dc7ff..928c3dc 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/msgctl.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/msgctl.c
@@ -15,18 +15,11 @@
    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 <shlib-compat.h>
 
-int __msgctl (int msqid, int cmd, struct msqid_ds *buf);
+#undef SHLIB_COMPAT
+#define SHLIB_COMPAT(a, b, c) 0
 
-int
-__msgctl (int msqid, int cmd, struct msqid_ds *buf)
-{
-  return INLINE_SYSCALL (msgctl, 3, msqid, cmd | __IPC_64, buf);
-}
+#define DEFAULT_VERSION GLIBC_2_0
 
-#include <shlib-compat.h>
-versioned_symbol (libc, __msgctl, msgctl, GLIBC_2_0);
+#include <sysdeps/unix/sysv/linux/msgctl.c>
diff --git a/sysdeps/unix/sysv/linux/msgctl.c b/sysdeps/unix/sysv/linux/msgctl.c
index e48fbb3..45bf350 100644
--- a/sysdeps/unix/sysv/linux/msgctl.c
+++ b/sysdeps/unix/sysv/linux/msgctl.c
@@ -16,17 +16,30 @@
    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 <shlib-compat.h>
+#include <errno.h>
+
+#ifndef DEFAULT_VERSION
+# define DEFAULT_VERSION GLIBC_2_2
+#endif
+
+int
+__new_msgctl (int msqid, int cmd, struct msqid_ds *buf)
+{
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (msgctl, msqid, cmd | __IPC_64, buf);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd | __IPC_64, 0,
+			      buf);
+#endif
+}
+versioned_symbol (libc, __new_msgctl, msgctl, DEFAULT_VERSION);
 
-#include <kernel-features.h>
 
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
 struct __old_msqid_ds
 {
   struct __old_ipc_perm msg_perm;	/* structure describing operation permission */
@@ -44,27 +57,15 @@ struct __old_msqid_ds
   __ipc_pid_t msg_lrpid;		/* pid of last msgrcv() */
 };
 
-/* Allows to control internal state and destruction of message queue
-   objects.  */
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
-int __old_msgctl (int, int, struct __old_msqid_ds *);
-#endif
-int __new_msgctl (int, int, struct msqid_ds *);
-
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
 int
 attribute_compat_text_section
 __old_msgctl (int msqid, int cmd, struct __old_msqid_ds *buf)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (msgctl, msqid, cmd | __IPC_64, buf);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);
+#endif
 }
 compat_symbol (libc, __old_msgctl, msgctl, GLIBC_2_0);
 #endif
-
-int
-__new_msgctl (int msqid, int cmd, struct msqid_ds *buf)
-{
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf);
-}
-
-versioned_symbol (libc, __new_msgctl, msgctl, GLIBC_2_2);
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 9f03d26..808cbbb 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # semaphore and shm system calls
-msgctl		-	msgctl		i:iip	__msgctl	msgctl
 msgget		-	msgget		i:ii	__msgget	msgget
 msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 8aed2f4..4d19d75 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -2,7 +2,6 @@
 
 arch_prctl	EXTRA	arch_prctl	i:ii	__arch_prctl	arch_prctl
 modify_ldt	EXTRA	modify_ldt	i:ipi	__modify_ldt	modify_ldt
-msgctl		-	msgctl		i:iip	__msgctl	msgctl
 msgget		-	msgget		i:ii	__msgget	msgget
 msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 12/17] Add SYSV semaphore test
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (8 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 05/17] Use msgsnd syscall for Linux implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 09/17] Use semget syscall for Linux implementation Adhemerval Zanella
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch adds a simple SYSV semaphore test to check for correct
argument passing on kernel.  The idea is neither to be an extensive
testing nor to check for any specific Linux test.

	* sysvipc/Makefile (tests): Add test-sysvsem.
	* sysvipc/test-sysvsem.c: New file.
---
 ChangeLog              |   3 ++
 sysvipc/Makefile       |   2 +-
 sysvipc/test-sysvsem.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 sysvipc/test-sysvsem.c

diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index 73bb9cf..32d64dc 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -30,7 +30,7 @@ routines := ftok \
 	    semop semget semctl semtimedop \
 	    shmat shmdt shmget shmctl
 
-tests    := test-sysvmsg
+tests    := test-sysvmsg test-sysvsem
 
 include ../Rules
 
diff --git a/sysvipc/test-sysvsem.c b/sysvipc/test-sysvsem.c
new file mode 100644
index 0000000..fd9db4f
--- /dev/null
+++ b/sysvipc/test-sysvsem.c
@@ -0,0 +1,116 @@
+/* Basic tests for SYSV semaphore functions.
+   Copyright (C) 2016 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 <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+
+#include <support/support.h>
+#include <support/check.h>
+#include <support/temp_file.h>
+
+/* These are for the temporary file we generate.  */
+static char *name;
+static int semid;
+
+static void
+remove_sem (void)
+{
+  /* Enforce message queue removal in case of early test failure.
+     Ignore error since the sem may already have being removed.  */
+  semctl (semid, 0, IPC_RMID, 0);
+}
+
+static void
+do_prepare (int argc, char *argv[])
+{
+  int fd = create_temp_file ("tst-sysvsem.", &name);
+  if (fd == -1)
+    FAIL_EXIT1 ("cannot create temporary file (errno=%d)", errno);
+}
+
+#define PREPARE do_prepare
+
+/* It is not an extensive test, but rather a functional one aimed to check
+   correct parameter passing on kernel.  */
+
+#define SEM_MODE 0644
+
+static int
+do_test (void)
+{
+  atexit (remove_sem);
+
+  key_t key = ftok (name, 'G');
+  if (key == -1)
+    FAIL_EXIT1 ("ftok failed");
+
+  semid = semget(key, 1, IPC_CREAT | IPC_EXCL | SEM_MODE);
+  if (semid == -1)
+    {
+      if (errno == ENOSYS)
+	FAIL_UNSUPPORTED ("msgget not supported");
+      FAIL_EXIT1 ("semget failed (errno=%d)", errno);
+    }
+
+  /* Get semaphore kernel information and do some sanity checks.  */
+  struct semid_ds seminfo;
+  if (semctl (semid, 0, IPC_STAT, &seminfo) == -1)
+    FAIL_EXIT1 ("semctl with IPC_STAT failed (errno=%d)", errno);
+
+  if (seminfo.sem_perm.__key != key)
+    FAIL_EXIT1 ("semid_ds::sem_perm::key (%d) != %d",
+		(int) seminfo.sem_perm.__key, (int) key);
+  if (seminfo.sem_perm.mode != SEM_MODE)
+    FAIL_EXIT1 ("semid_ds::sem_perm::mode (%o) != %o",
+		seminfo.sem_perm.mode, SEM_MODE);
+  if (seminfo.sem_nsems != 1)
+    FAIL_EXIT1 ("semid_ds::sem_nsems (%lu) != 1",
+		(long unsigned) seminfo.sem_nsems);
+
+  /* Some lock/unlock basic tests.  */
+  struct sembuf sb1 = { 0, 1, 0 };
+  if (semop (semid, &sb1, 1) == -1)
+    FAIL_EXIT1 ("semop failed (errno=%i)", errno);
+
+  struct sembuf sb2 = { 0, -1, 0 };
+  if (semop (semid, &sb2, 1) == -1)
+    FAIL_EXIT1 ("semop failed (errno=%i)", errno);
+
+#ifdef _GNU_SOURCE
+  /* Set a time for half a second.  The semaphore operation should timeout
+     with EAGAIN.  */
+  struct timespec ts = { 0 /* sec */, 500000000 /* nsec */ };
+  if (semtimedop (semid, &sb2, 1, &ts) != -1
+      || (errno != EAGAIN && errno != ENOSYS))
+    FAIL_EXIT1 ("semtimedop succeed or returned errno != {EAGAIN,ENOSYS} "
+		"(errno=%i)", errno);
+#endif
+
+  /* Finally free up the semnaphore resource.  */
+  if (semctl (semid, 0, IPC_RMID, 0) == -1)
+    FAIL_EXIT1 ("semctl failed (errno=%d)", errno);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 15/17] Use shmdt syscall for linux implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (6 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 03/17] Consolidate Linux msgctl implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 05/17] Use msgsnd syscall for Linux implementation Adhemerval Zanella
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

this patch add a direct call to shmdt syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmdt): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (shmdt): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (shmdt): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmdt): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmdt): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmdt): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmdt):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmdt):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmdt): Likewise.
	* sysdeps/unix/sysv/linux/shmdt.c (shmdt): Use shmdt syscall if it is
	defined.
---
 ChangeLog                                          | 14 ++++++++++++++
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/syscalls.list          |  1 -
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/syscalls.list   |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list  |  1 -
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/shmdt.c                    | 12 +++++++-----
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 11 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index bf9c8ad..096bf22 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -1,6 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 
 sigstack	-	sigstack	2	sigstack
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index f50a5cf..b1ea664 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -23,7 +23,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 
 # proper socket implementations:
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index 80244c4..51ce148 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -2,7 +2,6 @@
 
 # SysV APIs
 shmget		-	shmget		i:iii	__shmget	shmget
-shmdt		-	shmdt		i:s	__shmdt		shmdt
 
 # Socket APIs
 socket		-	socket		i:iii	__socket	socket
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index d755bfd..e75dd43 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # semaphore and shm system calls
-shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 
 # proper socket implementations:
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 90bd870..5ebade1 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -5,7 +5,6 @@ umount2		-	umount		2	__umount2	umount2
 getpriority	-	getpriority	i:ii	__getpriority	getpriority
 
 # semaphore and shm system calls
-shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 
 # proper socket implementations:
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index 8b844f2..7a5666f 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -8,5 +8,4 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
index e93c87a..e8e381b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -2,5 +2,4 @@
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 4d478ce..0ccbffa 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -1,5 +1,4 @@
 # File name     Caller  Syscall name    # args  Strong name     Weak names
 
 # semaphore and shm system calls
-shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
diff --git a/sysdeps/unix/sysv/linux/shmdt.c b/sysdeps/unix/sysv/linux/shmdt.c
index 7224d6f..5f3363e 100644
--- a/sysdeps/unix/sysv/linux/shmdt.c
+++ b/sysdeps/unix/sysv/linux/shmdt.c
@@ -16,12 +16,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <sys/shm.h>
+#include <sys/msg.h>
 #include <ipc_priv.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <errno.h>
 
 /* Detach shared memory segment starting at address specified by SHMADDR
    from the caller's data segment.  */
@@ -29,5 +27,9 @@
 int
 shmdt (const void *shmaddr)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmdt, 0, 0, 0, (void *) shmaddr);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (shmdt, shmaddr);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_shmdt, 0, 0, 0, shmaddr);
+#endif
 }
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 18bd588..cb1a9f9 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -6,7 +6,6 @@ pread64		-	pread64		Ci:ipii	__libc_pread	__libc_pread64 __pread64 pread64 __prea
 preadv64	-	preadv		Ci:ipii	preadv64	preadv
 pwrite64	-	pwrite64	Ci:ipii	__libc_pwrite	__libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite
 pwritev64	-	pwritev		Ci:ipii	pwritev64	pwritev
-shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 syscall_clock_gettime	EXTRA	clock_gettime	Ei:ip		__syscall_clock_gettime
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 10/17] Use semop syscall for Linux implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (2 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 07/17] Add SYSV message queue test Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 16/17] Use shmget syscall for linux implementation Adhemerval Zanella
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch add a direct call to semop syscall if it is supported by
kernel headers.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (semop): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (semop): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (semop): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (semop): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (semop): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (semop): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semop):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semop):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semop): Likewise.
	* sysdeps/unix/sysv/linux/semop.c (semop): Use semop syscall if it is
	defined.
---
 ChangeLog                                          | 14 ++++++++++++++
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/syscalls.list          |  1 -
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/syscalls.list   |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list  |  1 -
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/semop.c                    | 10 ++++++----
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 11 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 2533263..c20543a 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -4,7 +4,6 @@ shmat		-	osf_shmat	i:ipi	__shmat		shmat
 oldshmctl	EXTRA	shmctl		i:iip	__old_shmctl	shmctl@GLIBC_2.0
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 
 sigstack	-	sigstack	2	sigstack
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index ef5bd01..3014db8 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -26,7 +26,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 
 # proper socket implementations:
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index 485f6fe..54e1778 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -2,7 +2,6 @@
 
 # SysV APIs
 semtimedop	-	semtimedop	i:ipip	semtimedop
-semop		-	semop		i:ipi	__semop		semop
 shmget		-	shmget		i:iii	__shmget	shmget
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmat		-	shmat		i:ipi	__shmat		shmat
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index 685ab93..8fbcaba 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -5,7 +5,6 @@ shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semop		-	semop		i:ipi	__semop		semop
 semtimedop      -       semtimedop      i:ipip  semtimedop
 
 # proper socket implementations:
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 56200ba..b9271cc 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -9,7 +9,6 @@ shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 
 # proper socket implementations:
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index a0b8ebf..3da653d 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -11,5 +11,4 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 shmat           -       shmat           i:ipi   __shmat         shmat
 shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
-semop           -       semop           i:ipi   __semop         semop
 semtimedop      -       semtimedop      i:ipip  semtimedop
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
index 374fcc2..720db96 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -5,5 +5,4 @@
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 288e080..924d182 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -5,4 +5,3 @@ shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semop		-	semop		i:ipi	__semop		semop
diff --git a/sysdeps/unix/sysv/linux/semop.c b/sysdeps/unix/sysv/linux/semop.c
index 593eb4c..c179fcc 100644
--- a/sysdeps/unix/sysv/linux/semop.c
+++ b/sysdeps/unix/sysv/linux/semop.c
@@ -16,17 +16,19 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
 #include <sys/sem.h>
 #include <ipc_priv.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <errno.h>
 
 /* Perform user-defined atomical operation of array of semaphores.  */
 
 int
 semop (int semid, struct sembuf *sops, size_t nsops)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semop, semid, (int) nsops, 0, sops);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (semop, semid, sops, nsops);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_semop, semid, nsops, 0, sops);
+#endif
 }
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index d77a7ca..d17a186 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -10,7 +10,6 @@ shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 syscall_clock_gettime	EXTRA	clock_gettime	Ei:ip		__syscall_clock_gettime
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 13/17] Use shmat syscall for Linux implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (10 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 09/17] Use semget syscall for Linux implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 11/17] Consolidate Linux semtimedop implementation Adhemerval Zanella
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch add a direct call to shmat syscall if it is supported by
kernel features.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmat): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmat):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmat):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h (__NR_shmat):
	Define to __NR_osf_shmat.
	* sysdeps/unix/sysv/linux/shmat.c (shmat): Use shmat syscall if it is
	defined.
---
 ChangeLog                                          | 16 ++++++++++++++++
 sysdeps/unix/sysv/linux/alpha/kernel-features.h    |  3 +++
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/syscalls.list          |  1 -
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/syscalls.list   |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list  |  1 -
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  9 ++++-----
 sysdeps/unix/sysv/linux/shmat.c                    | 17 ++++++++---------
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 12 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/kernel-features.h b/sysdeps/unix/sysv/linux/alpha/kernel-features.h
index f09222d..2fc3b77 100644
--- a/sysdeps/unix/sysv/linux/alpha/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/alpha/kernel-features.h
@@ -29,4 +29,7 @@
 #undef __ASSUME_STATFS64
 #define __ASSUME_STATFS64 0
 
+/* Alpha defines SysV ipc shmat syscall with a different name.  */
+#define __NR_shmat __NR_osf_shmat
+
 #endif /* _KERNEL_FEATURES_H */
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 8d3a042..9948d2d 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -1,6 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-shmat		-	osf_shmat	i:ipi	__shmat		shmat
 oldshmctl	EXTRA	shmctl		i:iip	__old_shmctl	shmctl@GLIBC_2.0
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index 1b2de93..f50a5cf 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -23,7 +23,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index e12fb3e..0df73a9 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -3,7 +3,6 @@
 # SysV APIs
 shmget		-	shmget		i:iii	__shmget	shmget
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
-shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 
 # Socket APIs
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index a8fbc44..f757f02 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # semaphore and shm system calls
-shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index eda4e4e..b0a3a44 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -5,7 +5,6 @@ umount2		-	umount		2	__umount2	umount2
 getpriority	-	getpriority	i:ii	__getpriority	getpriority
 
 # semaphore and shm system calls
-shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index d9afda0..8b844f2 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -8,6 +8,5 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-shmat           -       shmat           i:ipi   __shmat         shmat
 shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
index 9cbbd38..e93c87a 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -2,6 +2,5 @@
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 924d182..40ed7c5 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -1,7 +1,6 @@
-# File name	Caller	Syscall name	# args	Strong name	Weak names
+# File name     Caller  Syscall name    # args  Strong name     Weak names
 
 # semaphore and shm system calls
-shmat		-	shmat		i:ipi	__shmat		shmat
-shmctl		-	shmctl		i:iip	__shmctl	shmctl
-shmdt		-	shmdt		i:s	__shmdt		shmdt
-shmget		-	shmget		i:iii	__shmget	shmget
+shmctl          -       shmctl          i:iip   __shmctl        shmctl
+shmdt           -       shmdt           i:s     __shmdt         shmdt
+shmget          -       shmget          i:iii   __shmget        shmget
diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c
index 5afc93c..d1ef323 100644
--- a/sysdeps/unix/sysv/linux/shmat.c
+++ b/sysdeps/unix/sysv/linux/shmat.c
@@ -16,13 +16,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <sys/shm.h>
+#include <sys/msg.h>
 #include <ipc_priv.h>
-
 #include <sysdep.h>
-#include <unistd.h>
-#include <sys/syscall.h>
+#include <errno.h>
 
 /* Attach the shared memory segment associated with SHMID to the data
    segment of the calling process.  SHMADDR and SHMFLG determine how
@@ -31,17 +28,19 @@
 void *
 shmat (int shmid, const void *shmaddr, int shmflg)
 {
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return (void*) INLINE_SYSCALL_CALL (shmat, shmid, shmaddr, shmflg);
+#else
   INTERNAL_SYSCALL_DECL(err);
   unsigned long resultvar;
   void *raddr;
 
-  resultvar = INTERNAL_SYSCALL (ipc, err, 5, IPCOP_shmat,
-				shmid, shmflg,
-				(long int) &raddr,
-				(void *) shmaddr);
+  resultvar = INTERNAL_SYSCALL_CALL (ipc, err, IPCOP_shmat, shmid, shmflg,
+				     &raddr, shmaddr);
   if (INTERNAL_SYSCALL_ERROR_P (resultvar, err))
     return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (resultvar,
 									       err));
 
   return raddr;
+#endif
 }
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 573ed07..8712bb8 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -6,7 +6,6 @@ pread64		-	pread64		Ci:ipii	__libc_pread	__libc_pread64 __pread64 pread64 __prea
 preadv64	-	preadv		Ci:ipii	preadv64	preadv
 pwrite64	-	pwrite64	Ci:ipii	__libc_pwrite	__libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite
 pwritev64	-	pwritev		Ci:ipii	pwritev64	pwritev
-shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 05/17] Use msgsnd syscall for Linux implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (7 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 15/17] Use shmdt syscall for linux implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 12/17] Add SYSV semaphore test Adhemerval Zanella
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch add a direct call to msgsnd syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgsnd): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (msgsnd): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (msgsnd): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgsnd): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgsnd): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (msgsnd): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (msgsnd):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgsnd):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgsnd): Likewise.
	* sysdeps/unix/sysv/linux/msgsnd.c (__libc_msgsnd): Use msgsnd syscall
	if defined.
---
 ChangeLog                                          | 14 ++++++++++++++
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/syscalls.list          |  1 -
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/syscalls.list   |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list  |  1 -
 sysdeps/unix/sysv/linux/msgsnd.c                   |  9 +++++----
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 11 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index ddbd672..ced9c10 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 msgget		-	msgget		i:ii	__msgget	msgget
-msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	osf_shmat	i:ipi	__shmat		shmat
 oldshmctl	EXTRA	shmctl		i:iip	__old_shmctl	shmctl@GLIBC_2.0
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index 297f7e7..43c464d 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -24,7 +24,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
 msgget		-	msgget		i:ii	__msgget	msgget
-msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index 6869a48..f65598a 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -2,7 +2,6 @@
 
 # SysV APIs
 msgget		-	msgget		i:ii	__msgget	msgget
-msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 semget		-	semget		i:iii	__semget	semget
 semctl		-	semctl		i:iiii	__semctl	semctl
 semtimedop	-	semtimedop	i:ipip	semtimedop
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index e4e40a0..3fbd81a 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -2,7 +2,6 @@
 
 # semaphore and shm system calls
 msgget		-	msgget		i:ii	__msgget	msgget
-msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index a60e615..9edcbe6 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -6,7 +6,6 @@ getpriority	-	getpriority	i:ii	__getpriority	getpriority
 
 # semaphore and shm system calls
 msgget		-	msgget		i:ii	__msgget	msgget
-msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index 99dc33b..ed715ba 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -9,7 +9,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
 msgget          -       msgget          i:ii    __msgget        msgget
-msgsnd          -       msgsnd          Ci:ibni __msgsnd        msgsnd
 shmat           -       shmat           i:ipi   __shmat         shmat
 shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
index 07b421d..4c59a33 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -3,7 +3,6 @@
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
 msgget		-	msgget		i:ii	__msgget	msgget
-msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/msgsnd.c b/sysdeps/unix/sysv/linux/msgsnd.c
index 1457e43..53cf3c1 100644
--- a/sysdeps/unix/sysv/linux/msgsnd.c
+++ b/sysdeps/unix/sysv/linux/msgsnd.c
@@ -16,17 +16,18 @@
    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-cancel.h>
-#include <sys/syscall.h>
 
 int
 __libc_msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
 {
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return SYSCALL_CANCEL (msgsnd, msqid, msgp, msgsz, msgflg);
+#else
   return SYSCALL_CANCEL (ipc, IPCOP_msgsnd, msqid, msgsz, msgflg,
-			 (void *) msgp);
+			 msgp);
+#endif
 }
 weak_alias (__libc_msgsnd, msgsnd)
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 59b93fe..259bdfc 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -2,7 +2,6 @@
 
 # semaphore and shm system calls
 msgget		-	msgget		i:ii	__msgget	msgget
-msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 7192a96..2d46bb3 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -3,7 +3,6 @@
 arch_prctl	EXTRA	arch_prctl	i:ii	__arch_prctl	arch_prctl
 modify_ldt	EXTRA	modify_ldt	i:ipi	__modify_ldt	modify_ldt
 msgget		-	msgget		i:ii	__msgget	msgget
-msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 pread64		-	pread64		Ci:ipii	__libc_pread	__libc_pread64 __pread64 pread64 __pread pread
 preadv64	-	preadv		Ci:ipii	preadv64	preadv
 pwrite64	-	pwrite64	Ci:ipii	__libc_pwrite	__libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 04/17] Consolidate Linux msgrcv implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (4 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 16/17] Use shmget syscall for linux implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 03/17] Consolidate Linux msgctl implementation Adhemerval Zanella
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the msgrcv Linux implementation in only
one default file, sysdeps/unix/sysv/linux/msgrcv.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgctl): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (msgctl): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (msgctl): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgctl): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgctl): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (msgctl): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgctl):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgctl): Likewise,
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (msgctl):
	Likewise.
	* sysdeps/unix/sysv/linux/msgrcv.c (__libc_msgrcv): Use msgrcv syscall
	if defined.
	* sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c: Remove file.
---
 ChangeLog                                          | 15 ++++++++++
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/syscalls.list          |  1 -
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/syscalls.list   |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list  |  1 -
 sysdeps/unix/sysv/linux/msgrcv.c                   | 26 ++++--------------
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c     | 32 ----------------------
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 12 files changed, 21 insertions(+), 61 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c

diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index f82c9da..ddbd672 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 msgget		-	msgget		i:ii	__msgget	msgget
-msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	osf_shmat	i:ipi	__shmat		shmat
 oldshmctl	EXTRA	shmctl		i:iip	__old_shmctl	shmctl@GLIBC_2.0
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index 82402b1..297f7e7 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -24,7 +24,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
 msgget		-	msgget		i:ii	__msgget	msgget
-msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index dea452b..6869a48 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -2,7 +2,6 @@
 
 # SysV APIs
 msgget		-	msgget		i:ii	__msgget	msgget
-msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 semget		-	semget		i:iii	__semget	semget
 semctl		-	semctl		i:iiii	__semctl	semctl
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index ead0e99..e4e40a0 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -2,7 +2,6 @@
 
 # semaphore and shm system calls
 msgget		-	msgget		i:ii	__msgget	msgget
-msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 8a66ca9..a60e615 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -6,7 +6,6 @@ getpriority	-	getpriority	i:ii	__getpriority	getpriority
 
 # semaphore and shm system calls
 msgget		-	msgget		i:ii	__msgget	msgget
-msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index da0fd4e..99dc33b 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -9,7 +9,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
 msgget          -       msgget          i:ii    __msgget        msgget
-msgrcv          -       msgrcv          Ci:ibnii __msgrcv       msgrcv
 msgsnd          -       msgsnd          Ci:ibni __msgsnd        msgsnd
 shmat           -       shmat           i:ipi   __shmat         shmat
 shmdt           -       shmdt           i:s     __shmdt         shmdt
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
index d0d9b9a..07b421d 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -3,7 +3,6 @@
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
 msgget		-	msgget		i:ii	__msgget	msgget
-msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
diff --git a/sysdeps/unix/sysv/linux/msgrcv.c b/sysdeps/unix/sysv/linux/msgrcv.c
index c4dd219..489d629 100644
--- a/sysdeps/unix/sysv/linux/msgrcv.c
+++ b/sysdeps/unix/sysv/linux/msgrcv.c
@@ -16,33 +16,19 @@
    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-cancel.h>
-#include <sys/syscall.h>
-
-/* Kludge to work around Linux' restriction of only up to five
-   arguments to a system call.  */
-struct ipc_kludge
-  {
-    void *msgp;
-    long int msgtyp;
-  };
-
 
 ssize_t
 __libc_msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp,
 	       int msgflg)
 {
-  /* The problem here is that Linux' calling convention only allows up to
-     fives parameters to a system call.  */
-  struct ipc_kludge tmp;
-
-  tmp.msgp = msgp;
-  tmp.msgtyp = msgtyp;
-
-  return SYSCALL_CANCEL (ipc, IPCOP_msgrcv, msqid, msgsz, msgflg, &tmp);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return SYSCALL_CANCEL (msgrcv, msqid, msgp, msgsz, msgtyp, msgflg);
+#else
+  return SYSCALL_CANCEL (ipc, IPCOP_msgrcv, msqid, msgsz, msgflg,
+			 MSGRCV_ARGS (msgp, msgtyp));
+#endif
 }
 weak_alias (__libc_msgrcv, msgrcv)
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 808cbbb..59b93fe 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -2,7 +2,6 @@
 
 # semaphore and shm system calls
 msgget		-	msgget		i:ii	__msgget	msgget
-msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c b/sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c
deleted file mode 100644
index ccaa4ee..0000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2010-2016 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-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp,
-	       int msgflg)
-{
-  return SYSCALL_CANCEL (ipc, IPCOP_msgrcv, msqid, msgsz, msgflg,
-			 msgp, msgtyp);
-}
-weak_alias (__libc_msgrcv, msgrcv)
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 4d19d75..7192a96 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -3,7 +3,6 @@
 arch_prctl	EXTRA	arch_prctl	i:ii	__arch_prctl	arch_prctl
 modify_ldt	EXTRA	modify_ldt	i:ipi	__modify_ldt	modify_ldt
 msgget		-	msgget		i:ii	__msgget	msgget
-msgrcv		-	msgrcv		Ci:ibnii __msgrcv	msgrcv
 msgsnd		-	msgsnd		Ci:ibni	__msgsnd	msgsnd
 pread64		-	pread64		Ci:ipii	__libc_pread	__libc_pread64 __pread64 pread64 __pread pread
 preadv64	-	preadv		Ci:ipii	preadv64	preadv
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 09/17] Use semget syscall for Linux implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (9 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 12/17] Add SYSV semaphore test Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 13/17] Use shmat " Adhemerval Zanella
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch add a direct call to semget syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (semget): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (semget): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (semget): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (semget): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (semget): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (semget): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semget):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semget):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semget): Likewise.
	* sysdeps/unix/sysv/linux/semget.c (semget): Use semget syscall
	if it is defined.
---
 ChangeLog                                          | 14 ++++++++++++++
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/syscalls.list          |  1 -
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/syscalls.list   |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list  |  1 -
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/semget.c                   | 11 ++++++-----
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 11 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index c12620a..2533263 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -6,7 +6,6 @@ shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
-semget		-	semget		i:iii	__semget	semget
 
 sigstack	-	sigstack	2	sigstack
 
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index 4bf4826..ef5bd01 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -28,7 +28,6 @@ shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
-semget		-	semget		i:iii	__semget	semget
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index f95f1f7..485f6fe 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # SysV APIs
-semget		-	semget		i:iii	__semget	semget
 semtimedop	-	semtimedop	i:ipip	semtimedop
 semop		-	semop		i:ipi	__semop		semop
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index 5040ef3..685ab93 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -7,7 +7,6 @@ shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop      -       semtimedop      i:ipip  semtimedop
-semget		-	semget		i:iii	__semget	semget
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index ca5cba4..56200ba 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -11,7 +11,6 @@ shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
-semget		-	semget		i:iii	__semget	semget
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index c40bac3..a0b8ebf 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -13,4 +13,3 @@ shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
 semop           -       semop           i:ipi   __semop         semop
 semtimedop      -       semtimedop      i:ipip  semtimedop
-semget          -       semget          i:iii   __semget        semget
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
index 7c992d7..374fcc2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -7,4 +7,3 @@ shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
-semget		-	semget		i:iii	__semget	semget
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 09ab580..288e080 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -6,4 +6,3 @@ shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
-semget		-	semget		i:iii	__semget	semget
diff --git a/sysdeps/unix/sysv/linux/semget.c b/sysdeps/unix/sysv/linux/semget.c
index 52189fd..a8876f5 100644
--- a/sysdeps/unix/sysv/linux/semget.c
+++ b/sysdeps/unix/sysv/linux/semget.c
@@ -16,13 +16,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
 #include <sys/sem.h>
 #include <ipc_priv.h>
-#include <stdlib.h>		/* for definition of NULL */
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <errno.h>
 
 /* Return identifier for array of NSEMS semaphores associated with
    KEY.  */
@@ -30,5 +27,9 @@
 int
 semget (key_t key, int nsems, int semflg)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semget, key, nsems, semflg, NULL);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (semget, key, nsems, semflg);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_semget, key, nsems, semflg, NULL);
+#endif
 }
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index f3a1541..d77a7ca 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -12,7 +12,6 @@ shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
-semget		-	semget		i:iii	__semget	semget
 syscall_clock_gettime	EXTRA	clock_gettime	Ei:ip		__syscall_clock_gettime
 
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 11/17] Consolidate Linux semtimedop implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (11 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 13/17] Use shmat " Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 08/17] Consolidate Linux semctl implementation Adhemerval Zanella
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the semtimedop Linux implementation in only
one default file, sysdeps/unix/sysv/linux/semtimedop.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (semtimedop): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (semtimedop): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (semtimedop):
	Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (semtimedop): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (semtimedop): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (semtimedop):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semtimedop):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semtimedop): Likewise.
	* sysdeps/unix/sysv/linux/m68k/semtimedop.S: Remove file.
	* sysdeps/unix/sysv/linux/s390/semtimedop.c: Reorganize headers and
	add a comment about s390 syscall difference from default one.
	* sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Use semtimedop
	syscall if it is defined.
---
 ChangeLog                                         | 17 ++++++
 sysdeps/unix/sysv/linux/alpha/syscalls.list       |  1 -
 sysdeps/unix/sysv/linux/arm/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/generic/syscalls.list     |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/m68k/semtimedop.S         | 69 -----------------------
 sysdeps/unix/sysv/linux/microblaze/syscalls.list  |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/s390/semtimedop.c         | 12 ++--
 sysdeps/unix/sysv/linux/semtimedop.c              | 13 +++--
 sysdeps/unix/sysv/linux/x86_64/syscalls.list      |  1 -
 12 files changed, 31 insertions(+), 88 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/semtimedop.S

diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index c20543a..8d3a042 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -4,7 +4,6 @@ shmat		-	osf_shmat	i:ipi	__shmat		shmat
 oldshmctl	EXTRA	shmctl		i:iip	__old_shmctl	shmctl@GLIBC_2.0
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semtimedop	-	semtimedop	i:ipip	semtimedop
 
 sigstack	-	sigstack	2	sigstack
 
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index 3014db8..1b2de93 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -26,7 +26,6 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semtimedop	-	semtimedop	i:ipip	semtimedop
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index 54e1778..e12fb3e 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -1,7 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # SysV APIs
-semtimedop	-	semtimedop	i:ipip	semtimedop
 shmget		-	shmget		i:iii	__shmget	shmget
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmat		-	shmat		i:ipi	__shmat		shmat
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index 8fbcaba..a8fbc44 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -5,7 +5,6 @@ shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semtimedop      -       semtimedop      i:ipip  semtimedop
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index b9271cc..eda4e4e 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -9,7 +9,6 @@ shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semtimedop	-	semtimedop	i:ipip	semtimedop
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/m68k/semtimedop.S b/sysdeps/unix/sysv/linux/m68k/semtimedop.S
deleted file mode 100644
index b291070..0000000
--- a/sysdeps/unix/sysv/linux/m68k/semtimedop.S
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (C) 2003-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Andreas Schwab <schwab@suse.de>, 2003.
-
-   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 <sysdep.h>
-
-#define SYSOP_semtimedop 4
-
-#define SVRSP	8		/* saved register space */
-#define PARMS	4+SVRSP		/* space for 3 saved regs */
-#define SEMID	PARMS
-#define SOPS	SEMID+4
-#define NSOPS	SOPS+4
-#define TIMEOUT	NSOPS+4
-
-	.text
-ENTRY (semtimedop)
-
-	/* Save registers.  */
-	move.l	%d2, %a1
-	move.l	%d3, -(%sp)
-	cfi_adjust_cfa_offset (4)
-	move.l	%d5, -(%sp)
-	cfi_adjust_cfa_offset (4)
-	cfi_register (%d2, %a1)
-	cfi_rel_offset (%d3, 0)
-	cfi_rel_offset (%d5, 4)
-
-	move.l	#SYSOP_semtimedop, %d1
-	move.l	SEMID(%sp), %d2
-	move.l	NSOPS(%sp), %d3
-	move.l	SOPS(%sp), %d5
-	move.l	TIMEOUT(%sp), %a0
-	move.l	#SYS_ify (ipc), %d0
-
-	trap	#0
-
-	/* Restore registers.  */
-	move.l	(%sp)+, %d5
-	cfi_adjust_cfa_offset (-4)
-	cfi_restore (%d5)
-	move.l	(%sp)+, %d3
-	cfi_adjust_cfa_offset (-4)
-	cfi_restore (%d3)
-	move.l	%a1, %d2
-	cfi_restore (%d2)
-
-	/* Check for error.  */
-	tst.l	%d0
-	jmi	SYSCALL_ERROR_LABEL
-
-	/* Successful; return the syscall's value.  */
-	ret
-
-PSEUDO_END (semtimedop)
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index 3da653d..d9afda0 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -11,4 +11,3 @@ personality	EXTRA	personality	Ei:i	__personality	personality
 shmat           -       shmat           i:ipi   __shmat         shmat
 shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
-semtimedop      -       semtimedop      i:ipip  semtimedop
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
index 720db96..9cbbd38 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -5,4 +5,3 @@
 shmat		-	shmat		i:ipi	__shmat		shmat
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semtimedop	-	semtimedop	i:ipip	semtimedop
diff --git a/sysdeps/unix/sysv/linux/s390/semtimedop.c b/sysdeps/unix/sysv/linux/s390/semtimedop.c
index f226953..db43f00 100644
--- a/sysdeps/unix/sysv/linux/s390/semtimedop.c
+++ b/sysdeps/unix/sysv/linux/s390/semtimedop.c
@@ -16,12 +16,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
 #include <sys/sem.h>
 #include <ipc_priv.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <errno.h>
 
 /* Perform user-defined atomical operation of array of semaphores.  */
 
@@ -29,6 +27,10 @@ int
 semtimedop (int semid, struct sembuf *sops, size_t nsops,
 	    const struct timespec *timeout)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semtimedop,
-			 semid, (int) nsops, timeout, sops);
+  /* The s390 sys_ipc variant has only five parameters instead of six
+     (as for default variant) and the only difference is the handling of
+     SEMTIMEDOP where on s390 the third parameter is used as a pointer
+     to a struct timespec where the generic variant uses fifth parameter.  */
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, nsops, timeout,
+			      sops);
 }
diff --git a/sysdeps/unix/sysv/linux/semtimedop.c b/sysdeps/unix/sysv/linux/semtimedop.c
index 30ee7fe..4216dda 100644
--- a/sysdeps/unix/sysv/linux/semtimedop.c
+++ b/sysdeps/unix/sysv/linux/semtimedop.c
@@ -16,12 +16,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
 #include <sys/sem.h>
 #include <ipc_priv.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <errno.h>
 
 /* Perform user-defined atomical operation of array of semaphores.  */
 
@@ -29,7 +27,10 @@ int
 semtimedop (int semid, struct sembuf *sops, size_t nsops,
 	    const struct timespec *timeout)
 {
-  return INLINE_SYSCALL (ipc, 6, IPCOP_semtimedop,
-			 semid, (int) nsops, 0, sops,
-			 timeout);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (semtimedop, semid, sops, nsops, timeout);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, nsops, 0, sops,
+			      timeout);
+#endif
 }
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index d17a186..573ed07 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -10,7 +10,6 @@ shmat		-	shmat		i:ipi	__shmat		shmat
 shmctl		-	shmctl		i:iip	__shmctl	shmctl
 shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
-semtimedop	-	semtimedop	i:ipip	semtimedop
 syscall_clock_gettime	EXTRA	clock_gettime	Ei:ip		__syscall_clock_gettime
 
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 16/17] Use shmget syscall for linux implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (3 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 10/17] Use semop syscall for Linux implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 04/17] Consolidate Linux msgrcv implementation Adhemerval Zanella
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

this patch add a direct call to shmget syscall if it is supported by
kernel features.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmget): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (shmget): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (shmget): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmget): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmget): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmget): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmget):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmget):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmget): Likewise.
	* sysdeps/unix/sysv/linux/shmget.c (shmget): Use shmget syscall if it
	is defined.
---
 ChangeLog                                          | 14 ++++++++++++++
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  2 --
 sysdeps/unix/sysv/linux/arm/syscalls.list          |  4 ----
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  3 ---
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  3 ---
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  3 ---
 sysdeps/unix/sysv/linux/microblaze/syscalls.list   |  4 ----
 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list  |  5 -----
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  4 ----
 sysdeps/unix/sysv/linux/shmget.c                   | 13 +++++++------
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 11 files changed, 21 insertions(+), 35 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list

diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 096bf22..4001020 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -1,7 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-shmget		-	shmget		i:iii	__shmget	shmget
-
 sigstack	-	sigstack	2	sigstack
 
 getpriority	-	getpriority	i:ii	__getpriority	getpriority
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index b1ea664..0263eee 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -21,10 +21,6 @@ fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	fanotify_mark
 
 personality	EXTRA	personality	Ei:i	__personality	personality
 
-# Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
-# wrappers (to set __IPC_64).
-shmget		-	shmget		i:iii	__shmget	shmget
-
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
 bind		-	bind		i:ipi	__bind		bind
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index 51ce148..3bb5473 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -1,8 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-# SysV APIs
-shmget		-	shmget		i:iii	__shmget	shmget
-
 # Socket APIs
 socket		-	socket		i:iii	__socket	socket
 socketpair	-	socketpair	i:iiif	__socketpair	socketpair
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index e75dd43..6d47b11 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -1,8 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-# semaphore and shm system calls
-shmget		-	shmget		i:iii	__shmget	shmget
-
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
 bind		-	bind		i:ipi	__bind		bind
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 5ebade1..dd07db3 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -4,9 +4,6 @@ umount2		-	umount		2	__umount2	umount2
 
 getpriority	-	getpriority	i:ii	__getpriority	getpriority
 
-# semaphore and shm system calls
-shmget		-	shmget		i:iii	__shmget	shmget
-
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
 bind		-	bind		i:ipi	__bind		bind
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index 7a5666f..932c9cc 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -5,7 +5,3 @@ cacheflush	EXTRA	cacheflush	i:iiii	__cacheflush	cacheflush
 prlimit64	EXTRA	prlimit64	i:iipp	prlimit64
 fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	fanotify_mark
 personality	EXTRA	personality	Ei:i	__personality	personality
-
-# Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
-# wrappers (to set __IPC_64).
-shmget          -       shmget          i:iii   __shmget        shmget
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
deleted file mode 100644
index e8e381b..0000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ /dev/null
@@ -1,5 +0,0 @@
-# File name	Caller	Syscall name	Args	Strong name	Weak names
-
-# Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
-# wrappers (to set __IPC_64).
-shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
deleted file mode 100644
index 0ccbffa..0000000
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ /dev/null
@@ -1,4 +0,0 @@
-# File name     Caller  Syscall name    # args  Strong name     Weak names
-
-# semaphore and shm system calls
-shmget          -       shmget          i:iii   __shmget        shmget
diff --git a/sysdeps/unix/sysv/linux/shmget.c b/sysdeps/unix/sysv/linux/shmget.c
index bd624fc..2cea696 100644
--- a/sysdeps/unix/sysv/linux/shmget.c
+++ b/sysdeps/unix/sysv/linux/shmget.c
@@ -16,13 +16,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <sys/shm.h>
+#include <sys/msg.h>
 #include <ipc_priv.h>
-#include <stdlib.h>		/* for definition of NULL */
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <errno.h>
 
 /* Return an identifier for an shared memory segment of at least size SIZE
    which is associated with KEY.  */
@@ -30,5 +27,9 @@
 int
 shmget (key_t key, size_t size, int shmflg)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmget, key, size, shmflg, NULL);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (shmget, key, size, shmflg, NULL);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_shmget, key, size, shmflg, NULL);
+#endif
 }
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index cb1a9f9..45d5ebf 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -6,7 +6,6 @@ pread64		-	pread64		Ci:ipii	__libc_pread	__libc_pread64 __pread64 pread64 __prea
 preadv64	-	preadv		Ci:ipii	preadv64	preadv
 pwrite64	-	pwrite64	Ci:ipii	__libc_pwrite	__libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite
 pwritev64	-	pwritev		Ci:ipii	pwritev64	pwritev
-shmget		-	shmget		i:iii	__shmget	shmget
 syscall_clock_gettime	EXTRA	clock_gettime	Ei:ip		__syscall_clock_gettime
 
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 07/17] Add SYSV message queue test
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
  2016-12-12 12:33 ` [PATCH 02/17] Refactor Linux ipc_priv header Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 17/17] Add SYSV shared memory test Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 10/17] Use semop syscall for Linux implementation Adhemerval Zanella
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch adds a simple SYSV message queue test to check for correct
argument passing on kernel.  The idea is neither to be an extensive
testing nor to check for any specific Linux test.

	* sysvipc/Makefile (tests): Add test-sysvmsg.
	* sysvipc/test-sysvmsg.c: New file.
	* test-skeleton.c (FAIL_UNSUPPORTED): New define.
---
 ChangeLog              |   4 ++
 support/check.h        |   5 ++
 sysvipc/Makefile       |   2 +
 sysvipc/test-sysvmsg.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 139 insertions(+)
 create mode 100644 sysvipc/test-sysvmsg.c

diff --git a/support/check.h b/support/check.h
index ff2652c..8c04a7e 100644
--- a/support/check.h
+++ b/support/check.h
@@ -35,6 +35,11 @@ __BEGIN_DECLS
 #define FAIL_EXIT1(...) \
   support_exit_failure_impl (1, __FILE__, __LINE__, __VA_ARGS__)
 
+/* Print failure message and terminate with as unsupported test (exit
+   status of 77).  */
+#define FAIL_UNSUPPORTED(...) \
+  support_exit_failure_impl (77, __FILE__, __LINE__, __VA_ARGS__)
+
 int support_print_failure_impl (const char *file, int line,
                                 const char *format, ...)
   __attribute__ ((nonnull (1), format (printf, 3, 4)));
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index 5f3479e..73bb9cf 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -30,6 +30,8 @@ routines := ftok \
 	    semop semget semctl semtimedop \
 	    shmat shmdt shmget shmctl
 
+tests    := test-sysvmsg
+
 include ../Rules
 
 CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg.c b/sysvipc/test-sysvmsg.c
new file mode 100644
index 0000000..75cfebf
--- /dev/null
+++ b/sysvipc/test-sysvmsg.c
@@ -0,0 +1,128 @@
+/* Basic tests for SYSV message queue functions.
+   Copyright (C) 2016 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 <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <support/support.h>
+#include <support/check.h>
+#include <support/temp_file.h>
+
+#define TEXTSIZE 32
+struct msgbuf_t
+{
+#ifdef _GNU_SOURCE
+  __syscall_slong_t type;
+#else
+  long type;
+#endif
+  char buf[TEXTSIZE];
+};
+
+#define MSGTYPE 0x01020304
+#define MSGDATA "0123456789"
+
+/* These are for the temporary file we generate.  */
+static char *name;
+static int msqid;
+
+static void
+remove_msq (void)
+{
+  /* Enforce message queue removal in case of early test failure.
+     Ignore error since the msgq may already have being removed.  */
+  msgctl (msqid, IPC_RMID, NULL);
+}
+
+static void
+do_prepare (int argc, char *argv[])
+{
+  int fd = create_temp_file ("tst-sysvmsg.", &name);
+  if (fd == -1)
+    FAIL_EXIT1 ("cannot create temporary file (errno=%d)", errno);
+}
+
+#define PREPARE do_prepare
+
+/* It is not an extensive test, but rather a functional one aimed to check
+   correct parameter passing on kernel.  */
+
+#define MSGQ_MODE 0644
+
+static int
+do_test (void)
+{
+  atexit (remove_msq);
+
+  key_t key = ftok (name, 'G');
+  if (key == -1)
+    FAIL_EXIT1 ("ftok failed");
+
+  msqid = msgget (key, MSGQ_MODE | IPC_CREAT);
+  if (msqid == -1)
+    {
+      if (errno == ENOSYS)
+	FAIL_UNSUPPORTED ("msgget not supported");
+      FAIL_EXIT1 ("msgget failed (errno=%d)", errno);
+    }
+
+  /* Get message queue kernel information and do some sanity checks.  */
+  struct msqid_ds msginfo;
+  if (msgctl (msqid, IPC_STAT, &msginfo) == -1)
+    FAIL_EXIT1 ("msgctl with IPC_STAT failed (errno=%d)", errno);
+
+  if (msginfo.msg_perm.__key != key)
+    FAIL_EXIT1 ("msgid_ds::msg_perm::key (%d) != %d",
+		(int) msginfo.msg_perm.__key, (int) key);
+  if (msginfo.msg_perm.mode != MSGQ_MODE)
+    FAIL_EXIT1 ("msgid_ds::msg_perm::mode (%o) != %o",
+		msginfo.msg_perm.mode, MSGQ_MODE);
+  if (msginfo.msg_qnum != 0)
+    FAIL_EXIT1 ("msgid_ds::msg_qnum (%lu) != 0",
+		(long unsigned) msginfo.msg_qnum);
+
+  /* Check if last argument (IPC_NOWAIT) is correctly handled.  */
+  struct msgbuf_t msg2rcv = { 0 };
+  if (msgrcv (msqid, &msg2rcv, sizeof (msg2rcv.buf), MSGTYPE, 
+	      IPC_NOWAIT) == -1
+      && errno != ENOMSG)
+    FAIL_EXIT1 ("msgrcv failed (errno=%d)", errno);
+
+  struct msgbuf_t msg2snd = { MSGTYPE, MSGDATA };
+  if (msgsnd (msqid, &msg2snd, sizeof (msg2snd.buf), 0) == -1)
+    FAIL_EXIT1 ("msgsnd failed (errno=%d)", errno);
+
+  if (msgrcv (msqid, &msg2rcv, sizeof (msg2rcv.buf), MSGTYPE, 0) == -1)
+    FAIL_EXIT1 ("msgrcv failed (errno=%d)", errno);
+
+  int ret = 0;
+  if (strncmp (msg2snd.buf, msg2rcv.buf, TEXTSIZE) != 0)
+    ret = 1;
+
+  if (msgctl (msqid, IPC_RMID, NULL) == -1)
+    FAIL_EXIT1 ("msgctl failed");
+
+  return ret;
+}
+
+#include <support/test-driver.c>
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 01/17] Add __ASSUME_DIRECT_SYSVIPC_SYSCALL for Linux
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (15 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 06/17] Use msgget syscall for Linux implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-19 18:18 ` Adhemerval Zanella
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

On current minimum supported kernels, the SysV IPC on Linux is provided
by either the ipc syscalls or correspondent wire syscalls.  Also, for
architectures that supports wire syscalls all syscalls are supported
in a set (msgct, msgrcv, msgsnd, msgget, semctl, semget, semop, semtimedop,
shmctl, shmat, shmget, shmdt).

The architectures that only supports ipc syscall are:

  - i386, m68k, microblaze, mips32, powerpc (powerpc32, powerpc64, and
    powerpc64le), s390 (32 and 64 bits), sh, sparc32, and sparc64.

And the architectures that only supports wired syscalls are:

  - aarch64, alpha, hppa, ia64, mips64, mips64n32, nios2, tile
    (tilepro, tilegx, and tilegx64), and x86_64

Also arm is the only one that supports both wire syscalls and the
ipc, although the ipc one is deprecated.

This patch adds a new define, __ASSUME_DIRECT_SYSVIPC_SYSCALL, that wired
syscalls are supported on the system and the general idea is to use
it where possible.

I also checked the syscall table for all architectures on Linux 4.9
and there is no change on described support for Linux 2.6.32/3.2.

	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_DIRECT_SYSVIPC_SYSCALL): New define.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Undef.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
---
 ChangeLog                                         | 19 +++++++++++++++++++
 sysdeps/unix/sysv/linux/i386/kernel-features.h    |  3 +++
 sysdeps/unix/sysv/linux/kernel-features.h         |  4 ++++
 sysdeps/unix/sysv/linux/m68k/kernel-features.h    |  3 +++
 sysdeps/unix/sysv/linux/mips/kernel-features.h    |  2 ++
 sysdeps/unix/sysv/linux/powerpc/kernel-features.h |  3 +++
 sysdeps/unix/sysv/linux/s390/kernel-features.h    |  3 +++
 sysdeps/unix/sysv/linux/sh/kernel-features.h      |  3 +++
 sysdeps/unix/sysv/linux/sparc/kernel-features.h   |  3 +++
 9 files changed, 43 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/i386/kernel-features.h b/sysdeps/unix/sysv/linux/i386/kernel-features.h
index 148963c..0a557f8 100644
--- a/sysdeps/unix/sysv/linux/i386/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/i386/kernel-features.h
@@ -52,3 +52,6 @@
 # undef __ASSUME_SENDMSG_SYSCALL
 # undef __ASSUME_RECVMSG_SYSCALL
 #endif
+
+/* i686 only supports ipc syscall.  */
+#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 1d3b554..19125ce 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -147,3 +147,7 @@
    separate syscalls were only added later.  */
 #define __ASSUME_SENDMSG_SYSCALL	1
 #define __ASSUME_RECVMSG_SYSCALL	1
+
+/* Support for SysV IPC through wired syscalls.  All supported architectures
+   either support ipc syscall and/or all the ipc correspondent syscalls.  */
+#define __ASSUME_DIRECT_SYSVIPC_SYSCALLS	1
diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h
index 46ec601..b03de4c 100644
--- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h
@@ -54,3 +54,6 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* m68k only supports ipc syscall.  */
+#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h
index b486d90..fae34aa 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h
@@ -32,6 +32,8 @@
    pairs to start with an even-number register.  */
 #if _MIPS_SIM == _ABIO32
 # define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+/* mips32 only supports ipc syscall.  */
+# undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
 #endif
 
 /* Define that mips64-n32 is a ILP32 ABI to set the correct interface to
diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
index 42a53f2..5a84b6b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
@@ -52,3 +52,6 @@
 #endif
 
 #include_next <kernel-features.h>
+
+/* powerpc only supports ipc syscall.  */
+#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h
index b3edee4..10eade3 100644
--- a/sysdeps/unix/sysv/linux/s390/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h
@@ -48,3 +48,6 @@
 # undef __ASSUME_SENDMSG_SYSCALL
 # undef __ASSUME_RECVMSG_SYSCALL
 #endif
+
+/* s390 only supports ipc syscall.  */
+#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
diff --git a/sysdeps/unix/sysv/linux/sh/kernel-features.h b/sysdeps/unix/sysv/linux/sh/kernel-features.h
index d03aafa..9eb8ff4 100644
--- a/sysdeps/unix/sysv/linux/sh/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/sh/kernel-features.h
@@ -54,4 +54,7 @@
    before the offset.  */
 #define __ASSUME_PRW_DUMMY_ARG	1
 
+/* sh only supports ipc syscall.  */
+#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+
 #endif
diff --git a/sysdeps/unix/sysv/linux/sparc/kernel-features.h b/sysdeps/unix/sysv/linux/sparc/kernel-features.h
index 69c9c7c..e487efe 100644
--- a/sysdeps/unix/sysv/linux/sparc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/sparc/kernel-features.h
@@ -37,3 +37,6 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* sparc only supports ipc syscall.  */
+#undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 08/17] Consolidate Linux semctl implementation
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (12 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 11/17] Consolidate Linux semtimedop implementation Adhemerval Zanella
@ 2016-12-12 12:33 ` Adhemerval Zanella
  2016-12-16 14:08   ` Adhemerval Zanella
  2016-12-12 12:33 ` [PATCH 14/17] Consolidate Linux shmctl implementation Adhemerval Zanella
                   ` (3 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:33 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the semctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/semctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
	oldsemctl.
	* sysdeps/unix/sysv/linux/alpha/semctl.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/semctl.c: Use defaulf
	implementation.
	* sysdeps/unix/sysv/linux/semctl.c (__new_semctl): Use semctl
	syscall if it is defined.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (semctl): Remove.
	* sysdeps/unix/sysv/linux/alpha/syscalls.list (semctl): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (semctl): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (semctl): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semctl):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semctl): Likewise.
---
 ChangeLog                                          | 18 +++++++
 sysdeps/unix/sysv/linux/alpha/Makefile             |  2 +-
 sysdeps/unix/sysv/linux/alpha/semctl.c             |  1 -
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/semctl.c               | 54 --------------------
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/semctl.c        |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/semctl.c       | 38 ++------------
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/semctl.c                   | 58 +++++++++++-----------
 sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c     | 54 --------------------
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 14 files changed, 54 insertions(+), 178 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/semctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/semctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/semctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c

diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile
index c24dc2e..386b3fd 100644
--- a/sysdeps/unix/sysv/linux/alpha/Makefile
+++ b/sysdeps/unix/sysv/linux/alpha/Makefile
@@ -18,7 +18,7 @@ sysdep_routines += osf_select osf_gettimeofday osf_settimeofday \
 		   osf_getrusage osf_wait4
 
 # Support old ipc control
-sysdep_routines += oldsemctl oldshmctl
+sysdep_routines += oldshmctl
 
 CFLAGS-ioperm.c = -Wa,-mev6
 endif
diff --git a/sysdeps/unix/sysv/linux/alpha/semctl.c b/sysdeps/unix/sysv/linux/alpha/semctl.c
deleted file mode 100644
index 4cb834a..0000000
--- a/sysdeps/unix/sysv/linux/alpha/semctl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/arm/semctl.c>
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 54c1752..c12620a 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -7,7 +7,6 @@ shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 semget		-	semget		i:iii	__semget	semget
-oldsemctl	EXTRA	semctl		i:iiii	__old_semctl	semctl@GLIBC_2.0
 
 sigstack	-	sigstack	2	sigstack
 
diff --git a/sysdeps/unix/sysv/linux/arm/semctl.c b/sysdeps/unix/sysv/linux/arm/semctl.c
deleted file mode 100644
index 79d9d3e..0000000
--- a/sysdeps/unix/sysv/linux/arm/semctl.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1995-2016 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 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 <stdarg.h>
-#include <sys/sem.h>
-#include <ipc_priv.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 */
-};
-
-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);
-
-  return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd | __IPC_64,
-			 arg.array);
-}
-
-#include <shlib-compat.h>
-versioned_symbol (libc, __new_semctl, semctl, GLIBC_2_2);
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index ad75223..f95f1f7 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -2,7 +2,6 @@
 
 # SysV APIs
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
 semtimedop	-	semtimedop	i:ipip	semtimedop
 semop		-	semop		i:ipi	__semop		semop
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index da2c9ab..5040ef3 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -8,7 +8,6 @@ shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop      -       semtimedop      i:ipip  semtimedop
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 8056781..ca5cba4 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -12,7 +12,6 @@ shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/microblaze/semctl.c b/sysdeps/unix/sysv/linux/microblaze/semctl.c
deleted file mode 100644
index 4cb834a..0000000
--- a/sysdeps/unix/sysv/linux/microblaze/semctl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/arm/semctl.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/semctl.c b/sysdeps/unix/sysv/linux/mips/mips64/semctl.c
index 1115a25..5a0c2a3 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/semctl.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/semctl.c
@@ -15,39 +15,11 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stdarg.h>
-#include <sys/sem.h>
-#include <ipc_priv.h>
-#include <sysdep.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 */
-};
-
-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);
-
-  /* Get the argument.  */
-  arg = va_arg (ap, union semun);
+#include <shlib-compat.h>
 
-  va_end (ap);
+#undef SHLIB_COMPAT
+#define SHLIB_COMPAT(a, b, c) 0
 
-  return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd | __IPC_64,
-			 arg.array);
-}
+#define DEFAULT_VERSION GLIBC_2_0
 
-#include <shlib-compat.h>
-versioned_symbol (libc, __semctl, semctl, GLIBC_2_0);
+#include <sysdeps/unix/sysv/linux/semctl.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index f23b379..09ab580 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -7,4 +7,3 @@ shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
index ee84a1e..eae2a99 100644
--- a/sysdeps/unix/sysv/linux/semctl.c
+++ b/sysdeps/unix/sysv/linux/semctl.c
@@ -16,18 +16,14 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stdarg.h>
 #include <sys/sem.h>
+#include <stdarg.h>
 #include <ipc_priv.h>
-
 #include <sysdep.h>
-#include <string.h>
-#include <sys/syscall.h>
 #include <shlib-compat.h>
+#include <errno.h>
 
-#include <kernel-features.h>
-
+/* Old semid_ds definition.  */
 struct __old_semid_ds
 {
   struct __old_ipc_perm sem_perm;	/* operation permission struct */
@@ -50,23 +46,17 @@ union semun
   struct __old_semid_ds *__old_buf;
 };
 
-/* Return identifier for array of NSEMS semaphores associated with
-   KEY.  */
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
-int __old_semctl (int semid, int semnum, int cmd, ...);
+#ifndef DEFAULT_VERSION
+# define DEFAULT_VERSION GLIBC_2_2
 #endif
-int __new_semctl (int semid, int semnum, int cmd, ...);
 
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
 int
-attribute_compat_text_section
-__old_semctl (int semid, int semnum, int cmd, ...)
+__new_semctl (int semid, int semnum, int cmd, ...)
 {
-  union semun arg;
+  union semun arg = { 0 };
   va_list ap;
 
   /* Get the argument only if required.  */
-  arg.buf = NULL;
   switch (cmd)
     {
     case SETVAL:        /* arg.val */
@@ -83,20 +73,28 @@ __old_semctl (int semid, int semnum, int cmd, ...)
       break;
     }
 
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
-			 &arg);
-}
-compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64,
+			      arg.array);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
+			      SEMCTL_ARG_ADDRESS (arg));
 #endif
+}
+versioned_symbol (libc, __new_semctl, semctl, DEFAULT_VERSION);
+
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
+int __old_semctl (int semid, int semnum, int cmd, ...);
 
 int
-__new_semctl (int semid, int semnum, int cmd, ...)
+attribute_compat_text_section
+__old_semctl (int semid, int semnum, int cmd, ...)
 {
-  union semun arg;
+  union semun arg = { 0 };
   va_list ap;
 
   /* Get the argument only if required.  */
-  arg.buf = NULL;
   switch (cmd)
     {
     case SETVAL:        /* arg.val */
@@ -113,8 +111,12 @@ __new_semctl (int semid, int semnum, int cmd, ...)
       break;
     }
 
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
-			 &arg);
+# ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd, arg.array);
+# else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd,
+			      SEMCTL_ARG_ADDRESS (arg));
+# endif
 }
-
-versioned_symbol (libc, __new_semctl, semctl, GLIBC_2_2);
+compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c b/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c
deleted file mode 100644
index a9ae4c6..0000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1995-2016 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 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 <stdarg.h>
-#include <sys/sem.h>
-#include <ipc_priv.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.array);
-}
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 75b25a1..f3a1541 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -13,7 +13,6 @@ shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
 syscall_clock_gettime	EXTRA	clock_gettime	Ei:ip		__syscall_clock_gettime
 
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] Refactor Linux ipc_priv header
  2016-12-12 12:33 ` [PATCH 02/17] Refactor Linux ipc_priv header Adhemerval Zanella
@ 2016-12-12 12:47   ` Arnd Bergmann
  2016-12-12 12:58     ` Adhemerval Zanella
  2016-12-12 13:05   ` Andreas Schwab
  1 sibling, 1 reply; 33+ messages in thread
From: Arnd Bergmann @ 2016-12-12 12:47 UTC (permalink / raw)
  To: libc-alpha; +Cc: Adhemerval Zanella

On Monday, December 12, 2016 10:32:55 AM CET Adhemerval Zanella wrote:

> Since current IPC_64 default now on kernel is 0x100, some architectures
> require it to 0 (for instance x86_64) while others continue to use a
> non zero default regardless (powerpc).

I find the explanation is a bit confusing, it's not that the kernel
requires IPC_64 to be 0x100, it's that some architectures support
the the old-style IPC and require IPC_64 to be passed, while new
architectures should default to the new version.

> index 0000000..1a31396
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
...
> +
> +#include <sys/ipc.h>  /* For __key_t  */
> +
> +#define __IPC_64	0x0
> +
> +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.  */
> +};

I don't understand this part at all: the #define line first says
that the old IPC is not supported, but then you define the structure
anyway?

What is the structure actually used for in glibc? My interpretation
is that it's only needed to implement the SHLIB_COMPAT version
of the library calls that don't exist on ARM64 either.

	Arnd

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] Refactor Linux ipc_priv header
  2016-12-12 12:47   ` Arnd Bergmann
@ 2016-12-12 12:58     ` Adhemerval Zanella
  2016-12-12 13:25       ` Arnd Bergmann
  0 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 12:58 UTC (permalink / raw)
  To: Arnd Bergmann, libc-alpha



On 12/12/2016 10:47, Arnd Bergmann wrote:
> On Monday, December 12, 2016 10:32:55 AM CET Adhemerval Zanella wrote:
> 
>> Since current IPC_64 default now on kernel is 0x100, some architectures
>> require it to 0 (for instance x86_64) while others continue to use a
>> non zero default regardless (powerpc).
> 
> I find the explanation is a bit confusing, it's not that the kernel
> requires IPC_64 to be 0x100, it's that some architectures support
> the the old-style IPC and require IPC_64 to be passed, while new
> architectures should default to the new version.

Right, I did not want to expose some kernel internal implementation,
but I think your explanation should be better.  I will change to

"
Some architectures support the old-style IPC and require IPC_64
equal to 0x100 to be passed along SysV IPC syscalls, while new
architectures should default to new IPC version (without the
flags being set).

This patch refactor current ipc_priv.h Linux headers in two directions:

  - Remove cross platform references (for instance alpha including powerpc
    definition) and add required definition for each required port.  The
    idea is to avoid tie one architecture definition with another and make
    platform change independent.

  - Move all common definitions (the ipc syscall commands) on a common
    header, ipc_ops.h.
"

Do you think it is less confusing?

> 
>> index 0000000..1a31396
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
> ...
>> +
>> +#include <sys/ipc.h>  /* For __key_t  */
>> +
>> +#define __IPC_64	0x0
>> +
>> +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.  */
>> +};
> 
> I don't understand this part at all: the #define line first says
> that the old IPC is not supported, but then you define the structure
> anyway?
> 
> What is the structure actually used for in glibc? My interpretation
> is that it's only needed to implement the SHLIB_COMPAT version
> of the library calls that don't exist on ARM64 either.

You are right and it is mainly a limitation on how my code defines the
'union semun' in semctl.c.  I will change it to use an opaque type
instead of a pointer to __old_ipc_perm.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] Refactor Linux ipc_priv header
  2016-12-12 12:33 ` [PATCH 02/17] Refactor Linux ipc_priv header Adhemerval Zanella
  2016-12-12 12:47   ` Arnd Bergmann
@ 2016-12-12 13:05   ` Andreas Schwab
  2016-12-12 13:41     ` Adhemerval Zanella
  1 sibling, 1 reply; 33+ messages in thread
From: Andreas Schwab @ 2016-12-12 13:05 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Dez 12 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

>   - Move all common definitions (the ipc syscall commands) on a common
>     header, ipc_ops.h.

Shouldn't that be in bits/?

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] Refactor Linux ipc_priv header
  2016-12-12 12:58     ` Adhemerval Zanella
@ 2016-12-12 13:25       ` Arnd Bergmann
  2016-12-12 14:29         ` Adhemerval Zanella
  0 siblings, 1 reply; 33+ messages in thread
From: Arnd Bergmann @ 2016-12-12 13:25 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Monday, December 12, 2016 10:57:51 AM CET Adhemerval Zanella wrote:
> 
> On 12/12/2016 10:47, Arnd Bergmann wrote:
> > On Monday, December 12, 2016 10:32:55 AM CET Adhemerval Zanella wrote:
> > 
> >> Since current IPC_64 default now on kernel is 0x100, some architectures
> >> require it to 0 (for instance x86_64) while others continue to use a
> >> non zero default regardless (powerpc).
> > 
> > I find the explanation is a bit confusing, it's not that the kernel
> > requires IPC_64 to be 0x100, it's that some architectures support
> > the the old-style IPC and require IPC_64 to be passed, while new
> > architectures should default to the new version.
> 
> Right, I did not want to expose some kernel internal implementation,
> but I think your explanation should be better.  I will change to
> 
> "
> Some architectures support the old-style IPC and require IPC_64
> equal to 0x100 to be passed along SysV IPC syscalls, while new
> architectures should default to new IPC version (without the
> flags being set).
> 
> This patch refactor current ipc_priv.h Linux headers in two directions:
> 
>   - Remove cross platform references (for instance alpha including powerpc
>     definition) and add required definition for each required port.  The
>     idea is to avoid tie one architecture definition with another and make
>     platform change independent.
> 
>   - Move all common definitions (the ipc syscall commands) on a common
>     header, ipc_ops.h.
> "
> 
> Do you think it is less confusing?

Sounds good, thanks!

> > 
> >> index 0000000..1a31396
> >> --- /dev/null
> >> +++ b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
> > ...
> >> +
> >> +#include <sys/ipc.h>  /* For __key_t  */
> >> +
> >> +#define __IPC_64	0x0
> >> +
> >> +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.  */
> >> +};
> > 
> > I don't understand this part at all: the #define line first says
> > that the old IPC is not supported, but then you define the structure
> > anyway?
> > 
> > What is the structure actually used for in glibc? My interpretation
> > is that it's only needed to implement the SHLIB_COMPAT version
> > of the library calls that don't exist on ARM64 either.
> 
> You are right and it is mainly a limitation on how my code defines the
> 'union semun' in semctl.c.  I will change it to use an opaque type
> instead of a pointer to __old_ipc_perm.

I guess we can even remove the entire definition of
struct __old_semid_ds etc on all architectures since we
just pass a pointer from the compat entry point to the
kernel without looking at the contents?

	Arnd

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] Refactor Linux ipc_priv header
  2016-12-12 13:05   ` Andreas Schwab
@ 2016-12-12 13:41     ` Adhemerval Zanella
  2016-12-12 13:50       ` Andreas Schwab
  0 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 13:41 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha



On 12/12/2016 11:05, Andreas Schwab wrote:
> On Dez 12 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
> 
>>   - Move all common definitions (the ipc syscall commands) on a common
>>     header, ipc_ops.h.
> 
> Shouldn't that be in bits/?

My understanding is IPCOP_* definitions are used only internally for
IPC calls, users should use the sysv exported symbol instead of
using syscall plus IPCOP_*.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] Refactor Linux ipc_priv header
  2016-12-12 13:41     ` Adhemerval Zanella
@ 2016-12-12 13:50       ` Andreas Schwab
  0 siblings, 0 replies; 33+ messages in thread
From: Andreas Schwab @ 2016-12-12 13:50 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Dez 12 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> On 12/12/2016 11:05, Andreas Schwab wrote:
>> On Dez 12 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
>> 
>>>   - Move all common definitions (the ipc syscall commands) on a common
>>>     header, ipc_ops.h.
>> 
>> Shouldn't that be in bits/?
>
> My understanding is IPCOP_* definitions are used only internally for
> IPC calls, users should use the sysv exported symbol instead of
> using syscall plus IPCOP_*.

Yes, I misunderstood.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] Refactor Linux ipc_priv header
  2016-12-12 13:25       ` Arnd Bergmann
@ 2016-12-12 14:29         ` Adhemerval Zanella
  2016-12-16 14:05           ` Adhemerval Zanella
  0 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-12 14:29 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: libc-alpha



On 12/12/2016 11:25, Arnd Bergmann wrote:
> On Monday, December 12, 2016 10:57:51 AM CET Adhemerval Zanella wrote:
>>
>> On 12/12/2016 10:47, Arnd Bergmann wrote:
>>> On Monday, December 12, 2016 10:32:55 AM CET Adhemerval Zanella wrote:
>>>
>>>> Since current IPC_64 default now on kernel is 0x100, some architectures
>>>> require it to 0 (for instance x86_64) while others continue to use a
>>>> non zero default regardless (powerpc).
>>>
>>> I find the explanation is a bit confusing, it's not that the kernel
>>> requires IPC_64 to be 0x100, it's that some architectures support
>>> the the old-style IPC and require IPC_64 to be passed, while new
>>> architectures should default to the new version.
>>
>> Right, I did not want to expose some kernel internal implementation,
>> but I think your explanation should be better.  I will change to
>>
>> "
>> Some architectures support the old-style IPC and require IPC_64
>> equal to 0x100 to be passed along SysV IPC syscalls, while new
>> architectures should default to new IPC version (without the
>> flags being set).
>>
>> This patch refactor current ipc_priv.h Linux headers in two directions:
>>
>>   - Remove cross platform references (for instance alpha including powerpc
>>     definition) and add required definition for each required port.  The
>>     idea is to avoid tie one architecture definition with another and make
>>     platform change independent.
>>
>>   - Move all common definitions (the ipc syscall commands) on a common
>>     header, ipc_ops.h.
>> "
>>
>> Do you think it is less confusing?
> 
> Sounds good, thanks!
> 
>>>
>>>> index 0000000..1a31396
>>>> --- /dev/null
>>>> +++ b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
>>> ...
>>>> +
>>>> +#include <sys/ipc.h>  /* For __key_t  */
>>>> +
>>>> +#define __IPC_64	0x0
>>>> +
>>>> +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.  */
>>>> +};
>>>
>>> I don't understand this part at all: the #define line first says
>>> that the old IPC is not supported, but then you define the structure
>>> anyway?
>>>
>>> What is the structure actually used for in glibc? My interpretation
>>> is that it's only needed to implement the SHLIB_COMPAT version
>>> of the library calls that don't exist on ARM64 either.
>>
>> You are right and it is mainly a limitation on how my code defines the
>> 'union semun' in semctl.c.  I will change it to use an opaque type
>> instead of a pointer to __old_ipc_perm.
> 
> I guess we can even remove the entire definition of
> struct __old_semid_ds etc on all architectures since we
> just pass a pointer from the compat entry point to the
> kernel without looking at the contents?

Yeap, this is what I ended up doing in my local branch (remove aarch64
ipc_priv.h ununsed definitions and cleanup semctl old ipc struct
definitions).


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] Refactor Linux ipc_priv header
  2016-12-12 14:29         ` Adhemerval Zanella
@ 2016-12-16 14:05           ` Adhemerval Zanella
  0 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-16 14:05 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: libc-alpha



On 12/12/2016 12:29, Adhemerval Zanella wrote:
> 
> 
> On 12/12/2016 11:25, Arnd Bergmann wrote:
>> On Monday, December 12, 2016 10:57:51 AM CET Adhemerval Zanella wrote:
>>>
>>> On 12/12/2016 10:47, Arnd Bergmann wrote:
>>>> On Monday, December 12, 2016 10:32:55 AM CET Adhemerval Zanella wrote:
>>>>
>>>>> Since current IPC_64 default now on kernel is 0x100, some architectures
>>>>> require it to 0 (for instance x86_64) while others continue to use a
>>>>> non zero default regardless (powerpc).
>>>>
>>>> I find the explanation is a bit confusing, it's not that the kernel
>>>> requires IPC_64 to be 0x100, it's that some architectures support
>>>> the the old-style IPC and require IPC_64 to be passed, while new
>>>> architectures should default to the new version.
>>>
>>> Right, I did not want to expose some kernel internal implementation,
>>> but I think your explanation should be better.  I will change to
>>>
>>> "
>>> Some architectures support the old-style IPC and require IPC_64
>>> equal to 0x100 to be passed along SysV IPC syscalls, while new
>>> architectures should default to new IPC version (without the
>>> flags being set).
>>>
>>> This patch refactor current ipc_priv.h Linux headers in two directions:
>>>
>>>   - Remove cross platform references (for instance alpha including powerpc
>>>     definition) and add required definition for each required port.  The
>>>     idea is to avoid tie one architecture definition with another and make
>>>     platform change independent.
>>>
>>>   - Move all common definitions (the ipc syscall commands) on a common
>>>     header, ipc_ops.h.
>>> "
>>>
>>> Do you think it is less confusing?
>>
>> Sounds good, thanks!
>>
>>>>
>>>>> index 0000000..1a31396
>>>>> --- /dev/null
>>>>> +++ b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
>>>> ...
>>>>> +
>>>>> +#include <sys/ipc.h>  /* For __key_t  */
>>>>> +
>>>>> +#define __IPC_64	0x0
>>>>> +
>>>>> +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.  */
>>>>> +};
>>>>
>>>> I don't understand this part at all: the #define line first says
>>>> that the old IPC is not supported, but then you define the structure
>>>> anyway?
>>>>
>>>> What is the structure actually used for in glibc? My interpretation
>>>> is that it's only needed to implement the SHLIB_COMPAT version
>>>> of the library calls that don't exist on ARM64 either.
>>>
>>> You are right and it is mainly a limitation on how my code defines the
>>> 'union semun' in semctl.c.  I will change it to use an opaque type
>>> instead of a pointer to __old_ipc_perm.
>>
>> I guess we can even remove the entire definition of
>> struct __old_semid_ds etc on all architectures since we
>> just pass a pointer from the compat entry point to the
>> kernel without looking at the contents?
> 
> Yeap, this is what I ended up doing in my local branch (remove aarch64
> ipc_priv.h ununsed definitions and cleanup semctl old ipc struct
> definitions).

This is the updated patch based on previous comments (CL is essentially
the same):

--

Some architectures support the old-style IPC and require IPC_64 equal to
0x100 to be passed along SysV IPC syscalls, while new architectures should
default to new IPC version (without the flags being set).

This patch refactor current ipc_priv.h Linux headers in two directions:

- Remove cross platform references (for instance alpha including powerpc
  definition) and add required definition for each required port.  The
  idea is to avoid tie one architecture definition with another and make
  platform change independent.

- Move all common definitions (the ipc syscall commands) on a common
  header, ipc_ops.h.

	* sysdeps/unix/sysv/linux/aarch64/ipc_priv.h: New file.
	* sysdeps/unix/sysv/linux/alpha/ipc_priv.h: Avoid included other arch
	definition and define its own.
	* sysdeps/unix/sysv/linux/ipc_ops.h: New file.
	* sysdeps/unix/sysv/linux/x86_64/ipc_priv.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/ipc_priv.h: Remove file.
	* sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h: New file.
	* sysdeps/unix/sysv/linux/ipc_priv.h: Move ipc syscall operation
	definitions to common header.
	* sysdeps/unix/sysv/linux/powerpc/ipc_priv.h: Use common syscall
	operation from ipc_ops.h.
---
 ChangeLog                                        | 12 +++++++
 sysdeps/unix/sysv/linux/aarch64/ipc_priv.h       | 21 ++++++++++++
 sysdeps/unix/sysv/linux/alpha/ipc_priv.h         | 33 ++++++++++++++++++-
 sysdeps/unix/sysv/linux/ipc_ops.h                | 30 +++++++++++++++++
 sysdeps/unix/sysv/linux/ipc_priv.h               | 23 +++++--------
 sysdeps/unix/sysv/linux/mips/ipc_priv.h          |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h   | 32 ++++++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/ipc_priv.h       | 23 +++++--------
 sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h | 41 ++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/x86_64/ipc_priv.h        | 32 ++++++++++++++++++
 10 files changed, 216 insertions(+), 32 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/ipc_ops.h
 delete mode 100644 sysdeps/unix/sysv/linux/mips/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/ipc_priv.h

diff --git a/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
new file mode 100644
index 0000000..f73530c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
@@ -0,0 +1,21 @@
+/* Old SysV permission definition for Linux.  AArch64 version.
+   Copyright (C) 2016 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 <sys/ipc.h>  /* For __key_t  */
+
+#define __IPC_64	0x0
diff --git a/sysdeps/unix/sysv/linux/alpha/ipc_priv.h b/sysdeps/unix/sysv/linux/alpha/ipc_priv.h
index 67883be..06444fc 100644
--- a/sysdeps/unix/sysv/linux/alpha/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/alpha/ipc_priv.h
@@ -1 +1,32 @@
-#include <sysdeps/unix/sysv/linux/powerpc/ipc_priv.h>
+/* Old SysV permission definition for Linux.  Alpha version.
+   Copyright (C) 2016 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 <sys/ipc.h>  /* For __key_t  */
+
+#define __IPC_64	0x100
+
+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.  */
+};
diff --git a/sysdeps/unix/sysv/linux/ipc_ops.h b/sysdeps/unix/sysv/linux/ipc_ops.h
new file mode 100644
index 0000000..ea3028c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ipc_ops.h
@@ -0,0 +1,30 @@
+/* The codes for the functions to use the ipc syscall multiplexer.
+   Copyright (C) 2016 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/>.  */
+
+#define IPCOP_semop	 	1
+#define IPCOP_semget	 	2
+#define IPCOP_semctl	 	3
+#define IPCOP_semtimedop 	4
+#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
diff --git a/sysdeps/unix/sysv/linux/ipc_priv.h b/sysdeps/unix/sysv/linux/ipc_priv.h
index 7ded463..9b97f00 100644
--- a/sysdeps/unix/sysv/linux/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/ipc_priv.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
+/* Old SysV permission definition for Linux.  Default version.
+   Copyright (C) 1995-2016 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
@@ -15,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>
+#include <sys/ipc.h>  /* For __key_t  */
 
 #define __IPC_64	0x100
 
@@ -30,17 +31,9 @@ struct __old_ipc_perm
   unsigned short int __seq;		/* Sequence number.  */
 };
 
+#define SEMCTL_ARG_ADDRESS(__arg) &__arg.array
 
-/* The codes for the functions to use the ipc syscall multiplexer.  */
-#define IPCOP_semop	 1
-#define IPCOP_semget	 2
-#define IPCOP_semctl	 3
-#define IPCOP_semtimedop 4
-#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
+#define MSGRCV_ARGS(__msgp, __msgtyp) \
+  ((long int []){ (long int) __msgp, __msgtyp })
+
+#include <ipc_ops.h>
diff --git a/sysdeps/unix/sysv/linux/mips/ipc_priv.h b/sysdeps/unix/sysv/linux/mips/ipc_priv.h
deleted file mode 100644
index 67883be..0000000
--- a/sysdeps/unix/sysv/linux/mips/ipc_priv.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/powerpc/ipc_priv.h>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h b/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
new file mode 100644
index 0000000..9f47d89
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
@@ -0,0 +1,32 @@
+/* Old SysV permission definition for Linux.  MIPS64 version.
+   Copyright (C) 2016 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 <sys/ipc.h>
+
+#define __IPC_64	0x100
+
+struct __old_ipc_perm
+{
+  __key_t __key;		/* Key.  */
+  int uid;			/* Owner's user ID.  */
+  int gid;			/* Owner's group ID.  */
+  int cuid;			/* Creator's user ID.  */
+  int cgid;			/* Creator's group ID.  */
+  int mode;			/* Read/write permission.  */
+  unsigned short int __seq;	/* Sequence number.  */
+};
diff --git a/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h b/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
index baae7ab..4f72f58 100644
--- a/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
+/* Old SysV permission definition for Linux.  PowerPC version.
+   Copyright (C) 1995-2016 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
@@ -15,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>
+#include <sys/ipc.h>  /* For __key_t  */
 
 #define __IPC_64	0x100
 
@@ -30,17 +31,9 @@ struct __old_ipc_perm
   unsigned short int __seq;		/* Sequence number.  */
 };
 
+#define SEMCTL_ARG_ADDRESS(__arg) &__arg.array
 
-/* The codes for the functions to use the ipc syscall multiplexer.  */
-#define IPCOP_semop	 1
-#define IPCOP_semget	 2
-#define IPCOP_semctl	 3
-#define IPCOP_semtimedop 4
-#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
+#define MSGRCV_ARGS(__msgp, __msgtyp) \
+  ((long int []){ (long int) __msgp, __msgtyp })
+
+#include <ipc_ops.h>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h b/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
new file mode 100644
index 0000000..386ff8a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
@@ -0,0 +1,41 @@
+/* Old SysV permission definition for Linux.  x86_64 version.
+   Copyright (C) 2016 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 <sys/ipc.h>  /* For __key_t  */
+
+#define __IPC_64	0x0
+
+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.  */
+};
+
+/* SPARC semctl multiplex syscall expects the union pointed address, not
+   the union address itself.  */
+#define SEMCTL_ARG_ADDRESS(__arg) __arg.array
+
+/* Also for msgrcv it does not use the kludge on final 2 arguments.  */
+#define MSGRCV_ARGS(__msgp, __msgtyp) __msgp, __msgtyp
+
+#include <ipc_ops.h>
diff --git a/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h b/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h
new file mode 100644
index 0000000..d39db53
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h
@@ -0,0 +1,32 @@
+/* Old SysV permission definition for Linux.  x86_64 version.
+   Copyright (C) 2016 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 <sys/ipc.h>  /* For __key_t  */
+
+#define __IPC_64	0x0
+
+struct __old_ipc_perm
+{
+  __key_t __key;		/* Key.  */
+  unsigned short uid;		/* Owner's user ID.  */
+  unsigned short gid;		/* Owner's group ID.  */
+  unsigned short cuid;		/* Creator's user ID.  */
+  unsigned short cgid;		/* Creator's group ID.  */
+  unsigned short mode;		/* Read/write permission.  */
+  unsigned short int __seq;	/* Sequence number.  */
+};
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 08/17] Consolidate Linux semctl implementation
  2016-12-12 12:33 ` [PATCH 08/17] Consolidate Linux semctl implementation Adhemerval Zanella
@ 2016-12-16 14:08   ` Adhemerval Zanella
  0 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-16 14:08 UTC (permalink / raw)
  To: libc-alpha

On 12/12/2016 10:33, Adhemerval Zanella wrote:
> This patch consolidates the semctl Linux implementation in only
> one default file, sysdeps/unix/sysv/linux/semctl.c.  If tries to use
> the direct syscall if it is supported, otherwise will use the old ipc
> multiplex mechanism.

This is an updated patch based on previous ipc_priv.h header one
discussion.  Basically I removed the old compatibility structure
definition because they are not really required:

--

This patch consolidates the semctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/semctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
	oldsemctl.
	* sysdeps/unix/sysv/linux/alpha/semctl.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/semctl.c: Use defaulf
	implementation.
	* sysdeps/unix/sysv/linux/semctl.c (__new_semctl): Use semctl
	syscall if it is defined.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (semctl): Remove.
	* sysdeps/unix/sysv/linux/alpha/syscalls.list (semctl): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (semctl): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (semctl): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semctl):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semctl): Likewise.
---
 ChangeLog                                          | 18 ++++++
 sysdeps/unix/sysv/linux/alpha/Makefile             |  2 +-
 sysdeps/unix/sysv/linux/alpha/semctl.c             |  1 -
 sysdeps/unix/sysv/linux/alpha/syscalls.list        |  1 -
 sysdeps/unix/sysv/linux/arm/semctl.c               | 54 ----------------
 sysdeps/unix/sysv/linux/generic/syscalls.list      |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/ia64/syscalls.list         |  1 -
 sysdeps/unix/sysv/linux/microblaze/semctl.c        |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/semctl.c       | 38 ++----------
 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  1 -
 sysdeps/unix/sysv/linux/semctl.c                   | 71 +++++++++-------------
 sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c     | 54 ----------------
 sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  1 -
 14 files changed, 54 insertions(+), 191 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/semctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/semctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/semctl.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c

diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile
index c24dc2e..386b3fd 100644
--- a/sysdeps/unix/sysv/linux/alpha/Makefile
+++ b/sysdeps/unix/sysv/linux/alpha/Makefile
@@ -18,7 +18,7 @@ sysdep_routines += osf_select osf_gettimeofday osf_settimeofday \
 		   osf_getrusage osf_wait4
 
 # Support old ipc control
-sysdep_routines += oldsemctl oldshmctl
+sysdep_routines += oldshmctl
 
 CFLAGS-ioperm.c = -Wa,-mev6
 endif
diff --git a/sysdeps/unix/sysv/linux/alpha/semctl.c b/sysdeps/unix/sysv/linux/alpha/semctl.c
deleted file mode 100644
index 4cb834a..0000000
--- a/sysdeps/unix/sysv/linux/alpha/semctl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/arm/semctl.c>
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 54c1752..c12620a 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -7,7 +7,6 @@ shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 semget		-	semget		i:iii	__semget	semget
-oldsemctl	EXTRA	semctl		i:iiii	__old_semctl	semctl@GLIBC_2.0
 
 sigstack	-	sigstack	2	sigstack
 
diff --git a/sysdeps/unix/sysv/linux/arm/semctl.c b/sysdeps/unix/sysv/linux/arm/semctl.c
deleted file mode 100644
index 79d9d3e..0000000
--- a/sysdeps/unix/sysv/linux/arm/semctl.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1995-2016 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 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 <stdarg.h>
-#include <sys/sem.h>
-#include <ipc_priv.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 */
-};
-
-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);
-
-  return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd | __IPC_64,
-			 arg.array);
-}
-
-#include <shlib-compat.h>
-versioned_symbol (libc, __new_semctl, semctl, GLIBC_2_2);
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index ad75223..f95f1f7 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -2,7 +2,6 @@
 
 # SysV APIs
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
 semtimedop	-	semtimedop	i:ipip	semtimedop
 semop		-	semop		i:ipi	__semop		semop
 shmget		-	shmget		i:iii	__shmget	shmget
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index da2c9ab..5040ef3 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -8,7 +8,6 @@ shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop      -       semtimedop      i:ipip  semtimedop
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 8056781..ca5cba4 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -12,7 +12,6 @@ shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
 
 # proper socket implementations:
 accept		-	accept		Ci:iBN	__libc_accept	__accept accept
diff --git a/sysdeps/unix/sysv/linux/microblaze/semctl.c b/sysdeps/unix/sysv/linux/microblaze/semctl.c
deleted file mode 100644
index 4cb834a..0000000
--- a/sysdeps/unix/sysv/linux/microblaze/semctl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/arm/semctl.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/semctl.c b/sysdeps/unix/sysv/linux/mips/mips64/semctl.c
index 1115a25..5a0c2a3 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/semctl.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/semctl.c
@@ -15,39 +15,11 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stdarg.h>
-#include <sys/sem.h>
-#include <ipc_priv.h>
-#include <sysdep.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 */
-};
-
-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);
-
-  /* Get the argument.  */
-  arg = va_arg (ap, union semun);
+#include <shlib-compat.h>
 
-  va_end (ap);
+#undef SHLIB_COMPAT
+#define SHLIB_COMPAT(a, b, c) 0
 
-  return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd | __IPC_64,
-			 arg.array);
-}
+#define DEFAULT_VERSION GLIBC_2_0
 
-#include <shlib-compat.h>
-versioned_symbol (libc, __semctl, semctl, GLIBC_2_0);
+#include <sysdeps/unix/sysv/linux/semctl.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index f23b379..09ab580 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -7,4 +7,3 @@ shmdt		-	shmdt		i:s	__shmdt		shmdt
 shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
index ee84a1e..dde2241 100644
--- a/sysdeps/unix/sysv/linux/semctl.c
+++ b/sysdeps/unix/sysv/linux/semctl.c
@@ -16,29 +16,12 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stdarg.h>
 #include <sys/sem.h>
+#include <stdarg.h>
 #include <ipc_priv.h>
-
 #include <sysdep.h>
-#include <string.h>
-#include <sys/syscall.h>
 #include <shlib-compat.h>
-
-#include <kernel-features.h>
-
-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 */
-};
+#include <errno.h>
 
 /* Define a `union semun' suitable for Linux here.  */
 union semun
@@ -47,26 +30,19 @@ union semun
   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 */
-  struct __old_semid_ds *__old_buf;
 };
 
-/* Return identifier for array of NSEMS semaphores associated with
-   KEY.  */
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
-int __old_semctl (int semid, int semnum, int cmd, ...);
+#ifndef DEFAULT_VERSION
+# define DEFAULT_VERSION GLIBC_2_2
 #endif
-int __new_semctl (int semid, int semnum, int cmd, ...);
 
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
 int
-attribute_compat_text_section
-__old_semctl (int semid, int semnum, int cmd, ...)
+__new_semctl (int semid, int semnum, int cmd, ...)
 {
-  union semun arg;
+  union semun arg = { 0 };
   va_list ap;
 
   /* Get the argument only if required.  */
-  arg.buf = NULL;
   switch (cmd)
     {
     case SETVAL:        /* arg.val */
@@ -83,20 +59,29 @@ __old_semctl (int semid, int semnum, int cmd, ...)
       break;
     }
 
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
-			 &arg);
-}
-compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
+#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64,
+			      arg.array);
+#else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
+			      SEMCTL_ARG_ADDRESS (arg));
 #endif
+}
+versioned_symbol (libc, __new_semctl, semctl, DEFAULT_VERSION);
+
 
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
+/* Since semctl use a variadic argument for semid_ds there is not need to
+   define and tie the compatibility symbol to the old 'union semun'
+   definition.  */
 int
-__new_semctl (int semid, int semnum, int cmd, ...)
+attribute_compat_text_section
+__old_semctl (int semid, int semnum, int cmd, ...)
 {
-  union semun arg;
+  union semun arg = { 0 };
   va_list ap;
 
   /* Get the argument only if required.  */
-  arg.buf = NULL;
   switch (cmd)
     {
     case SETVAL:        /* arg.val */
@@ -113,8 +98,12 @@ __new_semctl (int semid, int semnum, int cmd, ...)
       break;
     }
 
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
-			 &arg);
+# ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+  return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd, arg.array);
+# else
+  return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd,
+			      SEMCTL_ARG_ADDRESS (arg));
+# endif
 }
-
-versioned_symbol (libc, __new_semctl, semctl, GLIBC_2_2);
+compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c b/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c
deleted file mode 100644
index a9ae4c6..0000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1995-2016 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 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 <stdarg.h>
-#include <sys/sem.h>
-#include <ipc_priv.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.array);
-}
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 75b25a1..f3a1541 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -13,7 +13,6 @@ shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semtimedop	-	semtimedop	i:ipip	semtimedop
 semget		-	semget		i:iii	__semget	semget
-semctl		-	semctl		i:iiii	__semctl	semctl
 syscall_clock_gettime	EXTRA	clock_gettime	Ei:ip		__syscall_clock_gettime
 
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re:
       [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
                   ` (16 preceding siblings ...)
  2016-12-12 12:33 ` [PATCH 01/17] Add __ASSUME_DIRECT_SYSVIPC_SYSCALL for Linux Adhemerval Zanella
@ 2016-12-19 18:18 ` Adhemerval Zanella
  17 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2016-12-19 18:18 UTC (permalink / raw)
  To: libc-alpha

Is any other blocker for this patchset besides the already ones
addresses for ipc_priv.h on aarch64 [1] and the old definition
for semctl [2]?

I would like to include it for 2.25 (I already added on the
desirable features).

[1] https://sourceware.org/ml/libc-alpha/2016-12/msg00610.html
[2] https://sourceware.org/ml/libc-alpha/2016-12/msg00611.html

On 12/12/2016 10:32, Adhemerval Zanella wrote:
> Subject: [PATCH v4 00/17] Consolidate Linux sysvipc implementation
> 
> Changes from previous version:
> 
>  - Change __ASSUME_SYSVIPC_SYSCALL to __ASSUME_DIRECT_SYSVIPC_SYSCALL.
>  - Remove some misplaced comments.
>  - Fixed some misspelling and grammatical mistakes.
>  - Adjust to use the new subdirectory for test infrastructure (commit
>    c23de0aacbea).
> 
> Also, I did not add AArch64/ILP32 __IPC_64 definition because I would
> to confirm that 1 is really the expected value for the architecture.
> 
> --
> 
> This patchset is a continuation of my Linux syscall consolidation
> implementation and aimed for SySV IPC (message queue, semaphore,
> and shared memory).
> 
> Current Linux default implementation only defines the old ipc
> syscall method.  Architectures need to either to imply the generic
> syscalls.list or reimplement the syscall definition.  To simplify
> and allow to remove some old arch-specific implementation, I added
> the direct syscall method for all supported IPC mechanisms.
> 
> Other changes are simple code reorganization to simplify and all
> compatibility required for various ports.
> 
> The patchset also adds 3 simple tests that aims to check for correct
> argument passing on syscall.  The idea is not to be an extensive
> testing of all supported IPC.
> 
> Checked on x86_64, i686, armhf, aarch64, and powerpc64le.
> 
> Adhemerval Zanella (17):
>   Add __ASSUME_DIRECT_SYSVIPC_SYSCALL for Linux
>   Refactor Linux ipc_priv header
>   Consolidate Linux msgctl implementation
>   Consolidate Linux msgrcv implementation
>   Use msgsnd syscall for Linux implementation
>   Use msgget syscall for Linux implementation
>   Add SYSV message queue test
>   Consolidate Linux semctl implementation
>   Use semget syscall for Linux implementation
>   Use semop syscall for Linux implementation
>   Consolidate Linux semtimedop implementation
>   Add SYSV semaphore test
>   Use shmat syscall for Linux implementation
>   Consolidate Linux shmctl implementation
>   Use shmdt syscall for linux implementation
>   Use shmget syscall for linux implementation
>   Add SYSV shared memory test
> 
>  ChangeLog                                          | 229 +++++++++++++++++++++
>  support/check.h                                    |   5 +
>  sysdeps/unix/sysv/linux/aarch64/ipc_priv.h         |  32 +++
>  sysdeps/unix/sysv/linux/alpha/Makefile             |   3 -
>  sysdeps/unix/sysv/linux/alpha/ipc_priv.h           |  33 ++-
>  sysdeps/unix/sysv/linux/alpha/kernel-features.h    |   3 +
>  sysdeps/unix/sysv/linux/alpha/msgctl.c             |   1 -
>  sysdeps/unix/sysv/linux/alpha/semctl.c             |   1 -
>  sysdeps/unix/sysv/linux/alpha/shmctl.c             |   1 -
>  sysdeps/unix/sysv/linux/alpha/syscalls.list        |  13 --
>  sysdeps/unix/sysv/linux/arm/msgctl.c               |  33 ---
>  sysdeps/unix/sysv/linux/arm/semctl.c               |  54 -----
>  sysdeps/unix/sysv/linux/arm/shmctl.c               |  34 ---
>  sysdeps/unix/sysv/linux/arm/syscalls.list          |  12 --
>  sysdeps/unix/sysv/linux/generic/syscalls.list      |  14 --
>  sysdeps/unix/sysv/linux/hppa/syscalls.list         |  14 --
>  sysdeps/unix/sysv/linux/i386/kernel-features.h     |   3 +
>  sysdeps/unix/sysv/linux/ia64/syscalls.list         |  14 --
>  sysdeps/unix/sysv/linux/ipc_ops.h                  |  30 +++
>  sysdeps/unix/sysv/linux/ipc_priv.h                 |  23 +--
>  sysdeps/unix/sysv/linux/kernel-features.h          |   4 +
>  sysdeps/unix/sysv/linux/m68k/kernel-features.h     |   3 +
>  sysdeps/unix/sysv/linux/m68k/semtimedop.S          |  69 -------
>  sysdeps/unix/sysv/linux/microblaze/msgctl.c        |   1 -
>  sysdeps/unix/sysv/linux/microblaze/semctl.c        |   1 -
>  sysdeps/unix/sysv/linux/microblaze/shmctl.c        |   1 -
>  sysdeps/unix/sysv/linux/microblaze/syscalls.list   |  12 --
>  sysdeps/unix/sysv/linux/mips/ipc_priv.h            |   1 -
>  sysdeps/unix/sysv/linux/mips/kernel-features.h     |   2 +
>  sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h     |  32 +++
>  sysdeps/unix/sysv/linux/mips/mips64/msgctl.c       |  17 +-
>  sysdeps/unix/sysv/linux/mips/mips64/semctl.c       |  38 +---
>  sysdeps/unix/sysv/linux/mips/mips64/shmctl.c       |  17 +-
>  sysdeps/unix/sysv/linux/mips/mips64/syscalls.list  |  13 --
>  sysdeps/unix/sysv/linux/msgctl.c                   |  45 ++--
>  sysdeps/unix/sysv/linux/msgget.c                   |  11 +-
>  sysdeps/unix/sysv/linux/msgrcv.c                   |  26 +--
>  sysdeps/unix/sysv/linux/msgsnd.c                   |   9 +-
>  sysdeps/unix/sysv/linux/powerpc/ipc_priv.h         |  23 +--
>  sysdeps/unix/sysv/linux/powerpc/kernel-features.h  |   3 +
>  sysdeps/unix/sysv/linux/s390/kernel-features.h     |   3 +
>  sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list |  14 --
>  sysdeps/unix/sysv/linux/s390/semtimedop.c          |  12 +-
>  sysdeps/unix/sysv/linux/semctl.c                   |  58 +++---
>  sysdeps/unix/sysv/linux/semget.c                   |  11 +-
>  sysdeps/unix/sysv/linux/semop.c                    |  10 +-
>  sysdeps/unix/sysv/linux/semtimedop.c               |  13 +-
>  sysdeps/unix/sysv/linux/sh/kernel-features.h       |   3 +
>  sysdeps/unix/sysv/linux/shmat.c                    |  17 +-
>  sysdeps/unix/sysv/linux/shmctl.c                   |  59 +++---
>  sysdeps/unix/sysv/linux/shmdt.c                    |  12 +-
>  sysdeps/unix/sysv/linux/shmget.c                   |  13 +-
>  sysdeps/unix/sysv/linux/sparc/kernel-features.h    |   3 +
>  sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h   |  41 ++++
>  sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c     |  32 ---
>  sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c     |  54 -----
>  sysdeps/unix/sysv/linux/x86_64/ipc_priv.h          |  32 +++
>  sysdeps/unix/sysv/linux/x86_64/syscalls.list       |  12 --
>  sysvipc/Makefile                                   |   2 +
>  sysvipc/test-sysvmsg.c                             | 128 ++++++++++++
>  sysvipc/test-sysvsem.c                             | 116 +++++++++++
>  sysvipc/test-sysvshm.c                             | 131 ++++++++++++
>  62 files changed, 1013 insertions(+), 643 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/msgctl.c
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/semctl.c
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/shmctl.c
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/msgctl.c
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/semctl.c
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/shmctl.c
>  create mode 100644 sysdeps/unix/sysv/linux/ipc_ops.h
>  delete mode 100644 sysdeps/unix/sysv/linux/m68k/semtimedop.S
>  delete mode 100644 sysdeps/unix/sysv/linux/microblaze/msgctl.c
>  delete mode 100644 sysdeps/unix/sysv/linux/microblaze/semctl.c
>  delete mode 100644 sysdeps/unix/sysv/linux/microblaze/shmctl.c
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/ipc_priv.h
>  create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
>  create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
>  delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c
>  delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c
>  create mode 100644 sysdeps/unix/sysv/linux/x86_64/ipc_priv.h
>  create mode 100644 sysvipc/test-sysvmsg.c
>  create mode 100644 sysvipc/test-sysvsem.c
>  create mode 100644 sysvipc/test-sysvshm.c
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re:
  2023-07-10 15:58   ` Noah Goldstein
  2023-07-14  2:21     ` Re: Noah Goldstein
@ 2023-07-14  7:39     ` sajan karumanchi
  1 sibling, 0 replies; 33+ messages in thread
From: sajan karumanchi @ 2023-07-14  7:39 UTC (permalink / raw)
  To: Noah Goldstein
  Cc: premachandra.mallappa, dj, hjl.tools, libc-alpha, carlos,
	Sajan Karumanchi

* Noah,
On Mon, Jul 10, 2023 at 9:28 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> On Mon, Jul 10, 2023 at 12:23 AM Sajan Karumanchi
> <sajan.karumanchi@gmail.com> wrote:
> >
> > Noah,
> > I verified your patches on the master branch that impacts the non-threshold
> >  parameter on x86 CPUs. This patch modifies the non-temporal threshold value
> > from 24MB(3/4th of L3$) to 8MB(1/4th of L3$) on ZEN4.
> > From the Glibc benchmarks, we saw a significant performance drop ranging
> > from 15% to 99% for size ranges of 8MB to 16MB.
> > I also ran the new tool developed by you on all Zen architectures and the
> > results conclude that 3/4th L3 size holds good on AMD CPUs.
> > Hence the current patch degrades the performance of AMD CPUs.
> > We strongly recommend marking this change to Intel CPUs only.
> >
>
> So it shouldn't actually go down. I think what is missing is:
> ```
> get_common_cache_info (&shared, &shared_per_thread, &threads, core);
> ```
>
The cache info of AMD CPUs is spread across CPUID registers:
0x80000005,  0x80000006, and  0x8000001D.
But, 'get_common_cache_info(...)' is using CPUID register 0x00000004
for enumerating cache details. This leads to an infinite loop in the
initialization stage for enumerating the cache details on AMD CPUs.

> In the AMD case shared == shared_per_thread which shouldn't really
> be the case.
>
> The intended new calculation is: Total_L3_Size / Scale
> as opposed to: (L3_Size / NThread) / Scale"
>
AMD Zen CPUs are chiplet based, so we consider only L3/CCX for
computing the nt_threshold.
* handle_amd(_SC_LEVEL3_CACHE_SIZE) initializes 'shared' variable with
'l3_cache_per_ccx' for Zen architectures and 'l3_cache_per_thread' for
pre-Zen architectures.

> Before just going with default for AMD, maybe try out the following patch?
>
Since the cache info registers and the approach to compute the cache
details on AMD are different from Intel, we cannot use the below
patch.
> ```
> ---
>  sysdeps/x86/dl-cacheinfo.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
> index c98fa57a7b..c1866ca898 100644
> --- a/sysdeps/x86/dl-cacheinfo.h
> +++ b/sysdeps/x86/dl-cacheinfo.h
> @@ -717,6 +717,7 @@ dl_init_cacheinfo (struct cpu_features *cpu_features)
>        level3_cache_assoc = handle_amd (_SC_LEVEL3_CACHE_ASSOC);
>        level3_cache_linesize = handle_amd (_SC_LEVEL3_CACHE_LINESIZE);
>
> +      get_common_cache_info (&shared, &shared_per_thread, &threads, core);
>        if (shared <= 0)
>          /* No shared L3 cache.  All we have is the L2 cache.  */
>   shared = core;
> --
> 2.34.1
> ```
> > Thanks,
> > Sajan K.
> >

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re:
  2023-07-10 15:58   ` Noah Goldstein
@ 2023-07-14  2:21     ` Noah Goldstein
  2023-07-14  7:39     ` Re: sajan karumanchi
  1 sibling, 0 replies; 33+ messages in thread
From: Noah Goldstein @ 2023-07-14  2:21 UTC (permalink / raw)
  To: Sajan Karumanchi; +Cc: premachandra.mallappa, dj, hjl.tools, libc-alpha, carlos

On Mon, Jul 10, 2023 at 10:58 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> On Mon, Jul 10, 2023 at 12:23 AM Sajan Karumanchi
> <sajan.karumanchi@gmail.com> wrote:
> >
> > Noah,
> > I verified your patches on the master branch that impacts the non-threshold
> >  parameter on x86 CPUs. This patch modifies the non-temporal threshold value
> > from 24MB(3/4th of L3$) to 8MB(1/4th of L3$) on ZEN4.
> > From the Glibc benchmarks, we saw a significant performance drop ranging
> > from 15% to 99% for size ranges of 8MB to 16MB.
> > I also ran the new tool developed by you on all Zen architectures and the
> > results conclude that 3/4th L3 size holds good on AMD CPUs.
> > Hence the current patch degrades the performance of AMD CPUs.
> > We strongly recommend marking this change to Intel CPUs only.
> >
>
> So it shouldn't actually go down. I think what is missing is:
> ```
> get_common_cache_info (&shared, &shared_per_thread, &threads, core);
> ```
>
> In the AMD case shared == shared_per_thread which shouldn't really
> be the case.
>
> The intended new calculation is: Total_L3_Size / Scale
> as opposed to: (L3_Size / NThread) / Scale"
>
> Before just going with default for AMD, maybe try out the following patch?
>
> ```
> ---
>  sysdeps/x86/dl-cacheinfo.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
> index c98fa57a7b..c1866ca898 100644
> --- a/sysdeps/x86/dl-cacheinfo.h
> +++ b/sysdeps/x86/dl-cacheinfo.h
> @@ -717,6 +717,7 @@ dl_init_cacheinfo (struct cpu_features *cpu_features)
>        level3_cache_assoc = handle_amd (_SC_LEVEL3_CACHE_ASSOC);
>        level3_cache_linesize = handle_amd (_SC_LEVEL3_CACHE_LINESIZE);
>
> +      get_common_cache_info (&shared, &shared_per_thread, &threads, core);
>        if (shared <= 0)
>          /* No shared L3 cache.  All we have is the L2 cache.  */
>   shared = core;
> --
> 2.34.1
> ```
> > Thanks,
> > Sajan K.
> >

ping. 2.38 is approaching and I expect you want to get any fixes in before
that.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re:
  2023-07-10  5:23 ` Sajan Karumanchi
@ 2023-07-10 15:58   ` Noah Goldstein
  2023-07-14  2:21     ` Re: Noah Goldstein
  2023-07-14  7:39     ` Re: sajan karumanchi
  0 siblings, 2 replies; 33+ messages in thread
From: Noah Goldstein @ 2023-07-10 15:58 UTC (permalink / raw)
  To: Sajan Karumanchi; +Cc: premachandra.mallappa, dj, hjl.tools, libc-alpha, carlos

On Mon, Jul 10, 2023 at 12:23 AM Sajan Karumanchi
<sajan.karumanchi@gmail.com> wrote:
>
> Noah,
> I verified your patches on the master branch that impacts the non-threshold
>  parameter on x86 CPUs. This patch modifies the non-temporal threshold value
> from 24MB(3/4th of L3$) to 8MB(1/4th of L3$) on ZEN4.
> From the Glibc benchmarks, we saw a significant performance drop ranging
> from 15% to 99% for size ranges of 8MB to 16MB.
> I also ran the new tool developed by you on all Zen architectures and the
> results conclude that 3/4th L3 size holds good on AMD CPUs.
> Hence the current patch degrades the performance of AMD CPUs.
> We strongly recommend marking this change to Intel CPUs only.
>

So it shouldn't actually go down. I think what is missing is:
```
get_common_cache_info (&shared, &shared_per_thread, &threads, core);
```

In the AMD case shared == shared_per_thread which shouldn't really
be the case.

The intended new calculation is: Total_L3_Size / Scale
as opposed to: (L3_Size / NThread) / Scale"

Before just going with default for AMD, maybe try out the following patch?

```
---
 sysdeps/x86/dl-cacheinfo.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
index c98fa57a7b..c1866ca898 100644
--- a/sysdeps/x86/dl-cacheinfo.h
+++ b/sysdeps/x86/dl-cacheinfo.h
@@ -717,6 +717,7 @@ dl_init_cacheinfo (struct cpu_features *cpu_features)
       level3_cache_assoc = handle_amd (_SC_LEVEL3_CACHE_ASSOC);
       level3_cache_linesize = handle_amd (_SC_LEVEL3_CACHE_LINESIZE);

+      get_common_cache_info (&shared, &shared_per_thread, &threads, core);
       if (shared <= 0)
         /* No shared L3 cache.  All we have is the L2 cache.  */
  shared = core;
-- 
2.34.1
```
> Thanks,
> Sajan K.
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re:
@ 2023-01-13  5:41 father.dominic
  0 siblings, 0 replies; 33+ messages in thread
From: father.dominic @ 2023-01-13  5:41 UTC (permalink / raw)
  To: father.dominic

Hello 

 

I'm obliged to inform you that a monetary donation of $800,000.00 USD has
been awarded to you. Contact  stef@stefaniekoren.com for more information.


 

Regards.

 

 

 



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re:
  2021-06-06 19:19 Davidlohr Bueso
@ 2021-06-07 16:02 ` André Almeida
  0 siblings, 0 replies; 33+ messages in thread
From: André Almeida @ 2021-06-07 16:02 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
	linux-kernel, Steven Rostedt, Sebastian Andrzej Siewior, kernel,
	krisman, pgriffais, z.figura12, joel, malteskarupke, linux-api,
	fweimer, libc-alpha, linux-kselftest, shuah, acme, corbet,
	Peter Oskolkov, Andrey Semashev, mtk.manpages

Às 16:19 de 06/06/21, Davidlohr Bueso escreveu:
> Bcc:
> Subject: Re: [PATCH v4 07/15] docs: locking: futex2: Add documentation
> Reply-To:
> In-Reply-To: <20210603195924.361327-8-andrealmeid@collabora.com>
> 
> On Thu, 03 Jun 2021, Andr� Almeida wrote:
> 
>> Add a new documentation file specifying both userspace API and internal
>> implementation details of futex2 syscalls.
> 
> I think equally important would be to provide a manpage for each new
> syscall you are introducing, and keep mkt in the loop as in the past he
> extensively documented and improved futex manpages, and overall has a
> lot of experience with dealing with kernel interfaces.

Right, I'll add the man pages in a future version and make sure to have
mkt in the loop, thanks for the tip.

> 
> Thanks,
> Davidlohr
> 
>>
>> Signed-off-by: André Almeida <andrealmeid@collabora.com>
>> ---
>> Documentation/locking/futex2.rst | 198 +++++++++++++++++++++++++++++++
>> Documentation/locking/index.rst  |   1 +
>> 2 files changed, 199 insertions(+)
>> create mode 100644 Documentation/locking/futex2.rst
>>
>> diff --git a/Documentation/locking/futex2.rst
>> b/Documentation/locking/futex2.rst
>> new file mode 100644
>> index 000000000000..2f74d7c97a55
>> --- /dev/null
>> +++ b/Documentation/locking/futex2.rst
>> @@ -0,0 +1,198 @@
>> +.. SPDX-License-Identifier: GPL-2.0
>> +
>> +======
>> +futex2
>> +======
>> +
>> +:Author: André Almeida <andrealmeid@collabora.com>
>> +
>> +futex, or fast user mutex, is a set of syscalls to allow userspace to
>> create
>> +performant synchronization mechanisms, such as mutexes, semaphores and
>> +conditional variables in userspace. C standard libraries, like glibc,
>> uses it
>> +as a means to implement more high level interfaces like pthreads.
>> +
>> +The interface
>> +=============
>> +
>> +uAPI functions
>> +--------------
>> +
>> +.. kernel-doc:: kernel/futex2.c
>> +   :identifiers: sys_futex_wait sys_futex_wake sys_futex_waitv
>> sys_futex_requeue
>> +
>> +uAPI structures
>> +---------------
>> +
>> +.. kernel-doc:: include/uapi/linux/futex.h
>> +
>> +The ``flag`` argument
>> +---------------------
>> +
>> +The flag is used to specify the size of the futex word
>> +(FUTEX_[8, 16, 32, 64]). It's mandatory to define one, since there's no
>> +default size.
>> +
>> +By default, the timeout uses a monotonic clock, but can be used as a
>> realtime
>> +one by using the FUTEX_REALTIME_CLOCK flag.
>> +
>> +By default, futexes are of the private type, that means that this
>> user address
>> +will be accessed by threads that share the same memory region. This
>> allows for
>> +some internal optimizations, so they are faster. However, if the
>> address needs
>> +to be shared with different processes (like using ``mmap()`` or
>> ``shm()``), they
>> +need to be defined as shared and the flag FUTEX_SHARED_FLAG is used
>> to set that.
>> +
>> +By default, the operation has no NUMA-awareness, meaning that the
>> user can't
>> +choose the memory node where the kernel side futex data will be
>> stored. The
>> +user can choose the node where it wants to operate by setting the
>> +FUTEX_NUMA_FLAG and using the following structure (where X can be 8,
>> 16, 32 or
>> +64)::
>> +
>> + struct futexX_numa {
>> +         __uX value;
>> +         __sX hint;
>> + };
>> +
>> +This structure should be passed at the ``void *uaddr`` of futex
>> functions. The
>> +address of the structure will be used to be waited on/waken on, and the
>> +``value`` will be compared to ``val`` as usual. The ``hint`` member
>> is used to
>> +define which node the futex will use. When waiting, the futex will be
>> +registered on a kernel-side table stored on that node; when waking,
>> the futex
>> +will be searched for on that given table. That means that there's no
>> redundancy
>> +between tables, and the wrong ``hint`` value will lead to undesired
>> behavior.
>> +Userspace is responsible for dealing with node migrations issues that
>> may
>> +occur. ``hint`` can range from [0, MAX_NUMA_NODES), for specifying a
>> node, or
>> +-1, to use the same node the current process is using.
>> +
>> +When not using FUTEX_NUMA_FLAG on a NUMA system, the futex will be
>> stored on a
>> +global table on allocated on the first node.
>> +
>> +The ``timo`` argument
>> +---------------------
>> +
>> +As per the Y2038 work done in the kernel, new interfaces shouldn't
>> add timeout
>> +options known to be buggy. Given that, ``timo`` should be a 64-bit
>> timeout at
>> +all platforms, using an absolute timeout value.
>> +
>> +Implementation
>> +==============
>> +
>> +The internal implementation follows a similar design to the original
>> futex.
>> +Given that we want to replicate the same external behavior of current
>> futex,
>> +this should be somewhat expected.
>> +
>> +Waiting
>> +-------
>> +
>> +For the wait operations, they are all treated as if you want to wait
>> on N
>> +futexes, so the path for futex_wait and futex_waitv is the basically
>> the same.
>> +For both syscalls, the first step is to prepare an internal list for
>> the list
>> +of futexes to wait for (using struct futexv_head). For futex_wait()
>> calls, this
>> +list will have a single object.
>> +
>> +We have a hash table, where waiters register themselves before
>> sleeping. Then
>> +the wake function checks this table looking for waiters at uaddr. 
>> The hash
>> +bucket to be used is determined by a struct futex_key, that stores
>> information
>> +to uniquely identify an address from a given process. Given the huge
>> address
>> +space, there'll be hash collisions, so we store information to be
>> later used on
>> +collision treatment.
>> +
>> +First, for every futex we want to wait on, we check if (``*uaddr ==
>> val``).
>> +This check is done holding the bucket lock, so we are correctly
>> serialized with
>> +any futex_wake() calls. If any waiter fails the check above, we
>> dequeue all
>> +futexes. The check (``*uaddr == val``) can fail for two reasons:
>> +
>> +- The values are different, and we return -EAGAIN. However, if while
>> +  dequeueing we found that some futexes were awakened, we prioritize
>> this
>> +  and return success.
>> +
>> +- When trying to access the user address, we do so with page faults
>> +  disabled because we are holding a bucket's spin lock (and can't sleep
>> +  while holding a spin lock). If there's an error, it might be a page
>> +  fault, or an invalid address. We release the lock, dequeue everyone
>> +  (because it's illegal to sleep while there are futexes enqueued, we
>> +  could lose wakeups) and try again with page fault enabled. If we
>> +  succeed, this means that the address is valid, but we need to do
>> +  all the work again. For serialization reasons, we need to have the
>> +  spin lock when getting the user value. Additionally, for shared
>> +  futexes, we also need to recalculate the hash, since the underlying
>> +  mapping mechanisms could have changed when dealing with page fault.
>> +  If, even with page fault enabled, we can't access the address, it
>> +  means it's an invalid user address, and we return -EFAULT. For this
>> +  case, we prioritize the error, even if some futexes were awaken.
>> +
>> +If the check is OK, they are enqueued on a linked list in our bucket,
>> and
>> +proceed to the next one. If all waiters succeed, we put the thread to
>> sleep
>> +until a futex_wake() call, timeout expires or we get a signal. After
>> waking up,
>> +we dequeue everyone, and check if some futex was awakened. This
>> dequeue is done
>> +by iteratively walking at each element of struct futex_head list.
>> +
>> +All enqueuing/dequeuing operations requires to hold the bucket lock,
>> to avoid
>> +racing while modifying the list.
>> +
>> +Waking
>> +------
>> +
>> +We get the bucket that's storing the waiters at uaddr, and wake the
>> required
>> +number of waiters, checking for hash collision.
>> +
>> +There's an optimization that makes futex_wake() not take the bucket
>> lock if
>> +there's no one to be woken on that bucket. It checks an atomic
>> counter that each
>> +bucket has, if it says 0, then the syscall exits. In order for this
>> to work, the
>> +waiter thread increases it before taking the lock, so the wake thread
>> will
>> +correctly see that there's someone waiting and will continue the path
>> to take
>> +the bucket lock. To get the correct serialization, the waiter issues
>> a memory
>> +barrier after increasing the bucket counter and the waker issues a
>> memory
>> +barrier before checking it.
>> +
>> +Requeuing
>> +---------
>> +
>> +The requeue path first checks for each struct futex_requeue and their
>> flags.
>> +Then, it will compare the expected value with the one at uaddr1::uaddr.
>> +Following the same serialization explained at Waking_, we increase
>> the atomic
>> +counter for the bucket of uaddr2 before taking the lock. We need to
>> have both
>> +buckets locks at same time so we don't race with other futex
>> operation. To
>> +ensure the locks are taken in the same order for all threads (and
>> thus avoiding
>> +deadlocks), every requeue operation takes the "smaller" bucket first,
>> when
>> +comparing both addresses.
>> +
>> +If the compare with user value succeeds, we proceed by waking
>> ``nr_wake``
>> +futexes, and then requeuing ``nr_requeue`` from bucket of uaddr1 to
>> the uaddr2.
>> +This consists in a simple list deletion/addition and replacing the
>> old futex key
>> +with the new one.
>> +
>> +Futex keys
>> +----------
>> +
>> +There are two types of futexes: private and shared ones. The private
>> are futexes
>> +meant to be used by threads that share the same memory space, are
>> easier to be
>> +uniquely identified and thus can have some performance optimization. The
>> +elements for identifying one are: the start address of the page where
>> the
>> +address is, the address offset within the page and the current->mm
>> pointer.
>> +
>> +Now, for uniquely identifying a shared futex:
>> +
>> +- If the page containing the user address is an anonymous page, we can
>> +  just use the same data used for private futexes (the start address of
>> +  the page, the address offset within the page and the current->mm
>> +  pointer); that will be enough for uniquely identifying such futex. We
>> +  also set one bit at the key to differentiate if a private futex is
>> +  used on the same address (mixing shared and private calls does not
>> +  work).
>> +
>> +- If the page is file-backed, current->mm maybe isn't the same one for
>> +  every user of this futex, so we need to use other data: the
>> +  page->index, a UUID for the struct inode and the offset within the
>> +  page.
>> +
>> +Note that members of futex_key don't have any particular meaning
>> after they
>> +are part of the struct - they are just bytes to identify a futex. 
>> Given that,
>> +we don't need to use a particular name or type that matches the
>> original data,
>> +we only need to care about the bitsize of each component and make
>> both private
>> +and shared fit in the same memory space.
>> +
>> +Source code documentation
>> +=========================
>> +
>> +.. kernel-doc:: kernel/futex2.c
>> +   :no-identifiers: sys_futex_wait sys_futex_wake sys_futex_waitv
>> sys_futex_requeue
>> diff --git a/Documentation/locking/index.rst
>> b/Documentation/locking/index.rst
>> index 7003bd5aeff4..9bf03c7fa1ec 100644
>> --- a/Documentation/locking/index.rst
>> +++ b/Documentation/locking/index.rst
>> @@ -24,6 +24,7 @@ locking
>>     percpu-rw-semaphore
>>     robust-futexes
>>     robust-futex-ABI
>> +    futex2
>>
>> .. only::  subproject and html
>>
>> -- 
>> 2.31.1
>>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re:
@ 2005-07-15 21:51 ИнфоПространство
  0 siblings, 0 replies; 33+ messages in thread
From: ИнфоПространство @ 2005-07-15 21:51 UTC (permalink / raw)
  To: libc-alpha

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; format=flowed; charset="windows-1251"; reply-type=original, Size: 2487 bytes --]

  =- ÊÎÐÏÎÐÀÒÈÂÍÛÅ ÌÅÐÎÏÐÈßÒÈß -=
  =- ÍÀ ÎÑÒÎÆÅÍÊÅ ÍÀ 2000 êâ.ì -=

 • êîíôåðåíöèè, ñåìèíàðû, ñîáðàíèÿ
 • âûñòàâêè, ïðåçåíòàöèè, ïðàçäíèêè
 • áàíêåòû, ôóðøåòû

 1. Ôóíêöèîíàëüíàÿ ïðèíàäëåæíîñòü: Öåíòð ïðåäíàçíà÷åí äëÿ ïðîâåäåíèÿ âûñòàâîê, êîíôåðåíöèé, ñåìèíàðîâ, ïðåçåíòàöèé, ïîêàçîâ è ïðàçäíè÷íûõ ìåðîïðèÿòèé.

 2. Ìåñòîíàõîæäåíèå: Èñòîðè÷åñêèé öåíòð, 300 ìåòðîâ îò Õðàìà Õðèñòà Ñïàñèòåëÿ, ì.Êðîïîòêèíñêàÿ, ìèêð-í Îñòîæåíêà, 50 ìåòðîâ îò Ïðå÷èñòåíñêîé íàá.

 3. Òåõíè÷åñêèå õàðàêòåðèñòèêè: Îáùàÿ ïëîùàäü öåíòðà 2000 êâ.ì, óíèâåðñàëüíûé çàë-òðàíñôîðìåð ñ äèàïàçîíîì ïëîùàäåé îò 20 äî 1500 êâ.ì, 2 VIP-çàëà, Êàôå-ïèööåðèÿ-êîíäèòåðñêàÿ.

 4. Îñîáåííîñòè:
 - Ñïåöèàëüíûå âûñòàâî÷íûå ñòåíäû äî ïîòîëêà ñ ðàçëè÷íîé öâåòîâîé è ôóíêöèîíàëüíîé ãàììîé.
 - Âîçìîæíîñòü ýêñïîíèðîâàíèÿ àâòîìîáèëåé.
 - Âñòðîåííîå â ïîòîëîê âûñòàâî÷íîå îñâåùåíèå.
 - Øèðîêèé âûáîð ìåáåëè.
 - 2 ñöåíû
 - 2 âõîäà: öåíòðàëüíûé è òåõíè÷åñêèé.
 - Âûñîêîêà÷åñòâåííîå êîâðîâîå ïîêðûòèå
 - Ïðîôåññèîíàëüíîå çâóêîóñèëèòåëüíîå îáîðóäîâàíèå.

 Êîíôåðåíö-ïàêåò îò 36 ó.å. Âíóòð. êóðñ êîìïàíèè: 1 ó.å.=30 ðóá.

 Äèðåêòîð ïî ðàçâèòèþ áèçíåñà è îðãàíèçàöèè êîðïîðàòèâíûõ ìåðîïðèÿòèé:
 Ñàâðàñîâà Íàòàëüÿ  òåë.: 290~06~21, 290~7241, 290~0066; ô.: 290-06-49
-------------------------------------------
                 Ìåæäóíàðîäíûé 
                 èíôîðìàöèîííî-
                 âûñòàâî÷íûé öåíòð 

                 =- ÈíôîÏðîñòðàíñòâî -=

                 1-é Çà÷àòüåâñêèé ïåð.,4
                 òåë. (095) 290-7-241
                 ôàêñ (095) 202-92-45
\0

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2023-07-14  7:39 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1481545990-7247-1-git-send-email-adhemerval.zanella@linaro.org>
2016-12-12 12:33 ` [PATCH 02/17] Refactor Linux ipc_priv header Adhemerval Zanella
2016-12-12 12:47   ` Arnd Bergmann
2016-12-12 12:58     ` Adhemerval Zanella
2016-12-12 13:25       ` Arnd Bergmann
2016-12-12 14:29         ` Adhemerval Zanella
2016-12-16 14:05           ` Adhemerval Zanella
2016-12-12 13:05   ` Andreas Schwab
2016-12-12 13:41     ` Adhemerval Zanella
2016-12-12 13:50       ` Andreas Schwab
2016-12-12 12:33 ` [PATCH 17/17] Add SYSV shared memory test Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 07/17] Add SYSV message queue test Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 10/17] Use semop syscall for Linux implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 16/17] Use shmget syscall for linux implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 04/17] Consolidate Linux msgrcv implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 03/17] Consolidate Linux msgctl implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 15/17] Use shmdt syscall for linux implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 05/17] Use msgsnd syscall for Linux implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 12/17] Add SYSV semaphore test Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 09/17] Use semget syscall for Linux implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 13/17] Use shmat " Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 11/17] Consolidate Linux semtimedop implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 08/17] Consolidate Linux semctl implementation Adhemerval Zanella
2016-12-16 14:08   ` Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 14/17] Consolidate Linux shmctl implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 06/17] Use msgget syscall for Linux implementation Adhemerval Zanella
2016-12-12 12:33 ` [PATCH 01/17] Add __ASSUME_DIRECT_SYSVIPC_SYSCALL for Linux Adhemerval Zanella
2016-12-19 18:18 ` Adhemerval Zanella
2023-05-27 18:46 [PATCH v10 3/3] x86: Make the divisor in setting `non_temporal_threshold` cpu specific Noah Goldstein
2023-07-10  5:23 ` Sajan Karumanchi
2023-07-10 15:58   ` Noah Goldstein
2023-07-14  2:21     ` Re: Noah Goldstein
2023-07-14  7:39     ` Re: sajan karumanchi
  -- strict thread matches above, loose matches on Subject: below --
2023-01-13  5:41 Re: father.dominic
2021-06-06 19:19 Davidlohr Bueso
2021-06-07 16:02 ` André Almeida
2005-07-15 21:51 Re: ИнфоПространство

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).