MCPcopy Create free account
hub / github.com/NVIDIA/cccl / getSymbol

Method getSymbol

c/parallel/src/hostjit/loader.cpp:147–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147void* DynamicLibrary::getSymbol(const std::string& symbol_name)
148{
149 if (!handle_)
150 {
151 last_error_ = "Library not loaded";
152 return nullptr;
153 }
154
155#ifdef _WIN32
156 SetLastError(0);
157 void* symbol = reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(handle_), symbol_name.c_str()));
158
159 if (!symbol)
160 {
161 last_error_ = getWindowsError();
162 if (last_error_.empty())
163 {
164 last_error_ = "Symbol not found: " + symbol_name;
165 }
166 return nullptr;
167 }
168#else
169 dlerror();
170 void* symbol = dlsym(handle_, symbol_name.c_str());
171
172 const char* error = dlerror();
173 if (error)
174 {
175 last_error_ = error;
176 return nullptr;
177 }
178#endif
179
180 last_error_.clear();
181 return symbol;
182}
183
184bool DynamicLibrary::isLoaded() const
185{

Callers

nothing calls this directly

Calls 3

getWindowsErrorFunction · 0.85
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected