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 --- configure.ac | 1 - include/grail-bits.h | 33 ++++++++++++++++++++++++++++----- include/grail.h | 25 +++++++++++++------------ src/Makefile.am | 5 +++-- src/grail-api.c | 14 +++++++------- src/grail-bits.c | 12 +++++++----- src/grail-event.c | 4 ++-- src/grail-inserter.c | 6 +++--- utouch-grail.sym.in | 13 ------------- 9 files changed, 63 insertions(+), 50 deletions(-) delete mode 100644 utouch-grail.sym.in diff --git a/configure.ac b/configure.ac index 37fa429..f40631d 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,5 @@ AC_CONFIG_FILES([Makefile src/Makefile tools/Makefile test/Makefile - utouch-grail.sym utouch-grail.pc]) AC_OUTPUT 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 } diff --git a/src/Makefile.am b/src/Makefile.am index da1a46e..c344342 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,6 @@ lib_LTLIBRARIES = libutouch-grail.la libutouch_grail_la_LDFLAGS = \ -version-info @LIB_VERSION@ \ - -export-symbols ../utouch-grail.sym \ -lm \ $(MTDEV_LIBS) \ $(EVEMU_LIBS) \ @@ -28,7 +27,9 @@ libutouch_grail_la_SOURCES = \ grail-impl.h \ grail-api.c -AM_CFLAGS = $(CWARNFLAGS) +# These are flags required to properly set up +# the build. -fvisibility requires GCC > 4 (or clang) +AM_CFLAGS = $(CWARNFLAGS) -DBUILDING_GRAIL -fvisibility=hidden INCLUDES = -I$(top_srcdir)/include/ diff --git a/src/grail-api.c b/src/grail-api.c index 5a0beb4..259f5a0 100644 --- a/src/grail-api.c +++ b/src/grail-api.c @@ -34,13 +34,13 @@ #define DIM_FRAMES 100 #define FRAME_RATE 100 -void grail_filter_abs_events(struct grail *ge, int usage) +void GRAIL_PUBLIC grail_filter_abs_events(struct grail *ge, int usage) { struct grail_impl *x = ge->impl; x->filter_abs = usage; } -int grail_open(struct grail *ge, int fd) +int GRAIL_PUBLIC grail_open(struct grail *ge, int fd) { struct grail_impl *x; struct stat fs; @@ -116,7 +116,7 @@ int grail_open(struct grail *ge, int fd) return ret; } -void grail_close(struct grail *ge, int fd) +void GRAIL_PUBLIC grail_close(struct grail *ge, int fd) { struct grail_impl *x = ge->impl; gru_destroy(ge); @@ -131,7 +131,7 @@ void grail_close(struct grail *ge, int fd) ge->impl = 0; } -int grail_idle(struct grail *ge, int fd, int ms) +int GRAIL_PUBLIC grail_idle(struct grail *ge, int fd, int ms) { struct grail_impl *x = ge->impl; if (x->fptest) @@ -141,8 +141,8 @@ int grail_idle(struct grail *ge, int fd, int ms) return 1; } -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) { struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh); min->x = s->min_x; @@ -287,7 +287,7 @@ static int grail_pull_fstest(struct grail *ge, int fd) return count > 0 ? count : -1; } -int grail_pull(struct grail *ge, int fd) +int GRAIL_PUBLIC grail_pull(struct grail *ge, int fd) { struct grail_impl *impl = ge->impl; struct input_event ev; diff --git a/src/grail-bits.c b/src/grail-bits.c index 4c8b941..8ebfb18 100644 --- a/src/grail-bits.c +++ b/src/grail-bits.c @@ -46,19 +46,21 @@ static const int grail_first_set_bit[256] = 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, }; -void grail_mask_set_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) { while (bytes--) *a++ |= *b++; } -void grail_mask_clear_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) { while (bytes--) *a++ &= ~*b++; } -int grail_mask_count(const grail_mask_t *mask, int bytes) +int GRAIL_PUBLIC grail_mask_count(const grail_mask_t *mask, int bytes) { int count = 0; while (bytes--) @@ -66,7 +68,7 @@ int grail_mask_count(const grail_mask_t *mask, int bytes) return count; } -int grail_mask_get_first(const grail_mask_t *mask, int bytes) +int GRAIL_PUBLIC grail_mask_get_first(const grail_mask_t *mask, int bytes) { int k; for (k = 0; k < bytes; k++) @@ -75,7 +77,7 @@ int grail_mask_get_first(const grail_mask_t *mask, int bytes) return -1; } -int grail_mask_get_next(int i, const grail_mask_t *mask, int bytes) +int GRAIL_PUBLIC grail_mask_get_next(int i, const grail_mask_t *mask, int bytes) { int k = ++i >> 3; if (k < bytes) { diff --git a/src/grail-event.c b/src/grail-event.c index 504ed10..bb75a06 100644 --- a/src/grail-event.c +++ b/src/grail-event.c @@ -118,8 +118,8 @@ void gin_send_event(struct grail *ge, struct slot_state *s, } } -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) { const struct gesture_inserter *gin = ge->gin; const struct utouch_frame *frame = ge->impl->frame; diff --git a/src/grail-inserter.c b/src/grail-inserter.c index ab81ece..8a10b2e 100644 --- a/src/grail-inserter.c +++ b/src/grail-inserter.c @@ -288,9 +288,9 @@ void gin_gid_end(struct grail *ge, int gid, s->status = GRAIL_STATUS_END; } -void grail_set_bbox(struct grail *ge, - const struct grail_coord *tmin, - const struct grail_coord *tmax) +void GRAIL_PUBLIC grail_set_bbox(struct grail *ge, + const struct grail_coord *tmin, + const struct grail_coord *tmax) { struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh); diff --git a/utouch-grail.sym.in b/utouch-grail.sym.in deleted file mode 100644 index e2039ff..0000000 --- a/utouch-grail.sym.in +++ /dev/null @@ -1,13 +0,0 @@ -grail_close -grail_filter_abs_events -grail_get_contacts -grail_get_units -grail_idle -grail_mask_clear_mask -grail_mask_count -grail_mask_get_first -grail_mask_get_next -grail_mask_set_mask -grail_open -grail_pull -grail_set_bbox -- cgit v1.2.3