utils: remove Xfuncproto.h and use our own macros

Add XKB_EXPORT to replace _X_EXPORT, and copy the definitions of
_X_ATTRIBUTE_FOO as ATTR_FOO.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-07-20 17:09:49 +03:00
parent 8b0e9f929c
commit 58f8d2c151
8 changed files with 75 additions and 56 deletions

View File

@ -45,7 +45,7 @@ struct xkb_context {
/**
* Append one directory to the context's include path.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_context_include_path_append(struct xkb_context *ctx, const char *path)
{
struct stat stat_buf;
@ -77,7 +77,7 @@ xkb_context_include_path_append(struct xkb_context *ctx, const char *path)
/**
* Append the default include directories to the context.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_context_include_path_append_default(struct xkb_context *ctx)
{
const char *home;
@ -101,7 +101,7 @@ xkb_context_include_path_append_default(struct xkb_context *ctx)
/**
* Remove all entries in the context's include path.
*/
_X_EXPORT void
XKB_EXPORT void
xkb_context_include_path_clear(struct xkb_context *ctx)
{
char **path;
@ -115,7 +115,7 @@ xkb_context_include_path_clear(struct xkb_context *ctx)
/**
* xkb_context_include_path_clear() + xkb_context_include_path_append_default()
*/
_X_EXPORT int
XKB_EXPORT int
xkb_context_include_path_reset_defaults(struct xkb_context *ctx)
{
xkb_context_include_path_clear(ctx);
@ -125,7 +125,7 @@ xkb_context_include_path_reset_defaults(struct xkb_context *ctx)
/**
* Returns the number of entries in the context's include path.
*/
_X_EXPORT unsigned int
XKB_EXPORT unsigned int
xkb_context_num_include_paths(struct xkb_context *ctx)
{
return darray_size(ctx->includes);
@ -135,7 +135,7 @@ xkb_context_num_include_paths(struct xkb_context *ctx)
* Returns the given entry in the context's include path, or NULL if an
* invalid index is passed.
*/
_X_EXPORT const char *
XKB_EXPORT const char *
xkb_context_include_path_get(struct xkb_context *ctx, unsigned int idx)
{
if (idx >= xkb_context_num_include_paths(ctx))
@ -153,7 +153,7 @@ xkb_context_take_file_id(struct xkb_context *ctx)
/**
* Take a new reference on the context.
*/
_X_EXPORT struct xkb_context *
XKB_EXPORT struct xkb_context *
xkb_context_ref(struct xkb_context *ctx)
{
ctx->refcnt++;
@ -164,7 +164,7 @@ xkb_context_ref(struct xkb_context *ctx)
* Drop an existing reference on the context, and free it if the refcnt is
* now 0.
*/
_X_EXPORT void
XKB_EXPORT void
xkb_context_unref(struct xkb_context *ctx)
{
if (--ctx->refcnt > 0)
@ -178,7 +178,7 @@ xkb_context_unref(struct xkb_context *ctx)
/**
* Create a new context.
*/
_X_EXPORT struct xkb_context *
XKB_EXPORT struct xkb_context *
xkb_context_new(enum xkb_context_flags flags)
{
struct xkb_context *ctx = calloc(1, sizeof(*ctx));

View File

@ -934,7 +934,7 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
return true;
}
_X_EXPORT char *
XKB_EXPORT char *
xkb_map_get_as_string(struct xkb_keymap *keymap)
{
char *ret = NULL;

View File

@ -843,7 +843,7 @@ struct codepair {
{ 0xffbd, 0x003d }, /* KP_Equal = EQUAL SIGN */
};
_X_EXPORT uint32_t
XKB_EXPORT uint32_t
xkb_keysym_to_utf32(xkb_keysym_t keysym)
{
int min = 0;
@ -943,7 +943,7 @@ utf32_to_utf8(uint32_t unichar, char *buffer)
return length + 1;
}
_X_EXPORT int
XKB_EXPORT int
xkb_keysym_to_utf8(xkb_keysym_t keysym, char *buffer, size_t size)
{
uint32_t codepoint;

View File

@ -32,7 +32,7 @@
#include "xkb-priv.h"
#include "ks_tables.h"
_X_EXPORT void
XKB_EXPORT void
xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size)
{
int i, n, h, idx;
@ -80,7 +80,7 @@ xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size)
snprintf(buffer, size, "0x%08x", ks);
}
_X_EXPORT xkb_keysym_t
XKB_EXPORT xkb_keysym_t
xkb_keysym_from_name(const char *s)
{
int i, n, h, c, idx;

View File

@ -54,7 +54,7 @@
/**
* Returns the total number of modifiers active in the keymap.
*/
_X_EXPORT xkb_mod_index_t
XKB_EXPORT xkb_mod_index_t
xkb_map_num_mods(struct xkb_keymap *keymap)
{
xkb_mod_index_t i;
@ -71,7 +71,7 @@ xkb_map_num_mods(struct xkb_keymap *keymap)
/**
* Return the name for a given modifier.
*/
_X_EXPORT const char *
XKB_EXPORT const char *
xkb_map_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx)
{
if (idx >= xkb_map_num_mods(keymap))
@ -106,7 +106,7 @@ xkb_map_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx)
/**
* Returns the index for a named modifier.
*/
_X_EXPORT xkb_mod_index_t
XKB_EXPORT xkb_mod_index_t
xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_mod_index_t i;
@ -139,7 +139,7 @@ xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name)
/**
* Return the total number of active groups in the keymap.
*/
_X_EXPORT xkb_group_index_t
XKB_EXPORT xkb_group_index_t
xkb_map_num_groups(struct xkb_keymap *keymap)
{
xkb_group_index_t ret = 0;
@ -155,7 +155,7 @@ xkb_map_num_groups(struct xkb_keymap *keymap)
/**
* Returns the name for a given group.
*/
_X_EXPORT const char *
XKB_EXPORT const char *
xkb_map_group_get_name(struct xkb_keymap *keymap, xkb_group_index_t idx)
{
if (idx >= xkb_map_num_groups(keymap))
@ -167,7 +167,7 @@ xkb_map_group_get_name(struct xkb_keymap *keymap, xkb_group_index_t idx)
/**
* Returns the index for a named group.
*/
_X_EXPORT xkb_group_index_t
XKB_EXPORT xkb_group_index_t
xkb_map_group_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_group_index_t num_groups = xkb_map_num_groups(keymap);
@ -184,7 +184,7 @@ xkb_map_group_get_index(struct xkb_keymap *keymap, const char *name)
/**
* Returns the number of groups active for a particular key.
*/
_X_EXPORT xkb_group_index_t
XKB_EXPORT xkb_group_index_t
xkb_key_num_groups(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
if (XkbKeycodeInRange(keymap, kc))
@ -195,7 +195,7 @@ xkb_key_num_groups(struct xkb_keymap *keymap, xkb_keycode_t kc)
/**
* Return the total number of active LEDs in the keymap.
*/
_X_EXPORT xkb_led_index_t
XKB_EXPORT xkb_led_index_t
xkb_map_num_leds(struct xkb_keymap *keymap)
{
xkb_led_index_t ret = 0;
@ -213,7 +213,7 @@ xkb_map_num_leds(struct xkb_keymap *keymap)
/**
* Returns the name for a given group.
*/
_X_EXPORT const char *
XKB_EXPORT const char *
xkb_map_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx)
{
if (idx >= xkb_map_num_leds(keymap))
@ -225,7 +225,7 @@ xkb_map_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx)
/**
* Returns the index for a named group.
*/
_X_EXPORT xkb_group_index_t
XKB_EXPORT xkb_group_index_t
xkb_map_led_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_led_index_t num_leds = xkb_map_num_leds(keymap);
@ -336,7 +336,7 @@ err:
* Provides the symbols to use for the given key and state. Returns the
* number of symbols pointed to in syms_out.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_key_get_syms(struct xkb_state *state, xkb_keycode_t kc,
const xkb_keysym_t **syms_out)
{
@ -368,7 +368,7 @@ err:
/**
* Simple boolean specifying whether or not the key should repeat.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_key_repeats(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
if (!XkbKeycodeInRange(keymap, kc))

View File

@ -479,7 +479,7 @@ xkb_filter_apply_all(struct xkb_state *state, xkb_keycode_t kc,
return;
}
_X_EXPORT struct xkb_state *
XKB_EXPORT struct xkb_state *
xkb_state_new(struct xkb_keymap *keymap)
{
struct xkb_state *ret;
@ -497,14 +497,14 @@ xkb_state_new(struct xkb_keymap *keymap)
return ret;
}
_X_EXPORT struct xkb_state *
XKB_EXPORT struct xkb_state *
xkb_state_ref(struct xkb_state *state)
{
state->refcnt++;
return state;
}
_X_EXPORT void
XKB_EXPORT void
xkb_state_unref(struct xkb_state *state)
{
state->refcnt--;
@ -517,7 +517,7 @@ xkb_state_unref(struct xkb_state *state)
free(state);
}
_X_EXPORT struct xkb_keymap *
XKB_EXPORT struct xkb_keymap *
xkb_state_get_map(struct xkb_state *state)
{
return state->keymap;
@ -593,7 +593,7 @@ xkb_state_update_derived(struct xkb_state *state)
* Given a particular key event, updates the state structure to reflect the
* new modifiers.
*/
_X_EXPORT void
XKB_EXPORT void
xkb_state_update_key(struct xkb_state *state, xkb_keycode_t kc,
enum xkb_key_direction direction)
{
@ -634,7 +634,7 @@ xkb_state_update_key(struct xkb_state *state, xkb_keycode_t kc,
* lossy, and should only be used to update a slave state mirroring the
* master, e.g. in a client/server window system.
*/
_X_EXPORT void
XKB_EXPORT void
xkb_state_update_mask(struct xkb_state *state,
xkb_mod_mask_t base_mods,
xkb_mod_mask_t latched_mods,
@ -669,7 +669,7 @@ xkb_state_update_mask(struct xkb_state *state,
* Serialises the requested modifier state into an xkb_mod_mask_t, with all
* the same disclaimers as in xkb_state_update_mask.
*/
_X_EXPORT xkb_mod_mask_t
XKB_EXPORT xkb_mod_mask_t
xkb_state_serialize_mods(struct xkb_state *state,
enum xkb_state_component type)
{
@ -692,7 +692,7 @@ xkb_state_serialize_mods(struct xkb_state *state,
* Serialises the requested group state, with all the same disclaimers as
* in xkb_state_update_mask.
*/
_X_EXPORT xkb_group_index_t
XKB_EXPORT xkb_group_index_t
xkb_state_serialize_group(struct xkb_state *state,
enum xkb_state_component type)
{
@ -715,7 +715,7 @@ xkb_state_serialize_group(struct xkb_state *state,
* Returns 1 if the given modifier is active with the specified type(s), 0 if
* not, or -1 if the modifier is invalid.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_state_mod_index_is_active(struct xkb_state *state,
xkb_mod_index_t idx,
enum xkb_state_component type)
@ -760,7 +760,7 @@ match_mod_masks(struct xkb_state *state, enum xkb_state_match match,
* Returns 1 if the modifiers are active with the specified type(s), 0 if
* not, or -1 if any of the modifiers are invalid.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_state_mod_indices_are_active(struct xkb_state *state,
enum xkb_state_component type,
enum xkb_state_match match,
@ -793,7 +793,7 @@ xkb_state_mod_indices_are_active(struct xkb_state *state,
* Returns 1 if the given modifier is active with the specified type(s), 0 if
* not, or -1 if the modifier is invalid.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type)
{
@ -809,7 +809,7 @@ xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
* Returns 1 if the modifiers are active with the specified type(s), 0 if
* not, or -1 if any of the modifiers are invalid.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_state_mod_names_are_active(struct xkb_state *state,
enum xkb_state_component type,
enum xkb_state_match match,
@ -845,7 +845,7 @@ xkb_state_mod_names_are_active(struct xkb_state *state,
* Returns 1 if the given group is active with the specified type(s), 0 if
* not, or -1 if the group is invalid.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_state_group_index_is_active(struct xkb_state *state,
xkb_group_index_t idx,
enum xkb_state_component type)
@ -869,7 +869,7 @@ xkb_state_group_index_is_active(struct xkb_state *state,
* Returns 1 if the given modifier is active with the specified type(s), 0 if
* not, or -1 if the modifier is invalid.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_state_group_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type)
{
@ -884,7 +884,7 @@ xkb_state_group_name_is_active(struct xkb_state *state, const char *name,
/**
* Returns 1 if the given LED is active, 0 if not, or -1 if the LED is invalid.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
{
if (idx >= xkb_map_num_leds(state->keymap))
@ -896,7 +896,7 @@ xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
/**
* Returns 1 if the given LED is active, 0 if not, or -1 if the LED is invalid.
*/
_X_EXPORT int
XKB_EXPORT int
xkb_state_led_name_is_active(struct xkb_state *state, const char *name)
{
xkb_led_index_t idx = xkb_map_led_get_index(state->keymap, name);

View File

@ -33,8 +33,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xfuncproto.h>
/*
* We sometimes malloc strings and then expose them as const char*'s. This
* macro is used when we free these strings in order to avoid -Wcast-qual
@ -46,40 +44,61 @@
#define uStringText(s) ((s) == NULL ? "<NullString>" : (s))
#define uStrCasePrefix(s1, s2) (strncasecmp((s1), (s2), strlen(s1)) == 0)
/***====================================================================***/
/* Compiler Attributes */
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__)
# define XKB_EXPORT __attribute__((visibility("default")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
# define XKB_EXPORT __global
#else /* not gcc >= 4 and not Sun Studio >= 8 */
# define XKB_EXPORT
#endif
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
# define ATTR_PRINTF(x,y) __attribute__((__format__(__printf__, x, y)))
#else /* not gcc >= 2.3 */
# define ATTR_PRINTF(x,y)
#endif
#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
|| (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
# define ATTR_NORETURN __attribute__((__noreturn__))
#else
# define ATTR_NORETURN
#endif /* GNUC */
extern bool
uSetErrorFile(char *name);
#define INFO uInformation
extern _X_ATTRIBUTE_PRINTF(1, 2) void
ATTR_PRINTF(1, 2) void
uInformation(const char *s, ...);
#define ACTION uAction
extern _X_ATTRIBUTE_PRINTF(1, 2) void
ATTR_PRINTF(1, 2) void
uAction(const char *s, ...);
#define WARN uWarning
extern _X_ATTRIBUTE_PRINTF(1, 2) void
ATTR_PRINTF(1, 2) void
uWarning(const char *s, ...);
#define ERROR uError
extern _X_ATTRIBUTE_PRINTF(1, 2) void
ATTR_PRINTF(1, 2) void
uError(const char *s, ...);
#define FATAL uFatalError
extern _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN void
ATTR_PRINTF(1, 2) ATTR_NORETURN void
uFatalError(const char *s, ...);
/* WSGO stands for "Weird Stuff Going On" (wtf???) */
#define WSGO uInternalError
extern _X_ATTRIBUTE_PRINTF(1, 2) void
ATTR_PRINTF(1, 2) void
uInternalError(const char *s, ...);
#endif /* UTILS_H */

View File

@ -231,7 +231,7 @@ xkb_map_new_from_kccgst(struct xkb_context *ctx,
return keymap;
}
_X_EXPORT struct xkb_keymap *
XKB_EXPORT struct xkb_keymap *
xkb_map_new_from_names(struct xkb_context *ctx,
const struct xkb_rule_names *rmlvo,
enum xkb_map_compile_flags flags)
@ -262,7 +262,7 @@ xkb_map_new_from_names(struct xkb_context *ctx,
return keymap;
}
_X_EXPORT struct xkb_keymap *
XKB_EXPORT struct xkb_keymap *
xkb_map_new_from_string(struct xkb_context *ctx,
const char *string,
enum xkb_keymap_format format,
@ -293,7 +293,7 @@ xkb_map_new_from_string(struct xkb_context *ctx,
return keymap;
}
_X_EXPORT struct xkb_keymap *
XKB_EXPORT struct xkb_keymap *
xkb_map_new_from_file(struct xkb_context *ctx,
FILE *file,
enum xkb_keymap_format format,
@ -324,14 +324,14 @@ xkb_map_new_from_file(struct xkb_context *ctx,
return keymap;
}
_X_EXPORT struct xkb_keymap *
XKB_EXPORT struct xkb_keymap *
xkb_map_ref(struct xkb_keymap *keymap)
{
keymap->refcnt++;
return keymap;
}
_X_EXPORT void
XKB_EXPORT void
xkb_map_unref(struct xkb_keymap *keymap)
{
if (!keymap || --keymap->refcnt > 0)