[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg-devel
Subject:    Re: [PATCH 2/2] Namespace list api to reduce conflicts with similar system headers
From:       Peter Hutterer <peter.hutterer () who-t ! net>
Date:       2012-01-28 11:33:14
Message-ID: 20120128113313.GA27037 () yabbi ! HOME
[Download RAW message or body]

On Fri, Jan 27, 2012 at 09:55:31PM -0800, Alan Coopersmith wrote:
> Rename functions/macros from list_* to xorg_list_*
> Rename struct from struct list to struct xorg_list.
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

I think if we're renaming the API, we should also prefix the nt_list macros.
Not that anyone should use them, but...

In-sed-I-trust: Peter Hutterer <peter.hutterer@who-t.net>

Cheers,
  Peter

> ---
> dix/events.c                   |   18 +++---
> hw/xfree86/common/xf86Xinput.c |   10 ++--
> hw/xfree86/dri2/dri2.c         |   20 +++---
> hw/xfree86/parser/InputClass.c |   76 ++++++++++++------------
> hw/xfree86/parser/xf86Parser.h |   20 +++---
> include/inputstr.h             |    4 +-
> include/list.h                 |  114 +++++++++++++++++-----------------
> test/input.c                   |   12 ++--
> test/list.c                    |  132 ++++++++++++++++++++--------------------
> xfixes/cursor.c                |   16 +++---
> 10 files changed, 211 insertions(+), 211 deletions(-)
> 
> diff --git a/dix/events.c b/dix/events.c
> index 04d7fb5..e9f3685 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -1122,8 +1122,8 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
> int		eventlen;
> DeviceEvent *event = &ev->device_event;
> 
> -    if (!list_is_empty(&syncEvents.pending))
> -        tail = list_last_entry(&syncEvents.pending, QdEventRec, next);
> +    if (!xorg_list_is_empty(&syncEvents.pending))
> +        tail = xorg_list_last_entry(&syncEvents.pending, QdEventRec, next);
> 
> NoticeTime((InternalEvent*)event);
> 
> @@ -1183,13 +1183,13 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
> qe = malloc(sizeof(QdEventRec) + eventlen);
> if (!qe)
> 	return;
> -    list_init(&qe->next);
> +    xorg_list_init(&qe->next);
> qe->device = device;
> qe->pScreen = pSprite->hotPhys.pScreen;
> qe->months = currentTime.months;
> qe->event = (InternalEvent *)(qe + 1);
> memcpy(qe->event, event, eventlen);
> -    list_append(&qe->next, &syncEvents.pending);
> +    xorg_list_append(&qe->next, &syncEvents.pending);
> }
> 
> /**
> @@ -1210,10 +1210,10 @@ PlayReleasedEvents(void)
> DeviceIntPtr pDev;
> 
> restart:
> -    list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next) {
> +    xorg_list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next) {
> 	if (!qe->device->deviceGrab.sync.frozen)
> 	{
> -	    list_del(&qe->next);
> +	    xorg_list_del(&qe->next);
> 	    pDev = qe->device;
> 	    if (qe->event->any.type == ET_Motion)
> 		CheckVirtualMotion(pDev, qe, NullWindow);
> @@ -1297,7 +1297,7 @@ ComputeFreezes(void)
> 	FreezeThaw(dev, dev->deviceGrab.sync.other ||
> (dev->deviceGrab.sync.state >= FROZEN));
> if (syncEvents.playingEvents ||
> -        (!replayDev && list_is_empty(&syncEvents.pending)))
> +        (!replayDev && xorg_list_is_empty(&syncEvents.pending)))
> 	return;
> syncEvents.playingEvents = TRUE;
> if (replayDev)
> @@ -5392,9 +5392,9 @@ InitEvents(void)
> syncEvents.replayDev = (DeviceIntPtr)NULL;
> syncEvents.replayWin = NullWindow;
> if (syncEvents.pending.next)
> -        list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next)
> +        xorg_list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next)
> free(qe);
> -    list_init(&syncEvents.pending);
> +    xorg_list_init(&syncEvents.pending);
> syncEvents.playingEvents = FALSE;
> syncEvents.time.months = 0;
> syncEvents.time.milliseconds = 0;	/* hardly matters */
> diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
> index fd40f28..f6be999 100644
> --- a/hw/xfree86/common/xf86Xinput.c
> +++ b/hw/xfree86/common/xf86Xinput.c
> @@ -516,13 +516,13 @@ match_string_implicit(const char *attr, const char *pattern)
> * If a pattern in each list entry is matched, return TRUE.
> */
> static Bool
> -MatchAttrToken(const char *attr, struct list *patterns,
> +MatchAttrToken(const char *attr, struct xorg_list *patterns,
> int (*compare)(const char *attr, const char *pattern))
> {
> const xf86MatchGroup *group;
> 
> /* If there are no patterns, accept the match */
> -    if (list_is_empty(patterns))
> +    if (xorg_list_is_empty(patterns))
> return TRUE;
> 
> /* If there are patterns but no attribute, reject the match */
> @@ -533,7 +533,7 @@ MatchAttrToken(const char *attr, struct list *patterns,
> * Otherwise, iterate the list of patterns ensuring each entry has a
> * match. Each list entry is a separate Match line of the same type.
> */
> -    list_for_each_entry(group, patterns, entry) {
> +    xorg_list_for_each_entry(group, patterns, entry) {
> char * const *cur;
> Bool match = FALSE;
> 
> @@ -590,7 +590,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const \
>                 InputInfoPtr idev,
> * MatchTag string
> * See if any of the device's tags match any of the MatchTag tokens.
> */
> -    if (!list_is_empty(&iclass->match_tag)) {
> +    if (!xorg_list_is_empty(&iclass->match_tag)) {
> char * const *tag;
> Bool match;
> 
> @@ -607,7 +607,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const \
> InputInfoPtr idev, }
> 
> /* MatchLayout string */
> -    if (!list_is_empty(&iclass->match_layout)) {
> +    if (!xorg_list_is_empty(&iclass->match_layout)) {
> if (!MatchAttrToken(xf86ConfigLayout.id,
> &iclass->match_layout, match_string_implicit))
> return FALSE;
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index d6441a2..5cc9068 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -67,7 +67,7 @@ typedef struct _DRI2Screen *DRI2ScreenPtr;
> typedef struct _DRI2Drawable {
> DRI2ScreenPtr        dri2_screen;
> DrawablePtr		 drawable;
> -    struct list		 reference_list;
> +    struct xorg_list	 reference_list;
> int			 width;
> int			 height;
> DRI2BufferPtr	*buffers;
> @@ -179,7 +179,7 @@ DRI2AllocateDrawable(DrawablePtr pDraw)
> pPriv->swap_limit = 1; /* default to double buffering */
> pPriv->last_swap_msc = 0;
> pPriv->last_swap_ust = 0;
> -    list_init(&pPriv->reference_list);
> +    xorg_list_init(&pPriv->reference_list);
> pPriv->serialNumber = DRI2DrawableSerial(pDraw);
> pPriv->needInvalidate = FALSE;
> 
> @@ -229,7 +229,7 @@ typedef struct DRI2DrawableRefRec {
> XID		  dri2_id;
> DRI2InvalidateProcPtr	invalidate;
> void	 *priv;
> -    struct list	  link;
> +    struct xorg_list		link;
> } DRI2DrawableRefRec, *DRI2DrawableRefPtr;
> 
> static DRI2DrawableRefPtr
> @@ -237,7 +237,7 @@ DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
> {
> DRI2DrawableRefPtr ref;
> 
> -    list_for_each_entry(ref, &pPriv->reference_list, link) {
> +    xorg_list_for_each_entry(ref, &pPriv->reference_list, link) {
> 	if (ref->id == id)
> 	    return ref;
> }
> @@ -270,7 +270,7 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
> ref->dri2_id = dri2_id; 
> ref->invalidate = invalidate;
> ref->priv = priv;
> -    list_add(&ref->link, &pPriv->reference_list);
> +    xorg_list_add(&ref->link, &pPriv->reference_list);
> 
> return Success;
> }
> @@ -307,9 +307,9 @@ static int DRI2DrawableGone(pointer p, XID id)
> DrawablePtr pDraw;
> int i;
> 
> -    list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
> +    xorg_list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
> 	if (ref->dri2_id == id) {
> -	    list_del(&ref->link);
> +	    xorg_list_del(&ref->link);
> 	    /* If this was the last ref under this X drawable XID,
> 	     * unregister the X drawable resource. */
> 	    if (!DRI2LookupDrawableRef(pPriv, ref->id))
> @@ -319,13 +319,13 @@ static int DRI2DrawableGone(pointer p, XID id)
> 	}
> 
> 	if (ref->id == id) {
> -	    list_del(&ref->link);
> +	    xorg_list_del(&ref->link);
> 	    FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
> 	    free(ref);
> 	}
> }
> 
> -    if (!list_is_empty(&pPriv->reference_list))
> +    if (!xorg_list_is_empty(&pPriv->reference_list))
> 	return Success;
> 
> pDraw = pPriv->drawable;
> @@ -586,7 +586,7 @@ DRI2InvalidateDrawable(DrawablePtr pDraw)
> 
> pPriv->needInvalidate = FALSE;
> 
> -    list_for_each_entry(ref, &pPriv->reference_list, link)
> +    xorg_list_for_each_entry(ref, &pPriv->reference_list, link)
> 	ref->invalidate(pDraw, ref->priv, ref->id);
> }
> 
> diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c
> index 919ae18..c25117c 100644
> --- a/hw/xfree86/parser/InputClass.c
> +++ b/hw/xfree86/parser/InputClass.c
> @@ -67,14 +67,14 @@ xf86ConfigSymTabRec InputClassTab[] =
> #define TOKEN_SEP "|"
> 
> static void
> -add_group_entry(struct list *head, char **values)
> +add_group_entry(struct xorg_list *head, char **values)
> {
> xf86MatchGroup *group;
> 
> group = malloc(sizeof(*group));
> if (group) {
> group->values = values;
> -        list_add(&group->entry, head);
> +        xorg_list_add(&group->entry, head);
> }
> }
> 
> @@ -87,15 +87,15 @@ xf86parseInputClassSection(void)
> parsePrologue(XF86ConfInputClassPtr, XF86ConfInputClassRec)
> 
> /* Initialize MatchGroup lists */
> -    list_init(&ptr->match_product);
> -    list_init(&ptr->match_vendor);
> -    list_init(&ptr->match_device);
> -    list_init(&ptr->match_os);
> -    list_init(&ptr->match_pnpid);
> -    list_init(&ptr->match_usbid);
> -    list_init(&ptr->match_driver);
> -    list_init(&ptr->match_tag);
> -    list_init(&ptr->match_layout);
> +    xorg_list_init(&ptr->match_product);
> +    xorg_list_init(&ptr->match_vendor);
> +    xorg_list_init(&ptr->match_device);
> +    xorg_list_init(&ptr->match_os);
> +    xorg_list_init(&ptr->match_pnpid);
> +    xorg_list_init(&ptr->match_usbid);
> +    xorg_list_init(&ptr->match_driver);
> +    xorg_list_init(&ptr->match_tag);
> +    xorg_list_init(&ptr->match_layout);
> 
> while ((token = xf86getToken(InputClassTab)) != ENDSECTION) {
> switch (token) {
> @@ -274,63 +274,63 @@ xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr \
> ptr) if (ptr->driver)
> fprintf(cf, "\tDriver          \"%s\"\n", ptr->driver);
> 
> -        list_for_each_entry(group, &ptr->match_product, entry) {
> +        xorg_list_for_each_entry(group, &ptr->match_product, entry) {
> fprintf(cf, "\tMatchProduct    \"");
> for (cur = group->values; *cur; cur++)
> fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
> *cur);
> fprintf(cf, "\"\n");
> }
> -        list_for_each_entry(group, &ptr->match_vendor, entry) {
> +        xorg_list_for_each_entry(group, &ptr->match_vendor, entry) {
> fprintf(cf, "\tMatchVendor     \"");
> for (cur = group->values; *cur; cur++)
> fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
> *cur);
> fprintf(cf, "\"\n");
> }
> -        list_for_each_entry(group, &ptr->match_device, entry) {
> +        xorg_list_for_each_entry(group, &ptr->match_device, entry) {
> fprintf(cf, "\tMatchDevicePath \"");
> for (cur = group->values; *cur; cur++)
> fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
> *cur);
> fprintf(cf, "\"\n");
> }
> -        list_for_each_entry(group, &ptr->match_os, entry) {
> +        xorg_list_for_each_entry(group, &ptr->match_os, entry) {
> fprintf(cf, "\tMatchOS         \"");
> for (cur = group->values; *cur; cur++)
> fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
> *cur);
> fprintf(cf, "\"\n");
> }
> -        list_for_each_entry(group, &ptr->match_pnpid, entry) {
> +        xorg_list_for_each_entry(group, &ptr->match_pnpid, entry) {
> fprintf(cf, "\tMatchPnPID      \"");
> for (cur = group->values; *cur; cur++)
> fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
> *cur);
> fprintf(cf, "\"\n");
> }
> -        list_for_each_entry(group, &ptr->match_usbid, entry) {
> +        xorg_list_for_each_entry(group, &ptr->match_usbid, entry) {
> fprintf(cf, "\tMatchUSBID      \"");
> for (cur = group->values; *cur; cur++)
> fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
> *cur);
> fprintf(cf, "\"\n");
> }
> -        list_for_each_entry(group, &ptr->match_driver, entry) {
> +        xorg_list_for_each_entry(group, &ptr->match_driver, entry) {
> fprintf(cf, "\tMatchDriver     \"");
> for (cur = group->values; *cur; cur++)
> fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
> *cur);
> fprintf(cf, "\"\n");
> }
> -        list_for_each_entry(group, &ptr->match_tag, entry) {
> +        xorg_list_for_each_entry(group, &ptr->match_tag, entry) {
> fprintf(cf, "\tMatchTag        \"");
> for (cur = group->values; *cur; cur++)
> fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
> *cur);
> fprintf(cf, "\"\n");
> }
> -        list_for_each_entry(group, &ptr->match_layout, entry) {
> +        xorg_list_for_each_entry(group, &ptr->match_layout, entry) {
> fprintf(cf, "\tMatchLayout     \"");
> for (cur = group->values; *cur; cur++)
> fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
> @@ -374,56 +374,56 @@ xf86freeInputClassList (XF86ConfInputClassPtr ptr)
> TestFree(ptr->identifier);
> TestFree(ptr->driver);
> 
> -        list_for_each_entry_safe(group, next, &ptr->match_product, entry) {
> -            list_del(&group->entry);
> +        xorg_list_for_each_entry_safe(group, next, &ptr->match_product, entry) {
> +            xorg_list_del(&group->entry);
> for (list = group->values; *list; list++)
> free(*list);
> free(group);
> }
> -        list_for_each_entry_safe(group, next, &ptr->match_vendor, entry) {
> -            list_del(&group->entry);
> +        xorg_list_for_each_entry_safe(group, next, &ptr->match_vendor, entry) {
> +            xorg_list_del(&group->entry);
> for (list = group->values; *list; list++)
> free(*list);
> free(group);
> }
> -        list_for_each_entry_safe(group, next, &ptr->match_device, entry) {
> -            list_del(&group->entry);
> +        xorg_list_for_each_entry_safe(group, next, &ptr->match_device, entry) {
> +            xorg_list_del(&group->entry);
> for (list = group->values; *list; list++)
> free(*list);
> free(group);
> }
> -        list_for_each_entry_safe(group, next, &ptr->match_os, entry) {
> -            list_del(&group->entry);
> +        xorg_list_for_each_entry_safe(group, next, &ptr->match_os, entry) {
> +            xorg_list_del(&group->entry);
> for (list = group->values; *list; list++)
> free(*list);
> free(group);
> }
> -        list_for_each_entry_safe(group, next, &ptr->match_pnpid, entry) {
> -            list_del(&group->entry);
> +        xorg_list_for_each_entry_safe(group, next, &ptr->match_pnpid, entry) {
> +            xorg_list_del(&group->entry);
> for (list = group->values; *list; list++)
> free(*list);
> free(group);
> }
> -        list_for_each_entry_safe(group, next, &ptr->match_usbid, entry) {
> -            list_del(&group->entry);
> +        xorg_list_for_each_entry_safe(group, next, &ptr->match_usbid, entry) {
> +            xorg_list_del(&group->entry);
> for (list = group->values; *list; list++)
> free(*list);
> free(group);
> }
> -        list_for_each_entry_safe(group, next, &ptr->match_driver, entry) {
> -            list_del(&group->entry);
> +        xorg_list_for_each_entry_safe(group, next, &ptr->match_driver, entry) {
> +            xorg_list_del(&group->entry);
> for (list = group->values; *list; list++)
> free(*list);
> free(group);
> }
> -        list_for_each_entry_safe(group, next, &ptr->match_tag, entry) {
> -            list_del(&group->entry);
> +        xorg_list_for_each_entry_safe(group, next, &ptr->match_tag, entry) {
> +            xorg_list_del(&group->entry);
> for (list = group->values; *list; list++)
> free(*list);
> free(group);
> }
> -        list_for_each_entry_safe(group, next, &ptr->match_layout, entry) {
> -            list_del(&group->entry);
> +        xorg_list_for_each_entry_safe(group, next, &ptr->match_layout, entry) {
> +            xorg_list_del(&group->entry);
> for (list = group->values; *list; list++)
> free(*list);
> free(group);
> diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
> index 7d4662b..beac354 100644
> --- a/hw/xfree86/parser/xf86Parser.h
> +++ b/hw/xfree86/parser/xf86Parser.h
> @@ -340,7 +340,7 @@ xf86TriState;
> 
> typedef struct
> {
> -	struct list entry;
> +	struct xorg_list entry;
> 	char **values;
> }
> xf86MatchGroup;
> @@ -350,15 +350,15 @@ typedef struct
> 	GenericListRec list;
> 	char *identifier;
> 	char *driver;
> -	struct list match_product;
> -	struct list match_vendor;
> -	struct list match_device;
> -	struct list match_os;
> -	struct list match_pnpid;
> -	struct list match_usbid;
> -	struct list match_driver;
> -	struct list match_tag;
> -	struct list match_layout;
> +	struct xorg_list match_product;
> +	struct xorg_list match_vendor;
> +	struct xorg_list match_device;
> +	struct xorg_list match_os;
> +	struct xorg_list match_pnpid;
> +	struct xorg_list match_usbid;
> +	struct xorg_list match_driver;
> +	struct xorg_list match_tag;
> +	struct xorg_list match_layout;
> 	xf86TriState is_keyboard;
> 	xf86TriState is_pointer;
> 	xf86TriState is_joystick;
> diff --git a/include/inputstr.h b/include/inputstr.h
> index c3297db..8a08f67 100644
> --- a/include/inputstr.h
> +++ b/include/inputstr.h
> @@ -622,7 +622,7 @@ extern _X_EXPORT InputInfo inputInfo;
> /* for keeping the events for devices grabbed synchronously */
> typedef struct _QdEvent *QdEventPtr;
> typedef struct _QdEvent {
> -    struct list		next;
> +    struct xorg_list	next;
> DeviceIntPtr	device;
> ScreenPtr		pScreen;	/* what screen the pointer was on */
> unsigned long	months;		/* milliseconds is in the event */
> @@ -638,7 +638,7 @@ typedef struct _QdEvent {
> * replayed and processed as if they would come from the device directly.
> */
> typedef struct _EventSyncInfo {
> -    struct list         pending;
> +    struct xorg_list    pending;
> 
> /** The device to replay events for. Only set in AllowEvents(), in which
> * case it is set to the device specified in the request. */
> diff --git a/include/list.h b/include/list.h
> index 6ec2bac..14c671f 100644
> --- a/include/list.h
> +++ b/include/list.h
> @@ -23,8 +23,8 @@
> *
> */
> 
> -#ifndef _LIST_H_
> -#define _LIST_H_
> +#ifndef _XORG_LIST_H_
> +#define _XORG_LIST_H_
> 
> /**
> * @file Classic doubly-link circular list implementation.
> @@ -41,17 +41,17 @@
> *     }
> *
> * We need one list head in bar and a list element in all list_of_foos (both are of
> - * data type 'struct list').
> + * data type 'struct xorg_list').
> *
> *     struct bar {
> *          ...
> - *          struct list list_of_foos;
> + *          struct xorg_list list_of_foos;
> *          ...
> *     }
> *
> *     struct foo {
> *          ...
> - *          struct list entry;
> + *          struct xorg_list entry;
> *          ...
> *     }
> *
> @@ -59,74 +59,74 @@
> *
> *     struct bar bar;
> *     ...
> - *     list_init(&bar.list_of_foos);
> + *     xorg_list_init(&bar.list_of_foos);
> *
> * Then we create the first element and add it to this list:
> *
> *     struct foo *foo = malloc(...);
> *     ....
> - *     list_add(&foo->entry, &bar.list_of_foos);
> + *     xorg_list_add(&foo->entry, &bar.list_of_foos);
> *
> * Repeat the above for each element you want to add to the list. Deleting
> * works with the element itself.
> - *      list_del(&foo->entry);
> + *      xorg_list_del(&foo->entry);
> *      free(foo);
> *
> - * Note: calling list_del(&bar.list_of_foos) will set bar.list_of_foos to an empty
> + * Note: calling xorg_list_del(&bar.list_of_foos) will set bar.list_of_foos to an \
>                 empty
> * list again.
> *
> * Looping through the list requires a 'struct foo' as iterator and the
> * name of the field the subnodes use.
> *
> * struct foo *iterator;
> - * list_for_each_entry(iterator, &bar.list_of_foos, entry) {
> + * xorg_list_for_each_entry(iterator, &bar.list_of_foos, entry) {
> *      if (iterator->something == ...)
> *             ...
> * }
> *
> - * Note: You must not call list_del() on the iterator if you continue the
> + * Note: You must not call xorg_list_del() on the iterator if you continue the
> * loop. You need to run the safe for-each loop instead:
> *
> * struct foo *iterator, *next;
> - * list_for_each_entry_safe(iterator, next, &bar.list_of_foos, entry) {
> + * xorg_list_for_each_entry_safe(iterator, next, &bar.list_of_foos, entry) {
> *      if (...)
> - *              list_del(&iterator->entry);
> + *              xorg_list_del(&iterator->entry);
> * }
> *
> */
> 
> /**
> * The linkage struct for list nodes. This struct must be part of your
> - * to-be-linked struct. struct list is required for both the head of the
> + * to-be-linked struct. struct xorg_list is required for both the head of the
> * list and for each list node.
> *
> - * Position and name of the struct list field is irrelevant.
> + * Position and name of the struct xorg_list field is irrelevant.
> * There are no requirements that elements of a list are of the same type.
> - * There are no requirements for a list head, any struct list can be a list
> + * There are no requirements for a list head, any struct xorg_list can be a list
> * head.
> */
> -struct list {
> -    struct list *next, *prev;
> +struct xorg_list {
> +    struct xorg_list *next, *prev;
> };
> 
> /**
> * Initialize the list as an empty list.
> *
> * Example:
> - * list_init(&bar->list_of_foos);
> + * xorg_list_init(&bar->list_of_foos);
> *
> * @param The list to initialized.
> */
> static void
> -list_init(struct list *list)
> +xorg_list_init(struct xorg_list *list)
> {
> list->next = list->prev = list;
> }
> 
> static inline void
> -__list_add(struct list *entry,
> -	    struct list *prev,
> -	    struct list *next)
> +__xorg_list_add(struct xorg_list *entry,
> +	    struct xorg_list *prev,
> +	    struct xorg_list *next)
> {
> next->prev = entry;
> entry->next = next;
> @@ -144,15 +144,15 @@ __list_add(struct list *entry,
> *
> * Example:
> * struct foo *newfoo = malloc(...);
> - * list_add(&newfoo->entry, &bar->list_of_foos);
> + * xorg_list_add(&newfoo->entry, &bar->list_of_foos);
> *
> * @param entry The new element to prepend to the list.
> * @param head The existing list.
> */
> static inline void
> -list_add(struct list *entry, struct list *head)
> +xorg_list_add(struct xorg_list *entry, struct xorg_list *head)
> {
> -    __list_add(entry, head, head->next);
> +    __xorg_list_add(entry, head, head->next);
> }
> 
> /**
> @@ -165,20 +165,20 @@ list_add(struct list *entry, struct list *head)
> *
> * Example:
> * struct foo *newfoo = malloc(...);
> - * list_append(&newfoo->entry, &bar->list_of_foos);
> + * xorg_list_append(&newfoo->entry, &bar->list_of_foos);
> *
> * @param entry The new element to prepend to the list.
> * @param head The existing list.
> */
> static inline void
> -list_append(struct list *entry, struct list *head)
> +xorg_list_append(struct xorg_list *entry, struct xorg_list *head)
> {
> -    __list_add(entry, head->prev, head);
> +    __xorg_list_add(entry, head->prev, head);
> }
> 
> 
> static inline void
> -__list_del(struct list *prev, struct list *next)
> +__xorg_list_del(struct xorg_list *prev, struct xorg_list *next)
> {
> next->prev = prev;
> prev->next = next;
> @@ -189,32 +189,32 @@ __list_del(struct list *prev, struct list *next)
> * the pointers to/from this element so it is removed from the list. It does
> * NOT free the element itself or manipulate it otherwise.
> *
> - * Using list_del on a pure list head (like in the example at the top of
> + * Using xorg_list_del on a pure list head (like in the example at the top of
> * this file) will NOT remove the first element from
> * the list but rather reset the list as empty list.
> *
> * Example:
> - * list_del(&foo->entry);
> + * xorg_list_del(&foo->entry);
> *
> * @param entry The element to remove.
> */
> static inline void
> -list_del(struct list *entry)
> +xorg_list_del(struct xorg_list *entry)
> {
> -    __list_del(entry->prev, entry->next);
> -    list_init(entry);
> +    __xorg_list_del(entry->prev, entry->next);
> +    xorg_list_init(entry);
> }
> 
> /**
> * Check if the list is empty.
> *
> * Example:
> - * list_is_empty(&bar->list_of_foos);
> + * xorg_list_is_empty(&bar->list_of_foos);
> *
> * @return True if the list contains one or more elements or False otherwise.
> */
> static inline Bool
> -list_is_empty(struct list *head)
> +xorg_list_is_empty(struct xorg_list *head)
> {
> return head->next == head;
> }
> @@ -227,9 +227,9 @@ list_is_empty(struct list *head)
> * f = container_of(&foo->entry, struct foo, entry);
> * assert(f == foo);
> *
> - * @param ptr Pointer to the struct list.
> + * @param ptr Pointer to the struct xorg_list.
> * @param type Data type of the list element.
> - * @param member Member name of the struct list field in the list element.
> + * @param member Member name of the struct xorg_list field in the list element.
> * @return A pointer to the data struct containing the list head.
> */
> #ifndef container_of
> @@ -240,7 +240,7 @@ list_is_empty(struct list *head)
> /**
> * Alias of container_of
> */
> -#define list_entry(ptr, type, member) \
> +#define xorg_list_entry(ptr, type, member) \
> container_of(ptr, type, member)
> 
> /**
> @@ -248,30 +248,30 @@ list_is_empty(struct list *head)
> *
> * Example:
> * struct foo *first;
> - * first = list_first_entry(&bar->list_of_foos, struct foo, list_of_foos);
> + * first = xorg_list_first_entry(&bar->list_of_foos, struct foo, list_of_foos);
> *
> * @param ptr The list head
> * @param type Data type of the list element to retrieve
> - * @param member Member name of the struct list field in the list element.
> + * @param member Member name of the struct xorg_list field in the list element.
> * @return A pointer to the first list element.
> */
> -#define list_first_entry(ptr, type, member) \
> -    list_entry((ptr)->next, type, member)
> +#define xorg_list_first_entry(ptr, type, member) \
> +    xorg_list_entry((ptr)->next, type, member)
> 
> /**
> * Retrieve the last list entry for the given listpointer.
> *
> * Example:
> * struct foo *first;
> - * first = list_last_entry(&bar->list_of_foos, struct foo, list_of_foos);
> + * first = xorg_list_last_entry(&bar->list_of_foos, struct foo, list_of_foos);
> *
> * @param ptr The list head
> * @param type Data type of the list element to retrieve
> - * @param member Member name of the struct list field in the list element.
> + * @param member Member name of the struct xorg_list field in the list element.
> * @return A pointer to the last list element.
> */
> -#define list_last_entry(ptr, type, member) \
> -    list_entry((ptr)->prev, type, member)
> +#define xorg_list_last_entry(ptr, type, member) \
> +    xorg_list_entry((ptr)->prev, type, member)
> 
> #define __container_of(ptr, sample, member)				\
> (void *)((char *)(ptr)						\
> @@ -281,19 +281,19 @@ list_is_empty(struct list *head)
> *
> * Example:
> * struct foo *iterator;
> - * list_for_each_entry(iterator, &bar->list_of_foos, entry) {
> + * xorg_list_for_each_entry(iterator, &bar->list_of_foos, entry) {
> *      [modify iterator]
> * }
> *
> - * This macro is not safe for node deletion. Use list_for_each_entry_safe
> + * This macro is not safe for node deletion. Use xorg_list_for_each_entry_safe
> * instead.
> *
> * @param pos Iterator variable of the type of the list elements.
> * @param head List head
> - * @param member Member name of the struct list in the list elements.
> + * @param member Member name of the struct xorg_list in the list elements.
> *
> */
> -#define list_for_each_entry(pos, head, member)				\
> +#define xorg_list_for_each_entry(pos, head, member)				\
> for (pos = __container_of((head)->next, pos, member);		\
> 	 &pos->member != (head);					\
> 	 pos = __container_of(pos->member.next, pos, member))
> @@ -303,9 +303,9 @@ list_is_empty(struct list *head)
> * macro allows for the deletion of a list element while looping through the
> * list.
> *
> - * See list_for_each_entry for more details.
> + * See xorg_list_for_each_entry for more details.
> */
> -#define list_for_each_entry_safe(pos, tmp, head, member)		\
> +#define xorg_list_for_each_entry_safe(pos, tmp, head, member)		\
> for (pos = __container_of((head)->next, pos, member),		\
> 	 tmp = __container_of(pos->member.next, pos, member);		\
> 	 &pos->member != (head);					\
> @@ -315,9 +315,9 @@ list_is_empty(struct list *head)
> 
> /* NULL-Terminated List Interface
> *
> - * The interface below does _not_ use the struct list as described above.
> + * The interface below does _not_ use the struct xorg_list as described above.
> * It is mainly for legacy structures that cannot easily be switched to
> - * struct list.
> + * struct xorg_list.
> *
> * This interface is for structs like
> *      struct foo {
> @@ -349,7 +349,7 @@ list_is_empty(struct list *head)
> * struct foo *element = list;
> * while ((element = nt_list_next(element, next)) { }
> *
> - * This macro is not safe for node deletion. Use list_for_each_entry_safe
> + * This macro is not safe for node deletion. Use xorg_list_for_each_entry_safe
> * instead.
> *
> * @param list The list or current element.
> diff --git a/test/input.c b/test/input.c
> index 576cd85..e029141 100644
> --- a/test/input.c
> +++ b/test/input.c
> @@ -1714,7 +1714,7 @@ dix_enqueue_events(void) {
> spriteInfo.sprite = &sprite;
> 
> InitEvents();
> -    assert(list_is_empty(&syncEvents.pending));
> +    assert(xorg_list_is_empty(&syncEvents.pending));
> 
> /* this way PlayReleasedEvents really runs through all events in the
> * queue */
> @@ -1728,22 +1728,22 @@ dix_enqueue_events(void) {
> ev[i].any.length = sizeof(*ev);
> ev[i].any.type = i;
> EnqueueEvent(&ev[i], &dev);
> -        assert(!list_is_empty(&syncEvents.pending));
> -        qe = list_last_entry(&syncEvents.pending, QdEventRec, next);
> +        assert(!xorg_list_is_empty(&syncEvents.pending));
> +        qe = xorg_list_last_entry(&syncEvents.pending, QdEventRec, next);
> assert(memcmp(qe->event, &ev[i], ev[i].any.length) == 0);
> -        qe = list_first_entry(&syncEvents.pending, QdEventRec, next);
> +        qe = xorg_list_first_entry(&syncEvents.pending, QdEventRec, next);
> assert(memcmp(qe->event, &ev[0], ev[i].any.length) == 0);
> }
> 
> /* calls process_input_proc */
> dev.deviceGrab.sync.frozen = 1;
> PlayReleasedEvents();
> -    assert(!list_is_empty(&syncEvents.pending));
> +    assert(!xorg_list_is_empty(&syncEvents.pending));
> 
> 
> dev.deviceGrab.sync.frozen = 0;
> PlayReleasedEvents();
> -    assert(list_is_empty(&syncEvents.pending));
> +    assert(xorg_list_is_empty(&syncEvents.pending));
> 
> inputInfo.devices = NULL;
> }
> diff --git a/test/list.c b/test/list.c
> index ffb85ef..14bc74a 100644
> --- a/test/list.c
> +++ b/test/list.c
> @@ -33,18 +33,18 @@
> 
> struct parent {
> int a;
> -    struct list children;
> +    struct xorg_list children;
> int b;
> };
> 
> struct child {
> int foo;
> int bar;
> -    struct list node;
> +    struct xorg_list node;
> };
> 
> static void
> -test_list_init(void)
> +test_xorg_list_init(void)
> {
> struct parent parent, tmp;
> 
> @@ -54,146 +54,146 @@ test_list_init(void)
> 
> tmp = parent;
> 
> -    list_init(&parent.children);
> +    xorg_list_init(&parent.children);
> 
> /* test we haven't touched anything else. */
> assert(parent.a == tmp.a);
> assert(parent.b == tmp.b);
> 
> -    assert(list_is_empty(&parent.children));
> +    assert(xorg_list_is_empty(&parent.children));
> }
> 
> static void
> -test_list_add(void)
> +test_xorg_list_add(void)
> {
> struct parent parent = {0};
> struct child child[3];
> struct child *c;
> 
> -    list_init(&parent.children);
> +    xorg_list_init(&parent.children);
> 
> -    list_add(&child[0].node, &parent.children);
> -    assert(!list_is_empty(&parent.children));
> +    xorg_list_add(&child[0].node, &parent.children);
> +    assert(!xorg_list_is_empty(&parent.children));
> 
> -    c = list_first_entry(&parent.children, struct child, node);
> +    c = xorg_list_first_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
> 
> -    /* note: list_add prepends */
> -    list_add(&child[1].node, &parent.children);
> -    c = list_first_entry(&parent.children, struct child, node);
> +    /* note: xorg_list_add prepends */
> +    xorg_list_add(&child[1].node, &parent.children);
> +    c = xorg_list_first_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[1], sizeof(struct child)) == 0);
> 
> -    list_add(&child[2].node, &parent.children);
> -    c = list_first_entry(&parent.children, struct child, node);
> +    xorg_list_add(&child[2].node, &parent.children);
> +    c = xorg_list_first_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[2], sizeof(struct child)) == 0);
> };
> 
> static void
> -test_list_append(void)
> +test_xorg_list_append(void)
> {
> struct parent parent = {0};
> struct child child[3];
> struct child *c;
> int i;
> 
> -    list_init(&parent.children);
> +    xorg_list_init(&parent.children);
> 
> -    list_append(&child[0].node, &parent.children);
> -    assert(!list_is_empty(&parent.children));
> +    xorg_list_append(&child[0].node, &parent.children);
> +    assert(!xorg_list_is_empty(&parent.children));
> 
> -    c = list_first_entry(&parent.children, struct child, node);
> +    c = xorg_list_first_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
> -    c = list_last_entry(&parent.children, struct child, node);
> +    c = xorg_list_last_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
> 
> -    list_append(&child[1].node, &parent.children);
> -    c = list_first_entry(&parent.children, struct child, node);
> +    xorg_list_append(&child[1].node, &parent.children);
> +    c = xorg_list_first_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
> -    c = list_last_entry(&parent.children, struct child, node);
> +    c = xorg_list_last_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[1], sizeof(struct child)) == 0);
> 
> -    list_append(&child[2].node, &parent.children);
> -    c = list_first_entry(&parent.children, struct child, node);
> +    xorg_list_append(&child[2].node, &parent.children);
> +    c = xorg_list_first_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
> -    c = list_last_entry(&parent.children, struct child, node);
> +    c = xorg_list_last_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[2], sizeof(struct child)) == 0);
> 
> i = 0;
> -    list_for_each_entry(c, &parent.children, node) {
> +    xorg_list_for_each_entry(c, &parent.children, node) {
> assert(memcmp(c, &child[i++], sizeof(struct child)) == 0);
> }
> };
> 
> static void
> -test_list_del(void)
> +test_xorg_list_del(void)
> {
> struct parent parent = {0};
> struct child child[3];
> struct child *c;
> 
> -    list_init(&parent.children);
> +    xorg_list_init(&parent.children);
> 
> -    list_add(&child[0].node, &parent.children);
> -    assert(!list_is_empty(&parent.children));
> +    xorg_list_add(&child[0].node, &parent.children);
> +    assert(!xorg_list_is_empty(&parent.children));
> 
> -    list_del(&parent.children);
> -    assert(list_is_empty(&parent.children));
> +    xorg_list_del(&parent.children);
> +    assert(xorg_list_is_empty(&parent.children));
> 
> -    list_add(&child[0].node, &parent.children);
> -    list_del(&child[0].node);
> -    assert(list_is_empty(&parent.children));
> +    xorg_list_add(&child[0].node, &parent.children);
> +    xorg_list_del(&child[0].node);
> +    assert(xorg_list_is_empty(&parent.children));
> 
> -    list_add(&child[0].node, &parent.children);
> -    list_add(&child[1].node, &parent.children);
> +    xorg_list_add(&child[0].node, &parent.children);
> +    xorg_list_add(&child[1].node, &parent.children);
> 
> -    c = list_first_entry(&parent.children, struct child, node);
> +    c = xorg_list_first_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[1], sizeof(struct child)) == 0);
> 
> /* delete first node */
> -    list_del(&child[1].node);
> -    assert(!list_is_empty(&parent.children));
> -    assert(list_is_empty(&child[1].node));
> -    c = list_first_entry(&parent.children, struct child, node);
> +    xorg_list_del(&child[1].node);
> +    assert(!xorg_list_is_empty(&parent.children));
> +    assert(xorg_list_is_empty(&child[1].node));
> +    c = xorg_list_first_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
> 
> /* delete last node */
> -    list_add(&child[1].node, &parent.children);
> -    list_del(&child[0].node);
> -    c = list_first_entry(&parent.children, struct child, node);
> +    xorg_list_add(&child[1].node, &parent.children);
> +    xorg_list_del(&child[0].node);
> +    c = xorg_list_first_entry(&parent.children, struct child, node);
> assert(memcmp(c, &child[1], sizeof(struct child)) == 0);
> 
> /* delete list head */
> -    list_add(&child[0].node, &parent.children);
> -    list_del(&parent.children);
> -    assert(list_is_empty(&parent.children));
> -    assert(!list_is_empty(&child[1].node));
> -    assert(!list_is_empty(&child[2].node));
> +    xorg_list_add(&child[0].node, &parent.children);
> +    xorg_list_del(&parent.children);
> +    assert(xorg_list_is_empty(&parent.children));
> +    assert(!xorg_list_is_empty(&child[1].node));
> +    assert(!xorg_list_is_empty(&child[2].node));
> }
> 
> static void
> -test_list_for_each(void)
> +test_xorg_list_for_each(void)
> {
> struct parent parent = {0};
> struct child child[3];
> struct child *c;
> int i = 0;
> 
> -    list_init(&parent.children);
> +    xorg_list_init(&parent.children);
> 
> -    list_add(&child[2].node, &parent.children);
> -    list_add(&child[1].node, &parent.children);
> -    list_add(&child[0].node, &parent.children);
> +    xorg_list_add(&child[2].node, &parent.children);
> +    xorg_list_add(&child[1].node, &parent.children);
> +    xorg_list_add(&child[0].node, &parent.children);
> 
> -    list_for_each_entry(c, &parent.children, node) {
> +    xorg_list_for_each_entry(c, &parent.children, node) {
> assert(memcmp(c, &child[i], sizeof(struct child)) == 0);
> i++;
> }
> 
> /* foreach on empty list */
> -    list_del(&parent.children);
> -    assert(list_is_empty(&parent.children));
> +    xorg_list_del(&parent.children);
> +    assert(xorg_list_is_empty(&parent.children));
> 
> -    list_for_each_entry(c, &parent.children, node) {
> +    xorg_list_for_each_entry(c, &parent.children, node) {
> assert(0); /* we must not get here */
> }
> }
> @@ -359,11 +359,11 @@ test_nt_list_delete(void)
> 
> int main(int argc, char** argv)
> {
> -    test_list_init();
> -    test_list_add();
> -    test_list_append();
> -    test_list_del();
> -    test_list_for_each();
> +    test_xorg_list_init();
> +    test_xorg_list_add();
> +    test_xorg_list_append();
> +    test_xorg_list_del();
> +    test_xorg_list_for_each();
> 
> test_nt_list_init();
> test_nt_list_append();
> diff --git a/xfixes/cursor.c b/xfixes/cursor.c
> index 53f9f20..7c46269 100644
> --- a/xfixes/cursor.c
> +++ b/xfixes/cursor.c
> @@ -116,7 +116,7 @@ typedef struct PointerBarrierClient *PointerBarrierClientPtr;
> struct PointerBarrierClient {
> ScreenPtr screen;
> struct PointerBarrier barrier;
> -    struct list entry;
> +    struct xorg_list entry;
> };
> 
> /*
> @@ -128,7 +128,7 @@ typedef struct _CursorScreen {
> CloseScreenProcPtr		CloseScreen;
> ConstrainCursorHarderProcPtr ConstrainCursorHarder;
> CursorHideCountPtr          pCursorHideCounts;
> -    struct list                 barriers;
> +    struct xorg_list            barriers;
> } CursorScreenRec, *CursorScreenPtr;
> 
> #define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, \
> CursorScreenPrivateKey)) @@ -1172,7 +1172,7 @@ barrier_find_nearest(CursorScreenPtr \
> cs, int dir, struct PointerBarrier *nearest = NULL;
> double min_distance = INT_MAX; /* can't get higher than that in X anyway */
> 
> -    list_for_each_entry(c, &cs->barriers, entry) {
> +    xorg_list_for_each_entry(c, &cs->barriers, entry) {
> 	struct PointerBarrier *b = &c->barrier;
> 	double distance;
> 
> @@ -1224,7 +1224,7 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr \
> screen, int mode, int *x {
> CursorScreenPtr cs = GetCursorScreen(screen);
> 
> -    if (!list_is_empty(&cs->barriers) && !IsFloating(dev) && mode == Relative) {
> +    if (!xorg_list_is_empty(&cs->barriers) && !IsFloating(dev) && mode == \
> Relative) {  int ox, oy;
> 	int dir;
> 	struct PointerBarrier *nearest = NULL;
> @@ -1285,7 +1285,7 @@ CreatePointerBarrierClient(ScreenPtr screen, ClientPtr \
> client,  ret->barrier.directions &= ~(BarrierPositiveX | BarrierNegativeX);
> 	if (barrier_is_vertical(&ret->barrier))
> 	    ret->barrier.directions &= ~(BarrierPositiveY | BarrierNegativeY);
> -	list_add(&ret->entry, &cs->barriers);
> +	xorg_list_add(&ret->entry, &cs->barriers);
> }
> 
> return ret;
> @@ -1364,9 +1364,9 @@ CursorFreeBarrier(void *data, XID id)
> cs = GetCursorScreen(screen);
> 
> /* find and unlink from the screen private */
> -    list_for_each_entry(b, &cs->barriers, entry) {
> +    xorg_list_for_each_entry(b, &cs->barriers, entry) {
> 	if (b == barrier) {
> -	    list_del(&b->entry);
> +	    xorg_list_del(&b->entry);
> 	    break;
> 	}
> }
> @@ -1426,7 +1426,7 @@ XFixesCursorInit (void)
> 	cs = (CursorScreenPtr) calloc(1, sizeof (CursorScreenRec));
> 	if (!cs)
> 	    return FALSE;
> -	list_init(&cs->barriers);
> +	xorg_list_init(&cs->barriers);
> 	Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
> 	Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
> 	Wrap (cs, pScreen, ConstrainCursorHarder, CursorConstrainCursorHarder);
> -- 
> 1.7.3.2
> 
> _______________________________________________
> xorg-devel@lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 
_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic