xref: /libCEED/backends/memcheck/ceed-memcheck-blocked.c (revision caee03026e6576cbf7a399c2fc51bb918c77f451)
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
25   //   through unless overridden
26   Ceed ceed_ref;
27   CeedCallBackend(CeedInit("/cpu/self/ref/blocked", &ceed_ref));
28   CeedCallBackend(CeedSetDelegate(ceed, ceed_ref));
29 
30   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Memcheck));
31   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionContextCreate", CeedQFunctionContextCreate_Memcheck));
32 
33   return CEED_ERROR_SUCCESS;
34 }
35 
36 //------------------------------------------------------------------------------
37 // Backend Register
38 //------------------------------------------------------------------------------
39 CEED_INTERN int CeedRegister_Memcheck_Blocked(void) { return CeedRegister("/cpu/self/memcheck/blocked", CeedInit_Memcheck, 110); }
40 //------------------------------------------------------------------------------
41