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
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
)
37 (void) CHECK_1 (arg
->buf
);
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
);
56 (void) CHECK_1 (arg
->__buf
);
60 return __ptrvalue (arg
);
64 # define CHECK_SEMCTL(ARGP, SEMID, CMD) (ARGP)
67 #endif /* _bp_semctl_h_ */