MAP_ANON, -1, 0)) == MAP_FAILED)
MAP_ANON|MAP_FIXED, -1, 0)) == MAP_FAILED)
main(int argc, char *argv[]){	u_int64_t stack[TESTSZ/8];	/* assuming the testfly() will fit */	struct sigaction sa;	int (*func)(void *, size_t);	size_t size;	char *ep;	void *p, *ptr;	int ch;	if ((page_size = sysconf(_SC_PAGESIZE)) < 0)		err(1, "sysconf");	p = NULL;	func = &noexec;	size = TESTSZ;	while ((ch = getopt(argc, argv, "TDBHSmps")) != -1)		switch (ch) {		case 'T':			p = &testfly;			strcat(label, "text");			break;		case 'D':			p = &data[PAD/8];			strcat(label, "data");			break;		case 'B':			p = &bss[PAD/8];			strcat(label, "bss");			break;		case 'H':			p = malloc(size + 2 * page_size);			if (p == NULL)				err(2, "malloc");			p += page_size;			p = (void *)ALIGN((long)p);			strcat(label, "heap");			break;		case 'S':			p = getaddr(&stack);			strcat(label, "stack");			break;		case 's':	/* only valid for heap and size */			size = strtoul(optarg, &ep, 0);			if (size > ULONG_MAX)				errno = ERANGE;			if (errno)				err(1, "invalid size: %s", optarg);			if (*ep)				errx(1, "invalid size: %s", optarg);			break;		case 'm':			if (p) {				if ((ptr = mmap(p, size + 2 * page_size,				    PROT_READ|PROT_WRITE,				    MAP_ANON, -1, 0)) == MAP_FAILED)					err(1, "mmap");				strcat(label, "-mmap");			} else {				if ((ptr = mmap(p, size + 2 * page_size,				    PROT_READ|PROT_WRITE|PROT_EXEC,				    MAP_ANON, -1, 0)) == MAP_FAILED)					err(1, "mmap");				func = &noexec_mmap;				strcat(label, "mmap");			}			p = ptr;			break;		case 'p':			func = &noexec_mprotect;			strcat(label, "-mprotect");			break;		default:			usage();		}	argc -= optind;	argv += optind;	if (argc > 0)		usage();	if (p == NULL)		exit(2);	sa.sa_sigaction = &sigsegv;	sa.sa_flags = SA_SIGINFO;	sigemptyset(&sa.sa_mask);	sigaction(SIGSEGV, &sa, NULL);	if (p != &testfly) {		memcpy(p, &testfly, TESTSZ);		fdcache(p, size);	}	exit((*func)(p, size));}