summaryrefslogtreecommitdiff
path: root/libc/misc/sysvipc
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/sysvipc')
-rw-r--r--libc/misc/sysvipc/Makefile.in22
-rw-r--r--libc/misc/sysvipc/__syscall_ipc.c2
-rw-r--r--libc/misc/sysvipc/ftok.c14
-rw-r--r--libc/misc/sysvipc/ipc.h10
-rw-r--r--libc/misc/sysvipc/msgq.c55
-rw-r--r--libc/misc/sysvipc/sem.c19
-rw-r--r--libc/misc/sysvipc/shm.c16
7 files changed, 90 insertions, 48 deletions
diff --git a/libc/misc/sysvipc/Makefile.in b/libc/misc/sysvipc/Makefile.in
index 6b88ad6f0..d1c124430 100644
--- a/libc/misc/sysvipc/Makefile.in
+++ b/libc/misc/sysvipc/Makefile.in
@@ -1,30 +1,32 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := ftok.c __syscall_ipc.c
+subdirs += libc/misc/sysvipc
+
+CSRC-y := ftok.c __syscall_ipc.c
# multi source sem.c
-CSRC += semget.c semctl.c semop.c semtimedop.c
+CSRC-y += semget.c semctl.c semop.c semtimedop.c
# multi source shm.c
-CSRC += shmat.c shmctl.c shmdt.c shmget.c
+CSRC-y += shmat.c shmctl.c shmdt.c shmget.c
# multi source msgq.c
-CSRC += msgctl.c msgget.c msgrcv.c msgsnd.c
+CSRC-y += msgctl.c msgget.c msgrcv.c msgsnd.c
MISC_SYSVIPC_DIR := $(top_srcdir)libc/misc/sysvipc
MISC_SYSVIPC_OUT := $(top_builddir)libc/misc/sysvipc
-MISC_SYSVIPC_SRC := $(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC))
-MISC_SYSVIPC_OBJ := $(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC))
+MISC_SYSVIPC_SRC := $(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC-y))
+MISC_SYSVIPC_OBJ := $(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_SYSVIPC_OBJ)
-objclean-y += misc_sysvipc_objclean
+objclean-y += CLEAN_libc/misc/sysvipc
-misc_sysvipc_objclean:
- $(RM) $(MISC_SYSVIPC_OUT)/*.{o,os}
+CLEAN_libc/misc/sysvipc:
+ $(do_rm) $(addprefix $(MISC_SYSVIPC_OUT)/*., o os)
diff --git a/libc/misc/sysvipc/__syscall_ipc.c b/libc/misc/sysvipc/__syscall_ipc.c
index 99dfbf49f..304a42c29 100644
--- a/libc/misc/sysvipc/__syscall_ipc.c
+++ b/libc/misc/sysvipc/__syscall_ipc.c
@@ -13,5 +13,5 @@
#define __NR___syscall_ipc __NR_ipc
#include "ipc.h"
_syscall6(int, __syscall_ipc, unsigned int, call, long, first, long, second, long,
- third, void *, ptr, void *, fifth);
+ third, void *, ptr, void *, fifth)
#endif
diff --git a/libc/misc/sysvipc/ftok.c b/libc/misc/sysvipc/ftok.c
index 12627cad1..1e7549984 100644
--- a/libc/misc/sysvipc/ftok.c
+++ b/libc/misc/sysvipc/ftok.c
@@ -14,20 +14,22 @@
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ see <http://www.gnu.org/licenses/>. */
#include <sys/ipc.h>
#include <sys/stat.h>
-
-libc_hidden_proto(stat)
+#ifdef __UCLIBC_HAS_LFS__
+# include <_lfs_64.h>
+#else
+# define stat64 stat
+#endif
key_t ftok (const char *pathname, int proj_id)
{
- struct stat st;
+ struct stat64 st;
key_t key;
- if (stat(pathname, &st) < 0)
+ if (stat64(pathname, &st) < 0)
return (key_t) -1;
key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16)
diff --git a/libc/misc/sysvipc/ipc.h b/libc/misc/sysvipc/ipc.h
index 339d1364b..b342dc1cf 100644
--- a/libc/misc/sysvipc/ipc.h
+++ b/libc/misc/sysvipc/ipc.h
@@ -3,10 +3,14 @@
#include <syscall.h>
#include <bits/wordsize.h>
-#if __WORDSIZE == 32 || defined __alpha__ || defined __mips__
-# define __IPC_64 0x100
+#ifndef __ARCH_HAS_DEPRECATED_SYSCALLS__
+# define __IPC_64 0x0
#else
-# define __IPC_64 0x0
+# if __WORDSIZE == 32 || defined __alpha__ || defined __mips__
+# define __IPC_64 0x100
+# else
+# define __IPC_64 0x0
+# endif
#endif
#ifdef __NR_ipc
diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c
index d83ed2208..185cd268b 100644
--- a/libc/misc/sysvipc/msgq.c
+++ b/libc/misc/sysvipc/msgq.c
@@ -1,13 +1,18 @@
#include <errno.h>
#include <sys/msg.h>
#include "ipc.h"
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include "sysdep-cancel.h"
+#else
+#define SINGLE_THREAD_P 1
+#endif
#ifdef L_msgctl
#ifdef __NR_msgctl
#define __NR___libc_msgctl __NR_msgctl
-static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf);
+static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf)
#endif
/* Message queue control operation. */
int msgctl(int msqid, int cmd, struct msqid_ds *buf)
@@ -43,31 +48,65 @@ struct new_msg_buf{
#ifdef L_msgrcv
#ifdef __NR_msgrcv
-_syscall5(int, msgrcv, int, msqid, void *, msgp, size_t, msgsz, long int, msgtyp, int, msgflg);
-#else
-int msgrcv (int msqid, void *msgp, size_t msgsz,
- long int msgtyp, int msgflg)
+#define __NR___syscall_msgrcv __NR_msgrcv
+static inline _syscall5(ssize_t, __syscall_msgrcv, int, msqid, void *, msgp,
+ size_t, msgsz, long int, msgtyp, int, msgflg)
+#endif
+static inline ssize_t do_msgrcv (int msqid, void *msgp, size_t msgsz,
+ long int msgtyp, int msgflg)
{
+#ifdef __NR_msgrcv
+ return __syscall_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg);
+#else
struct new_msg_buf temp;
temp.r_msgtyp = msgtyp;
temp.oldmsg = msgp;
return __syscall_ipc(IPCOP_msgrcv ,msqid ,msgsz ,msgflg ,&temp, 0);
+#endif
}
+ssize_t msgrcv (int msqid, void *msgp, size_t msgsz,
+ long int msgtyp, int msgflg)
+{
+ if (SINGLE_THREAD_P)
+ return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
#endif
+}
#endif
#ifdef L_msgsnd
#ifdef __NR_msgsnd
-_syscall4(int, msgsnd, int, msqid, const void *, msgp, size_t, msgsz, int, msgflg);
-#else
+#define __NR___syscall_msgsnd __NR_msgsnd
+static inline _syscall4(int, __syscall_msgsnd, int, msqid, const void *, msgp,
+ size_t, msgsz, int, msgflg)
+#endif
/* Send message to message queue. */
-int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
+static inline int do_msgsnd (int msqid, const void *msgp, size_t msgsz,
+ int msgflg)
{
+#ifdef __NR_msgsnd
+ return __syscall_msgsnd(msqid, msgp, msgsz, msgflg);
+#else
return __syscall_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg, (void *)msgp, 0);
+#endif
}
+int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
+{
+ if (SINGLE_THREAD_P)
+ return do_msgsnd(msqid, msgp, msgsz, msgflg);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = do_msgsnd(msqid, msgp, msgsz, msgflg);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
#endif
+}
#endif
diff --git a/libc/misc/sysvipc/sem.c b/libc/misc/sysvipc/sem.c
index 1caec5a8c..64be1cae0 100644
--- a/libc/misc/sysvipc/sem.c
+++ b/libc/misc/sysvipc/sem.c
@@ -14,12 +14,13 @@
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ see <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <sys/sem.h>
#include <stddef.h>
+#include <stdlib.h> /* for NULL */
+
#include "ipc.h"
@@ -27,7 +28,6 @@
/* Return identifier for array of NSEMS semaphores associated with
KEY. */
#include <stdarg.h>
-#include <stdlib.h>
/* arg for semctl system calls. */
union semun {
int val; /* value for SETVAL */
@@ -40,7 +40,7 @@ union semun {
#ifdef __NR_semctl
#define __NR___semctl __NR_semctl
-static __inline__ _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, void *, arg);
+static __inline__ _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, void *, arg)
#endif
int semctl(int semid, int semnum, int cmd, ...)
@@ -61,11 +61,8 @@ int semctl(int semid, int semnum, int cmd, ...)
#endif
#ifdef L_semget
-/* for definition of NULL */
-#include <stdlib.h>
-
#ifdef __NR_semget
-_syscall3(int, semget, key_t, key, int, nsems, int, semflg);
+_syscall3(int, semget, key_t, key, int, nsems, int, semflg)
#else
/* Return identifier for array of NSEMS semaphores associated
@@ -80,7 +77,7 @@ int semget (key_t key, int nsems, int semflg)
#ifdef L_semop
#ifdef __NR_semop
-_syscall3(int, semop, int, semid, struct sembuf *, sops, size_t, nsops);
+_syscall3(int, semop, int, semid, struct sembuf *, sops, size_t, nsops)
#else
/* Perform user-defined atomical operation of array of semaphores. */
@@ -94,14 +91,14 @@ int semop (int semid, struct sembuf *sops, size_t nsops)
#ifdef L_semtimedop
#ifdef __NR_semtimedop
-_syscall4(int, semtimedop, int, semid, struct sembuf *, sops, size_t, nsops, const struct timespec *, timeout);
+_syscall4(int, semtimedop, int, semid, struct sembuf *, sops, size_t, nsops, const struct timespec *, timeout)
#else
int semtimedop(int semid, struct sembuf *sops, size_t nsops,
const struct timespec *timeout)
{
- return __syscall_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, timeout);
+ return __syscall_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, (void *) timeout);
}
#endif
#endif
diff --git a/libc/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c
index b1af943b8..cd46ff0dd 100644
--- a/libc/misc/sysvipc/shm.c
+++ b/libc/misc/sysvipc/shm.c
@@ -14,8 +14,7 @@
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ see <http://www.gnu.org/licenses/>. */
/* SHMLBA uses it on most of the archs (not mips) */
#define __getpagesize getpagesize
@@ -34,11 +33,10 @@
# define __NR_shmat __NR_osf_shmat
#endif
#ifdef __NR_shmat
-_syscall3(void *, shmat, int, shmid, const void *,shmaddr, int, shmflg);
+_syscall3(void *, shmat, int, shmid, const void *,shmaddr, int, shmflg)
#else
/* psm: don't remove this, else mips will fail */
#include <unistd.h>
-libc_hidden_proto(getpagesize)
void * shmat (int shmid, const void *shmaddr, int shmflg)
{
@@ -55,13 +53,13 @@ void * shmat (int shmid, const void *shmaddr, int shmflg)
#ifdef L_shmctl
/* Provide operations to control over shared memory segments. */
#ifdef __NR_shmctl
-#define __NR___libc_shmctl __NR_shmctl
-static __inline__ _syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf);
+#define __NR___syscall_shmctl __NR_shmctl
+static __always_inline _syscall3(int, __syscall_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf)
#endif
int shmctl(int shmid, int cmd, struct shmid_ds *buf)
{
#ifdef __NR_shmctl
- return __libc_shmctl(shmid, cmd | __IPC_64, buf);
+ return __syscall_shmctl(shmid, cmd | __IPC_64, buf);
#else
return __syscall_ipc(IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf, 0);
#endif
@@ -73,7 +71,7 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf)
/* Detach shared memory segment starting at address specified by SHMADDR
from the caller's data segment. */
#ifdef __NR_shmdt
-_syscall1(int, shmdt, const void *, shmaddr);
+_syscall1(int, shmdt, const void *, shmaddr)
#else
int shmdt (const void *shmaddr)
{
@@ -86,7 +84,7 @@ int shmdt (const void *shmaddr)
/* Return an identifier for an shared memory segment of at least size SIZE
which is associated with KEY. */
#ifdef __NR_shmget
-_syscall3(int, shmget, key_t, key, size_t, size, int, shmflg);
+_syscall3(int, shmget, key_t, key, size_t, size, int, shmflg)
#else
int shmget (key_t key, size_t size, int shmflg)
{