1 // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 #include "ceed-backend-weak.h" 9 #include <ceed.h> 10 #include <ceed/backend.h> 11 #include <stdarg.h> 12 13 // LCOV_EXCL_START 14 // This function provides improved error messages for uncompiled backends 15 static int CeedInit_Weak(const char *resource, Ceed ceed) { 16 return CeedError(ceed, CEED_ERROR_UNSUPPORTED, "Backend not currently compiled: %s\nConsult the installation instructions to compile this backend", 17 resource); 18 } 19 20 // This function provides a debug target for weak symbols 21 int CeedRegister_Weak(const char *name, int num_prefixes, ...) { 22 va_list prefixes; 23 int ierr; 24 25 va_start(prefixes, num_prefixes); 26 for (int i = 0; i < num_prefixes; i++) { 27 const char *prefix = va_arg(prefixes, const char *); 28 29 CeedDebugEnv("Weak Register : %s", prefix); 30 ierr = CeedRegisterImpl(prefix, CeedInit_Weak, CEED_MAX_BACKEND_PRIORITY); 31 if (ierr) { 32 va_end(prefixes); // Prevent leak on error 33 return ierr; 34 } 35 } 36 va_end(prefixes); 37 return CEED_ERROR_SUCCESS; 38 } 39 // LCOV_EXCL_STOP 40