#include <stdio.h>
-typedef int myint;
-
-#define TESTANZ 16
-#define IMM 23
-#define test16_1 42
-#define test16_2 11
-#define test32_1 0x001200AB
-#define test32_2 0x00341500
-#define test32_s 7
-
-
-
-myint test_add(myint a, myint b) {
- return a+b;
-}
-
-myint test_addi(myint a) {
- return a+IMM;
-}
-
-myint test_sub(myint a, myint b) {
- return a-b;
-}
-
-myint test_subi(myint a) {
- return a-IMM;
-}
-
-myint test_subfi(myint a) {
- return IMM-a;
-}
-
-myint test_mul(myint a, myint b) {
- return a*b;
-}
-
-myint test_muli(myint a) {
- return a*IMM;
-}
-
-myint test_div(myint a, myint b) {
- return a/b;
-}
-
-myint test_divi(myint a) {
- return a/IMM;
-}
-
-myint test_shl(myint a, myint b) {
- return a<<b;
-}
-
-myint test_shli(myint a) {
- return a<<IMM;
-}
-
-myint test_shr(myint a, myint b) {
- return a>>b;
-}
-
-myint test_shri(myint a) {
- return a>>IMM;
-}
-
-myint test_cmp(myint a, myint b) {
- return (a>b) ? 1 : 0;
-}
-
-myint test_cmpi(myint a) {
- return (a>IMM) ? 1 : 0;
-}
+#define tname(x) x##long
+#define T long
+#include "optest.h"
+
+#undef tname
+#undef T
+#define tname(x) x##int
+#define T int
+#include "optest.h"
+
+#undef tname
+#undef T
+#define tname(x) x##short
+#define T short
+#include "optest.h"
+
+#undef tname
+#undef T
+#define tname(x) x##char
+#define T char
+#include "optest.h"
+
+#undef tname
+#undef T
+#define tname(x) x##unsigned_long
+#define T unsigned long
+#include "optest.h"
+
+#undef tname
+#undef T
+#define tname(x) x##unsigned_int
+#define T unsigned int
+#include "optest.h"
+
+#undef tname
+#undef T
+#define tname(x) x##unsigned_short
+#define T unsigned short
+#include "optest.h"
+
+#undef tname
+#undef T
+#define tname(x) x##unsigned_char
+#define T unsigned char
+#include "optest.h"
+
+#if 0
+#undef tname
+#undef T
+#define tname(x) x##unsigned_long_long
+#define T unsigned long long
+#include "optest.h"
+
+#undef tname
+#undef T
+#define tname(x) x##long_long
+#define T long long
+#include "optest.h"
+#endif
int main(int argc, char *argv[]) {
- myint res16[TESTANZ];
- myint res32[TESTANZ];
- int i;
-
- res16[ 0] = test_add (test16_1, test16_2);
- res16[ 1] = test_sub (test16_1, test16_2);
- res16[ 2] = test_mul (test16_1, test16_2);
- res16[ 3] = test_div (test16_1, test16_2);
- res16[ 4] = test_shl (test16_1, test16_2);
- res16[ 5] = test_shr (test16_1, test16_2);
- res16[ 6] = test_div (test16_1, test16_2);
- res16[ 7] = test_cmp (test16_1, test16_2);
- res16[ 8] = test_addi (test16_1);
- res16[ 9] = test_subi (test16_1);
- res16[10] = test_subfi(test16_1);
- res16[11] = test_muli (test16_1);
- res16[12] = test_divi (test16_1);
- res16[13] = test_shli (test16_1);
- res16[14] = test_shri (test16_1);
- res16[15] = test_cmpi (test16_1);
-
- res32[ 0] = test_add (test32_1, test32_2);
- res32[ 1] = test_sub (test32_1, test32_2);
- res32[ 2] = test_mul (test32_1, test32_2);
- res32[ 3] = test_div (test32_1, test32_2);
- res32[ 4] = test_shl (test32_1, test32_s);
- res32[ 5] = test_shr (test32_1, test32_s);
- res32[ 6] = test_div (test32_1, test32_2);
- res32[ 7] = test_cmp (test32_1, test32_2);
- res32[ 8] = test_addi (test32_1);
- res32[ 9] = test_subi (test32_1);
- res32[10] = test_subfi(test32_1);
- res32[11] = test_muli (test32_1);
- res32[12] = test_divi (test32_1);
- res32[13] = test_shli (test32_1);
- res32[14] = test_shri (test32_1);
- res32[15] = test_cmpi (test32_1);
-
- for (i=0; i<TESTANZ; i++) {
- printf("res16[%d] = %d\n", i, res16[i]);
- printf("res32[%d] = %d\n", i, res32[i]);
- }
- return 0;
+ test_long();
+ test_int();
+ test_short();
+ test_char();
+ test_unsigned_long();
+ test_unsigned_int();
+ test_unsigned_short();
+ test_unsigned_char();
+#if 0
+ test_unsigned_long_long();
+ test_long_long();
+#endif
+ return 0;
}
--- /dev/null
+#ifndef TESTANZ
+#define TESTANZ 16
+#define IMM 23
+#define test16_1 42
+#define test16_2 11
+#define test32_1 0x001200AB
+#define test32_2 0x00341501
+#define test32_s 7
+#endif
+
+T tname(test_add_) (T a, T b) {
+ return a+b;
+}
+
+T tname(test_addi_) (T a) {
+ return a+IMM;
+}
+
+T tname(test_sub_) (T a, T b) {
+ return a-b;
+}
+
+T tname(test_subi_) (T a) {
+ return a-IMM;
+}
+
+T tname(test_subfi_) (T a) {
+ return IMM-a;
+}
+
+T tname(test_mul_) (T a, T b) {
+ return a*b;
+}
+
+T tname(test_muli_) (T a) {
+ return a*IMM;
+}
+
+T tname(test_div_) (T a, T b) {
+ return a/b;
+}
+
+T tname(test_divi_) (T a) {
+ return a/IMM;
+}
+
+#ifndef TEST_FLOAT
+T tname(test_shl_) (T a, T b) {
+ return a<<b;
+}
+
+T tname(test_shli_) (T a) {
+ return a<<IMM;
+}
+
+T tname(test_shr_) (T a, T b) {
+ return a>>b;
+}
+
+T tname(test_shri_) (T a) {
+ return a>>IMM;
+}
+#endif
+
+T tname(test_cmp_) (T a, T b) {
+ return (a>b) ? 1 : 0;
+}
+
+T tname(test_cmpi_) (T a) {
+ return (a>IMM) ? 1 : 0;
+}
+
+T tname(res16_) [TESTANZ];
+T tname(res32_) [TESTANZ];
+
+void tname(test_) () {
+ int i;
+ T *res16 = tname(res16_);
+ T *res32 = tname(res32_);
+
+ res16[ 0] = tname(test_add_) (test16_1, test16_2);
+ res16[ 1] = tname(test_sub_) (test16_1, test16_2);
+ res16[ 2] = tname(test_mul_) (test16_1, test16_2);
+ res16[ 3] = tname(test_div_) (test16_1, test16_2);
+#ifndef TEST_FLOAT
+ res16[ 4] = tname(test_shl_) (test16_1, test16_2);
+ res16[ 5] = tname(test_shr_) (test16_1, test16_2);
+#endif
+ res16[ 6] = tname(test_div_) (test16_1, test16_2);
+ res16[ 7] = tname(test_cmp_) (test16_1, test16_2);
+ res16[ 8] = tname(test_addi_) (test16_1);
+ res16[ 9] = tname(test_subi_) (test16_1);
+ res16[10] = tname(test_subfi_)(test16_1);
+ res16[11] = tname(test_muli_) (test16_1);
+ res16[12] = tname(test_divi_) (test16_1);
+#ifndef TEST_FLOAT
+ res16[13] = tname(test_shli_) (test16_1);
+ res16[14] = tname(test_shri_) (test16_1);
+#endif
+ res16[15] = tname(test_cmpi_) (test16_1);
+
+ res32[ 0] = tname(test_add_) (test32_1, test32_2);
+ res32[ 1] = tname(test_sub_) (test32_1, test32_2);
+ res32[ 2] = tname(test_mul_) (test32_1, test32_2);
+ res32[ 3] = tname(test_div_) (test32_1, test32_2);
+#ifndef TEST_FLOAT
+ res32[ 4] = tname(test_shl_) (test32_1, test32_2);
+ res32[ 5] = tname(test_shr_) (test32_1, test32_2);
+#endif
+ res32[ 6] = tname(test_div_) (test32_1, test32_2);
+ res32[ 7] = tname(test_cmp_) (test32_1, test32_2);
+ res32[ 8] = tname(test_addi_) (test32_1);
+ res32[ 9] = tname(test_subi_) (test32_1);
+ res32[10] = tname(test_subfi_)(test32_1);
+ res32[11] = tname(test_muli_) (test32_1);
+ res32[12] = tname(test_divi_) (test32_1);
+#ifndef TEST_FLOAT
+ res32[13] = tname(test_shli_) (test32_1);
+ res32[14] = tname(test_shri_) (test32_1);
+#endif
+ res32[15] = tname(test_cmpi_) (test32_1);
+
+ printf("Result for %s\n", __PRETTY_FUNCTION__);
+ for (i=0; i<TESTANZ; i++) {
+#ifndef TEST_FLOAT
+ printf("res16[%d] = %d\n", i, res16[i]);
+ printf("res32[%d] = %d\n", i, res32[i]);
+#else
+ printf("res16[%d] = %f\n", i, res16[i]);
+ printf("res32[%d] = %f\n", i, res32[i]);
+#endif
+ }
+}
--- /dev/null
+#include <stdio.h>
+
+#define TEST_FLOAT
+
+#define tname(x) x##float
+#define T float
+#include "optest.h"
+
+#undef tname
+#undef T
+#define tname(x) x##double
+#define T double
+#include "optest.h"
+
+#if 0
+#undef tname
+#undef T
+#define tname(x) x##long_double
+#define T long_double
+#include "optest.h"
+#endif
+
+int main(int argc, char *argv[]) {
+ test_float();
+ test_double();
+#if 0
+ test_long_double();
+#endif
+ return 0;
+}