From eb0a7cfb8da9c2ef9132234b1b074ad00a2e0305 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Fri, 15 Mar 2019 15:15:31 +0100 Subject: [PATCH] Export Fortran symbols Fixes #249 --- .travis.yml | 14 ++++---------- src/api/f77api.c | 8 ++++---- src/api/f77funcs_.h | 28 ++++++++++++++-------------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index e2c712d9..b4b3dda9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,13 +13,10 @@ matrix: - guile-2.0-dev - liboctave-dev - cmake - - g++-mingw-w64-i686 - - gcc-mingw-w64-i686 - - binutils-mingw-w64-i686 - - g++-mingw-w64-x86-64 - - gcc-mingw-w64-x86-64 - - binutils-mingw-w64-x86-64 - gfortran + - binutils-mingw-w64-x86-64 + - g++-mingw-w64-x86-64 + - gfortran-mingw-w64-x86-64 script: - pip install mkdocs python-markdown-math --user @@ -28,10 +25,7 @@ matrix: - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON .. - make install -j2 && ctest -j2 --output-on-failure - rm -rf * ~/.local - - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-i686-w64-mingw32.cmake .. - - make install -j2 - - rm -rf * ~/.local - - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake .. + - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake .. - make install -j2 - os: osx diff --git a/src/api/f77api.c b/src/api/f77api.c index 99b3d00b..f7a36430 100644 --- a/src/api/f77api.c +++ b/src/api/f77api.c @@ -82,12 +82,12 @@ static void f77_mfunc_wrap(unsigned m, double *result, unsigned n, const double /*-----------------------------------------------------------------------*/ -#define F77_GET(name,NAME,T) void F77_(nlo_get_##name,NLO_GET_##NAME)(T *val, nlopt_opt *opt) { *val = (T) nlopt_get_##name(*opt); } -#define F77_SET(name,NAME,T) void F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, *val); } +#define F77_GET(name,NAME,T) NLOPT_EXTERN(void) F77_(nlo_get_##name,NLO_GET_##NAME)(T *val, nlopt_opt *opt) { *val = (T) nlopt_get_##name(*opt); } +#define F77_SET(name,NAME,T) NLOPT_EXTERN(void) F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, *val); } #define F77_GETSET(name,NAME,T) F77_GET(name,NAME,T) F77_SET(name,NAME,T) -#define F77_GETA(name,NAME,T) void F77_(nlo_get_##name,NLO_GET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_get_##name(*opt, val); } -#define F77_SETA(name,NAME,T) void F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, val); } +#define F77_GETA(name,NAME,T) NLOPT_EXTERN(void) F77_(nlo_get_##name,NLO_GET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_get_##name(*opt, val); } +#define F77_SETA(name,NAME,T) NLOPT_EXTERN(void) F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, val); } #define F77_GETSETA(name,NAME,T) F77_GETA(name,NAME,T) F77_SETA(name,NAME,T) F77_SET(name##1,NAME##1,T) /*-----------------------------------------------------------------------*/ diff --git a/src/api/f77funcs_.h b/src/api/f77funcs_.h index 4bac153f..3a0a3ec1 100644 --- a/src/api/f77funcs_.h +++ b/src/api/f77funcs_.h @@ -31,7 +31,7 @@ The return value of a function is converted to the first argument of a subroutine. */ -void F77_(nlo_create, NLO_CREATE) (nlopt_opt * opt, int *alg, int *n) { +NLOPT_EXTERN(void) F77_(nlo_create, NLO_CREATE) (nlopt_opt * opt, int *alg, int *n) { if (*n < 0) *opt = NULL; else { @@ -40,19 +40,19 @@ void F77_(nlo_create, NLO_CREATE) (nlopt_opt * opt, int *alg, int *n) { } } -void F77_(nlo_copy, NLO_COPY) (nlopt_opt * nopt, nlopt_opt * opt) { +NLOPT_EXTERN(void) F77_(nlo_copy, NLO_COPY) (nlopt_opt * nopt, nlopt_opt * opt) { *nopt = nlopt_copy(*opt); } -void F77_(nlo_destroy, NLO_DESTROY) (nlopt_opt * opt) { +NLOPT_EXTERN(void) F77_(nlo_destroy, NLO_DESTROY) (nlopt_opt * opt) { nlopt_destroy(*opt); } -void F77_(nlo_optimize, NLO_OPTIMIZE) (int *ret, nlopt_opt * opt, double *x, double *optf) { +NLOPT_EXTERN(void) F77_(nlo_optimize, NLO_OPTIMIZE) (int *ret, nlopt_opt * opt, double *x, double *optf) { *ret = (int) nlopt_optimize(*opt, x, optf); } -void F77_(nlo_set_min_objective, NLO_SET_MIN_OBJECTIVE) (int *ret, nlopt_opt * opt, nlopt_f77_func f, void *f_data) { +NLOPT_EXTERN(void) F77_(nlo_set_min_objective, NLO_SET_MIN_OBJECTIVE) (int *ret, nlopt_opt * opt, nlopt_f77_func f, void *f_data) { f77_func_data *d = (f77_func_data *) malloc(sizeof(f77_func_data)); if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; @@ -63,7 +63,7 @@ void F77_(nlo_set_min_objective, NLO_SET_MIN_OBJECTIVE) (int *ret, nlopt_opt * o *ret = (int) nlopt_set_min_objective(*opt, f77_func_wrap, d); } -void F77_(nlo_set_max_objective, NLO_SET_MAX_OBJECTIVE) (int *ret, nlopt_opt * opt, nlopt_f77_func f, void *f_data) { +NLOPT_EXTERN(void) F77_(nlo_set_max_objective, NLO_SET_MAX_OBJECTIVE) (int *ret, nlopt_opt * opt, nlopt_f77_func f, void *f_data) { f77_func_data *d = (f77_func_data *) malloc(sizeof(f77_func_data)); if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; @@ -77,12 +77,12 @@ void F77_(nlo_set_max_objective, NLO_SET_MAX_OBJECTIVE) (int *ret, nlopt_opt * o F77_GET(algorithm, ALGORITHM, int) F77_GET(dimension, DIMENSION, int) F77_GETSETA(lower_bounds, LOWER_BOUNDS, double) F77_GETSETA(upper_bounds, UPPER_BOUNDS, double) -void F77_(nlo_remove_inequality_constraints, NLO_REMOVE_INEQUALITY_CONSTRAINTS) (int *ret, nlopt_opt * opt) +NLOPT_EXTERN(void) F77_(nlo_remove_inequality_constraints, NLO_REMOVE_INEQUALITY_CONSTRAINTS) (int *ret, nlopt_opt * opt) { *ret = (int) nlopt_remove_inequality_constraints(*opt); } -void F77_(nlo_add_inequality_constraint, NLO_ADD_INEQUALITY_CONSTRAINT) (int *ret, nlopt_opt * opt, nlopt_f77_func fc, void *fc_data, double *tol) { +NLOPT_EXTERN(void) F77_(nlo_add_inequality_constraint, NLO_ADD_INEQUALITY_CONSTRAINT) (int *ret, nlopt_opt * opt, nlopt_f77_func fc, void *fc_data, double *tol) { f77_func_data *d = (f77_func_data *) malloc(sizeof(f77_func_data)); if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; @@ -93,7 +93,7 @@ void F77_(nlo_add_inequality_constraint, NLO_ADD_INEQUALITY_CONSTRAINT) (int *re *ret = (int) nlopt_add_inequality_constraint(*opt, f77_func_wrap, d, *tol); } -void F77_(nlo_add_inequality_mconstraint, NLO_ADD_INEQUALITY_MCONSTRAINT) (int *ret, nlopt_opt * opt, int *m, nlopt_f77_mfunc mfc, void *mfc_data, double *tol) { +NLOPT_EXTERN(void) F77_(nlo_add_inequality_mconstraint, NLO_ADD_INEQUALITY_MCONSTRAINT) (int *ret, nlopt_opt * opt, int *m, nlopt_f77_mfunc mfc, void *mfc_data, double *tol) { f77_func_data *d; if (*m < 0) { *ret = (int) NLOPT_INVALID_ARGS; @@ -113,11 +113,11 @@ void F77_(nlo_add_inequality_mconstraint, NLO_ADD_INEQUALITY_MCONSTRAINT) (int * *ret = (int) nlopt_add_inequality_mconstraint(*opt, (unsigned) *m, f77_mfunc_wrap, d, tol); } -void F77_(nlo_remove_equality_constraints, NLO_REMOVE_EQUALITY_CONSTRAINTS) (int *ret, nlopt_opt * opt) { +NLOPT_EXTERN(void) F77_(nlo_remove_equality_constraints, NLO_REMOVE_EQUALITY_CONSTRAINTS) (int *ret, nlopt_opt * opt) { *ret = (int) nlopt_remove_equality_constraints(*opt); } -void F77_(nlo_add_equality_constraint, NLO_ADD_EQUALITY_CONSTRAINT) (int *ret, nlopt_opt * opt, nlopt_f77_func fc, void *fc_data, double *tol) { +NLOPT_EXTERN(void) F77_(nlo_add_equality_constraint, NLO_ADD_EQUALITY_CONSTRAINT) (int *ret, nlopt_opt * opt, nlopt_f77_func fc, void *fc_data, double *tol) { f77_func_data *d = (f77_func_data *) malloc(sizeof(f77_func_data)); if (!d) { *ret = (int) NLOPT_OUT_OF_MEMORY; @@ -128,7 +128,7 @@ void F77_(nlo_add_equality_constraint, NLO_ADD_EQUALITY_CONSTRAINT) (int *ret, n *ret = (int) nlopt_add_equality_constraint(*opt, f77_func_wrap, d, *tol); } -void F77_(nlo_add_equality_mconstraint, NLO_ADD_EQUALITY_MCONSTRAINT) (int *ret, nlopt_opt * opt, int *m, nlopt_f77_mfunc mfc, void *mfc_data, double *tol) { +NLOPT_EXTERN(void) F77_(nlo_add_equality_mconstraint, NLO_ADD_EQUALITY_MCONSTRAINT) (int *ret, nlopt_opt * opt, int *m, nlopt_f77_mfunc mfc, void *mfc_data, double *tol) { f77_func_data *d; if (*m < 0) { *ret = (int) NLOPT_INVALID_ARGS; @@ -153,7 +153,7 @@ F77_GETSET(ftol_rel, FTOL_REL, double) F77_GETSET(ftol_abs, FTOL_ABS, double) F77_GETSET(xtol_rel, XTOL_REL, double) F77_GETSETA(xtol_abs, XTOL_ABS, double) F77_GETSET(maxeval, MAXEVAL, int) F77_GET(numevals, NUMEVALS, int) F77_GETSET(maxtime, MAXTIME, double) F77_GETSET(force_stop, FORCE_STOP, int) -void F77_(nlo_force_stop, NLO_FORCE_STOP) (int *ret, nlopt_opt * opt) +NLOPT_EXTERN(void) F77_(nlo_force_stop, NLO_FORCE_STOP) (int *ret, nlopt_opt * opt) { *ret = (int) nlopt_force_stop(*opt); } @@ -161,7 +161,7 @@ void F77_(nlo_force_stop, NLO_FORCE_STOP) (int *ret, nlopt_opt * opt) F77_SET(local_optimizer, LOCAL_OPTIMIZER, nlopt_opt) F77_GETSET(population, POPULATION, unsigned) F77_GETSET(vector_storage, vector_storage, unsigned) F77_SETA(default_initial_step, DEFAULT_INITIAL_STEP, double) F77_SETA(initial_step, INITIAL_STEP, double) F77_SET(initial_step1, INITIAL_STEP1, double) -void F77_(nlo_get_initial_step, NLO_GET_INITIAL_STEP) (int *ret, nlopt_opt * opt, const double *x, double *dx) +NLOPT_EXTERN(void) F77_(nlo_get_initial_step, NLO_GET_INITIAL_STEP) (int *ret, nlopt_opt * opt, const double *x, double *dx) { *ret = (int) nlopt_get_initial_step(*opt, x, dx); }