Moved helper macro to a discrete include file.

To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.

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>
dev
Jon Cruz 10 years ago committed by Bryce Harrington
parent 4678bab13c
commit 35b2eaa989
  1. 1
      Makefile.am
  2. 3
      clients/calibrator.c
  3. 1
      clients/dnd.c
  4. 1
      clients/editor.c
  5. 1
      clients/eventdemo.c
  6. 2
      clients/ivi-shell-user-interface.c
  7. 1
      clients/nested.c
  8. 3
      clients/presentation-shm.c
  9. 3
      clients/simple-touch.c
  10. 1
      clients/stacking.c
  11. 1
      clients/subsurfaces.c
  12. 1
      clients/terminal.c
  13. 3
      clients/weston-info.c
  14. 1
      clients/window.c
  15. 2
      clients/window.h
  16. 1
      clients/wscreensaver.c
  17. 1
      ivi-shell/ivi-shell.c
  18. 3
      shared/cairo-util.c
  19. 48
      shared/helpers.h
  20. 3
      shared/image-loader.c
  21. 1
      src/compositor-drm.c
  22. 1
      src/compositor-fbdev.c
  23. 1
      src/compositor-headless.c
  24. 1
      src/compositor-rdp.c
  25. 1
      src/compositor-rpi.c
  26. 1
      src/compositor-wayland.c
  27. 1
      src/compositor-x11.c
  28. 1
      src/compositor.c
  29. 2
      src/compositor.h
  30. 1
      src/gl-renderer.c
  31. 1
      src/input.c
  32. 1
      tests/ivi_layout-test.c
  33. 1
      tests/presentation-test.c
  34. 1
      tests/vertex-clip-test.c
  35. 4
      tests/weston-test-runner.h
  36. 1
      xwayland/selection.c
  37. 1
      xwayland/window-manager.c

@ -189,6 +189,7 @@ westoninclude_HEADERS = \
src/timeline-object.h \
shared/matrix.h \
shared/config-parser.h \
shared/helpers.h \
shared/zalloc.h \
shared/platform.h

@ -35,10 +35,9 @@
#include <wayland-client.h>
#include "window.h"
#include "shared/helpers.h"
#include "shared/matrix.h"
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
/* Our points for the calibration must be not be on a line */
static const struct {
float x_ratio, y_ratio;

@ -41,6 +41,7 @@
#include "window.h"
#include "shared/cairo-util.h"
#include "shared/helpers.h"
struct dnd_drag;

@ -36,6 +36,7 @@
#include <pango/pangocairo.h>
#include "shared/helpers.h"
#include "window.h"
#include "text-client-protocol.h"

@ -38,6 +38,7 @@
#include <cairo.h>
#include "shared/helpers.h"
#include "window.h"
/** window title */

@ -35,6 +35,7 @@
#include <wayland-cursor.h>
#include "shared/cairo-util.h"
#include "shared/config-parser.h"
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
#include "ivi-application-client-protocol.h"
#include "ivi-hmi-controller-client-protocol.h"
@ -175,7 +176,6 @@ mem_alloc(size_t size, char *file, int32_t line)
}
#define MEM_ALLOC(s) mem_alloc((s),__FILE__,__LINE__)
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
/*****************************************************************************
* Event Handler

@ -46,6 +46,7 @@
#define WL_HIDE_DEPRECATED
#include <wayland-server.h>
#include "shared/helpers.h"
#include "window.h"
#define MIN(x,y) (((x) < (y)) ? (x) : (y))

@ -36,11 +36,10 @@
#include <time.h>
#include <wayland-client.h>
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
#include "presentation_timing-client-protocol.h"
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
enum run_mode {
RUN_MODE_FEEDBACK,
RUN_MODE_FEEDBACK_IDLE,

@ -33,10 +33,9 @@
#include <sys/mman.h>
#include <wayland-client.h>
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
struct seat {
struct touch *touch;
struct wl_seat *seat;

@ -32,6 +32,7 @@
#include <linux/input.h>
#include <cairo.h>
#include "shared/helpers.h"
#include "window.h"
struct stacking {

@ -41,6 +41,7 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "shared/helpers.h"
#include "window.h"
#if 0

@ -44,6 +44,7 @@
#include <wayland-client.h>
#include "shared/config-parser.h"
#include "shared/helpers.h"
#include "window.h"
static int option_fullscreen;

@ -32,11 +32,10 @@
#include <wayland-client.h>
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
#include "presentation_timing-client-protocol.h"
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
typedef void (*print_info_t)(void *info);

@ -67,6 +67,7 @@ typedef void *EGLContext;
#include <linux/input.h>
#include <wayland-client.h>
#include "shared/cairo-util.h"
#include "shared/helpers.h"
#include "xdg-shell-client-protocol.h"
#include "text-cursor-position-client-protocol.h"
#include "workspaces-client-protocol.h"

@ -33,8 +33,6 @@
#include "shared/zalloc.h"
#include "shared/platform.h"
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
#define container_of(ptr, type, member) ({ \
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})

@ -37,6 +37,7 @@
#include "desktop-shell-client-protocol.h"
#include "window.h"
#include "shared/helpers.h"
extern struct wscreensaver_plugin glmatrix_screensaver;

@ -45,6 +45,7 @@
#include "ivi-application-server-protocol.h"
#include "ivi-layout-export.h"
#include "ivi-layout-private.h"
#include "shared/helpers.h"
/* Representation of ivi_surface protocol object. */
struct ivi_shell_surface

@ -35,11 +35,10 @@
#include <cairo.h>
#include "cairo-util.h"
#include "shared/helpers.h"
#include "image-loader.h"
#include "config-parser.h"
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
void
surface_flush_device(cairo_surface_t *surface)
{

@ -0,0 +1,48 @@
/*
* Copyright © 2015 Samsung Electronics Co., Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef WESTON_HELPERS_H
#define WESTON_HELPERS_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file
* Simple misc helper macros.
*/
/**
* Compile-time computation of number of items in a hardcoded array.
*
* @param a the array being measured.
* @return the number of items hardcoded into the array.
*/
#ifndef ARRAY_LENGTH
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
#endif
#ifdef __cplusplus
}
#endif
#endif /* WESTON_HELPERS_H */

@ -34,10 +34,9 @@
#include <png.h>
#include <pixman.h>
#include "shared/helpers.h"
#include "image-loader.h"
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
#ifdef HAVE_WEBP
#include <webp/decode.h>
#endif

@ -46,6 +46,7 @@
#include <gbm.h>
#include <libudev.h>
#include "shared/helpers.h"
#include "libbacklight.h"
#include "compositor.h"
#include "gl-renderer.h"

@ -42,6 +42,7 @@
#include <libudev.h>
#include "shared/helpers.h"
#include "compositor.h"
#include "launcher-util.h"
#include "pixman-renderer.h"

@ -31,6 +31,7 @@
#include <sys/time.h>
#include <stdbool.h>
#include "shared/helpers.h"
#include "compositor.h"
#include "pixman-renderer.h"
#include "presentation_timing-server-protocol.h"

@ -65,6 +65,7 @@
#include <freerdp/locale/keyboard.h>
#include <winpr/input.h>
#include "shared/helpers.h"
#include "compositor.h"
#include "pixman-renderer.h"

@ -46,6 +46,7 @@
# include "rpi-bcm-stubs.h"
#endif
#include "shared/helpers.h"
#include "compositor.h"
#include "rpi-renderer.h"
#include "launcher-util.h"

@ -42,6 +42,7 @@
#include "compositor.h"
#include "gl-renderer.h"
#include "pixman-renderer.h"
#include "shared/helpers.h"
#include "shared/image-loader.h"
#include "shared/os-compatibility.h"
#include "shared/cairo-util.h"

@ -53,6 +53,7 @@
#include "gl-renderer.h"
#include "pixman-renderer.h"
#include "shared/config-parser.h"
#include "shared/helpers.h"
#include "shared/image-loader.h"
#include "presentation_timing-server-protocol.h"

@ -61,6 +61,7 @@
#include "compositor.h"
#include "scaler-server-protocol.h"
#include "presentation_timing-server-protocol.h"
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
#include "git-version.h"
#include "version.h"

@ -49,8 +49,6 @@ extern "C" {
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#endif
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
#define container_of(ptr, type, member) ({ \
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})

@ -40,6 +40,7 @@
#include "gl-renderer.h"
#include "vertex-clipping.h"
#include "shared/helpers.h"
#include "weston-egl-ext.h"
struct gl_shader {

@ -34,6 +34,7 @@
#include <fcntl.h>
#include <limits.h>
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
#include "compositor.h"

@ -28,6 +28,7 @@
#include <stdio.h>
#include <string.h>
#include "shared/helpers.h"
#include "weston-test-client-helper.h"
#include "ivi-application-client-protocol.h"
#include "ivi-test.h"

@ -31,6 +31,7 @@
#include <assert.h>
#include <time.h>
#include "shared/helpers.h"
#include "weston-test-client-helper.h"
#include "presentation_timing-client-protocol.h"

@ -30,6 +30,7 @@
#include "weston-test-runner.h"
#include "shared/helpers.h"
#include "src/vertex-clipping.h"
#define BOUNDING_BOX_TOP_Y 100.0f

@ -31,6 +31,8 @@
#include <stdlib.h>
#include "shared/helpers.h"
#ifdef NDEBUG
#error "Tests must not be built with NDEBUG defined, they rely on assert()."
#endif
@ -44,8 +46,6 @@ struct weston_test {
int must_fail;
} __attribute__ ((aligned (32)));
#define ARRAY_LENGTH(a) ((int) (sizeof (a) / sizeof (a)[0]))
#define TEST_BEGIN(name, arg) \
static void name(arg)

@ -31,6 +31,7 @@
#include <fcntl.h>
#include "xwayland.h"
#include "shared/helpers.h"
static int
writable_callback(int fd, uint32_t mask, void *data)

@ -42,6 +42,7 @@
#include "cairo-util.h"
#include "compositor.h"
#include "hash.h"
#include "shared/helpers.h"
struct wm_size_hints {
uint32_t flags;

Loading…
Cancel
Save