1 /* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 see <http://www.gnu.org/licenses/>. */
19 /* SHMLBA uses it on most of the archs (not mips) */
20 #define __getpagesize getpagesize
29 /* Attach the shared memory segment associated with SHMID to the data
30 segment of the calling process. SHMADDR and SHMFLG determine how
31 and where the segment is attached. */
32 #if defined(__NR_osf_shmat)
33 # define __NR_shmat __NR_osf_shmat
36 _syscall3(void *, shmat, int, shmid, const void *,shmaddr, int, shmflg)
38 /* psm: don't remove this, else mips will fail */
41 void * shmat (int shmid, const void *shmaddr, int shmflg)
46 retval = __syscall_ipc(IPCOP_shmat, shmid, shmflg, (int) &raddr, (void *) shmaddr, 0);
47 return ((unsigned long int) retval > -(unsigned long int) SHMLBA
48 ? (void *) retval : (void *) raddr);
54 /* Provide operations to control over shared memory segments. */
56 #define __NR___syscall_shmctl __NR_shmctl
57 static __always_inline _syscall3(int, __syscall_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf)
59 int shmctl(int shmid, int cmd, struct shmid_ds *buf)
62 return __syscall_shmctl(shmid, cmd | __IPC_64, buf);
64 return __syscall_ipc(IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf, 0);
71 /* Detach shared memory segment starting at address specified by SHMADDR
72 from the caller's data segment. */
74 _syscall1(int, shmdt, const void *, shmaddr)
76 int shmdt (const void *shmaddr)
78 return __syscall_ipc(IPCOP_shmdt, 0, 0, 0, (void *) shmaddr, 0);
84 /* Return an identifier for an shared memory segment of at least size SIZE
85 which is associated with KEY. */
87 _syscall3(int, shmget, key_t, key, size_t, size, int, shmflg)
89 int shmget (key_t key, size_t size, int shmflg)
91 return __syscall_ipc(IPCOP_shmget, key, size, shmflg, NULL, 0);