Search
lxdream.org :: lxdream/test/randmath.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/randmath.c
changeset 1169:23a9613aceb1
prev1131:4727c2006e0f
author Nathan Keynes <nkeynes@lxdream.org>
date Thu Apr 07 21:42:55 2011 +1000 (8 years ago)
permissions -rw-r--r--
last change Add german translation update from Riemann80, thanks!
file annotate diff log raw
1.1 --- a/test/randmath.c Wed Oct 06 08:47:13 2010 +1000
1.2 +++ b/test/randmath.c Thu Apr 07 21:42:55 2011 +1000
1.3 @@ -1,25 +1,25 @@
1.4 #include <stdlib.h>
1.5 #include <stdio.h>
1.6
1.7 -typedef unsigned char uint8_t;
1.8 -typedef signed char int8_t;
1.9 -typedef unsigned short uint16_t;
1.10 -typedef signed short int16_t;
1.11 -typedef unsigned int uint32_t;
1.12 -typedef signed int int32_t;
1.13 -typedef unsigned long long uint64_t;
1.14 -typedef signed long long int64_t;
1.15 +typedef unsigned char u8;
1.16 +typedef signed char i8;
1.17 +typedef unsigned short u16;
1.18 +typedef signed short i16;
1.19 +typedef unsigned int u32;
1.20 +typedef signed int i32;
1.21 +typedef unsigned long long u64;
1.22 +typedef signed long long i64;
1.23
1.24 #define TEST_REPS 64
1.25
1.26 -void printuint8_t(uint8_t a) { printf( "%08X ", (unsigned int)a ); }
1.27 -void printint8_t(int8_t a) { printf( "%08X ", (unsigned int)(uint8_t)a ); }
1.28 -void printuint16_t(uint16_t a) { printf( "%08X ", (unsigned int)a ); }
1.29 -void printint16_t(int16_t a) { printf( "%08X ", (unsigned int)(uint16_t)a ); }
1.30 -void printuint32_t(uint32_t a) { printf( "%08X ", (unsigned int)a ); }
1.31 -void printint32_t(int32_t a) { printf( "%08X ", (unsigned int)a ); }
1.32 -void printuint64_t(uint64_t a) { printf( "%08X%08X ", (unsigned int)(a>>32),(unsigned int)a ); }
1.33 -void printint64_t(int64_t a) { printf( "%08X%08X ", (unsigned int)(a>>32),(unsigned int)a ); }
1.34 +void printu8(u8 a) { printf( "%08X ", (unsigned int)a ); }
1.35 +void printi8(i8 a) { printf( "%08X ", (unsigned int)(u8)a ); }
1.36 +void printu16(u16 a) { printf( "%08X ", (unsigned int)a ); }
1.37 +void printi16(i16 a) { printf( "%08X ", (unsigned int)(u16)a ); }
1.38 +void printu32(u32 a) { printf( "%08X ", (unsigned int)a ); }
1.39 +void printi32(i32 a) { printf( "%08X ", (unsigned int)a ); }
1.40 +void printu64(u64 a) { printf( "%08X%08X ", (unsigned int)(a>>32),(unsigned int)a ); }
1.41 +void printi64(i64 a) { printf( "%08X%08X ", (unsigned int)(a>>32),(unsigned int)a ); }
1.42
1.43 #define TEST_TYPE(T) \
1.44 void test##T() { \
1.45 @@ -27,34 +27,34 @@
1.46 read(0,&a,sizeof(a)); read(0,&b,sizeof(b)); read(0,&c,sizeof(c)); read(0,&d,sizeof(d)); \
1.47 e = a * b - c * d;\
1.48 if( b != 0 && c != 0 ) { f = a / b + 1/c; }\
1.49 - T g = e - f / 2 + (uint32_t)b;\
1.50 + T g = e - f / 2 + (u32)b;\
1.51 T h = b * c / d; T i = a / -d; \
1.52 - printf( "%d| ", sizeof(a) ); \
1.53 + printf( "%d| ", (int)sizeof(a) ); \
1.54 print##T(a); print##T(b); print##T(c); print##T(d); \
1.55 printf( ": " ); print##T(e); print##T(f); print##T(g); \
1.56 print##T(h); print##T(i); \
1.57 printf( "\n" ); \
1.58 }
1.59
1.60 -TEST_TYPE(uint8_t);
1.61 -TEST_TYPE(int8_t);
1.62 -TEST_TYPE(uint16_t);
1.63 -TEST_TYPE(int16_t);
1.64 -TEST_TYPE(uint32_t);
1.65 -TEST_TYPE(int32_t);
1.66 -TEST_TYPE(uint64_t);
1.67 -TEST_TYPE(int64_t);
1.68 +TEST_TYPE(u8);
1.69 +TEST_TYPE(i8);
1.70 +TEST_TYPE(u16);
1.71 +TEST_TYPE(i16);
1.72 +TEST_TYPE(u32);
1.73 +TEST_TYPE(i32);
1.74 +TEST_TYPE(u64);
1.75 +TEST_TYPE(i64);
1.76
1.77 int main(int argc, char *argv[]) {
1.78 unsigned i;
1.79
1.80 - for(i=0;i<TEST_REPS;i++ ) { testuint64_t(); }
1.81 - for(i=0;i<TEST_REPS;i++ ) { testint64_t(); }
1.82 - for(i=0;i<TEST_REPS;i++ ) { testuint32_t(); }
1.83 - for(i=0;i<TEST_REPS;i++ ) { testint32_t(); }
1.84 - for(i=0;i<TEST_REPS;i++ ) { testuint16_t(); }
1.85 - for(i=0;i<TEST_REPS;i++ ) { testint16_t(); }
1.86 - for(i=0;i<TEST_REPS;i++ ) { testuint8_t(); }
1.87 - for(i=0;i<TEST_REPS;i++ ) { testint8_t(); }
1.88 + for(i=0;i<TEST_REPS;i++ ) { testu64(); }
1.89 + for(i=0;i<TEST_REPS;i++ ) { testi64(); }
1.90 + for(i=0;i<TEST_REPS;i++ ) { testu32(); }
1.91 + for(i=0;i<TEST_REPS;i++ ) { testi32(); }
1.92 + for(i=0;i<TEST_REPS;i++ ) { testu16(); }
1.93 + for(i=0;i<TEST_REPS;i++ ) { testi16(); }
1.94 + for(i=0;i<TEST_REPS;i++ ) { testu8(); }
1.95 + for(i=0;i<TEST_REPS;i++ ) { testi8(); }
1.96 return 0;
1.97 }
.