Annotation of dietlibc/t.c, revision 1.17

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.1       cvs        16: 
1.17    ! fefe       17: #if 0
1.16      fefe       18: int compint(const void *a,const void *b) {
                     19: /*  printf("comparing %d with %d\n",*(int*)a,*(int*)b); */
                     20:   return (*(int*)a-*(int*)b);
                     21: }
                     22: 
                     23: #define SIZE 100000
                     24: #define LOOKFOR ((SIZE/2)-2)
                     25: 
                     26: int array[SIZE];
                     27: 
                     28: #define rdtscl(low) \
                     29:      __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
                     30: 
                     31: static unsigned int seed=1;
                     32: 
                     33: static int rand() {
                     34:   return ((seed = seed * 1103515245 + 12345) % ((unsigned int)RAND_MAX + 1));
                     35: }
1.17    ! fefe       36: #endif
1.16      fefe       37: 
1.12      fefe       38: int main(int argc,char *argv[]) {
1.17    ! fefe       39:   double d=0.0;
        !            40:   long long t=0x12345678ABCDEF01;
        !            41:   d/=0.0;
        !            42:   printf("%d %llx\n",__isnan(d),t,*(long long*)&d);
        !            43: #if 0
1.16      fefe       44:   int i,j;
                     45:   long a,b,c;
                     46:   int *res;
                     47:   printf("%p\n",malloc(0));
                     48:   qsort(array,2,sizeof(int),compint);
                     49:   for (i=0; i<SIZE; ++i)
                     50:     array[i]=rand();
                     51:   rdtscl(a);
                     52:   qsort(array,SIZE,sizeof(int),compint);
                     53:   rdtscl(b);
                     54:   j=array[LOOKFOR];
                     55:   res=bsearch(&j,array,SIZE,sizeof(int),compint);
                     56:   rdtscl(c);
                     57:   printf("%lu cycles sort, %lu cycles bsearch\n",b-a,c-b);
                     58:   for (i=0; i<SIZE-1; ++i)
                     59:     if (array[i]>array[i+1]) {
                     60:       printf("qsort does not work, index %d: %d > %d\n",i,array[i],array[i+1]);
                     61:       return 1;
                     62:     }
                     63:   if (*res!=j)
                     64:     printf("besearch does not work, returned %p (%d) instead of %p (%d)\n",res,res?*res:-1,array+LOOKFOR,j);
                     65: /*  printf("array={%d,%d,%d,%d,%d}\n",array[0],array[1],array[2],array[3],array[4]); */
1.17    ! fefe       66: #endif
1.13      fefe       67: #if 0
1.12      fefe       68:   struct in_addr duh;
                     69:   printf("%d\n",inet_aton(argv[1]?argv[1]:"10.0.0.1",&duh));
                     70:   printf("%x\n",duh.s_addr);
1.13      fefe       71: #endif
1.12      fefe       72: /*  printf("%-19s %10lu %9lu %9lu %3d%% %s\n","/dev/ide/host0/bus0/target0/lun0/part2",8393688,705683,1337084,85,"/"); */
1.11      fefe       73: #if 0
1.10      fefe       74:   char buf[100];
                     75:   fgets(buf,100,stdin); printf("got %d bytes\n",strlen(buf));
                     76:   fgets(buf,100,stdin); printf("got %d bytes\n",strlen(buf));
1.11      fefe       77: #endif
1.9       fefe       78: #if 0
1.7       fefe       79:   struct tm duh;
                     80:   time_t t;
1.8       fefe       81:   time(&t);
                     82:   gmtime_r(&t,&duh);
                     83:   printf("%s\n",asctime(&duh));
1.9       fefe       84: #endif
1.8       fefe       85: #if 0
1.7       fefe       86:   char buf[30];
                     87:   duh.tm_sec=42;
                     88:   duh.tm_min=23;
                     89:   duh.tm_hour=17;
                     90:   duh.tm_mday=2;
                     91:   duh.tm_mon=7;
                     92:   duh.tm_year=100;
                     93:   t=mktime(&duh);
                     94:   printf("%s\n",asctime_r(&duh,buf));
1.8       fefe       95: #endif
1.2       fefe       96: #if 0
1.1       cvs        97:   int i;
                     98:   for (i=0; i<5; i++) {
                     99:     fprintf(stdout,"first message\n");
                    100:     fprintf(stdout,"second message\n");
                    101:     fprintf(stdout,"third message\n");
                    102:     printf("foo %d\n",i);
                    103:   }
1.2       fefe      104: #endif
1.1       cvs       105: #if 0
                    106:   char buf[1024];
                    107:   sscanf("foo bar","%s",buf);
                    108:   printf("%s\n",buf);
                    109: #endif
                    110: #if 0
                    111:   mount("/dev/scsi/host0/bus0/target2/lun0/cd", "/cd", "iso9660", MS_MGC_VAL|MS_RDONLY, NULL);
                    112:   perror("mount");
                    113: #endif
                    114: #if 0
                    115:   char *t="<4>Linux version 2.4.0-test10 (leitner@hellhound) (gcc version 2.95.2 19991024 (release))";
                    116:   int i=strtol(t+1,&t,10);
                    117:   printf("%d %s\n",i,t);
                    118: #endif
                    119: #if 0
                    120:   char **tmp;
                    121:   putenv("FOO");
                    122:   assert(1==2);
                    123:   for (tmp=environ; *tmp; tmp++)
                    124:     puts(*tmp);
                    125: #endif
                    126: #if 0
                    127:   char buf[1024];
                    128:   printf("%d\n",fprintf(stderr,"duh\n"));
                    129: #endif
                    130: #if 0
                    131:   struct passwd *p=getpwuid(100);
                    132:   puts(p->pw_name);
                    133: #endif
                    134: #if 0
                    135:   int pid;
                    136:   char name[32];
                    137:   sscanf("1 (init","%d (%15c",&pid,name);
                    138:   printf("pid %d name %s\n",pid,name);
                    139: #endif
                    140: #if 0
                    141:   DIR *d=opendir("/proc");
                    142:   if (d) {
                    143:     struct dirent *D;
                    144:     while (D=readdir(d))
                    145:       puts(D->d_name);
                    146:     closedir(d);
                    147:   }
                    148: #endif
                    149: #if 0
                    150:   char buf[1024];
                    151:   int fd=open("/etc/passwd",0);
                    152:   pread(fd,buf,30,32);
                    153:   close(fd);
                    154:   write(1,buf,32);
                    155: #endif
                    156: #if 0
                    157:   char *argv[] = {"echo","foo",0};
                    158:   char buf[100];
                    159:   buf[5]='x';
                    160:   sprintf(buf,"foo\n");
                    161:   if (buf[5] == 'x')
                    162:     exit(0);
                    163:   else
                    164:     exit(1);
                    165:   execvp(argv[0],argv);
                    166: #endif
1.10      fefe      167: #if 0
1.1       cvs       168:   struct stat64 f;
                    169:   char buf[128];
                    170:   fstat64(0,&f);
                    171:   fprintf(stderr,"%d %d\n",f.st_size,sizeof(f));
                    172:   return 0;
                    173: #endif
                    174: #if 0
                    175:   FILE *f=fopen("foo","w");
                    176:   fputc('a',f);
                    177:   fputc('b',f);
                    178:   fputc('c',f);
                    179: #endif
                    180: /*  fprintf(stdout,"foo\n"); */
                    181: }

LinuxTV legacy CVS <linuxtv.org/cvs>