mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-07 04:34:49 -05:00
Move ARRAY_LENGTH out of public headers
Exporting unprefixed symbols is a pretty bad idea so don't do that. Instea of redefining it WL_ARRAY_LENGTH, we just move the define to our private header. The scanner generates code that uses ARRAY_LENGTH, but we can just make it count the number elements and emit an integer constant instead.
This commit is contained in:
parent
56061674cd
commit
bdd272f024
5 changed files with 21 additions and 6 deletions
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include "os-compatibility.h"
|
#include "os-compatibility.h"
|
||||||
|
|
||||||
|
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
|
||||||
|
|
||||||
struct shm_pool {
|
struct shm_pool {
|
||||||
struct wl_shm_pool *pool;
|
struct wl_shm_pool *pool;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "wayland-server.h"
|
#include "wayland-server.h"
|
||||||
|
#include "wayland-private.h"
|
||||||
#include "wayland-os.h"
|
#include "wayland-os.h"
|
||||||
|
|
||||||
struct wl_event_loop {
|
struct wl_event_loop {
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,18 @@ struct parse_context {
|
||||||
unsigned int character_data_length;
|
unsigned int character_data_length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
list_length(struct wl_list *list)
|
||||||
|
{
|
||||||
|
struct wl_list *l;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0, l = list->next; l != list; i++, l = l->next)
|
||||||
|
;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
uppercase_dup(const char *src)
|
uppercase_dup(const char *src)
|
||||||
{
|
{
|
||||||
|
|
@ -1106,14 +1118,14 @@ emit_code(struct protocol *protocol)
|
||||||
i->name, i->name, i->version);
|
i->name, i->name, i->version);
|
||||||
|
|
||||||
if (!wl_list_empty(&i->request_list))
|
if (!wl_list_empty(&i->request_list))
|
||||||
printf("\tARRAY_LENGTH(%s_requests), %s_requests,\n",
|
printf("\t%d, %s_requests,\n",
|
||||||
i->name, i->name);
|
list_length(&i->request_list), i->name);
|
||||||
else
|
else
|
||||||
printf("\t0, NULL,\n");
|
printf("\t0, NULL,\n");
|
||||||
|
|
||||||
if (!wl_list_empty(&i->event_list))
|
if (!wl_list_empty(&i->event_list))
|
||||||
printf("\tARRAY_LENGTH(%s_events), %s_events,\n",
|
printf("\t%d, %s_events,\n",
|
||||||
i->name, i->name);
|
list_length(&i->event_list), i->name);
|
||||||
else
|
else
|
||||||
printf("\t0, NULL,\n");
|
printf("\t0, NULL,\n");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
#include <ffi.h>
|
#include <ffi.h>
|
||||||
#include "wayland-util.h"
|
#include "wayland-util.h"
|
||||||
|
|
||||||
|
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
|
||||||
|
|
||||||
#define WL_ZOMBIE_OBJECT ((void *) 2)
|
#define WL_ZOMBIE_OBJECT ((void *) 2)
|
||||||
|
|
||||||
#define WL_MAP_SERVER_SIDE 0
|
#define WL_MAP_SERVER_SIDE 0
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,6 @@ extern "C" {
|
||||||
#define WL_EXPORT
|
#define WL_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
|
|
||||||
|
|
||||||
#define container_of(ptr, type, member) ({ \
|
#define container_of(ptr, type, member) ({ \
|
||||||
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
|
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
|
||||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue