flock.c revision d35df493b4e7684c50d2d2fa032ee3a7ac228009
1d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes#include "tests.h"
2d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes#include <asm/unistd.h>
3d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes
4d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes#ifdef __NR_flock
5d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes
6d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# include <stdio.h>
7d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# include <sys/file.h>
8d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes# include <unistd.h>
9d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes
10d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughesint
11d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughesmain(void)
12d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes{
13d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes	const unsigned long fd = (long int) 0xdeadbeefffffffffULL;
14d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes
15d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes	long rc = syscall(__NR_flock, fd, LOCK_SH);
16d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes	printf("flock(%d, LOCK_SH) = %ld %s (%m)\n",
17d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes	       (int) fd, rc, errno2name());
18d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes
19d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes	puts("+++ exited with 0 +++");
20d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes	return 0;
21d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes}
22d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes
23d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes#else
24d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes
25d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott HughesSKIP_MAIN_UNDEFINED("__NR_flock")
26d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes
27d35df493b4e7684c50d2d2fa032ee3a7ac228009Elliott Hughes#endif
28