Permalink
Browse files

Merge pull request #39 from j-rivero/visibility

C visibility support
  • Loading branch information...
danfis committed Nov 14, 2017
2 parents 64f02f7 + d45672e commit 5677d384315d64c41a9e1dabe6a531f10ffbb7fb
Showing with 76 additions and 39 deletions.
  1. +10 −1 CMakeLists.txt
  2. +15 −1 src/CMakeLists.txt
  3. +1 −1 src/Makefile
  4. +2 −0 src/Makefile.am
  5. +6 −6 src/ccd/ccd.h
  6. +26 −0 src/ccd/ccd_export.h
  7. +0 −15 src/ccd/compiler.h
  8. +6 −5 src/ccd/vec3.h
  9. +9 −9 src/polytope.h
  10. +1 −1 src/support.h
View
@@ -4,7 +4,9 @@ if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
project(libccd C)
# Can not explicitly declared the software as C in project command due to bug:
# https://gitlab.kitware.com/cmake/cmake/issues/16967
project(libccd)
set(CCD_VERSION_MAJOR 2)
set(CCD_VERSION_MINOR 0)
@@ -23,6 +25,13 @@ option(BUILD_SHARED_LIBS "Build libccd as a shared library" ON)
option(ENABLE_DOUBLE_PRECISION
"Enable double precision computations instead of single precision" OFF)
# Option for some bundle-like build system in order not to expose
# any FCL binary symbols in their public ABI
option(CCD_HIDE_ALL_SYMBOLS "Hide all binary symbols" OFF)
if (CCD_HIDE_ALL_SYMBOLS)
add_definitions("-DCCD_STATIC_DEFINE")
endif()
# set the default build type
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING
View
@@ -21,6 +21,7 @@ configure_file(ccd/config.h.cmake.in ccd/config.h)
set(CCD_INCLUDES
ccd/ccd.h
ccd/compiler.h
ccd/ccd_export.h
ccd/quat.h
ccd/vec3.h
"${CMAKE_CURRENT_BINARY_DIR}/ccd/config.h")
@@ -69,6 +70,19 @@ install(TARGETS ccd
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(EXPORT ccd-targets DESTINATION "${CMAKE_INSTALL_LIBDIR}/ccd")
if(NOT WIN32 AND BUILD_TESTING)
macro (check_compiler_visibility)
include (CheckCXXCompilerFlag)
check_cxx_compiler_flag(-fvisibility=hidden COMPILER_SUPPORTS_VISIBILITY)
endmacro()
if(UNIX)
check_compiler_visibility()
if (COMPILER_SUPPORTS_VISIBILITY)
set_target_properties(ccd
PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
endif()
endif()
if(NOT WIN32 AND BUILD_TESTING AND NOT CCD_HIDE_ALL_SYMBOLS)
add_subdirectory(testsuites)
endif()
View
@@ -17,7 +17,7 @@
-include Makefile.include
CFLAGS += -I.
CFLAGS += -I. -fvisibility=hidden
TARGETS = libccd.a
OBJS = ccd.o mpr.o support.o vec3.o polytope.o
View
@@ -6,6 +6,7 @@ libccd_la_SOURCES = alloc.h \
ccd/compiler.h \
dbg.h \
ccd.c ccd/ccd.h \
ccd/ccd_export.h \
list.h \
polytope.c polytope.h \
ccd/quat.h \
@@ -14,3 +15,4 @@ libccd_la_SOURCES = alloc.h \
vec3.c ccd/vec3.h \
mpr.c
libccd_la_CFLAGS = -fvisibility=hidden
View
@@ -72,7 +72,7 @@ typedef struct _ccd_t ccd_t;
/**
* Default first direction.
*/
_ccd_export void ccdFirstDirDefault(const void *o1, const void *o2,
CCD_EXPORT void ccdFirstDirDefault(const void *o1, const void *o2,
ccd_vec3_t *dir);
#define CCD_INIT(ccd) \
@@ -93,7 +93,7 @@ _ccd_export void ccdFirstDirDefault(const void *o1, const void *o2,
/**
* Returns true if two given objects interest.
*/
_ccd_export int ccdGJKIntersect(const void *obj1, const void *obj2,
CCD_EXPORT int ccdGJKIntersect(const void *obj1, const void *obj2,
const ccd_t *ccd);
/**
@@ -104,7 +104,7 @@ _ccd_export int ccdGJKIntersect(const void *obj1, const void *obj2,
* vector. If obj1 and obj2 don't intersect -1 is returned.
* If memory allocation fails -2 is returned.
*/
_ccd_export int ccdGJKSeparate(const void *obj1, const void *obj2,
CCD_EXPORT int ccdGJKSeparate(const void *obj1, const void *obj2,
const ccd_t *ccd, ccd_vec3_t *sep);
/**
@@ -121,14 +121,14 @@ _ccd_export int ccdGJKSeparate(const void *obj1, const void *obj2,
* If obj1 and obj2 don't intersect -1 is returned.
* If memory allocation fails -2 is returned.
*/
_ccd_export int ccdGJKPenetration(const void *obj1, const void *obj2,
CCD_EXPORT int ccdGJKPenetration(const void *obj1, const void *obj2,
const ccd_t *ccd, ccd_real_t *depth,
ccd_vec3_t *dir, ccd_vec3_t *pos);
/**
* Returns true if two given objects intersect - MPR algorithm is used.
*/
_ccd_export int ccdMPRIntersect(const void *obj1, const void *obj2,
CCD_EXPORT int ccdMPRIntersect(const void *obj1, const void *obj2,
const ccd_t *ccd);
/**
@@ -143,7 +143,7 @@ _ccd_export int ccdMPRIntersect(const void *obj1, const void *obj2,
*
* Returns 0 if obj1 and obj2 intersect, otherwise -1 is returned.
*/
_ccd_export int ccdMPRPenetration(const void *obj1, const void *obj2,
CCD_EXPORT int ccdMPRPenetration(const void *obj1, const void *obj2,
const ccd_t *ccd, ccd_real_t *depth,
ccd_vec3_t *dir, ccd_vec3_t *pos);
View
@@ -0,0 +1,26 @@
#ifndef CCD_EXPORT_H
#define CCD_EXPORT_H
#ifdef CCD_STATIC_DEFINE
# define CCD_EXPORT
#else
# ifdef _MSC_VER
# ifdef ccd_EXPORTS
# define _ccd_export __declspec(dllexport)
# else /* ccd_EXPORTS */
# define _ccd_export __declspec(dllimport)
# endif /* ccd_EXPORTS */
# else
# ifndef CCD_EXPORT
# ifdef ccd_EXPORTS
/* We are building this library */
# define CCD_EXPORT __attribute__((visibility("default")))
# else
/* We are using this library */
# define CCD_EXPORT __attribute__((visibility("default")))
# endif
# endif
# endif
#endif
#endif
View
@@ -25,21 +25,6 @@
#define ccd_container_of(ptr, type, member) \
(type *)( (char *)ptr - ccd_offsetof(type, member))
/**
* Marks exported function.
*/
#ifdef _WIN32
# ifdef ccd_EXPORTS
# define _ccd_export __declspec(dllexport)
# else /* ccd_EXPORTS */
# define _ccd_export __declspec(dllimport)
# endif /* ccd_EXPORTS */
#else /* _WIN32 */
# define _ccd_export
#endif /* _WIN32 */
/**
* Marks inline function.
*/
View
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <ccd/compiler.h>
#include <ccd/config.h>
#include <ccd/ccd_export.h>
#ifdef __cplusplus
extern "C" {
@@ -93,13 +94,13 @@ typedef struct _ccd_vec3_t ccd_vec3_t;
/**
* Holds origin (0,0,0) - this variable is meant to be read-only!
*/
extern ccd_vec3_t *ccd_vec3_origin;
CCD_EXPORT extern ccd_vec3_t *ccd_vec3_origin;
/**
* Array of points uniformly distributed on unit sphere.
*/
extern ccd_vec3_t *ccd_points_on_sphere;
extern size_t ccd_points_on_sphere_len;
CCD_EXPORT extern ccd_vec3_t *ccd_points_on_sphere;
CCD_EXPORT extern size_t ccd_points_on_sphere_len;
/** Returns sign of value. */
_ccd_inline int ccdSign(ccd_real_t val);
@@ -184,7 +185,7 @@ _ccd_inline void ccdVec3Cross(ccd_vec3_t *d, const ccd_vec3_t *a, const ccd_vec3
* If witness is non-NULL it is filled with coordinates of point from which
* was computed distance to point P.
*/
_ccd_export ccd_real_t ccdVec3PointSegmentDist2(const ccd_vec3_t *P,
CCD_EXPORT ccd_real_t ccdVec3PointSegmentDist2(const ccd_vec3_t *P,
const ccd_vec3_t *a,
const ccd_vec3_t *b,
ccd_vec3_t *witness);
@@ -194,7 +195,7 @@ _ccd_export ccd_real_t ccdVec3PointSegmentDist2(const ccd_vec3_t *P,
* If witness vector is provided it is filled with coordinates of point
* from which was computed distance to point P.
*/
_ccd_export ccd_real_t ccdVec3PointTriDist2(const ccd_vec3_t *P,
CCD_EXPORT ccd_real_t ccdVec3PointTriDist2(const ccd_vec3_t *P,
const ccd_vec3_t *a,
const ccd_vec3_t *b,
const ccd_vec3_t *c,
View
@@ -101,8 +101,8 @@ struct _ccd_pt_t {
typedef struct _ccd_pt_t ccd_pt_t;
void ccdPtInit(ccd_pt_t *pt);
void ccdPtDestroy(ccd_pt_t *pt);
CCD_EXPORT void ccdPtInit(ccd_pt_t *pt);
CCD_EXPORT void ccdPtDestroy(ccd_pt_t *pt);
/**
* Returns vertices surrounding given triangle face.
@@ -134,20 +134,20 @@ _ccd_inline void ccdPtEdgeFaces(const ccd_pt_edge_t *e,
/**
* Adds vertex to polytope and returns pointer to newly created vertex.
*/
ccd_pt_vertex_t *ccdPtAddVertex(ccd_pt_t *pt, const ccd_support_t *v);
CCD_EXPORT ccd_pt_vertex_t *ccdPtAddVertex(ccd_pt_t *pt, const ccd_support_t *v);
_ccd_inline ccd_pt_vertex_t *ccdPtAddVertexCoords(ccd_pt_t *pt,
ccd_real_t x, ccd_real_t y, ccd_real_t z);
/**
* Adds edge to polytope.
*/
ccd_pt_edge_t *ccdPtAddEdge(ccd_pt_t *pt, ccd_pt_vertex_t *v1,
CCD_EXPORT ccd_pt_edge_t *ccdPtAddEdge(ccd_pt_t *pt, ccd_pt_vertex_t *v1,
ccd_pt_vertex_t *v2);
/**
* Adds face to polytope.
*/
ccd_pt_face_t *ccdPtAddFace(ccd_pt_t *pt, ccd_pt_edge_t *e1,
CCD_EXPORT ccd_pt_face_t *ccdPtAddFace(ccd_pt_t *pt, ccd_pt_edge_t *e1,
ccd_pt_edge_t *e2,
ccd_pt_edge_t *e3);
@@ -163,16 +163,16 @@ _ccd_inline int ccdPtDelFace(ccd_pt_t *pt, ccd_pt_face_t *);
/**
* Recompute distances from origin for all elements in pt.
*/
void ccdPtRecomputeDistances(ccd_pt_t *pt);
CCD_EXPORT void ccdPtRecomputeDistances(ccd_pt_t *pt);
/**
* Returns nearest element to origin.
*/
ccd_pt_el_t *ccdPtNearest(ccd_pt_t *pt);
CCD_EXPORT ccd_pt_el_t *ccdPtNearest(ccd_pt_t *pt);
void ccdPtDumpSVT(ccd_pt_t *pt, const char *fn);
void ccdPtDumpSVT2(ccd_pt_t *pt, FILE *);
CCD_EXPORT void ccdPtDumpSVT(ccd_pt_t *pt, const char *fn);
CCD_EXPORT void ccdPtDumpSVT2(ccd_pt_t *pt, FILE *);
/**** INLINES ****/
View
@@ -37,7 +37,7 @@ _ccd_inline void ccdSupportCopy(ccd_support_t *, const ccd_support_t *s);
* Computes support point of obj1 and obj2 in direction dir.
* Support point is returned via supp.
*/
void __ccdSupport(const void *obj1, const void *obj2,
CCD_EXPORT void __ccdSupport(const void *obj1, const void *obj2,
const ccd_vec3_t *dir, const ccd_t *ccd,
ccd_support_t *supp);

0 comments on commit 5677d38

Please sign in to comment.