00001 #include <stdio.h>
00002 #include <unistd.h>
00003
00004 int float_test(int n, float f1, float f2, float f3, float f4) {
00005 unsigned int ui;
00006
00007
00008 ui = *((unsigned int *)(&f1));
00009 printf("%d: %8.8e %X\n", n, f1, ui);
00010 ui = *((unsigned int *)(&f2));
00011 printf("%d: %8.8e %X\n", n, f2, ui);
00012 ui = *((unsigned int *)(&f3));
00013 printf("%d: %8.8e %X\n", n, f3, ui);
00014 ui = *((unsigned int *)(&f4));
00015 printf("%d: %8.8e %X\n", n, f4, ui);
00016
00017 return -1;
00018 }
00019
00020 int double_test(long n, double d1, double d2, double d3, double d4) {
00021 unsigned long ul;
00022
00023
00024 ul = *((unsigned long *)(&d1));
00025 printf("%ld: %16.16e %lX\n", n, d1, ul);
00026 ul = *((unsigned long *)(&d2));
00027 printf("%ld: %16.16e %lX\n", n, d2, ul);
00028 ul = *((unsigned long *)(&d3));
00029 printf("%ld: %16.16e %lX\n", n, d3, ul);
00030 ul = *((unsigned long *)(&d4));
00031 printf("%ld: %16.16e %lX\n", n, d4, ul);
00032
00033 return -1;
00034 }
00035
00036 int iv_test(int n, int *src) {
00037 int i;
00038 unsigned int *ui;
00039 printf("size = %d\n", n);
00040 for(i=0;i<n ;i++){
00041 ui = (unsigned int *)(&(src[i]));
00042 printf("%d: %d %X\n", i, src[i], *ui);
00043 }
00044 return -1;
00045 }
00046
00047 int lv_test(int n, long *src) {
00048 int i;
00049 unsigned long *ul;
00050 printf("size = %d\n", n);
00051 for(i=0;i<n ;i++){
00052 ul = (unsigned long *)(&(src[i]));
00053 printf("%d: %ld %lX\n", i, src[i], *ul);
00054 }
00055 return -1;
00056 }
00057
00058 int fv_test(int n, float *src) {
00059 int i;
00060 unsigned int *ui;
00061 printf("size = %d\n", n);
00062 for(i=0;i<n ;i++){
00063 ui = (unsigned int *)(&(src[i]));
00064 printf("%d: %e %X\n", i, src[i], *ui);
00065 }
00066 return -1;
00067 }
00068
00069 int dv_test(int n, double *src) {
00070 int i;
00071 unsigned long *ul;
00072 printf("size = %d\n", n);
00073 for(i=0;i<n ;i++){
00074 ul = (unsigned long *)(&(src[i]));
00075 printf("%d: %e %lX\n", i, src[i], *ul);
00076 }
00077 return -1;
00078 }
00079
00080 int str_test(int n, char *src) {
00081 int i;
00082 printf("size = %d\n", n);
00083 for(i=0;i<n ;i++){
00084 printf("%d: %c %X\n", i, src[i], src[i]);
00085 }
00086 return -1;
00087 }
00088
00089 int int_test(long l, int i, short s) {
00090 printf("long = %ld(%lX)\n",l,l);
00091 printf("int = %d(%X)\n",i,i);
00092 printf("short = %d(%X)\n",s,s);
00093
00094 return l + i + s;
00095 }
00096
00097 float ret_float(double a, double b) {
00098 float ret = (float) (a + b);
00099 unsigned int *ui;
00100 ui = (unsigned int *)&ret;
00101 printf("// return %e, %X\n", ret, *ui);
00102 return ret;
00103 }
00104
00105 double ret_double(double a, double b) {
00106 double ret = (a + b);
00107 unsigned long *ul;
00108 ul = (unsigned long *)&ret;
00109 printf("// return %e, %lX\n", ret, *ul);
00110 return ret;
00111 }
00112
00113 long ret_long(long a, long b) {
00114 long ret = a + b;
00115 unsigned long *ul;
00116 ul = (unsigned long *)&ret;
00117 printf("// return %ld, %lX\n", ret, *ul);
00118 return ret;
00119 }
00120
00121 double test_testd(long i0, long i1, long i2,
00122 long i3, long i4, long i5,
00123 double d0, double d1, double d2, double d3,
00124 double d4, double d5, double d6, double d7,
00125 double d8, double d9,
00126 long i6, long i7) {
00127 printf("%ld %ld %ld\n", i0, i1, i2);
00128 printf("%ld %ld %ld\n", i3, i4, i5);
00129
00130
00131 printf("%lf %lf %lf %lf\n", d0, d1, d2, d3);
00132 printf("%lf %lf %lf %lf\n", d4, d5, d6, d7);
00133 printf("%lf %lf\n", d8, d9);
00134 printf("%ld %ld\n", i6, i7);
00135
00136
00137 return 1.23456;
00138 }
00139 double test_testd2(long i0, long i1, long i2,
00140 long i3, long i4, long i5,
00141 double d0, double d1, double d2, double d3,
00142 double d4, double d5, double d6, double d7,
00143 double d8, double d9, double d10,
00144 long i6, long i7) {
00145 printf("%ld %ld %ld\n", i0, i1, i2);
00146 printf("%ld %ld %ld\n", i3, i4, i5);
00147
00148
00149 printf("%lf %lf %lf %lf\n", d0, d1, d2, d3);
00150 printf("%lf %lf %lf %lf\n", d4, d5, d6, d7);
00151 printf("%lf %lf %lf\n", d8, d9, d10);
00152 printf("%ld %ld\n", i6, i7);
00153
00154
00155 return 1.23456;
00156 }
00157
00158 static long (*g)();
00159 static double (*gf) (long i0, long i1, long i2,
00160 long i3, long i4, long i5,
00161 double d0, double d1, double d2, double d3,
00162 double d4, double d5, double d6, double d7,
00163 double d8, double d9,
00164 long i6, long i7);
00165
00166 long set_ifunc(long (*f) ())
00167 {
00168 g = f;
00169 }
00170
00171 long set_ffunc(double (*f) ())
00172 {
00173 gf = (double (*) (long i0, long i1, long i2,
00174 long i3, long i4, long i5,
00175 double d0, double d1, double d2, double d3,
00176 double d4, double d5, double d6, double d7,
00177 double d8, double d9,
00178 long i6, long i7))f;
00179 }
00180
00181 long call_ifunc() {
00182 printf("g = %lX\n", g);
00183 return g();
00184 }
00185
00186 double call_ffunc() {
00187 printf("gf = %lX\n", gf);
00188 return gf(100,101,102,
00189 103,104,105,
00190 1000.0, 1010.0, 1020.0, 1030.0,
00191 1040.0, 1050.0, 1060.0, 1070.0,
00192 2080.0, 2090.0,
00193 206, 207);
00194 }