diff options
Diffstat (limited to 'REORG.TODO/sysvipc')
-rw-r--r-- | REORG.TODO/sysvipc/Makefile | 38 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/Versions | 20 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/ftok.c | 35 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/msgctl.c | 32 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/msgget.c | 32 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/msgrcv.c | 35 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/msgsnd.c | 35 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/semctl.c | 32 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/semget.c | 32 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/semop.c | 31 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/semtimedop.c | 32 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/shmat.c | 33 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/shmctl.c | 31 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/shmdt.c | 32 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/shmget.c | 32 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/sys/ipc.h | 54 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/sys/msg.h | 82 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/sys/sem.h | 67 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/sys/shm.h | 63 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/test-sysvmsg.c | 128 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/test-sysvsem.c | 123 | ||||
-rw-r--r-- | REORG.TODO/sysvipc/test-sysvshm.c | 131 |
22 files changed, 1130 insertions, 0 deletions
diff --git a/REORG.TODO/sysvipc/Makefile b/REORG.TODO/sysvipc/Makefile new file mode 100644 index 0000000000..9ac44bafca --- /dev/null +++ b/REORG.TODO/sysvipc/Makefile @@ -0,0 +1,38 @@ +# Copyright (C) 1995-2017 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/>. + +# +# Sub-makefile for sysvipc portion of the library. +# +subdir := sysvipc + +include ../Makeconfig + +headers := sys/ipc.h sys/msg.h sys/sem.h sys/shm.h \ + bits/ipctypes.h bits/ipc.h bits/msq.h bits/sem.h bits/shm.h + +routines := ftok \ + msgsnd msgrcv msgget msgctl \ + semop semget semctl semtimedop \ + shmat shmdt shmget shmctl + +tests := test-sysvmsg test-sysvsem test-sysvshm + +include ../Rules + +CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables diff --git a/REORG.TODO/sysvipc/Versions b/REORG.TODO/sysvipc/Versions new file mode 100644 index 0000000000..4c797e25ce --- /dev/null +++ b/REORG.TODO/sysvipc/Versions @@ -0,0 +1,20 @@ +libc { + GLIBC_2.0 { + # f* + ftok; + + # m* + msgctl; msgget; msgrcv; msgsnd; + + # s* + semctl; semget; semop; shmat; shmctl; shmdt; shmget; + } + GLIBC_2.3.3 { + # Non-standard function. + semtimedop; + } + GLIBC_PRIVATE { + # Cancellation point entries. + __libc_msgrcv; __libc_msgsnd; + } +} diff --git a/REORG.TODO/sysvipc/ftok.c b/REORG.TODO/sysvipc/ftok.c new file mode 100644 index 0000000000..00749031eb --- /dev/null +++ b/REORG.TODO/sysvipc/ftok.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1995-2017 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 <sys/ipc.h> +#include <sys/stat.h> + +key_t +ftok (const char *pathname, int proj_id) +{ + struct stat64 st; + key_t key; + + if (__xstat64 (_STAT_VER, pathname, &st) < 0) + return (key_t) -1; + + key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16) + | ((proj_id & 0xff) << 24)); + + return key; +} diff --git a/REORG.TODO/sysvipc/msgctl.c b/REORG.TODO/sysvipc/msgctl.c new file mode 100644 index 0000000000..01a07a8ba5 --- /dev/null +++ b/REORG.TODO/sysvipc/msgctl.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1995-2017 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 <sys/msg.h> +#include <errno.h> + +/* Allows to control internal state and destruction of message queue + objects. */ + +int +msgctl (int msqid, int cmd, struct msqid_ds *buf) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (msgctl) diff --git a/REORG.TODO/sysvipc/msgget.c b/REORG.TODO/sysvipc/msgget.c new file mode 100644 index 0000000000..0a439444db --- /dev/null +++ b/REORG.TODO/sysvipc/msgget.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1995-2017 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 <sys/msg.h> +#include <errno.h> + +/* Return descriptor for message queue associated with KEY. The MSGFLG + parameter describes how to proceed with clashing of key values. */ + +int +msgget (key_t key, int msgflg) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (msgget) diff --git a/REORG.TODO/sysvipc/msgrcv.c b/REORG.TODO/sysvipc/msgrcv.c new file mode 100644 index 0000000000..bc7744e430 --- /dev/null +++ b/REORG.TODO/sysvipc/msgrcv.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1995-2017 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 <sys/msg.h> +#include <errno.h> + +/* Read a message from the queue associated with the message queue + descriptor MSQID. At most MSGSZ bytes of the message are placed + in the buffer specified by the MSGP parameter. The MSGTYP parameter + describes which message is returned in MSGFLG describes the behaviour + in buffer overflow or queue underflow. */ + +ssize_t +msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (msgrcv) diff --git a/REORG.TODO/sysvipc/msgsnd.c b/REORG.TODO/sysvipc/msgsnd.c new file mode 100644 index 0000000000..b3346eb7e1 --- /dev/null +++ b/REORG.TODO/sysvipc/msgsnd.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1995-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <sys/msg.h> +#include <errno.h> + +/* Send a message to the queue associated with the message queue + descriptor MSQID. The parameter MSGP points to a structure + describing messages where the parameter MSGSZ gives the length + of the text. The MSGFLG parameter describes the action taken + when the limit of the message queue length is reached. */ + +int +msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (msgsnd) diff --git a/REORG.TODO/sysvipc/semctl.c b/REORG.TODO/sysvipc/semctl.c new file mode 100644 index 0000000000..117a86a72c --- /dev/null +++ b/REORG.TODO/sysvipc/semctl.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1995-2017 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 <sys/sem.h> +#include <errno.h> + +/* Return identifier for array of NSEMS semaphores associated with + KEY. */ + +int +semctl (int semid, int semnum, int cmd, ...) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (semctl) diff --git a/REORG.TODO/sysvipc/semget.c b/REORG.TODO/sysvipc/semget.c new file mode 100644 index 0000000000..697597181e --- /dev/null +++ b/REORG.TODO/sysvipc/semget.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1995-2017 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 <sys/sem.h> +#include <errno.h> + +/* Return identifier for array of NSEMS semaphores associated with + KEY. */ + +int +semget (key_t key, int nsems, int semflg) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (semget) diff --git a/REORG.TODO/sysvipc/semop.c b/REORG.TODO/sysvipc/semop.c new file mode 100644 index 0000000000..11fea80a32 --- /dev/null +++ b/REORG.TODO/sysvipc/semop.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1995-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <sys/sem.h> +#include <errno.h> + +/* Perform user-defined atomical operation of array of semaphores. */ + +int +semop (int semid, struct sembuf *sops, size_t nsops) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (semop) diff --git a/REORG.TODO/sysvipc/semtimedop.c b/REORG.TODO/sysvipc/semtimedop.c new file mode 100644 index 0000000000..567730634e --- /dev/null +++ b/REORG.TODO/sysvipc/semtimedop.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2003-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <sys/sem.h> +#include <errno.h> + +/* Perform user-defined atomical operation of array of semaphores. */ + +int +semtimedop (int semid, struct sembuf *sops, size_t nsops, + const struct timespec *timeout) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (semtimedop) diff --git a/REORG.TODO/sysvipc/shmat.c b/REORG.TODO/sysvipc/shmat.c new file mode 100644 index 0000000000..4872c906ba --- /dev/null +++ b/REORG.TODO/sysvipc/shmat.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1995-2017 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 <sys/shm.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 + and where the segment is attached. */ + +void * +shmat (int shmid, const void *shmaddr, int shmflg) +{ + __set_errno (ENOSYS); + return (void *) -1; +} + +stub_warning (shmat) diff --git a/REORG.TODO/sysvipc/shmctl.c b/REORG.TODO/sysvipc/shmctl.c new file mode 100644 index 0000000000..a8e93a32d5 --- /dev/null +++ b/REORG.TODO/sysvipc/shmctl.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1995-2017 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 <sys/shm.h> +#include <errno.h> + +/* Provide operations to control over shared memory segments. */ + +int +shmctl (int shmid, int cmd, struct shmid_ds *buf) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (shmctl) diff --git a/REORG.TODO/sysvipc/shmdt.c b/REORG.TODO/sysvipc/shmdt.c new file mode 100644 index 0000000000..16f4583d6e --- /dev/null +++ b/REORG.TODO/sysvipc/shmdt.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1995-2017 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 <sys/shm.h> +#include <errno.h> + +/* Detach shared memory segment starting at address specified by SHMADDR + from the caller's data segment. */ + +int +shmdt (const void *shmaddr) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (shmdt) diff --git a/REORG.TODO/sysvipc/shmget.c b/REORG.TODO/sysvipc/shmget.c new file mode 100644 index 0000000000..57f6c98f60 --- /dev/null +++ b/REORG.TODO/sysvipc/shmget.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1995-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <sys/shm.h> +#include <errno.h> + +/* Return an identifier for an shared memory segment of at least size SIZE + which is associated with KEY. */ + +int +shmget (key_t key, size_t size, int shmflg) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (shmget) diff --git a/REORG.TODO/sysvipc/sys/ipc.h b/REORG.TODO/sysvipc/sys/ipc.h new file mode 100644 index 0000000000..9d724a8884 --- /dev/null +++ b/REORG.TODO/sysvipc/sys/ipc.h @@ -0,0 +1,54 @@ +/* Copyright (C) 1995-2017 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/>. */ + +#ifndef _SYS_IPC_H +#define _SYS_IPC_H 1 + +#include <features.h> + +/* Get system dependent definition of `struct ipc_perm' and more. */ +#include <bits/ipctypes.h> +#include <bits/ipc.h> + +#ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +#endif + +#ifndef __gid_t_defined +typedef __gid_t gid_t; +# define __gid_t_defined +#endif + +#ifndef __mode_t_defined +typedef __mode_t mode_t; +# define __mode_t_defined +#endif + +#ifndef __key_t_defined +typedef __key_t key_t; +# define __key_t_defined +#endif + +__BEGIN_DECLS + +/* Generates key for System V style IPC. */ +extern key_t ftok (const char *__pathname, int __proj_id) __THROW; + +__END_DECLS + +#endif /* sys/ipc.h */ diff --git a/REORG.TODO/sysvipc/sys/msg.h b/REORG.TODO/sysvipc/sys/msg.h new file mode 100644 index 0000000000..3610050014 --- /dev/null +++ b/REORG.TODO/sysvipc/sys/msg.h @@ -0,0 +1,82 @@ +/* Copyright (C) 1995-2017 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/>. */ + +#ifndef _SYS_MSG_H +#define _SYS_MSG_H + +#include <features.h> + +#define __need_size_t +#include <stddef.h> + +/* Get common definition of System V style IPC. */ +#include <sys/ipc.h> + +/* Get system dependent definition of `struct msqid_ds' and more. */ +#include <bits/msq.h> + +/* Define types required by the standard. */ +#include <bits/types/time_t.h> + +#ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +#endif + +#ifndef __ssize_t_defined +typedef __ssize_t ssize_t; +# define __ssize_t_defined +#endif + +/* The following System V style IPC functions implement a message queue + system. The definition is found in XPG2. */ + +#ifdef __USE_GNU +/* Template for struct to be used as argument for `msgsnd' and `msgrcv'. */ +struct msgbuf + { + __syscall_slong_t mtype; /* type of received/sent message */ + char mtext[1]; /* text of the message */ + }; +#endif + + +__BEGIN_DECLS + +/* Message queue control operation. */ +extern int msgctl (int __msqid, int __cmd, struct msqid_ds *__buf) __THROW; + +/* Get messages queue. */ +extern int msgget (key_t __key, int __msgflg) __THROW; + +/* Receive message from message queue. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t msgrcv (int __msqid, void *__msgp, size_t __msgsz, + long int __msgtyp, int __msgflg); + +/* Send message to message queue. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int msgsnd (int __msqid, const void *__msgp, size_t __msgsz, + int __msgflg); + +__END_DECLS + +#endif /* sys/msg.h */ diff --git a/REORG.TODO/sysvipc/sys/sem.h b/REORG.TODO/sysvipc/sys/sem.h new file mode 100644 index 0000000000..1fa58c5f09 --- /dev/null +++ b/REORG.TODO/sysvipc/sys/sem.h @@ -0,0 +1,67 @@ +/* Copyright (C) 1995-2017 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/>. */ + +#ifndef _SYS_SEM_H +#define _SYS_SEM_H 1 + +#include <features.h> + +#define __need_size_t +#include <stddef.h> + +/* Get common definition of System V style IPC. */ +#include <sys/ipc.h> + +/* Get system dependent definition of `struct semid_ds' and more. */ +#include <bits/sem.h> + +#ifdef __USE_GNU +# include <bits/types/struct_timespec.h> +#endif + +/* The following System V style IPC functions implement a semaphore + handling. The definition is found in XPG2. */ + +/* Structure used for argument to `semop' to describe operations. */ +struct sembuf +{ + unsigned short int sem_num; /* semaphore number */ + short int sem_op; /* semaphore operation */ + short int sem_flg; /* operation flag */ +}; + + +__BEGIN_DECLS + +/* Semaphore control operation. */ +extern int semctl (int __semid, int __semnum, int __cmd, ...) __THROW; + +/* Get semaphore. */ +extern int semget (key_t __key, int __nsems, int __semflg) __THROW; + +/* Operate on semaphore. */ +extern int semop (int __semid, struct sembuf *__sops, size_t __nsops) __THROW; + +#ifdef __USE_GNU +/* Operate on semaphore with timeout. */ +extern int semtimedop (int __semid, struct sembuf *__sops, size_t __nsops, + const struct timespec *__timeout) __THROW; +#endif + +__END_DECLS + +#endif /* sys/sem.h */ diff --git a/REORG.TODO/sysvipc/sys/shm.h b/REORG.TODO/sysvipc/sys/shm.h new file mode 100644 index 0000000000..c83fd4c3d5 --- /dev/null +++ b/REORG.TODO/sysvipc/sys/shm.h @@ -0,0 +1,63 @@ +/* Copyright (C) 1995-2017 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/>. */ + +#ifndef _SYS_SHM_H +#define _SYS_SHM_H 1 + +#include <features.h> + +#define __need_size_t +#include <stddef.h> + +/* Get common definition of System V style IPC. */ +#include <sys/ipc.h> + +/* Get system dependent definition of `struct shmid_ds' and more. */ +#include <bits/shm.h> + +/* Define types required by the standard. */ +#include <bits/types/time_t.h> + +#ifdef __USE_XOPEN +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +# endif +#endif /* X/Open */ + + +__BEGIN_DECLS + +/* The following System V style IPC functions implement a shared memory + facility. The definition is found in XPG4.2. */ + +/* Shared memory control operation. */ +extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) __THROW; + +/* Get shared memory segment. */ +extern int shmget (key_t __key, size_t __size, int __shmflg) __THROW; + +/* Attach shared memory segment. */ +extern void *shmat (int __shmid, const void *__shmaddr, int __shmflg) + __THROW; + +/* Detach shared memory segment. */ +extern int shmdt (const void *__shmaddr) __THROW; + +__END_DECLS + +#endif /* sys/shm.h */ diff --git a/REORG.TODO/sysvipc/test-sysvmsg.c b/REORG.TODO/sysvipc/test-sysvmsg.c new file mode 100644 index 0000000000..a0d84f3a39 --- /dev/null +++ b/REORG.TODO/sysvipc/test-sysvmsg.c @@ -0,0 +1,128 @@ +/* Basic tests for SYSV message queue functions. + Copyright (C) 2016-2017 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> diff --git a/REORG.TODO/sysvipc/test-sysvsem.c b/REORG.TODO/sysvipc/test-sysvsem.c new file mode 100644 index 0000000000..279eca9b09 --- /dev/null +++ b/REORG.TODO/sysvipc/test-sysvsem.c @@ -0,0 +1,123 @@ +/* Basic tests for SYSV semaphore functions. + Copyright (C) 2016-2017 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 + +union semun +{ + int val; + struct semid_ds *buf; + unsigned short *array; +}; + +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, (union semun) { .buf = &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> diff --git a/REORG.TODO/sysvipc/test-sysvshm.c b/REORG.TODO/sysvipc/test-sysvshm.c new file mode 100644 index 0000000000..b7ccd0e20e --- /dev/null +++ b/REORG.TODO/sysvipc/test-sysvshm.c @@ -0,0 +1,131 @@ +/* Basic tests for SYSV shared memory functions. + Copyright (C) 2016-2017 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> |