1 // Copyright (c) 2017-2022, 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.h> 9 #include <ceed/ceed.h> 10 #include <string.h> 11 12 #include "ceed-memcheck.h" 13 14 //------------------------------------------------------------------------------ 15 // Backend Init 16 //------------------------------------------------------------------------------ 17 static int CeedInit_Memcheck(const char *resource, Ceed ceed) { 18 if (strcmp(resource, "/cpu/self/memcheck/blocked")) { 19 // LCOV_EXCL_START 20 return CeedError(ceed, CEED_ERROR_BACKEND, "Valgrind Memcheck backend cannot use resource: %s", resource); 21 // LCOV_EXCL_STOP 22 } 23 24 // Create reference Ceed that implementation will be dispatched through unless overridden 25 Ceed ceed_ref; 26 CeedCallBackend(CeedInit("/cpu/self/ref/blocked", &ceed_ref)); 27 CeedCallBackend(CeedSetDelegate(ceed, ceed_ref)); 28 29 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Memcheck)); 30 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionContextCreate", CeedQFunctionContextCreate_Memcheck)); 31 32 return CEED_ERROR_SUCCESS; 33 } 34 35 //------------------------------------------------------------------------------ 36 // Backend Register 37 //------------------------------------------------------------------------------ 38 CEED_INTERN int CeedRegister_Memcheck_Blocked(void) { return CeedRegister("/cpu/self/memcheck/blocked", CeedInit_Memcheck, 110); } 39 //------------------------------------------------------------------------------ 40