1/*  Passing from fortran to C by value, using VALUE.  This is identical
2    to c_by_val_1.c, which performs the same function for %VAL.
3
4    Contributed by Paul Thomas <pault@gcc.gnu.org>  */
5
6/* We used to #include <complex.h>, but this fails for some platforms
7   (like cygwin) who don't have it yet.  */
8#define complex __complex__
9#define _Complex_I (1.0iF)
10
11extern float *f_to_f__ (float, float*);
12extern int *i_to_i__ (int, int*);
13extern void c_to_c__ (complex float*, complex float, complex float*);
14extern void abort (void);
15
16/* In f_to_f and i_to_i we return the second argument, so that we do
17   not have to worry about keeping track of memory allocation between
18   fortran and C.  All three functions check that the argument passed
19   by value is the same as that passed by reference.  Then the passed
20   by value argument is modified so that the caller can check that
21   its version has not changed.*/
22
23float *
24f_to_f__(float a1, float *a2)
25{
26  if ( a1 != *a2 ) abort();
27  *a2 = a1 * 2.0;
28  a1 = 0.0;
29  return a2;
30}
31
32int *
33i_to_i__(int i1, int *i2)
34{
35  if ( i1 != *i2 ) abort();
36  *i2 = i1 * 3;
37  i1 = 0;
38  return i2;
39}
40
41void
42c_to_c__(complex float *retval, complex float c1, complex float *c2)
43{
44  if ( c1 != *c2 ) abort();
45  c1 = 0.0 + 0.0 * _Complex_I;
46  *retval = *c2 * 4.0;
47  return;
48}
49
50