xref: /libCEED/rust/libceed-sys/c-src/interface/ceed-qfunction-register.c (revision 9ba83ac0e4b1fca39d6fa6737a318a9f0cbc172d)
1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
33d8e8822SJeremy L Thompson //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
53d8e8822SJeremy L Thompson //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
73d8e8822SJeremy L Thompson 
849aac155SJeremy L Thompson #include <ceed.h>
9ec3da8bcSJed Brown #include <ceed/backend.h>
1049aac155SJeremy L Thompson #include <stdbool.h>
111d013790SJed Brown 
121d013790SJed Brown static bool register_all_called;
131d013790SJed Brown 
1449aac155SJeremy L Thompson #define CEED_GALLERY_QFUNCTION(name) CEED_INTERN int name(void);
151d013790SJed Brown #include "../gallery/ceed-gallery-list.h"
1649aac155SJeremy L Thompson #undef CEED_GALLERY_QFUNCTION
171d013790SJed Brown 
181d013790SJed Brown /**
19ca94c3ddSJeremy L Thompson   @brief Register the gallery of pre-configured @ref CeedQFunction.
201d013790SJed Brown 
21ca94c3ddSJeremy L Thompson   This is called automatically by @ref CeedQFunctionCreateInteriorByName() and thus normally need not be called by users.
22ca94c3ddSJeremy L Thompson   Users can call @ref CeedQFunctionRegister() to register additional backends.
231d013790SJed Brown 
241d013790SJed Brown   @return An error code: 0 - success, otherwise - failure
251d013790SJed Brown 
261d013790SJed Brown   @sa CeedQFunctionRegister()
271d013790SJed Brown 
28ded9b81dSJeremy L Thompson   @ref User
291d013790SJed Brown **/
30360501f4SSebastian Grimberg int CeedQFunctionRegisterAll(void) {
3158c07c4fSSebastian Grimberg   int ierr = 0;
3258c07c4fSSebastian Grimberg 
3358c07c4fSSebastian Grimberg   CeedPragmaCritical(CeedQFunctionRegisterAll) {
3458c07c4fSSebastian Grimberg     if (!register_all_called) {
35c21e34e2SJeremy L Thompson       CeedDebugEnv256(CEED_DEBUG_COLOR_SUCCESS, "\n---------- Registering Gallery QFunctions ----------\n");
3658c07c4fSSebastian Grimberg #define CEED_GALLERY_QFUNCTION(name) \
3758c07c4fSSebastian Grimberg   if (!ierr) ierr = name();
381d013790SJed Brown #include "../gallery/ceed-gallery-list.h"
3949aac155SJeremy L Thompson #undef CEED_GALLERY_QFUNCTION
4058c07c4fSSebastian Grimberg       register_all_called = true;
4158c07c4fSSebastian Grimberg     }
4258c07c4fSSebastian Grimberg   }
4358c07c4fSSebastian Grimberg   return ierr;
441d013790SJed Brown }
45