1
##################################################################
2
# This file defines probes for local features that sfio requires.
3
# Such probes are interpreted by the "iffe" language interpreter.
4
# Results are stored in the FEATURE directory.
5
# Written by Kiem-Phong Vo (06/27/92).
6
# Converted to sfio v10/01/94 by Giampiero Sierra (06/08/95).
7
##################################################################
30
typ struct_stat64 compile{
31
#include <sys/types.h>
34
{ struct stat64 statb;
38
exit cleanup note{ stuck with standard _cleanup }end execute{
41
extern void exit _ARG_((int));
42
extern void _exit _ARG_((int));
43
extern void _cleanup();
44
void _cleanup() { _exit(0); }
46
main() { printf("cleanup\n"); exit(1); }
55
lib memchr note{ see if memchr is fast }end execute{
56
#include <sys/types.h>
57
#include <sys/times.h>
61
{ struct tms stm1, etm1, stm2, etm2;
63
register char *s, *ends;
67
for(p = 0; p < 100; ++p)
68
buf[p] = '0' + (p%10);
73
for(i = 0; i < 100000; ++i)
74
s = memchr(buf,'\n',p);
78
for(i = 0; i < 100000; ++i)
79
{ ends = (s = buf) + p;
86
t1 = (etm1.tms_utime - stm1.tms_utime) +
87
(etm1.tms_stime - stm1.tms_stime);
88
t2 = (etm2.tms_utime - stm2.tms_utime) +
89
(etm2.tms_stime - stm2.tms_stime);
91
return t1 < t2 ? 0 : 1;
95
lib memccpy note{ see if memccpy is fast }end execute{
96
#include <sys/types.h>
97
#include <sys/times.h>
101
{ struct tms stm1, etm1, stm2, etm2;
103
register char *s1, *s2;
105
char buf1[128], buf2[128];
107
for(i = 0; i < 100; ++i)
108
buf1[i] = '0' + (i%10);
113
for(i = 0; i < 100000; ++i)
115
memccpy(buf2,buf1,'\n',p);
120
for(i = 0; i < 100000; ++i)
121
{ s1 = buf1; s2 = buf2; p = 128;
122
while((*s2++ = *s1++) != '\n' && --p > 0)
127
t1 = (etm1.tms_utime - stm1.tms_utime) +
128
(etm1.tms_stime - stm1.tms_stime);
129
t2 = (etm2.tms_utime - stm2.tms_utime) +
130
(etm2.tms_stime - stm2.tms_stime);
132
return t1 < t2 ? 0 : 1;
136
sys stat note{ stat() in default lib(s) }end link{
140
#include <sys/types.h>
143
#include <sys/stat.h>
150
hdr stat note{ stat() in default lib(s) }end link{
154
#include <sys/types.h>
164
#############################################################
165
# See if memory mapping is available and fast enough to use
166
#############################################################
170
#include <sys/types.h>
171
#include <sys/mman.h>
172
#include <sys/times.h>
175
int creat _ARG_((char*, int));
176
int open _ARG_((char*, int));
177
int unlink _ARG_((char*));
178
int read _ARG_((int, char*, int));
181
#define MAPSIZE (64*1024)
182
#define BUFSIZE (MAPSIZE/8)
186
#define Failed(file) (unlink(file),1)
189
main(int argc, char** argv)
199
char file[1024], buf[MAPSIZE];
203
/* create data file */
204
f = argv[0]; t = file;
207
*t++ = '.'; *t++ = 'D'; *t = 0;
208
if ((fd = creat(file,0666)) < 0)
211
for (i = 0; i < sizeof(buf); ++i)
212
buf[i] = '0' + (i%10);
213
for (i = 0; i < WRITE; ++i)
214
if (write(fd,buf,sizeof(buf)) != sizeof(buf))
220
for(run = 0; run < RUN; ++run)
221
{ if((fd = open(file, 0)) < 0)
223
for (i = 0; i < WRITE; ++i)
224
{ for(k = 0; k < MAPSIZE; k += BUFSIZE)
225
if (read(fd,buf,BUFSIZE) != BUFSIZE)
231
rdtm = (etm.tms_utime-stm.tms_utime) + (etm.tms_stime-stm.tms_stime);
235
for(run = 0; run < RUN; ++run)
236
{ if ((fd = open(file,0)) < 0)
238
for(i = 0, mm = (caddr_t)0; i < WRITE; ++i)
241
mm = (caddr_t)mmap((caddr_t)0, MAPSIZE,
242
(PROT_READ|PROT_WRITE),
243
MAP_PRIVATE, fd, i*MAPSIZE );
244
if(mm == (caddr_t)(-1) || mm == (caddr_t)0)
247
/* the memcpy is < BUFSIZE to simulate the
248
fact that functions like sfreserve/sfgetr do
249
not do buffer copying.
252
for(k = 0; k < MAPSIZE; k += BUFSIZE, t += BUFSIZE)
253
memcpy(buf,t,(3*BUFSIZE)/4);
258
mmtm = (etm.tms_utime-stm.tms_utime) + (etm.tms_stime-stm.tms_stime);
262
if(4*mmtm <= 3*rdtm) /* mmap is great! */
263
printf("#define _mmap_worthy 2 \n");
264
else if(4*mmtm <= 5*rdtm) /* mmap is good */
265
printf("#define _mmap_worthy 1 \n");
271
##################################################
272
# vfork and any associated header files
273
##################################################
279
##################################################
280
# file control checks
281
##################################################
291
tmp rmfail note{ file not removable if still opened }end execute{
292
#include <sys/time.h>
294
extern int creat _ARG_((char*, int));
295
extern int unlink _ARG_((char*));
296
extern int write _ARG_((int, char*, int));
301
sprintf(file,"/tmp/iffe%lu",(unsigned long)time(0));
302
if((fw = creat(file,0666)) < 0)
304
if((fr = open(file,0)) < 0 )
308
if(write(fw,"0123456789",11) != 11 )
310
if(read(fr,file,11) != 11)
312
if(strcmp(file,"0123456789") != 0)
318
more void_int note{ voidptr is larger than int }end execute{
320
return sizeof(char*) > sizeof(int) ? 0 : 1;
324
more long_int note{ long is larger than int }end execute{
326
return sizeof(long) > sizeof(int) ? 0 : 1;
330
################################################################
331
# See if there is a preferred block size for a file system
332
################################################################
334
stat blksize note{ st_blksize is a field in struct stat }end compile{
335
#include <sys/types.h>
336
#include <sys/stat.h>
344
##################################################
345
# See if certain prototypes are required
346
##################################################
348
proto open note{ open() has a vararg prototype }end compile{
349
#include <sys/types.h>
355
extern int open _ARG_((const char*,int,...));
364
proto bcopy note{ bcopy() has prototype }end compile{
368
bcopy(buf, "abc", 3);
372
proto bzero note{ bzero() has prototype }end compile{
380
lib poll_fd_1 note{ fd is first arg to poll() }end execute{
383
extern int pipe _ARG_((int*));
388
if (pipe(rw) < 0) return 1;
392
return poll(&fd, 1, 0) < 0;
396
lib poll_fd_2 note{ fd is second arg to poll() }end execute{
399
extern int pipe _ARG_((int*));
404
if (pipe(rw) < 0) return 1;
408
return poll(1, &fd, 0) < 0;
412
lib select note{ select() has standard 5 arg interface }end link{
413
#include <sys/types.h>
414
#include <sys/time.h>
415
#include <sys/socket.h>
417
{ struct timeval tmb;
423
select(1,&rd,(fd_set*)0,(fd_set*)0,&tmb);
428
################################################################
429
## See if we can peek ahead in unseekable devices
430
################################################################
432
stream peek note{ ioctl(I_PEEK) works }end link{
433
#include <sys/types.h>
436
{ struct strpeek pbuf;
438
pbuf.ctlbuf.maxlen = pbuf.databuf.maxlen =
439
pbuf.ctlbuf.len = pbuf.databuf.len = 0;
440
pbuf.ctlbuf.buf = pbuf.databuf.buf = 0;
441
ioctl(0,I_PEEK,&pbuf);
446
socket peek note{ recv(MSG_PEEK) works }end link{
447
#include <sys/types.h>
448
#include <sys/socket.h>
451
recv(0,buf,sizeof(buf),MSG_PEEK);
457
################################################################
458
## See if register layout is ok for vax string operations
459
################################################################
461
vax asm note{ register layout ok for vax string operations }end execute{
467
register int r11, r10, r9, r8, r7, r6;
468
r11 = r10 = r9 = r8 = r7 = r6 = -1;
475
if(sizeof(int) != sizeof(char*) || r11 || r10 || r9 || r8 || r7 || r6 )
482
lib strtod note{ native strtod exists }end
484
################################################################
485
## See if there is "locale" stuff for conditioning printf/scanf
486
################################################################
488
lib locale note{ Check for localeconv }end compile{
491
{ struct lconv* lv = localeconv();