Annotation of dietlibc/t.c, revision 1.35
1.1 cvs 1: #include <unistd.h>
2: #include <endian.h>
3: #include <stdlib.h>
4: #include <dirent.h>
5: #include <pwd.h>
6: #include <stdio.h>
7: #include <assert.h>
8: #include <sys/mount.h>
1.7 fefe 9: #include <time.h>
1.9 fefe 10: #include <sys/stat.h>
1.10 fefe 11: #include <stdio.h>
1.12 fefe 12: #include <arpa/inet.h>
1.13 fefe 13: #include <sys/sem.h>
1.14 fefe 14: #include <sys/shm.h>
1.17 fefe 15: #include <math.h>
1.20 fefe 16: #include <termios.h>
1.22 fefe 17: #include <netdb.h>
1.1 cvs 18:
1.17 fefe 19: #if 0
1.16 fefe 20: int compint(const void *a,const void *b) {
21: /* printf("comparing %d with %d\n",*(int*)a,*(int*)b); */
22: return (*(int*)a-*(int*)b);
23: }
24:
25: #define SIZE 100000
26: #define LOOKFOR ((SIZE/2)-2)
27:
28: int array[SIZE];
29:
30: #define rdtscl(low) \
31: __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
32:
33: static unsigned int seed=1;
34:
35: static int rand() {
36: return ((seed = seed * 1103515245 + 12345) % ((unsigned int)RAND_MAX + 1));
37: }
1.17 fefe 38: #endif
1.16 fefe 39:
1.24 fefe 40: extern double atof(const char *c);
41:
1.12 fefe 42: int main(int argc,char *argv[]) {
1.35 ! fefe 43: shutdown(0,-1);
! 44: #if 0
1.33 fefe 45: char buf[128];
46: strcpy(buf,"/tmp/foo.XXXXXXX");
47: printf("%d\n",mkstemp(buf));
1.34 fefe 48: printf("%s\n",buf);
49: unlink(buf);
1.35 ! fefe 50: #endif
1.33 fefe 51: #if 0
1.32 fefe 52: char buf[512]="foo";
53: strncat(buf,"barbaz",3);
54: puts(buf);
1.33 fefe 55: #endif
1.32 fefe 56: #if 0
1.31 fefe 57: time_t oink=time(0);
58: struct tm *duh=localtime(&oink);
59: strftime(buf,512,"%A %B %Y\n",duh);
60: puts(buf);
1.32 fefe 61: #endif
1.31 fefe 62: #if 0
1.28 fefe 63: struct in_addr bar;
64: struct hostent *foo;
1.29 fefe 65: /* inet_aton("160.45.10.8",&bar); */
66: foo=gethostbyname("zeit.fu-berlin.de");
67: /* foo=gethostbyaddr(&bar,4,AF_INET); */
1.30 fefe 68: if (foo)
69: printf("%s -> %s\n",foo->h_name,inet_ntoa(*(struct in_addr*)foo->h_addr));
1.22 fefe 70: /* printf("%g %g\n",1e-10,1e10); */
1.31 fefe 71: #endif
1.18 fefe 72: #if 0
1.17 fefe 73: double d=0.0;
74: long long t=0x12345678ABCDEF01;
75: d/=0.0;
76: printf("%d %llx\n",__isnan(d),t,*(long long*)&d);
1.18 fefe 77: #endif
1.17 fefe 78: #if 0
1.16 fefe 79: int i,j;
80: long a,b,c;
81: int *res;
82: printf("%p\n",malloc(0));
83: qsort(array,2,sizeof(int),compint);
84: for (i=0; i<SIZE; ++i)
85: array[i]=rand();
86: rdtscl(a);
87: qsort(array,SIZE,sizeof(int),compint);
88: rdtscl(b);
89: j=array[LOOKFOR];
90: res=bsearch(&j,array,SIZE,sizeof(int),compint);
91: rdtscl(c);
92: printf("%lu cycles sort, %lu cycles bsearch\n",b-a,c-b);
93: for (i=0; i<SIZE-1; ++i)
94: if (array[i]>array[i+1]) {
95: printf("qsort does not work, index %d: %d > %d\n",i,array[i],array[i+1]);
96: return 1;
97: }
98: if (*res!=j)
99: printf("besearch does not work, returned %p (%d) instead of %p (%d)\n",res,res?*res:-1,array+LOOKFOR,j);
100: /* printf("array={%d,%d,%d,%d,%d}\n",array[0],array[1],array[2],array[3],array[4]); */
1.17 fefe 101: #endif
1.13 fefe 102: #if 0
1.12 fefe 103: struct in_addr duh;
104: printf("%d\n",inet_aton(argv[1]?argv[1]:"10.0.0.1",&duh));
105: printf("%x\n",duh.s_addr);
1.13 fefe 106: #endif
1.12 fefe 107: /* printf("%-19s %10lu %9lu %9lu %3d%% %s\n","/dev/ide/host0/bus0/target0/lun0/part2",8393688,705683,1337084,85,"/"); */
1.11 fefe 108: #if 0
1.10 fefe 109: char buf[100];
110: fgets(buf,100,stdin); printf("got %d bytes\n",strlen(buf));
111: fgets(buf,100,stdin); printf("got %d bytes\n",strlen(buf));
1.11 fefe 112: #endif
1.9 fefe 113: #if 0
1.7 fefe 114: struct tm duh;
115: time_t t;
1.8 fefe 116: time(&t);
117: gmtime_r(&t,&duh);
118: printf("%s\n",asctime(&duh));
1.9 fefe 119: #endif
1.8 fefe 120: #if 0
1.7 fefe 121: char buf[30];
122: duh.tm_sec=42;
123: duh.tm_min=23;
124: duh.tm_hour=17;
125: duh.tm_mday=2;
126: duh.tm_mon=7;
127: duh.tm_year=100;
128: t=mktime(&duh);
129: printf("%s\n",asctime_r(&duh,buf));
1.8 fefe 130: #endif
1.2 fefe 131: #if 0
1.1 cvs 132: int i;
133: for (i=0; i<5; i++) {
134: fprintf(stdout,"first message\n");
135: fprintf(stdout,"second message\n");
136: fprintf(stdout,"third message\n");
137: printf("foo %d\n",i);
138: }
1.2 fefe 139: #endif
1.1 cvs 140: #if 0
141: char buf[1024];
142: sscanf("foo bar","%s",buf);
143: printf("%s\n",buf);
144: #endif
145: #if 0
146: mount("/dev/scsi/host0/bus0/target2/lun0/cd", "/cd", "iso9660", MS_MGC_VAL|MS_RDONLY, NULL);
147: perror("mount");
148: #endif
149: #if 0
150: char *t="<4>Linux version 2.4.0-test10 (leitner@hellhound) (gcc version 2.95.2 19991024 (release))";
151: int i=strtol(t+1,&t,10);
152: printf("%d %s\n",i,t);
153: #endif
154: #if 0
155: char **tmp;
156: putenv("FOO");
157: assert(1==2);
158: for (tmp=environ; *tmp; tmp++)
159: puts(*tmp);
160: #endif
161: #if 0
162: char buf[1024];
163: printf("%d\n",fprintf(stderr,"duh\n"));
164: #endif
165: #if 0
166: struct passwd *p=getpwuid(100);
167: puts(p->pw_name);
168: #endif
169: #if 0
170: int pid;
171: char name[32];
172: sscanf("1 (init","%d (%15c",&pid,name);
173: printf("pid %d name %s\n",pid,name);
174: #endif
175: #if 0
176: DIR *d=opendir("/proc");
177: if (d) {
178: struct dirent *D;
179: while (D=readdir(d))
180: puts(D->d_name);
181: closedir(d);
182: }
183: #endif
184: #if 0
185: char buf[1024];
186: int fd=open("/etc/passwd",0);
187: pread(fd,buf,30,32);
188: close(fd);
189: write(1,buf,32);
190: #endif
191: #if 0
192: char *argv[] = {"echo","foo",0};
193: char buf[100];
194: buf[5]='x';
195: sprintf(buf,"foo\n");
196: if (buf[5] == 'x')
197: exit(0);
198: else
199: exit(1);
200: execvp(argv[0],argv);
201: #endif
1.10 fefe 202: #if 0
1.1 cvs 203: struct stat64 f;
204: char buf[128];
205: fstat64(0,&f);
206: fprintf(stderr,"%d %d\n",f.st_size,sizeof(f));
207: return 0;
208: #endif
209: #if 0
210: FILE *f=fopen("foo","w");
211: fputc('a',f);
212: fputc('b',f);
213: fputc('c',f);
214: #endif
215: /* fprintf(stdout,"foo\n"); */
216: }
LinuxTV legacy CVS <linuxtv.org/cvs>