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