Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add symbol visibility information to all the functions that are exported #36

Merged
merged 3 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ install(FILES ${qdldl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qdldl")
# Create qdldl shared library
add_library (qdldl SHARED ${qdldl_src} ${qdldl_headers})

# Declare that we are building the shared library to get proper symbol exports.
# Shared library consumers should also define QDLDL_SHARED_LIB to get the library
# exports properly, so we do it for them in the CMake interface by defining it as
# a PUBLIC compile definition.
target_compile_definitions(qdldl PRIVATE BUILDING_QDLDL)
target_compile_definitions(qdldl PUBLIC QDLDL_SHARED_LIB)

# Declare include directories for the cmake exported target
target_include_directories(qdldl
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
Expand Down
95 changes: 59 additions & 36 deletions include/qdldl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@
#include "qdldl_types.h"
#include "qdldl_version.h"

// Define the function attributes that are needed to mark functions as being
// visible for linking in the shared library version of QDLDL
#if defined(_WIN32)
# if defined(BUILDING_QDLDL)
# define QDLDL_API_EXPORT __declspec(dllexport)
# else
# define QDLDL_API_EXPORT __declspec(dllimport)
# endif
#else
# if defined(BUILDING_QDLDL)
# define QDLDL_API_EXPORT __attribute__((visibility("default")))
# else
# define QDLDL_API_EXPORT
# endif
#endif

// Only define API export parts when using the shared library
#if defined(QDLDL_SHARED_LIB)
# define QDLDL_API QDLDL_API_EXPORT
#else
# define QDLDL_API
#endif

# ifdef __cplusplus
extern "C" {
# endif // ifdef __cplusplus
Expand Down Expand Up @@ -44,12 +67,12 @@ extern "C" {
* Returns -2 if the return value overflows QDLDL_int.
*
*/
QDLDL_int QDLDL_etree(const QDLDL_int n,
const QDLDL_int* Ap,
const QDLDL_int* Ai,
QDLDL_int* work,
QDLDL_int* Lnz,
QDLDL_int* etree);
QDLDL_API QDLDL_int QDLDL_etree(const QDLDL_int n,
const QDLDL_int* Ap,
const QDLDL_int* Ai,
QDLDL_int* work,
QDLDL_int* Lnz,
QDLDL_int* etree);


/**
Expand Down Expand Up @@ -86,20 +109,20 @@ extern "C" {
* or otherwise LDL factorisable)
*
*/
QDLDL_int QDLDL_factor(const QDLDL_int n,
const QDLDL_int* Ap,
const QDLDL_int* Ai,
const QDLDL_float* Ax,
QDLDL_int* Lp,
QDLDL_int* Li,
QDLDL_float* Lx,
QDLDL_float* D,
QDLDL_float* Dinv,
const QDLDL_int* Lnz,
const QDLDL_int* etree,
QDLDL_bool* bwork,
QDLDL_int* iwork,
QDLDL_float* fwork);
QDLDL_API QDLDL_int QDLDL_factor(const QDLDL_int n,
const QDLDL_int* Ap,
const QDLDL_int* Ai,
const QDLDL_float* Ax,
QDLDL_int* Lp,
QDLDL_int* Li,
QDLDL_float* Lx,
QDLDL_float* D,
QDLDL_float* Dinv,
const QDLDL_int* Lnz,
const QDLDL_int* etree,
QDLDL_bool* bwork,
QDLDL_int* iwork,
QDLDL_float* fwork);


/**
Expand All @@ -116,12 +139,12 @@ QDLDL_int QDLDL_factor(const QDLDL_int n,
* @param x initialized to b. Equal to x on return
*
*/
void QDLDL_solve(const QDLDL_int n,
const QDLDL_int* Lp,
const QDLDL_int* Li,
const QDLDL_float* Lx,
const QDLDL_float* Dinv,
QDLDL_float* x);
QDLDL_API void QDLDL_solve(const QDLDL_int n,
const QDLDL_int* Lp,
const QDLDL_int* Li,
const QDLDL_float* Lx,
const QDLDL_float* Dinv,
QDLDL_float* x);


/**
Expand All @@ -137,11 +160,11 @@ void QDLDL_solve(const QDLDL_int n,
* @param x initialized to b. Equal to x on return
*
*/
void QDLDL_Lsolve(const QDLDL_int n,
const QDLDL_int* Lp,
const QDLDL_int* Li,
const QDLDL_float* Lx,
QDLDL_float* x);
QDLDL_API void QDLDL_Lsolve(const QDLDL_int n,
const QDLDL_int* Lp,
const QDLDL_int* Li,
const QDLDL_float* Lx,
QDLDL_float* x);


/**
Expand All @@ -157,11 +180,11 @@ void QDLDL_Lsolve(const QDLDL_int n,
* @param x initialized to b. Equal to x on return
*
*/
void QDLDL_Ltsolve(const QDLDL_int n,
const QDLDL_int* Lp,
const QDLDL_int* Li,
const QDLDL_float* Lx,
QDLDL_float* x);
QDLDL_API void QDLDL_Ltsolve(const QDLDL_int n,
const QDLDL_int* Lp,
const QDLDL_int* Li,
const QDLDL_float* Lx,
QDLDL_float* x);

# ifdef __cplusplus
}
Expand Down