From e25d7d06e35287c86b617a06ad947bb210f206a1 Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Thu, 13 Jun 2024 15:58:15 -0400 Subject: [PATCH] Update cutest_delegate.f90 --- .github/workflows/meson.yml | 40 ++++++++++++++++++++++++++++++++++- src/tools/cutest_delegate.f90 | 31 +++++++++++++++------------ 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml index ae8a55a..4931449 100644 --- a/.github/workflows/meson.yml +++ b/.github/workflows/meson.yml @@ -7,7 +7,7 @@ on: types: [opened, synchronize, reopened] jobs: build: - name: ${{ matrix.os }}/${{ matrix.compiler }}-v${{ matrix.version }}/Int${{ matrix.int }} + name: ${{ matrix.os }}/${{ matrix.compiler }}-v${{ matrix.version }}/Mode-${{ matrix.mode }}/Int${{ matrix.int }} strategy: fail-fast: false matrix: @@ -15,32 +15,69 @@ jobs: arch: ['x64'] version: ['11'] int: ['32', '64'] + mode: ['static', 'shared'] include: - compiler: gcc - os: ubuntu-latest compiler: intel-classic version: '2021.10' int: '32' + mode: 'static' + - os: ubuntu-latest + compiler: intel-classic + version: '2021.10' + int: '32' + mode: 'shared' + - os: ubuntu-latest + compiler: intel-classic + version: '2021.10' + int: '64' + mode: 'static' - os: ubuntu-latest compiler: intel-classic version: '2021.10' int: '64' + mode: 'shared' + - os: windows-latest + compiler: intel + version: '2023.2' + int: '32' + mode: 'static' - os: windows-latest compiler: intel version: '2023.2' int: '32' + mode: 'shared' - os: windows-latest compiler: intel version: '2023.2' int: '64' + mode: 'static' + - os: windows-latest + compiler: intel + version: '2023.2' + int: '64' + mode: 'shared' + - os: ubuntu-latest + compiler: intel + version: '2023.2' + int: '32' + mode: 'static' - os: ubuntu-latest compiler: intel version: '2023.2' int: '32' + mode: 'shared' + - os: ubuntu-latest + compiler: intel + version: '2023.2' + int: '64' + mode: 'static' - os: ubuntu-latest compiler: intel version: '2023.2' int: '64' + mode: 'shared' # - os: ubuntu-latest # compiler: nvidia-hpc # version: '24.05' @@ -81,6 +118,7 @@ jobs: fi meson setup builddir --buildtype=debug \ --prefix=$GITHUB_WORKSPACE/cutest \ + -Ddefault_library=${mode} \ -Dquadruple=true \ -Dcutest_int64=$INT64 diff --git a/src/tools/cutest_delegate.f90 b/src/tools/cutest_delegate.f90 index f477c2b..3d7285c 100644 --- a/src/tools/cutest_delegate.f90 +++ b/src/tools/cutest_delegate.f90 @@ -18,28 +18,36 @@ #define RANGE_BIND_NAME "range_" #endif +#ifdef _WIN32 +#define DLOPEN_BIND_NAME LoadLibrary +#define DLSYM_BIND_NAME GetProcAddress +#else +#define DLOPEN_BIND_NAME dlopen +#define DLSYM_BIND_NAME dlsym +#endif + module cutest_delegate_r use, intrinsic :: iso_c_binding implicit none - ! Interface pour dlopen + ! Interface for dlopen / LoadLibrary interface - function dlopen(name, mode) bind(C, name="dlopen") + function cutest_dlopen(name, mode) bind(C, name=DLOPEN_BIND_NAME) use iso_c_binding, only: c_ptr, c_int, c_char type(c_ptr) :: dlopen character(kind=c_char), dimension(*) :: name integer(kind=c_int) :: mode - end function dlopen + end function cutest_dlopen end interface - ! Interface pour dlsym + ! Interface for dlsym / GetProcAddress interface - function dlsym(handle, symbol) bind(C, name="dlsym") + function cutest_dlsym(handle, symbol) bind(C, name=DLSYM_BIND_NAME) use iso_c_binding, only: c_funptr, c_ptr, c_char type(c_funptr) :: dlsym type(c_ptr), value :: handle character(kind=c_char), dimension(*) :: symbol - end function dlsym + end function cutest_dlsym end interface ! Constantes pour les modes d'ouverture de bibliothèques @@ -65,15 +73,15 @@ subroutine load_routines(libname) bind(C, name=LOAD_ROUTINE_NAME) character(kind=c_char), dimension(*), intent(in) :: libname ! Charge la bibliothèque dynamique - lib_handle = dlopen(libname, RTLD_LAZY) + lib_handle = cutest_dlopen(libname, RTLD_LAZY) if (.not. c_associated(lib_handle)) then stop "Unable to load library" end if ! Récupère les adresses des fonctions - ptr_elfun = dlsym(lib_handle, "elfun"//c_null_char) - ptr_group = dlsym(lib_handle, "group"//c_null_char) - ptr_range = dlsym(lib_handle, "range"//c_null_char) + ptr_elfun = cutest_dlsym(lib_handle, ELFUN_BIND_NAME//c_null_char) + ptr_group = cutest_dlsym(lib_handle, GROUP_BIND_NAME//c_null_char) + ptr_range = cutest_dlsym(lib_handle, RANGE_BIND_NAME//c_null_char) ! Associe les pointeurs de procédure Fortran avec les adresses obtenues call c_f_procpointer(ptr_elfun, fun_elfun) @@ -81,7 +89,6 @@ subroutine load_routines(libname) bind(C, name=LOAD_ROUTINE_NAME) call c_f_procpointer(ptr_range, fun_range) end subroutine load_routines - ! Routine pour appeler la fonction elfun subroutine elfun() bind(C, name=ELFUN_BIND_NAME) if (associated(fun_elfun)) then call fun_elfun() @@ -90,7 +97,6 @@ subroutine elfun() bind(C, name=ELFUN_BIND_NAME) end if end subroutine elfun - ! Routine pour appeler la fonction group subroutine group() bind(C, name=GROUP_BIND_NAME) if (associated(fun_group)) then call fun_group() @@ -99,7 +105,6 @@ subroutine group() bind(C, name=GROUP_BIND_NAME) end if end subroutine group - ! Routine pour appeler la fonction range subroutine range() bind(C, name=RANGE_BIND_NAME) if (associated(fun_range)) then call fun_range()