From 753f11f3881eac51da49c5bb2c2eebc99bd47410 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Thu, 28 Apr 2011 14:46:17 +0200 Subject: Use visibility macros instead of symbol map Signed-off-by: Jussi Pakkanen Signed-off-by: Henrik Rydberg --- include/grail-bits.h | 33 ++++++++++++++++++++++++++++----- include/grail.h | 25 +++++++++++++------------ 2 files changed, 41 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/grail-bits.h b/include/grail-bits.h index c151c11..dfe5367 100644 --- a/include/grail-bits.h +++ b/include/grail-bits.h @@ -27,6 +27,26 @@ extern "C" { #endif +/* Macros that set symbol visibilities in shared libraries properly. + * Adapted from http://gcc.gnu.org/wiki/Visibility + */ + +#if defined _WIN32 || defined __CYGWIN__ + #ifdef BUILDING_GRAIL + #define GRAIL_PUBLIC __declspec(dllexport) + #else + #define GRAIL_PUBLIC __declspec(dllimport) + #endif + #define GRAIL_PRIVATE +#else + #if defined __GNUC__ + #define GRAIL_PUBLIC __attribute__ ((visibility("default"))) + #define GRAIL_PRIVATE __attribute__ ((visibility("hidden"))) + #else + #error "Unsupported compiler." + #endif +#endif + typedef unsigned char grail_mask_t; static inline void grail_mask_set(grail_mask_t *mask, int i) @@ -52,12 +72,15 @@ static inline int grail_mask_get(const grail_mask_t *mask, int i) return (mask[i >> 3] >> (i & 7)) & 1; } -void grail_mask_set_mask(grail_mask_t *a, const grail_mask_t *b, int bytes); -void grail_mask_clear_mask(grail_mask_t *a, const grail_mask_t *b, int bytes); +void GRAIL_PUBLIC grail_mask_set_mask(grail_mask_t *a, const grail_mask_t *b, + int bytes); +void GRAIL_PUBLIC grail_mask_clear_mask(grail_mask_t *a, const grail_mask_t *b, + int bytes); -int grail_mask_count(const grail_mask_t *mask, int bytes); -int grail_mask_get_first(const grail_mask_t *mask, int bytes); -int grail_mask_get_next(int i, const grail_mask_t *mask, int bytes); +int GRAIL_PUBLIC grail_mask_count(const grail_mask_t *mask, int bytes); +int GRAIL_PUBLIC grail_mask_get_first(const grail_mask_t *mask, int bytes); +int GRAIL_PUBLIC grail_mask_get_next(int i, const grail_mask_t *mask, + int bytes); #define grail_mask_foreach(i, mask, bytes) \ for (i = grail_mask_get_first(mask, bytes); \ diff --git a/include/grail.h b/include/grail.h index d61197d..d21d9e8 100644 --- a/include/grail.h +++ b/include/grail.h @@ -179,7 +179,7 @@ struct grail { * * Returns zero on success, negative error number otherwise. */ -int grail_open(struct grail *ge, int fd); +int GRAIL_PUBLIC grail_open(struct grail *ge, int fd); /** * grail_idle - check state of kernel device @@ -190,7 +190,7 @@ int grail_open(struct grail *ge, int fd); * Returns true if the device is idle, i.e., there are no fetched * events in the pipe and there is nothing to fetch from the device. */ -int grail_idle(struct grail *ge, int fd, int ms); +int GRAIL_PUBLIC grail_idle(struct grail *ge, int fd, int ms); /** * grail_pull - pull and process available events from the kernel device @@ -206,7 +206,7 @@ int grail_idle(struct grail *ge, int fd, int ms); * On success, returns the number of events read. Otherwise, * a standard negative error number is returned. */ -int grail_pull(struct grail *ge, int fd); +int GRAIL_PUBLIC grail_pull(struct grail *ge, int fd); /** * grail_close - close the grail device @@ -216,7 +216,7 @@ int grail_pull(struct grail *ge, int fd); * Deallocates all memory associated with grail, and clears the grail * structure. */ -void grail_close(struct grail *ge, int fd); +void GRAIL_PUBLIC grail_close(struct grail *ge, int fd); /** * grail_set_bbox - set the grail unit bounding box @@ -226,9 +226,9 @@ void grail_close(struct grail *ge, int fd); * * Sets the box within which the device coordinates should be presented. */ -void grail_set_bbox(struct grail *ge, - const struct grail_coord *min, - const struct grail_coord *max); +void GRAIL_PUBLIC grail_set_bbox(struct grail *ge, + const struct grail_coord *min, + const struct grail_coord *max); /** * grail_filter_abs_events - filter kernel motion events @@ -241,7 +241,7 @@ void grail_set_bbox(struct grail *ge, * stream. * */ -void grail_filter_abs_events(struct grail *ge, int usage); +void GRAIL_PUBLIC grail_filter_abs_events(struct grail *ge, int usage); /** * grail_get_units - get device coordinate ranges @@ -255,8 +255,9 @@ void grail_filter_abs_events(struct grail *ge, int usage); * function. This function reports the device coordinate ranges. * */ -void grail_get_units(const struct grail *ge, - struct grail_coord *min, struct grail_coord *max); +void GRAIL_PUBLIC grail_get_units(const struct grail *ge, + struct grail_coord *min, + struct grail_coord *max); /** * grail_get_contacts - get current contact state @@ -267,8 +268,8 @@ void grail_get_units(const struct grail *ge, * Extract the contact state as currently seen by grail. * */ -int grail_get_contacts(const struct grail *ge, - struct grail_contact *touch, int max_touch); +int GRAIL_PUBLIC grail_get_contacts(const struct grail *ge, + struct grail_contact *touch, int max_touch); #ifdef __cplusplus } -- cgit v1.2.3