xref: /libCEED/rust/libceed-sys/c-src/backends/memcheck/ceed-memcheck-serial.c (revision 2b730f8b5a9c809740a0b3b302db43a719c636b1)
13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, 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.
31ef3f58fSjeremylt //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
51ef3f58fSjeremylt //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
71ef3f58fSjeremylt 
8ec3da8bcSJed Brown #include <ceed/backend.h>
9*2b730f8bSJeremy L Thompson #include <ceed/ceed.h>
103d576824SJeremy L Thompson #include <string.h>
11*2b730f8bSJeremy L Thompson 
121ef3f58fSjeremylt #include "ceed-memcheck.h"
131ef3f58fSjeremylt 
14f10650afSjeremylt //------------------------------------------------------------------------------
15f10650afSjeremylt // Backend Init
16f10650afSjeremylt //------------------------------------------------------------------------------
171ef3f58fSjeremylt static int CeedInit_Memcheck(const char *resource, Ceed ceed) {
18*2b730f8bSJeremy L Thompson   if (strcmp(resource, "/cpu/self/memcheck") && strcmp(resource, "/cpu/self/memcheck/serial")) {
191ef3f58fSjeremylt     // LCOV_EXCL_START
20*2b730f8bSJeremy L Thompson     return CeedError(ceed, CEED_ERROR_BACKEND, "Valgrind Memcheck backend cannot use resource: %s", resource);
211ef3f58fSjeremylt     // LCOV_EXCL_STOP
22*2b730f8bSJeremy L Thompson   }
231ef3f58fSjeremylt 
245f67fadeSJeremy L Thompson   // Create reference CEED that implementation will be dispatched
251ef3f58fSjeremylt   //   through unless overridden
26d1d35e2fSjeremylt   Ceed ceed_ref;
27*2b730f8bSJeremy L Thompson   CeedCallBackend(CeedInit("/cpu/self/ref/serial", &ceed_ref));
28*2b730f8bSJeremy L Thompson   CeedCallBackend(CeedSetDelegate(ceed, ceed_ref));
291ef3f58fSjeremylt 
30*2b730f8bSJeremy L Thompson   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Memcheck));
31*2b730f8bSJeremy L Thompson   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionContextCreate", CeedQFunctionContextCreate_Memcheck));
321ef3f58fSjeremylt 
33e15f9bd0SJeremy L Thompson   return CEED_ERROR_SUCCESS;
341ef3f58fSjeremylt }
351ef3f58fSjeremylt 
36f10650afSjeremylt //------------------------------------------------------------------------------
37f10650afSjeremylt // Backend Register
38f10650afSjeremylt //------------------------------------------------------------------------------
39*2b730f8bSJeremy L Thompson CEED_INTERN int CeedRegister_Memcheck_Serial(void) { return CeedRegister("/cpu/self/memcheck/serial", CeedInit_Memcheck, 100); }
40f10650afSjeremylt //------------------------------------------------------------------------------
41