[PATCH 4/7] Use gcc aliases instead of wrapping function calls

Peter Hutterer peter.hutterer at who-t.net
Wed Aug 21 22:05:48 PDT 2013


On Sat, Aug 17, 2013 at 01:58:16PM +0200, David Herrmann wrote:
> There is no reson to add the overhead of an additional function call if we
> can simply point the symbols at the same function.
> 
> Use gcc alias-attributes to point deprecated aliases to the new function
> calls and save some space.

yes, but no :)

we're still in early days and the API is not stable yet. Once we're
committed to something we can use this but these functions will simply be
dropped with the next release anyway.

Cheers,
   Peter

> Signed-off-by: David Herrmann <dh.herrmann at gmail.com>
> ---
>  libevdev/libevdev-int.h |  1 +
>  libevdev/libevdev.c     | 39 +++++++++++++++++++++++++--------------
>  2 files changed, 26 insertions(+), 14 deletions(-)
> 
> diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h
> index 7b6df65..a59eb65 100644
> --- a/libevdev/libevdev-int.h
> +++ b/libevdev/libevdev-int.h
> @@ -38,6 +38,7 @@
>  #define ABS_MT_MAX ABS_MT_TOOL_Y
>  #define ABS_MT_CNT (ABS_MT_MAX - ABS_MT_MIN + 1)
>  #define EXPORT __attribute__((visibility("default")))
> +#define ALIAS(_to) __attribute__((alias(#_to)))
>  
>  #undef min
>  #undef max
> diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
> index 9f81177..ef9318b 100644
> --- a/libevdev/libevdev.c
> +++ b/libevdev/libevdev.c
> @@ -684,16 +684,24 @@ EXPORT int libevdev_get_##name(const struct libevdev *dev) \
>  	return dev->ids.field; \
>  }
>  
> -PRODUCT_GETTER(product_id, product); /* DEPRECATED */
> -PRODUCT_GETTER(vendor_id, vendor); /* DEPRECATED */
> -PRODUCT_GETTER(bustype, bustype); /* DEPRECATED */
> -PRODUCT_GETTER(version, version); /* DEPRECATED */
> -
>  PRODUCT_GETTER(id_product, product);
>  PRODUCT_GETTER(id_vendor, vendor);
>  PRODUCT_GETTER(id_bustype, bustype);
>  PRODUCT_GETTER(id_version, version);
>  
> +/* DEPRECATED */
> +EXPORT int libevdev_get_product_id(const struct libevdev *dev)
> +ALIAS(libevdev_get_id_product);
> +/* DEPRECATED */
> +EXPORT int libevdev_get_vendor_id(const struct libevdev *dev)
> +ALIAS(libevdev_get_id_vendor);
> +/* DEPRECATED */
> +EXPORT int libevdev_get_bustype(const struct libevdev *dev)
> +ALIAS(libevdev_get_id_bustype);
> +/* DEPRECATED */
> +EXPORT int libevdev_get_version(const struct libevdev *dev)
> +ALIAS(libevdev_get_id_version);
> +
>  #define PRODUCT_SETTER(field) \
>  EXPORT void libevdev_set_id_##field(struct libevdev *dev, int field) \
>  { \
> @@ -839,14 +847,19 @@ EXPORT int libevdev_get_abs_##name(const struct libevdev *dev, unsigned int code
>  	return absinfo ? absinfo->field : 0; \
>  }
>  
> -ABS_GETTER(max, maximum); /* DEPRECATED */
> -ABS_GETTER(min, minimum); /* DEPRECATED */
>  ABS_GETTER(maximum, maximum);
>  ABS_GETTER(minimum, minimum);
>  ABS_GETTER(fuzz, fuzz)
>  ABS_GETTER(flat, flat)
>  ABS_GETTER(resolution, resolution)
>  
> +/* DEPRECATED */
> +EXPORT int libevdev_get_abs_max(const struct libevdev *dev, unsigned int code)
> +ALIAS(libevdev_get_abs_maximum);
> +/* DEPRECATED */
> +EXPORT int libevdev_get_abs_min(const struct libevdev *dev, unsigned int code)
> +ALIAS(libevdev_get_abs_minimum);
> +
>  #define ABS_SETTER(field) \
>  EXPORT void libevdev_set_abs_##field(struct libevdev *dev, unsigned int code, int val) \
>  { \
> @@ -1036,13 +1049,6 @@ libevdev_get_event_code_name(unsigned int type, unsigned int code)
>  	return event_type_map[type][code];
>  }
>  
> -/* DEPRECATED */
> -EXPORT const char*
> -libevdev_get_input_prop_name(unsigned int prop)
> -{
> -	return libevdev_get_property_name(prop);
> -}
> -
>  EXPORT const char*
>  libevdev_get_property_name(unsigned int prop)
>  {
> @@ -1052,6 +1058,11 @@ libevdev_get_property_name(unsigned int prop)
>  	return input_prop_map[prop];
>  }
>  
> +/* DEPRECATED */
> +EXPORT const char*
> +libevdev_get_input_prop_name(unsigned int prop)
> +ALIAS(libevdev_get_property_name);
> +
>  EXPORT int
>  libevdev_get_event_type_max(unsigned int type)
>  {
> -- 
> 1.8.3.4
> 


More information about the Input-tools mailing list