test_foreign.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <unistd.h>
3 
4 int float_test(int n, float f1, float f2, float f3, float f4) {
5  unsigned int ui;
6 
7  //printf("float_test in c\n");
8  ui = *((unsigned int *)(&f1));
9  printf("%d: %8.8e %X\n", n, f1, ui);
10  ui = *((unsigned int *)(&f2));
11  printf("%d: %8.8e %X\n", n, f2, ui);
12  ui = *((unsigned int *)(&f3));
13  printf("%d: %8.8e %X\n", n, f3, ui);
14  ui = *((unsigned int *)(&f4));
15  printf("%d: %8.8e %X\n", n, f4, ui);
16 
17  return -1;
18 }
19 
20 int double_test(long n, double d1, double d2, double d3, double d4) {
21  unsigned long ul;
22 
23  //printf("double_test in c\n");
24  ul = *((unsigned long *)(&d1));
25  printf("%ld: %16.16e %lX\n", n, d1, ul);
26  ul = *((unsigned long *)(&d2));
27  printf("%ld: %16.16e %lX\n", n, d2, ul);
28  ul = *((unsigned long *)(&d3));
29  printf("%ld: %16.16e %lX\n", n, d3, ul);
30  ul = *((unsigned long *)(&d4));
31  printf("%ld: %16.16e %lX\n", n, d4, ul);
32 
33  return -1;
34 }
35 
36 int iv_test(int n, int *src) {
37  int i;
38  unsigned int *ui;
39  printf("size = %d\n", n);
40  for(i=0;i<n ;i++){
41  ui = (unsigned int *)(&(src[i]));
42  printf("%d: %d %X\n", i, src[i], *ui);
43  }
44  return -1;
45 }
46 
47 int lv_test(int n, long *src) {
48  int i;
49  unsigned long *ul;
50  printf("size = %d\n", n);
51  for(i=0;i<n ;i++){
52  ul = (unsigned long *)(&(src[i]));
53  printf("%d: %ld %lX\n", i, src[i], *ul);
54  }
55  return -1;
56 }
57 
58 int fv_test(int n, float *src) {
59  int i;
60  unsigned int *ui;
61  printf("size = %d\n", n);
62  for(i=0;i<n ;i++){
63  ui = (unsigned int *)(&(src[i]));
64  printf("%d: %e %X\n", i, src[i], *ui);
65  }
66  return -1;
67 }
68 
69 int dv_test(int n, double *src) {
70  int i;
71  unsigned long *ul;
72  printf("size = %d\n", n);
73  for(i=0;i<n ;i++){
74  ul = (unsigned long *)(&(src[i]));
75  printf("%d: %e %lX\n", i, src[i], *ul);
76  }
77  return -1;
78 }
79 
80 int str_test(int n, char *src) {
81  int i;
82  printf("size = %d\n", n);
83  for(i=0;i<n ;i++){
84  printf("%d: %c %x\n", i, src[i], src[i]);
85  }
86  return -1;
87 }
88 
89 int int_test(long l, int i, short s) {
90  printf("long = %ld(%lX)\n",l,l);
91  printf("int = %d(%X)\n",i,i);
92  printf("short = %d(%X)\n",s,s);
93 
94  return l + i + s;
95 }
96 
97 float ret_float(double a, double b) {
98  float ret = (float) (a + b);
99  unsigned int *ui;
100  ui = (unsigned int *)&ret;
101  printf("// return %e, %X\n", ret, *ui);
102  return ret;
103 }
104 
105 double ret_double(double a, double b) {
106  double ret = (a + b);
107  unsigned long *ul;
108  ul = (unsigned long *)&ret;
109  printf("// return %e, %lX\n", ret, *ul);
110  return ret;
111 }
112 
113 long ret_long(long a, long b) {
114  long ret = a + b;
115  unsigned long *ul;
116  ul = (unsigned long *)&ret;
117  printf("// return %ld, %lX\n", ret, *ul);
118  return ret;
119 }
120 
121 double test_testd(long i0, long i1, long i2,
122  long i3, long i4, long i5,
123  double d0, double d1, double d2, double d3,
124  double d4, double d5, double d6, double d7,
125  double d8, double d9,
126  long i6, long i7) {
127  printf("%ld %ld %ld\n", i0, i1, i2);
128  printf("%ld %ld %ld\n", i3, i4, i5);
129  //printf("%ld %ld %ld %ld\n",
130  //(long)d0, (long)d1, (long)d2, (long)d3);
131  printf("%lf %lf %lf %lf\n", d0, d1, d2, d3);
132  printf("%lf %lf %lf %lf\n", d4, d5, d6, d7);
133  printf("%lf %lf\n", d8, d9);
134  printf("%ld %ld\n", i6, i7);
135 
136  //return 0x1234;
137  return 1.23456;
138 }
139 double test_testd2(long i0, long i1, long i2,
140  long i3, long i4, long i5,
141  double d0, double d1, double d2, double d3,
142  double d4, double d5, double d6, double d7,
143  double d8, double d9, double d10,
144  long i6, long i7) {
145  printf("%ld %ld %ld\n", i0, i1, i2);
146  printf("%ld %ld %ld\n", i3, i4, i5);
147  //printf("%ld %ld %ld %ld\n",
148  //(long)d0, (long)d1, (long)d2, (long)d3);
149  printf("%lf %lf %lf %lf\n", d0, d1, d2, d3);
150  printf("%lf %lf %lf %lf\n", d4, d5, d6, d7);
151  printf("%lf %lf %lf\n", d8, d9, d10);
152  printf("%ld %ld\n", i6, i7);
153 
154  //return 0x1234;
155  return 1.23456;
156 }
157 
158 static long (*g)();
159 static double (*gf) (long i0, long i1, long i2,
160  long i3, long i4, long i5,
161  double d0, double d1, double d2, double d3,
162  double d4, double d5, double d6, double d7,
163  double d8, double d9,
164  long i6, long i7);
165 
166 long set_ifunc(long (*f) ())
167 {
168  g = f;
169  printf("set_ifunc, g = %lX\n", g);
170 }
171 
172 long set_ffunc(double (*f) ())
173 {
174  gf = (double (*) (long i0, long i1, long i2,
175  long i3, long i4, long i5,
176  double d0, double d1, double d2, double d3,
177  double d4, double d5, double d6, double d7,
178  double d8, double d9,
179  long i6, long i7))f;
180  printf("set_ffunc, gf = %lX\n", gf);
181 }
182 
183 long call_ifunc() {
184  printf("call_ifunc, g = %lX\n", g);
185  return g();
186 }
187 
188 double call_ffunc() {
189  printf("call_ffunc, gf = %lX\n", gf);
190  return gf(100,101,102,
191  103,104,105,
192  1000.0, 1010.0, 1020.0, 1030.0,
193  1040.0, 1050.0, 1060.0, 1070.0,
194  2080.0, 2090.0,
195  206, 207);
196 }
197 
199  return (sizeof(void *));
200 }
201 
203  return (sizeof(float));
204 }
205 
207  return (sizeof(double));
208 }
209 
211  return (sizeof(long));
212 }
213 
215  return (sizeof(int));
216 }
int int_test(long l, int i, short s)
Definition: test_foreign.c:89
long ret_long(long a, long b)
Definition: test_foreign.c:113
f
long call_ifunc()
Definition: test_foreign.c:183
long get_size_of_long()
Definition: test_foreign.c:210
static long(* g)()
Definition: test_foreign.c:158
long get_size_of_pointer()
Definition: test_foreign.c:198
GLfloat n[6][3]
Definition: cube.c:15
float ret_float(double a, double b)
Definition: test_foreign.c:97
int lv_test(int n, long *src)
Definition: test_foreign.c:47
long set_ifunc(long(*f)())
Definition: test_foreign.c:166
double test_testd(long i0, long i1, long i2, long i3, long i4, long i5, double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, long i6, long i7)
Definition: test_foreign.c:121
long l
Definition: structsize.c:3
double call_ffunc()
Definition: test_foreign.c:188
short s
Definition: structsize.c:2
int str_test(int n, char *src)
Definition: test_foreign.c:80
double ret_double(double a, double b)
Definition: test_foreign.c:105
int float_test(int n, float f1, float f2, float f3, float f4)
Definition: test_foreign.c:4
long get_size_of_int()
Definition: test_foreign.c:214
long get_size_of_float32()
Definition: test_foreign.c:202
double test_testd2(long i0, long i1, long i2, long i3, long i4, long i5, double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10, long i6, long i7)
Definition: test_foreign.c:139
int double_test(long n, double d1, double d2, double d3, double d4)
Definition: test_foreign.c:20
int iv_test(int n, int *src)
Definition: test_foreign.c:36
long get_size_of_double()
Definition: test_foreign.c:206
long set_ffunc(double(*f)())
Definition: test_foreign.c:172
static double(* gf)(long i0, long i1, long i2, long i3, long i4, long i5, double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, long i6, long i7)
Definition: test_foreign.c:159
int dv_test(int n, double *src)
Definition: test_foreign.c:69
int fv_test(int n, float *src)
Definition: test_foreign.c:58
char a[26]
Definition: freq.c:4


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Jun 6 2019 20:00:44