* nis/nis_domain_of.c (__nis_domain_of): Make the code a bit more
[glibc.git] / sysdeps / generic / bp-semctl.h
blobd33ed2b356118a038900c5b074c1b288560a5e40
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, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #ifndef _bp_semctl_h_
22 #define _bp_semctl_h_ 1
24 #if __BOUNDED_POINTERS__
26 # define CHECK_SEMCTL(ARGP, SEMID, CMD) check_semctl (ARGP, SEMID, CMD)
28 union semun *__unbounded
29 check_semctl (union semun *arg, int semid, int cmd)
31 int ipc64 = (cmd & __IPC_64);
33 switch (cmd & ~__IPC_64)
35 case IPC_STAT:
36 case IPC_SET:
37 (void) CHECK_1 (arg->buf);
38 break;
40 case GETALL:
41 case SETALL:
43 struct semid_ds ds;
44 union semun un = { .buf = &ds };
45 unsigned int length = ~0;
47 /* It's unfortunate that we need to make a recursive
48 system call to get the size of the semaphore set... */
49 if (semctl (semid, 0, IPC_STAT | ipc64, un) == 0)
50 length = ds.sem_nsems;
51 (void) CHECK_N (arg->array, length);
52 break;
55 case IPC_INFO:
56 (void) CHECK_1 (arg->__buf);
57 break;
60 return __ptrvalue (arg);
63 #else
64 # define CHECK_SEMCTL(ARGP, SEMID, CMD) (ARGP)
65 #endif
67 #endif /* _bp_semctl_h_ */