ref	-D_def_map_ast=1
hdr	float,floatingpoint,math,values
sys	filio,ioctl
lib	qfrexp,qldexp
key	signed

tst	- note{ number of bits in pointer }end output{
	#include <stdio.h>
	int
	main(void)
	{
		printf("#define _ptr_bits	%d\n", sizeof(char*) * 8);
		return 0;
	}
}end fail{
	echo "$0: Output block failed to compile. Export IFFEFLAGS=-d1 to debug." >&2
	exit 1
}end

tst	tmp_rmfail note{ open files cannot be removed }end execute{
	#include <string.h>
	#include <time.h>
	int
	main(void)
	{
		int		n;
		char*		s;
		FILE*		fr;
		FILE*		fw;
		char		file[16];
		static char	data[] = "0123456789";
		s = file;
		*s++ = '1';
		*s++ = 'F';
		*s++ = 'F';
		*s++ = '3';
		n = (int)time(0);
		*s++ = (n & 0xF) + 'A';
		*s++ = ((n >> 4) & 0xF) + 'A';
		*s++ = ((n >> 8) & 0xF) + 'A';
		*s++ = ((n >> 12) & 0xF) + 'A';
		*s++ = '.';
		*s++ = 'T';
		*s++ = 'M';
		*s++ = 'P';
		*s = 0;
		remove(file);
		if (!(fw = fopen(file, "w")))
			return 0;
		if (!(fr = fopen(file, "r")))
		{
			fclose(fw);
			remove(file);
			return 0;
		}
		if (remove(file) < 0)
		{
			fclose(fr);
			fclose(fw);
			remove(file);
			return 0;
		}
		if (fwrite(data, sizeof(data), 1, fw) != 1)
			return 0;
		fclose(fw);
		if (fread(file, sizeof(data), 1, fr) != 1)
			return 0;
		fclose(fr);
		if (strcmp(file, data) != 0)
			return 0;
		return 1;
	}
}end

more void_int note{ voidptr is larger than int }end execute{
	int
	main(void)
	{
		return sizeof(char*) > sizeof(int) ? 0 : 1;
	}
}end

more long_int note{ long is larger than int }end execute{
	int
	main(void)
	{
		return sizeof(long) > sizeof(int) ? 0 : 1;
	}
}end

tst	vax_asm note{ layout ok for vax string operations }end execute{
	int
	main(void)
	{
	#ifndef vax
		return absurd = -1;
	#else
		int	r11, r10, r9, r8, r7, r6;
		r11 = r10 = r9 = r8 = r7 = r6 = -1;
		asm("clrw	r11");
		asm("clrw	r10");
		asm("clrw	r9");
		asm("clrw	r8");
		asm("clrw	r7");
		asm("clrw	r6");
		if(sizeof(int) != sizeof(char*) || r11 || r10 || r9 || r8 || r7 || r6 )
			return -1;
		return 0;
	#endif
	}
}end

tst	lib_cvt note{ native floating point conversions ok }end link{
	extern char* ecvt(double, int, int*, int*);
	extern char* fcvt(double, int, int*, int*);
	extern double strtod(const char*, char**);
	int
	main(void)
	{
		ecvt(0.0, 0, 0, 0);
		fcvt(0.0, 0, 0, 0);
		strtod(0, 0);
		return 0;
	}
}end

tst	xopen_stdio note{ Stdio fseek/fflush are X/Open-compliant }end execute{
	#include <fcntl.h>
	#include <unistd.h>
	#define Failed(file)	(unlink(file),1)
	int
	main(int argc, char **argv)
	{	FILE	*f1, *f2;
		char	file[1024], buf[1024], *f, *t;
		int	i, fd;

		/* create file */
		for(f = argv[0], t = file; (*t = *f++) != 0; )
			t++;
		*t++ = '.'; *t++ = 'D'; *t++ = 0;
		if((fd = creat(file,0666)) < 0)
			return 1;

		for (i = 0; i < sizeof(buf); ++i)
			buf[i] = '0' + (i%10);
		for (i = 0; i < 16; ++i)
			if (write(fd,buf,sizeof(buf)) != sizeof(buf))
				return Failed(file);
		close(fd);

		if(!(f1 = fopen(file,"r+")) ||
		   (fd = dup(fileno(f1))) < 0 ||
		   !(f2 = fdopen(fd,"r+")) )
			return Failed(file);

		if(fread(buf, 1, 7, f2) != 7 || ftell(f2) != 7)
			return Failed(file);

		if(fseek(f1, 1010, 0) < 0 || ftell(f1) != 1010)
			return Failed(file);

		fflush(f2); /* this should set the seek location to 1010 */
		if(ftell(f2) != 1010)
			return Failed(file);

		unlink(file);
		return 0;
	}
}end
