xref: /illumos-gate/usr/src/contrib/ast/src/lib/libast/features/asometh (revision fa4a3e77edc40df6d92e8da6fc4961d275e9896d)
1# aso method feature tests
2
3aso fcntl note{ fcntl(F_SETLCK[W]) work }end link{
4		#include <sys/types.h>
5		#include <unistd.h>
6		#include <fcntl.h>
7
8		int main()
9		{
10			struct flock	lock;
11
12			lock.l_type = F_WRLCK;
13			lock.l_whence = SEEK_SET;
14			lock.l_start = 0;
15			lock.l_len = 1;
16			return fcntl(1, F_SETLKW, &lock) < 0;
17		}
18}end
19
20aso semaphore note{ semget semop semctl work }end link{
21		#include <sys/types.h>
22		#include <sys/stat.h>
23		#include <unistd.h>
24		#include <fcntl.h>
25		#include <sys/ipc.h>
26		#include <sys/sem.h>
27
28		int main()
29		{
30			int		id;
31			struct sembuf	sem;
32
33			if ((id = semget(IPC_PRIVATE, 16, IPC_CREAT|IPC_EXCL|S_IRUSR|S_IWUSR)) < 0)
34				return 1;
35			sem.sem_num = 0;
36			sem.sem_op = 1;
37			sem.sem_flg = 0;
38			if (semop(id, &sem, 1) < 0)
39				return 1;
40			if (semctl(id, 0, IPC_RMID) < 0)
41				return 1;
42			return 0;
43		}
44}end
45