Sort sysdeps/powerpc/fpu/libm-test-ulps
[glibc.git] / sysdeps / generic / bp-semctl.h
blobaf132837cc40bcc949e074e0dfe6be9d5697fbaa
1 /* Bounded-pointer checking macros for C.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Greg McGary <greg@mcgary.org>
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _bp_semctl_h_
21 #define _bp_semctl_h_ 1
23 #if __BOUNDED_POINTERS__
25 # define CHECK_SEMCTL(ARGP, SEMID, CMD) check_semctl (ARGP, SEMID, CMD)
27 union semun *__unbounded
28 check_semctl (union semun *arg, int semid, int cmd)
30 int ipc64 = (cmd & __IPC_64);
32 switch (cmd & ~__IPC_64)
34 case IPC_STAT:
35 case IPC_SET:
36 (void) CHECK_1 (arg->buf);
37 break;
39 case GETALL:
40 case SETALL:
42 struct semid_ds ds;
43 union semun un = { .buf = &ds };
44 unsigned int length = ~0;
46 /* It's unfortunate that we need to make a recursive
47 system call to get the size of the semaphore set... */
48 if (semctl (semid, 0, IPC_STAT | ipc64, un) == 0)
49 length = ds.sem_nsems;
50 (void) CHECK_N (arg->array, length);
51 break;
54 case IPC_INFO:
55 (void) CHECK_1 (arg->__buf);
56 break;
59 return __ptrvalue (arg);
62 #else
63 # define CHECK_SEMCTL(ARGP, SEMID, CMD) (ARGP)
64 #endif
66 #endif /* _bp_semctl_h_ */