[llvm] [flang-rt] Add the ability to have user supplied callback functions to further customize the runtime environment. (PR #155646)

Peter Klausler via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 28 10:16:49 PDT 2025


================
@@ -35,13 +36,33 @@ RT_API_ATTRS Fortran::common::optional<Convert> GetConvertFromString(
     const char *, std::size_t);
 
 struct ExecutionEnvironment {
+
+  typedef void (*ConfigEnvCallbackPtr)(
+      int, const char *[], const char *[], const EnvironmentDefaultList *);
+
 #if !defined(_OPENMP)
   // FIXME: https://github.com/llvm/llvm-project/issues/84942
   constexpr
 #endif
       ExecutionEnvironment(){};
   void Configure(int argc, const char *argv[], const char *envp[],
       const EnvironmentDefaultList *envDefaults);
+
+  // Optional callback routines to be invoked pre and post
+  // execution environment setup.
+  // RTNAME(RegisterConfigureEnv) will return true if callback
+  // function(s) is(are) successfully added to small array of
+  // pointers.  False if more than nConfigEnvCallback registrations
+  // for either pre or post functions.
+
+  static constexpr int nConfigEnvCallback{8};
+  int nPreConfigEnvCallback{0};
----------------
klausler wrote:

I don't think that you want to define a variable like this in a header file.

https://github.com/llvm/llvm-project/pull/155646


More information about the llvm-commits mailing list