annotate src/fftw-3.3.8/api/f77api.c @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents bd3cc4d1df30
children
rev   line source
cannam@167 1 /*
cannam@167 2 * Copyright (c) 2003, 2007-14 Matteo Frigo
cannam@167 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
cannam@167 4 *
cannam@167 5 * This program is free software; you can redistribute it and/or modify
cannam@167 6 * it under the terms of the GNU General Public License as published by
cannam@167 7 * the Free Software Foundation; either version 2 of the License, or
cannam@167 8 * (at your option) any later version.
cannam@167 9 *
cannam@167 10 * This program is distributed in the hope that it will be useful,
cannam@167 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@167 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@167 13 * GNU General Public License for more details.
cannam@167 14 *
cannam@167 15 * You should have received a copy of the GNU General Public License
cannam@167 16 * along with this program; if not, write to the Free Software
cannam@167 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cannam@167 18 *
cannam@167 19 */
cannam@167 20
cannam@167 21 #include "api/api.h"
cannam@167 22 #include "dft/dft.h"
cannam@167 23 #include "rdft/rdft.h"
cannam@167 24
cannam@167 25 #include "api/x77.h"
cannam@167 26
cannam@167 27 /* if F77_FUNC is not defined, then we don't know how to mangle identifiers
cannam@167 28 for the Fortran linker, and we must omit the f77 API. */
cannam@167 29 #if defined(F77_FUNC) || defined(WINDOWS_F77_MANGLING)
cannam@167 30
cannam@167 31 /*-----------------------------------------------------------------------*/
cannam@167 32 /* some internal functions used by the f77 api */
cannam@167 33
cannam@167 34 /* in fortran, the natural array ordering is column-major, which
cannam@167 35 corresponds to reversing the dimensions relative to C's row-major */
cannam@167 36 static int *reverse_n(int rnk, const int *n)
cannam@167 37 {
cannam@167 38 int *nrev;
cannam@167 39 int i;
cannam@167 40 A(FINITE_RNK(rnk));
cannam@167 41 nrev = (int *) MALLOC(sizeof(int) * (unsigned)rnk, PROBLEMS);
cannam@167 42 for (i = 0; i < rnk; ++i)
cannam@167 43 nrev[rnk - i - 1] = n[i];
cannam@167 44 return nrev;
cannam@167 45 }
cannam@167 46
cannam@167 47 /* f77 doesn't have data structures, so we have to pass iodims as
cannam@167 48 parallel arrays */
cannam@167 49 static X(iodim) *make_dims(int rnk, const int *n,
cannam@167 50 const int *is, const int *os)
cannam@167 51 {
cannam@167 52 X(iodim) *dims;
cannam@167 53 int i;
cannam@167 54 A(FINITE_RNK(rnk));
cannam@167 55 dims = (X(iodim) *) MALLOC(sizeof(X(iodim)) * (unsigned)rnk, PROBLEMS);
cannam@167 56 for (i = 0; i < rnk; ++i) {
cannam@167 57 dims[i].n = n[i];
cannam@167 58 dims[i].is = is[i];
cannam@167 59 dims[i].os = os[i];
cannam@167 60 }
cannam@167 61 return dims;
cannam@167 62 }
cannam@167 63
cannam@167 64 typedef struct {
cannam@167 65 void (*f77_write_char)(char *, void *);
cannam@167 66 void *data;
cannam@167 67 } write_char_data;
cannam@167 68
cannam@167 69 static void write_char(char c, void *d)
cannam@167 70 {
cannam@167 71 write_char_data *ad = (write_char_data *) d;
cannam@167 72 ad->f77_write_char(&c, ad->data);
cannam@167 73 }
cannam@167 74
cannam@167 75 typedef struct {
cannam@167 76 void (*f77_read_char)(int *, void *);
cannam@167 77 void *data;
cannam@167 78 } read_char_data;
cannam@167 79
cannam@167 80 static int read_char(void *d)
cannam@167 81 {
cannam@167 82 read_char_data *ed = (read_char_data *) d;
cannam@167 83 int c;
cannam@167 84 ed->f77_read_char(&c, ed->data);
cannam@167 85 return (c < 0 ? EOF : c);
cannam@167 86 }
cannam@167 87
cannam@167 88 static X(r2r_kind) *ints2kinds(int rnk, const int *ik)
cannam@167 89 {
cannam@167 90 if (!FINITE_RNK(rnk) || rnk == 0)
cannam@167 91 return 0;
cannam@167 92 else {
cannam@167 93 int i;
cannam@167 94 X(r2r_kind) *k;
cannam@167 95
cannam@167 96 k = (X(r2r_kind) *) MALLOC(sizeof(X(r2r_kind)) * (unsigned)rnk, PROBLEMS);
cannam@167 97 /* reverse order for Fortran -> C */
cannam@167 98 for (i = 0; i < rnk; ++i)
cannam@167 99 k[i] = (X(r2r_kind)) ik[rnk - 1 - i];
cannam@167 100 return k;
cannam@167 101 }
cannam@167 102 }
cannam@167 103
cannam@167 104 /*-----------------------------------------------------------------------*/
cannam@167 105
cannam@167 106 #define F77(a, A) F77x(x77(a), X77(A))
cannam@167 107
cannam@167 108 #ifndef WINDOWS_F77_MANGLING
cannam@167 109
cannam@167 110 #if defined(F77_FUNC)
cannam@167 111 # define F77x(a, A) F77_FUNC(a, A)
cannam@167 112 # include "f77funcs.h"
cannam@167 113 #endif
cannam@167 114
cannam@167 115 /* If identifiers with underscores are mangled differently than those
cannam@167 116 without underscores, then we include *both* mangling versions. The
cannam@167 117 reason is that the only Fortran compiler that does such differing
cannam@167 118 mangling is currently g77 (which adds an extra underscore to names
cannam@167 119 with underscores), whereas other compilers running on the same
cannam@167 120 machine are likely to use non-underscored mangling. (I'm sick
cannam@167 121 of users complaining that FFTW works with g77 but not with e.g.
cannam@167 122 pgf77 or ifc on the same machine.) Note that all FFTW identifiers
cannam@167 123 contain underscores, and configure picks g77 by default. */
cannam@167 124 #if defined(F77_FUNC_) && !defined(F77_FUNC_EQUIV)
cannam@167 125 # undef F77x
cannam@167 126 # define F77x(a, A) F77_FUNC_(a, A)
cannam@167 127 # include "f77funcs.h"
cannam@167 128 #endif
cannam@167 129
cannam@167 130 #else /* WINDOWS_F77_MANGLING */
cannam@167 131
cannam@167 132 /* Various mangling conventions common (?) under Windows. */
cannam@167 133
cannam@167 134 /* g77 */
cannam@167 135 # define WINDOWS_F77_FUNC(a, A) a ## __
cannam@167 136 # define F77x(a, A) WINDOWS_F77_FUNC(a, A)
cannam@167 137 # include "f77funcs.h"
cannam@167 138
cannam@167 139 /* Intel, etc. */
cannam@167 140 # undef WINDOWS_F77_FUNC
cannam@167 141 # define WINDOWS_F77_FUNC(a, A) a ## _
cannam@167 142 # include "f77funcs.h"
cannam@167 143
cannam@167 144 /* Digital/Compaq/HP Visual Fortran, Intel Fortran. stdcall attribute
cannam@167 145 is apparently required to adjust for calling conventions (callee
cannam@167 146 pops stack in stdcall). See also:
cannam@167 147 http://msdn.microsoft.com/library/en-us/vccore98/html/_core_mixed.2d.language_programming.3a_.overview.asp
cannam@167 148 */
cannam@167 149 # undef WINDOWS_F77_FUNC
cannam@167 150 # if defined(__GNUC__)
cannam@167 151 # define WINDOWS_F77_FUNC(a, A) __attribute__((stdcall)) A
cannam@167 152 # elif defined(_MSC_VER) || defined(_ICC) || defined(_STDCALL_SUPPORTED)
cannam@167 153 # define WINDOWS_F77_FUNC(a, A) __stdcall A
cannam@167 154 # else
cannam@167 155 # define WINDOWS_F77_FUNC(a, A) A /* oh well */
cannam@167 156 # endif
cannam@167 157 # include "f77funcs.h"
cannam@167 158
cannam@167 159 #endif /* WINDOWS_F77_MANGLING */
cannam@167 160
cannam@167 161 #endif /* F77_FUNC */