Home | History | Annotate | Download | only in config
      1 #!/bin/sh
      2 
      3 cat > sed.script << "EOF"
      4 /^#/d
      5 /^$/d
      6 s/__extension__ //
      7 s/typedef \(.*\) __u\([1-9]*\);/#define __U\2_TYPEDEF \1/
      8 s/typedef \(.*\) __s\([1-9]*\);/#define __S\2_TYPEDEF \1/
      9 EOF
     10 
     11 if test -z "$CC"; then
     12     CC=gcc
     13 fi
     14 
     15 if test -z "$CPP"; then
     16     CPP="$CC -E"
     17 fi
     18 
     19 echo '#include <asm/types.h>' | $CPP - | \
     20     sed -f sed.script | grep '^#' > asm_types.h
     21 
     22 rm sed.script
     23 
     24 cp asm_types.h asm_types.c
     25 
     26 cat >> asm_types.c <<EOF
     27 #include <stdio.h>
     28 #include <stdlib.h>
     29 main(int argc, char **argv)
     30 {
     31 #ifdef __U8_TYPEDEF
     32 	if (sizeof(__U8_TYPEDEF) != 1) {
     33 		printf("Sizeof(__U8__TYPEDEF) is %d should be 1\n", 
     34 		       sizeof(__U8_TYPEDEF));
     35 		exit(1);
     36 	}
     37 #else
     38 #warning __U8_TYPEDEF not defined
     39 #endif
     40 #ifdef __S8_TYPEDEF
     41 	if (sizeof(__S8_TYPEDEF) != 1) {
     42 		printf("Sizeof(_S8__TYPEDEF) is %d should be 1\n", 
     43 		       sizeof(__S8_TYPEDEF));
     44 		exit(1);
     45 	}
     46 #else
     47 #warning __S8_TYPEDEF not defined
     48 #endif
     49 #ifdef __U16_TYPEDEF
     50 	if (sizeof(__U16_TYPEDEF) != 2) {
     51 		printf("Sizeof(__U16__TYPEDEF) is %d should be 2\n", 
     52 		       sizeof(__U16_TYPEDEF));
     53 		exit(1);
     54 	}
     55 #else
     56 #warning __U16_TYPEDEF not defined
     57 #endif
     58 #ifdef __S16_TYPEDEF
     59 	if (sizeof(__S16_TYPEDEF) != 2) {
     60 		printf("Sizeof(__S16__TYPEDEF) is %d should be 2\n", 
     61 		       sizeof(__S16_TYPEDEF));
     62 		exit(1);
     63 	}
     64 #else
     65 #warning __S16_TYPEDEF not defined
     66 #endif
     67 
     68 #ifdef __U32_TYPEDEF
     69 	if (sizeof(__U32_TYPEDEF) != 4) {
     70 		printf("Sizeof(__U32__TYPEDEF) is %d should be 4\n", 
     71 		       sizeof(__U32_TYPEDEF));
     72 		exit(1);
     73 	}
     74 #else
     75 #warning __U32_TYPEDEF not defined
     76 #endif
     77 #ifdef __S32_TYPEDEF
     78 	if (sizeof(__S32_TYPEDEF) != 4) {
     79 		printf("Sizeof(__S32__TYPEDEF) is %d should be 4\n", 
     80 		       sizeof(__S32_TYPEDEF));
     81 		exit(1);
     82 	}
     83 #else
     84 #warning __S32_TYPEDEF not defined
     85 #endif
     86 
     87 #ifdef __U64_TYPEDEF
     88 	if (sizeof(__U64_TYPEDEF) != 8) {
     89 		printf("Sizeof(__U64__TYPEDEF) is %d should be 8\n", 
     90 		       sizeof(__U64_TYPEDEF));
     91 		exit(1);
     92 	}
     93 #else
     94 #warning __U64_TYPEDEF not defined
     95 #endif
     96 #ifdef __S64_TYPEDEF
     97 	if (sizeof(__S64_TYPEDEF) != 8) {
     98 		printf("Sizeof(__S64__TYPEDEF) is %d should be 8\n", 
     99 		       sizeof(__S64_TYPEDEF));
    100 		exit(1);
    101 	}
    102 #else
    103 #warning __S64_TYPEDEF not defined
    104 #endif
    105 	exit(0);
    106 }
    107 EOF
    108 
    109 ${BUILD_CC-${CC-gcc}} -o asm_types asm_types.c
    110 if ./asm_types
    111 then
    112     true
    113 else
    114     echo "Problem detected with asm_types.h"
    115     echo "" > asm_types.h
    116 fi
    117 rm asm_types.c asm_types
    118 
    119