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