Unified multiple definitions of container_of() macro.
Removed duplicate definitions of the container_of() macro and refactored sources to use the single implementation. Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
This commit is contained in:
parent
d618f688d5
commit
867d50eea7
|
@ -40,6 +40,7 @@
|
|||
#include <wayland-client.h>
|
||||
|
||||
#include "window.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct clickdot {
|
||||
struct display *display;
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "window.h"
|
||||
#include "shared/cairo-util.h"
|
||||
#include "shared/config-parser.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
#include "desktop-shell-client-protocol.h"
|
||||
|
||||
|
|
|
@ -33,10 +33,6 @@
|
|||
#include "shared/zalloc.h"
|
||||
#include "shared/platform.h"
|
||||
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
struct window;
|
||||
struct widget;
|
||||
struct display;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <linux/input.h>
|
||||
|
||||
#include "shell.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct exposay_surface {
|
||||
struct desktop_shell *shell;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "shell.h"
|
||||
#include "desktop-shell-server-protocol.h"
|
||||
#include "input-method-server-protocol.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct input_panel_surface {
|
||||
struct wl_resource *resource;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "compositor.h"
|
||||
#include "fullscreen-shell-server-protocol.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct fullscreen_shell {
|
||||
struct wl_client *client;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
|
||||
#include "ivi-layout-export.h"
|
||||
#include "ivi-hmi-controller-server-protocol.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* structure, globals
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "ivi-shell.h"
|
||||
#include "input-method-server-protocol.h"
|
||||
#include "ivi-layout-private.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct input_panel_surface {
|
||||
struct wl_resource *resource;
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "ivi-layout-export.h"
|
||||
#include "ivi-layout-private.h"
|
||||
|
||||
#include "shared/helpers.h"
|
||||
#include "shared/os-compatibility.h"
|
||||
|
||||
struct link_layer {
|
||||
|
|
|
@ -39,10 +39,7 @@
|
|||
|
||||
#include <wayland-util.h>
|
||||
#include "config-parser.h"
|
||||
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#include "helpers.h"
|
||||
|
||||
struct weston_config_entry {
|
||||
char *key;
|
||||
|
|
|
@ -52,6 +52,43 @@ extern "C" {
|
|||
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns a pointer the the containing struct of a given member item.
|
||||
*
|
||||
* To demonstrate, the following example retrieves a pointer to
|
||||
* `example_container` given only its `destroy_listener` member:
|
||||
*
|
||||
* @code
|
||||
* struct example_container {
|
||||
* struct wl_listener destroy_listener;
|
||||
* // other members...
|
||||
* };
|
||||
*
|
||||
* void example_container_destroy(struct wl_listener *listener, void *data)
|
||||
* {
|
||||
* struct example_container *ctr;
|
||||
*
|
||||
* ctr = wl_container_of(listener, ctr, destroy_listener);
|
||||
* // destroy ctr...
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @param ptr A valid pointer to the contained item.
|
||||
*
|
||||
* @param type A pointer to the type of content that the list item
|
||||
* stores. Type does not need be a valid pointer; a null or
|
||||
* an uninitialised pointer will suffice.
|
||||
*
|
||||
* @param member The named location of ptr within the sample type.
|
||||
*
|
||||
* @return The container for the specified pointer.
|
||||
*/
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include "compositor.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
WL_EXPORT void
|
||||
weston_spring_init(struct weston_spring *spring,
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <linux/input.h>
|
||||
|
||||
#include "compositor.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct weston_binding {
|
||||
uint32_t key;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <sys/uio.h>
|
||||
|
||||
#include "compositor.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct clipboard_source {
|
||||
struct weston_data_source base;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "compositor.h"
|
||||
#include "cms-helper.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct cms_colord {
|
||||
struct weston_compositor *ec;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "compositor.h"
|
||||
#include "cms-helper.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct cms_static {
|
||||
struct weston_compositor *ec;
|
||||
|
|
|
@ -45,10 +45,6 @@ extern "C" {
|
|||
#include "zalloc.h"
|
||||
#include "timeline-object.h"
|
||||
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
struct weston_transform {
|
||||
struct weston_matrix matrix;
|
||||
struct wl_list link;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "compositor.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct weston_drag {
|
||||
struct wl_client *client;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "compositor.h"
|
||||
#include "libinput-device.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
#define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10)
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "launcher-util.h"
|
||||
#include "libinput-seat.h"
|
||||
#include "libinput-device.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
static const char default_seat[] = "seat0";
|
||||
static const char default_seat_name[] = "default";
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "pixman-renderer.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "compositor.h"
|
||||
#include "rpi-renderer.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
#ifdef ENABLE_EGL
|
||||
#include <EGL/egl.h>
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <wayland-client.h>
|
||||
|
||||
#include "compositor.h"
|
||||
#include "shared/helpers.h"
|
||||
#include "shared/os-compatibility.h"
|
||||
#include "fullscreen-shell-client-protocol.h"
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "compositor.h"
|
||||
#include "screenshooter-server-protocol.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
#include "wcap/wcap-decode.h"
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "compositor.h"
|
||||
#include "text-server-protocol.h"
|
||||
#include "input-method-server-protocol.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct text_input_manager;
|
||||
struct input_method;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "compositor.h"
|
||||
#include "text-cursor-position-server-protocol.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
static void
|
||||
weston_zoom_frame_z(struct weston_animation *animation,
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "weston-test-server-protocol.h"
|
||||
#include "ivi-test.h"
|
||||
#include "ivi-shell/ivi-layout-export.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct test_context;
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "src/weston-egl-ext.h"
|
||||
#endif /* ENABLE_EGL */
|
||||
|
||||
#include "shared/helpers.h"
|
||||
|
||||
struct weston_test {
|
||||
struct weston_compositor *compositor;
|
||||
struct weston_layer layer;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <signal.h>
|
||||
|
||||
#include "xwayland.h"
|
||||
#include "shared/helpers.h"
|
||||
|
||||
|
||||
static int
|
||||
|
|
Loading…
Reference in New Issue