On Wed, Sep 9, 2009 at 11:13 AM, Vincent Torri<vto...@univ-evry.fr> wrote: > > > On Wed, 9 Sep 2009, Enlightenment SVN wrote: >> >> Modified: trunk/eina/src/include/eina_inlist.h >> =================================================================== >> --- trunk/eina/src/include/eina_inlist.h 2009-09-09 10:44:25 UTC >> (rev 42365) >> +++ trunk/eina/src/include/eina_inlist.h 2009-09-09 14:05:31 UTC >> (rev 42366) >> @@ -52,7 +52,7 @@ >> >> #define EINA_INLIST Eina_Inlist __in_list >> #define EINA_INLIST_GET(Inlist) (&((Inlist)->__in_list)) >> -#define EINA_INLIST_CONTAINER_GET(ptr, type) ((type *) ((Eina_Inlist *) >> ptr - offsetof(type, __in_list))) >> +#define EINA_INLIST_CONTAINER_GET(ptr, type) ((type *) ((char *) ptr - >> offsetof(type, __in_list))) > > Iirc, i have already said that offsetof does not exist on Windows CE >
That macro was already there, I just fixed the cast to get the right address. I don't think it's used anywhere so it can be replaced by the macros below. > Also, I don't know if it is important or not, but on OpenSolaris with suncc, > char is a signed type (-128...127) > And char *? > Vincent > >> >> EAPI Eina_Inlist * eina_inlist_append(Eina_Inlist *in_list, Eina_Inlist >> *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; >> EAPI Eina_Inlist * eina_inlist_prepend(Eina_Inlist *in_list, Eina_Inlist >> *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; >> @@ -67,9 +67,14 @@ >> EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) >> EINA_MALLOC EINA_WARN_UNUSED_RESULT; >> EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) >> EINA_MALLOC EINA_WARN_UNUSED_RESULT; >> >> -#define EINA_INLIST_FOREACH(list, l) for (l = (void*)list; l; l = >> (void*)(l->__in_list.next)) >> -#define EINA_INLIST_REVERSE_FOREACH(list, l) for (l = (list ? >> (void*)(list->last) : NULL); l; l = (void*)(l->__in_list.prev)) >> +/* This two macros are helpers for the _FOREACH ones, don't use them */ >> +#define INLIST_OFFSET(ref) ((char*)&(ref)->__in_list - (char*)(ref)) >> +#define INLIST_CONTAINER(ref, ptr) (void*)((char*)(ptr) - >> INLIST_OFFSET(ref)) >> >> +#define EINA_INLIST_FOREACH(list, l) for (l = (list ? INLIST_CONTAINER(l, >> list) : NULL); l; l = (EINA_INLIST_GET(l)->next ? INLIST_CONTAINER(l, >> EINA_INLIST_GET(l)->next) : NULL)) >> +#define EINA_INLIST_REVERSE_FOREACH(list, l) for (l = (list ? >> INLIST_CONTAINER(l, list->last) : NULL); l; l = (EINA_INLIST_GET(l)->prev ? >> INLIST_CONTAINER(l, EINA_INLIST_GET(l)->prev) : NULL)) >> + >> + >> /** >> * @} >> */ >> >> Modified: trunk/eina/src/tests/eina_test_inlist.c >> =================================================================== >> --- trunk/eina/src/tests/eina_test_inlist.c 2009-09-09 10:44:25 UTC >> (rev 42365) >> +++ trunk/eina/src/tests/eina_test_inlist.c 2009-09-09 14:05:31 UTC >> (rev 42366) >> @@ -30,8 +30,8 @@ >> typedef struct _Eina_Test_Inlist Eina_Test_Inlist; >> struct _Eina_Test_Inlist >> { >> + int i; >> EINA_INLIST; >> - int i; >> }; >> >> static Eina_Test_Inlist* >> @@ -63,13 +63,13 @@ >> tmp = _eina_test_inlist_build(1664); >> lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), lst); >> fail_if(!lst); >> - fail_if(((Eina_Test_Inlist*)lst)->i != 42); >> + fail_if(EINA_INLIST_CONTAINER_GET(lst, Eina_Test_Inlist)->i != 42); >> >> prev = tmp; >> tmp = _eina_test_inlist_build(3227); >> lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), >> EINA_INLIST_GET(prev)); >> fail_if(!lst); >> - fail_if(((Eina_Test_Inlist*)lst)->i != 42); >> + fail_if(EINA_INLIST_CONTAINER_GET(lst, Eina_Test_Inlist)->i != 42); >> >> lst = eina_inlist_remove(lst, EINA_INLIST_GET(tmp)); >> >> @@ -111,16 +111,17 @@ >> fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); >> #endif >> >> - tmp = (Eina_Test_Inlist*) lst; >> + tmp = EINA_INLIST_CONTAINER_GET(lst, Eina_Test_Inlist); >> lst = eina_inlist_demote(lst, lst); >> - fail_if(lst == (Eina_Inlist*) tmp); >> + fail_if(EINA_INLIST_CONTAINER_GET(lst, Eina_Test_Inlist) == tmp); >> >> lst = eina_inlist_promote(lst, EINA_INLIST_GET(tmp)); >> - fail_if(lst != (Eina_Inlist*) tmp); >> + fail_if(lst != EINA_INLIST_GET(tmp)); >> >> - tmp = (Eina_Test_Inlist*) eina_inlist_find(lst, >> EINA_INLIST_GET(prev)); >> + tmp = EINA_INLIST_CONTAINER_GET(eina_inlist_find(lst, >> EINA_INLIST_GET(prev)), Eina_Test_Inlist); >> lst = eina_inlist_remove(lst, EINA_INLIST_GET(tmp)); >> - tmp = (Eina_Test_Inlist*) eina_inlist_find(lst, EINA_INLIST_GET(tmp)); >> + prev = eina_inlist_find(lst, EINA_INLIST_GET(tmp)); >> + tmp = prev ? EINA_INLIST_CONTAINER_GET(prev, Eina_Test_Inlist) : NULL; >> fail_if(tmp != NULL); >> >> while (lst) >> >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> enlightenment-svn mailing list >> enlightenment-...@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn >> >> -- >> Ce message a été vérifié par MailScanner >> pour des virus ou des polluriels et rien de >> suspect n'a été trouvé. >> Message délivré par le serveur de messagerie de l'Université d'Evry. >> > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > enlightenment-devel mailing list > enlightenment-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel