da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinref -D_def_map_ast=1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinhdr float,floatingpoint,math,values
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinsys filio,ioctl
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinlib qfrexp,qldexp
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinkey signed
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintst tmp_rmfail note{ open files cannot be removed }end execute{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin #include <string.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin #include <time.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin main()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin #if !_UWIN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int n;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char* s;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FILE* fr;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FILE* fw;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char file[16];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin static char data[] = "0123456789";
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin s = file;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = '1';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = 'F';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = 'F';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = '3';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin n = (int)time(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = (n & 0xF) + 'A';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = ((n >> 4) & 0xF) + 'A';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = ((n >> 8) & 0xF) + 'A';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = ((n >> 12) & 0xF) + 'A';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = '.';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = 'T';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = 'M';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s++ = 'P';
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *s = 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin remove(file);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (!(fw = fopen(file, "w")))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (!(fr = fopen(file, "r")))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin fclose(fw);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin remove(file);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (remove(file) < 0)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin fclose(fr);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin fclose(fw);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin remove(file);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (fwrite(data, sizeof(data), 1, fw) != 1)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin fclose(fw);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (fread(file, sizeof(data), 1, fr) != 1)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin fclose(fr);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (strcmp(file, data) != 0)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin #endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}end
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmore void_int note{ voidptr is larger than int }end execute{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin main()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return sizeof(char*) > sizeof(int) ? 0 : 1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}end
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmore long_int note{ long is larger than int }end execute{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin main()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return sizeof(long) > sizeof(int) ? 0 : 1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}end
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintst vax_asm note{ register layout ok for vax string operations }end execute{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin main()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin #ifndef vax
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return absurd = -1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin #else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int r11, r10, r9, r8, r7, r6;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin r11 = r10 = r9 = r8 = r7 = r6 = -1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin asm("clrw r11");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin asm("clrw r10");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin asm("clrw r9");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin asm("clrw r8");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin asm("clrw r7");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin asm("clrw r6");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(sizeof(int) != sizeof(char*) || r11 || r10 || r9 || r8 || r7 || r6 )
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return -1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin #endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}end
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintst lib_cvt note{ native floating point conversions ok }end link{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin _BEGIN_EXTERNS_
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin extern char* ecvt _ARG_((double, int, int*, int*));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin extern char* fcvt _ARG_((double, int, int*, int*));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin extern double strtod _ARG_((const char*, char**));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin _END_EXTERNS_
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin main()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin ecvt(0.0, 0, 0, 0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin fcvt(0.0, 0, 0, 0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin strtod(0, 0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}end
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintst xopen_stdio note{ Stdio fseek/fflush are X/Open-compliant }end execute{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin #define Failed(file) (unlink(file),1)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin main(argc, argv)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int argc;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char** argv;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin { FILE *f1, *f2;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char file[1024], buf[1024], *f, *t;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int i, fd;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* create file */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for(f = argv[0], t = file; (*t = *f++) != 0; )
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin t++;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *t++ = '.'; *t++ = 'D'; *t++ = 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if((fd = creat(file,0666)) < 0)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for (i = 0; i < sizeof(buf); ++i)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin buf[i] = '0' + (i%10);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for (i = 0; i < 16; ++i)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (write(fd,buf,sizeof(buf)) != sizeof(buf))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return Failed(file);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin close(fd);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!(f1 = fopen(file,"r+")) ||
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (fd = dup(fileno(f1))) < 0 ||
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin !(f2 = fdopen(fd,"r+")) )
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return Failed(file);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(fread(buf, 1, 7, f2) != 7 || ftell(f2) != 7)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return Failed(file);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(fseek(f1, 1010, 0) < 0 || ftell(f1) != 1010)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return Failed(file);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin fflush(f2); /* this should set the seek location to 1010 */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(ftell(f2) != 1010)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return Failed(file);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unlink(file);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}end