]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/generic/bp-semctl.h
Update to LGPL v2.1.
[thirdparty/glibc.git] / sysdeps / generic / bp-semctl.h
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>
5
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.
10
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.
15
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. */
20
21 #ifndef _bp_semctl_h_
22 #define _bp_semctl_h_ 1
23
24 #if __BOUNDED_POINTERS__
25
26 # define CHECK_SEMCTL(ARGP, SEMID, CMD) check_semctl (ARGP, SEMID, CMD)
27
28 union semun *__unbounded
29 check_semctl (union semun *arg, int semid, int cmd)
30 {
31 int ipc64 = (cmd & __IPC_64);
32
33 switch (cmd & ~__IPC_64)
34 {
35 case IPC_STAT:
36 case IPC_SET:
37 (void) CHECK_1 (arg->buf);
38 break;
39
40 case GETALL:
41 case SETALL:
42 {
43 struct semid_ds ds;
44 union semun un = { buf: &ds };
45 unsigned int length = ~0;
46
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;
53 }
54
55 case IPC_INFO:
56 (void) CHECK_1 (arg->__buf);
57 break;
58 }
59
60 return __ptrvalue (arg);
61 }
62
63 #else
64 # define CHECK_SEMCTL(ARGP, SEMID, CMD) (ARGP)
65 #endif
66
67 #endif /* _bp_semctl_h_ */