Pixar Arch
Loading...
Searching...
No Matches
library.h
Go to the documentation of this file.
1// Copyright 2016 Pixar
2//
3// Licensed under the terms set forth in the LICENSE.txt file available at
4// https://openusd.org/license.
5//
6// Modified by Jeremy Retailleau.
7
8#ifndef PXR_ARCH_LIBRARY_H
9#define PXR_ARCH_LIBRARY_H
10
11#include "./api.h"
12
13#include <string>
14
15#if defined(ARCH_OS_WINDOWS)
16# define ARCH_LIBRARY_LAZY 0
17# define ARCH_LIBRARY_NOW 0
18# define ARCH_LIBRARY_LOCAL 0
19# define ARCH_LIBRARY_GLOBAL 0
20# define ARCH_LIBRARY_SUFFIX ".dll"
21# define ARCH_STATIC_LIBRARY_SUFFIX ".lib"
22#else
23# include <dlfcn.h>
24# define ARCH_LIBRARY_LAZY RTLD_LAZY
25# define ARCH_LIBRARY_NOW RTLD_NOW
26# define ARCH_LIBRARY_LOCAL RTLD_LOCAL
27# define ARCH_LIBRARY_GLOBAL RTLD_GLOBAL
28# if defined(ARCH_OS_DARWIN)
29# define ARCH_LIBRARY_SUFFIX ".dylib"
30# else
31# define ARCH_LIBRARY_SUFFIX ".so"
32# endif
33# define ARCH_STATIC_LIBRARY_SUFFIX ".a"
34#endif
35
36// On MacOS shared libraries and loadable modules (aka loadable bundles aka
37// plugins) are different entities. Most cross-platform software packages
38// that create loadable modules use .so as the extension on MacOS for
39// compatibility, so we use that here.
40#if defined(ARCH_OS_DARWIN)
41# define ARCH_PLUGIN_SUFFIX ".so"
42#else
43# define ARCH_PLUGIN_SUFFIX ARCH_LIBRARY_SUFFIX
44#endif
45
46namespace pxr {
47
50
55ARCH_API
56void* ArchLibraryOpen(const std::string &filename, int flag);
57
60ARCH_API
61std::string ArchLibraryError();
62
64ARCH_API
65int ArchLibraryClose(void* handle);
66
72ARCH_API
73void* ArchLibraryGetSymbolAddress(void* handle, const char* name);
74
75} // namespace pxr
76
77#endif // PXR_ARCH_LIBRARY_H
ARCH_API void * ArchLibraryGetSymbolAddress(void *handle, const char *name)
Obtain the address of a symbol defined within an object opened with ArchLibraryOpen.
ARCH_API std::string ArchLibraryError()
Obtain a description of the most recent error that occurred from ArchLibraryOpen.
ARCH_API int ArchLibraryClose(void *handle)
Closes an object opened with ArchLibraryOpen.
ARCH_API void * ArchLibraryOpen(const std::string &filename, int flag)
library.h Architecture dependent loading and unloading of dynamic libraries.