cmd	universe
hdr	dirent,filio,jioctl,locale,mman,ndir,utime,vfork
dat	_tzname,tzname
lib	_cleanup,BSDsetpgrp,atexit,bcopy,bzero,dirread,dup2,fchmod
lib	fcntl,fnmatch,fork,getdents,getdirentries,getdtablesize,getgroups
lib	getpagesize,getrlimit,getuniverse,index,killpg,link,localeconv,lstat
lib	mbtowc,memccpy
lib	memchr,memcmp,memcpy,memdup,memmove,memset,mkdir,mkfifo,mknod,mktemp
lib	mount,on_exit,onexit,opendir,pathconf,readlink,remove,rename,rindex
lib	rmdir,rewinddir,setlocale,setpgid,setpgrp,setpgrp2,setreuid,setsid
lib	setuid,sigaction,sigprocmask,sigsetmask,sigunblock,sigvec
lib	socketpair,spawnve,strchr,strcoll,strdup,strerror,strrchr
lib	strtod,strtol,strtoul,strxfrm
lib	symlink,sysconf,telldir,tmpnam,tzset,universe,unlink,utime
lib	vfork,wait2,wait3,wait4,waitpid
lib	execve,pcreateve,NutForkExecve
mem	direct.d_reclen sys/types.h sys/dir.h
mem	dirent.d_fileno,dirent.d_ino,dirent.d_namlen,dirent.d_off,dirent.d_reclen sys/types.h dirent.h
mem	DIR.dd_fd sys/types.h - dirent.h - sys/dir.h
sys	dir,filio,jioctl,mman,ptem,resource,socket,stream,universe
sys	vfork,wait

tst	tst_errno link{
	#ifdef __cplusplus
	extern "C" {
	#endif
	extern int errno;
	error() { }
	strerror() { }
	#ifdef __cplusplus
	}
	#endif
	main() { errno = 0; error(); strerror(); }
}end

tst	lib_poll_fd_1 exec{
	#include <poll.h>
	#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
	#if defined(__cplusplus)
	extern "C" {
	#endif
	extern int	pipe(int*);
	#if defined(__cplusplus)
	}
	#endif
	#endif
	main()
	{	int		rw[2];
		struct pollfd	fd;
		if (pipe(rw) < 0) return 1;
		fd.fd = rw[0];
		fd.events = POLLIN;
		fd.revents = 0;
		return poll(&fd, 1, 0) < 0;
	}
}end

tst	lib_poll_fd_2 exec{
	#include <poll.h>
	#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
	#if defined(__cplusplus)
	extern "C" {
	#endif
	extern int	pipe(int*);
	#if defined(__cplusplus)
	}
	#endif
	#endif
	main()
	{	int		rw[2];
		struct pollfd	fd;
		if (pipe(rw) < 0) return 1;
		fd.fd = rw[0];
		fd.events = POLLIN;
		fd.revents = 0;
		return poll(1, &fd, 0) < 0;
	}
}end

cat{
	#if _lib_poll_fd_1 || _lib_poll_fd_2
	#define _lib_poll	1
	#endif
	#if _lib_NutForkExecve
	#define _map_spawnve	NutForkExecve
	#else
	#if _lib_pcreateve
	#define _map_spawnve	pcreateve
	#endif
	#endif
}end

tst	lib_select link{
	#include <sys/types.h>
	#include <sys/time.h>
	#include <sys/socket.h>
	main()
	{	struct timeval	tmb;
		fd_set		rd;
		FD_ZERO(&rd);
		FD_SET(0,&rd);
		tmb.tv_sec = 0;
		tmb.tv_usec = 0;
		select(1,&rd,(fd_set*)0,(fd_set*)0,&tmb);
		return 0;
	}
}end

tst	pipe_rw exec{
	#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
	#if defined(__cplusplus)
	extern "C" {
	#endif
	extern int	pipe(int*);
	extern int	read(int, void*, int);
	extern int	strcmp(const char*, const char*);
	extern int	write(int, void*, int);
	#if defined(__cplusplus)
	}
	#endif
	#endif
	main()
	{
		static char	test[] = "test\n";
		int		io[2];
		char		buf[sizeof(test)];
		if (pipe(io)) return(1);
		if (write(io[1], test, sizeof(test)) != sizeof(test)) return(1);
		if (read(io[0], buf, sizeof(test)) != sizeof(test)) return(1);
		if (strcmp(test, buf)) return(1);
		if (write(io[0], test, sizeof(test)) != sizeof(test)) return(1);
		if (read(io[1], buf, sizeof(test)) != sizeof(test)) return(1);
		if (strcmp(test, buf)) return(1);
		return(0);
	}
}end

tst	real_vfork exec{
	int		code;
	extern int	vfork();
	extern int	_exit(int);
	main()
	{
		code = 1;
		if (!vfork()) code = 0;
		_exit(code);
	}
}end

tst	stream_peek link{
	#include <sys/types.h>
	#include <stropts.h>
	main()
	{	struct strpeek	pbuf;
		pbuf.flags = 0;
		pbuf.ctlbuf.maxlen = pbuf.databuf.maxlen =
		pbuf.ctlbuf.len = pbuf.databuf.len = 0;
		pbuf.ctlbuf.buf = pbuf.databuf.buf = 0;
		ioctl(0,I_PEEK,&pbuf);
		return 0;
	}
}end

tst	socket_peek link{
	#include <sys/types.h>
	#include <sys/socket.h>
	main()
	{	char	buf[128];
		recv(0,buf,sizeof(buf),MSG_PEEK);
		return 0;
	}
}end

tst	lib_mmap sys/types.h fcntl.h mman.h sys/mman.h exec{
	main(argc, argv)
	int	argc;
	char**	argv;
	{
		int	fd;
		caddr_t	p;
		return((fd = open(argv[0], 0)) < 0 || !(p = (caddr_t)mmap((caddr_t)0, 1024, PROT_READ, MAP_SHARED, fd, 0L)) || p == ((caddr_t)-1));
	}
}end

tst	ptr_dd_buf sys/types.h - dirent.h - ndir.h - sys/dir.h comp{
	main()
	{
		DIR*	dirp;
		dirp->dd_buf = 0;
	}
}end

tst	run{
	u=att
	case `/bin/cat -s /dev/null/foo 2>&1` in
	'')	;;
	*)	case `/bin/echo '\\\\t'` in
		'\\t')	u=ucb ;;
		esac
		;;
	esac
	echo "#define _UNIV_DEFAULT	\\"$u\\""
}end

std     malloc exec{
	#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
	#if __cplusplus
	extern "C" {
	#endif
	extern char* strdup(const char*);
	char* malloc(unsigned n) { return 0; }
	#if __cplusplus
	}
	#endif
	#else
	extern char* strdup();
	char* malloc(n) unsigned n; { return 0; }
	#endif
	main() { return strdup("yo") == 0; }
}end

std     signal nolink{
	#if __cplusplus
	extern "C" {
	#endif
	extern int abort();
	int signal() { return 0; }
	#if __cplusplus
	}
	#endif
	main() { signal(); abort(); return 0; }
}end
