xref: /libCEED/rust/libceed-sys/c-src/include/ceed-fortran-name.h (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
1*3d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2*3d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
304822c1eSjeremylt //
4*3d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
504822c1eSjeremylt //
6*3d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
704822c1eSjeremylt 
8734e90feSThilina Rathnayake #ifndef _ceed_fortran_name_h
9734e90feSThilina Rathnayake #define _ceed_fortran_name_h
10734e90feSThilina Rathnayake 
11734e90feSThilina Rathnayake /* establishes some macros to establish
12734e90feSThilina Rathnayake    * the FORTRAN naming convention
13734e90feSThilina Rathnayake      default      gs_setup, etc.
14734e90feSThilina Rathnayake      -DUPCASE     GS_SETUP, etc.
15734e90feSThilina Rathnayake      -DUNDERSCORE gs_setup_, etc.
16734e90feSThilina Rathnayake    * a prefix for all external (non-FORTRAN) function names
17734e90feSThilina Rathnayake      for example, -DPREFIX=jl_   transforms fail -> jl_fail
18734e90feSThilina Rathnayake    * a prefix for all external FORTRAN function names
19734e90feSThilina Rathnayake      for example, -DFPREFIX=jlf_ transforms gs_setup_ -> jlf_gs_setup_
20734e90feSThilina Rathnayake */
21734e90feSThilina Rathnayake 
22734e90feSThilina Rathnayake /* the following macro functions like a##b,
23734e90feSThilina Rathnayake    but will expand a and/or b if they are themselves macros */
24734e90feSThilina Rathnayake #define TOKEN_PASTE_(a,b) a##b
25734e90feSThilina Rathnayake #define TOKEN_PASTE(a,b) TOKEN_PASTE_(a,b)
26734e90feSThilina Rathnayake 
27734e90feSThilina Rathnayake #ifdef PREFIX
28734e90feSThilina Rathnayake #  define PREFIXED_NAME(x) TOKEN_PASTE(PREFIX,x)
29734e90feSThilina Rathnayake #else
30734e90feSThilina Rathnayake #  define PREFIXED_NAME(x) x
31734e90feSThilina Rathnayake #endif
32734e90feSThilina Rathnayake 
33734e90feSThilina Rathnayake #ifdef FPREFIX
34734e90feSThilina Rathnayake #  define FPREFIXED_NAME(x) TOKEN_PASTE(FPREFIX,x)
35734e90feSThilina Rathnayake #else
36734e90feSThilina Rathnayake #  define FPREFIXED_NAME(x) x
37734e90feSThilina Rathnayake #endif
38734e90feSThilina Rathnayake 
39734e90feSThilina Rathnayake #if defined(UPCASE)
40734e90feSThilina Rathnayake #  define FORTRAN_NAME(low,up) FPREFIXED_NAME(up)
41734e90feSThilina Rathnayake #  define FORTRAN_UNPREFIXED(low,up) up
42734e90feSThilina Rathnayake #elif defined(UNDERSCORE)
43734e90feSThilina Rathnayake #  define FORTRAN_NAME(low,up) FPREFIXED_NAME(TOKEN_PASTE(low,_))
44734e90feSThilina Rathnayake #  define FORTRAN_UNPREFIXED(low,up) TOKEN_PASTE(low,_)
45734e90feSThilina Rathnayake #else
46734e90feSThilina Rathnayake #  define FORTRAN_NAME(low,up) FPREFIXED_NAME(low)
47734e90feSThilina Rathnayake #  define FORTRAN_UNPREFIXED(low,up) low
48734e90feSThilina Rathnayake #endif
49734e90feSThilina Rathnayake 
50734e90feSThilina Rathnayake #endif
51