* [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ @ 2012-10-18 17:33 Yann E. MORIN 2012-10-18 17:55 ` Yaakov (Cygwin/X) ` (3 more replies) 0 siblings, 4 replies; 16+ messages in thread From: Yann E. MORIN @ 2012-10-18 17:33 UTC (permalink / raw) To: linux-kbuild, linux-kernel Cc: Michal Marek, Tetsuo Handa, Benjamin Poirier, Yann E. MORIN, Yaakov Selkowitz Some systems (eg. Cygwin, FreeBSD) are missing the CIRCLEQ macros. They were removed in Y2000 from FreeBSD: http://svnweb.freebsd.org/base?view=revision&revision=70469 The reason was that TAILQ are perfectly capable of doing the exact same things: http://www.mavetju.org/mail/view_thread.php?list=freebsd-arch&id=915145&thread=yes (Thank Yaakov for the pointers!) So, switch to using TAILQ instead, which are more portable. Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Reported-by: Benjamin Poirier <bpoirier@suse.de> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Yaakov Selkowitz <yselkowitz@gmail.com> --- scripts/kconfig/expr.h | 4 ++-- scripts/kconfig/mconf.c | 4 ++-- scripts/kconfig/menu.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index bd2e098..c6a8b99 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -175,12 +175,12 @@ struct menu { #define MENU_ROOT 0x0002 struct jump_key { - CIRCLEQ_ENTRY(jump_key) entries; + TAILQ_ENTRY(jump_key) entries; size_t offset; struct menu *target; int index; }; -CIRCLEQ_HEAD(jk_head, jump_key); +TAILQ_HEAD(jk_head, jump_key); #define JUMP_NB 9 diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 48f6744..f1ee1c9 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -323,7 +323,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data) struct jump_key *pos; int k = 0; - CIRCLEQ_FOREACH(pos, data->head, entries) { + TAILQ_FOREACH(pos, data->head, entries) { if (pos->offset >= start && pos->offset < end) { char header[4]; @@ -375,7 +375,7 @@ again: sym_arr = sym_re_search(dialog_input); do { - struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head); + struct jk_head head = TAILQ_HEAD_INITIALIZER(head); struct menu *targets[JUMP_NB]; int keys[JUMP_NB + 1], i; struct search_data data = { diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index a3cade6..9eff451 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -544,12 +544,12 @@ static void get_prompt_str(struct gstr *r, struct property *prop, } else jump->target = location; - if (CIRCLEQ_EMPTY(head)) + if (TAILQ_EMPTY(head)) jump->index = 0; else - jump->index = CIRCLEQ_LAST(head)->index + 1; + jump->index = TAILQ_LAST(head, jk_head)->index + 1; - CIRCLEQ_INSERT_TAIL(head, jump, entries); + TAILQ_INSERT_TAIL(head, jump, entries); } if (i > 0) { -- 1.7.2.5 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-18 17:33 [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ Yann E. MORIN @ 2012-10-18 17:55 ` Yaakov (Cygwin/X) 2012-10-18 18:59 ` Yann E. MORIN 2012-10-19 12:10 ` Tetsuo Handa ` (2 subsequent siblings) 3 siblings, 1 reply; 16+ messages in thread From: Yaakov (Cygwin/X) @ 2012-10-18 17:55 UTC (permalink / raw) To: Yann E. MORIN Cc: linux-kbuild, linux-kernel, Michal Marek, Tetsuo Handa, Benjamin Poirier On Thu, 2012-10-18 at 19:33 +0200, Yann E. MORIN wrote: > Some systems (eg. Cygwin, FreeBSD) are missing the CIRCLEQ macros. > They were removed in Y2000 from FreeBSD: > http://svnweb.freebsd.org/base?view=revision&revision=70469 > > The reason was that TAILQ are perfectly capable of doing the exact > same things: > http://www.mavetju.org/mail/view_thread.php?list=freebsd-arch&id=915145&thread=yes > > (Thank Yaakov for the pointers!) And thank you again for the heads-up. > So, switch to using TAILQ instead, which are more portable. > > Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> > Reported-by: Benjamin Poirier <bpoirier@suse.de> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-18 17:55 ` Yaakov (Cygwin/X) @ 2012-10-18 18:59 ` Yann E. MORIN 2012-10-19 8:59 ` Yaakov (Cygwin/X) 0 siblings, 1 reply; 16+ messages in thread From: Yann E. MORIN @ 2012-10-18 18:59 UTC (permalink / raw) To: linux-kbuild Cc: Yaakov (Cygwin/X), linux-kernel, Michal Marek, Tetsuo Handa, Benjamin Poirier Yaakov, All, On Thursday 18 October 2012 Yaakov (Cygwin/X) wrote: > On Thu, 2012-10-18 at 19:33 +0200, Yann E. MORIN wrote: > > Some systems (eg. Cygwin, FreeBSD) are missing the CIRCLEQ macros. > > They were removed in Y2000 from FreeBSD: > > http://svnweb.freebsd.org/base?view=revision&revision=70469 > > > > The reason was that TAILQ are perfectly capable of doing the exact > > same things: > > http://www.mavetju.org/mail/view_thread.php?list=freebsd-arch&id=915145&thread=yes > > > > (Thank Yaakov for the pointers!) > > And thank you again for the heads-up. > > > So, switch to using TAILQ instead, which are more portable. > > > > Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> > > Reported-by: Benjamin Poirier <bpoirier@suse.de> > > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> > > Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> Out of curiosity: did you test on Cygwin? Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-18 18:59 ` Yann E. MORIN @ 2012-10-19 8:59 ` Yaakov (Cygwin/X) 0 siblings, 0 replies; 16+ messages in thread From: Yaakov (Cygwin/X) @ 2012-10-19 8:59 UTC (permalink / raw) To: Yann E. MORIN Cc: linux-kbuild, linux-kernel, Michal Marek, Tetsuo Handa, Benjamin Poirier On Thu, 2012-10-18 at 20:59 +0200, Yann E. MORIN wrote: > On Thursday 18 October 2012 Yaakov (Cygwin/X) wrote: > > Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> > > Out of curiosity: did you test on Cygwin? Yes, of course. Yaakov Cygwin Ports ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-18 17:33 [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ Yann E. MORIN 2012-10-18 17:55 ` Yaakov (Cygwin/X) @ 2012-10-19 12:10 ` Tetsuo Handa 2012-10-19 14:54 ` Michal Marek 2012-10-19 22:52 ` Yann E. MORIN 2012-10-20 17:56 ` [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists Benjamin Poirier 2012-10-23 13:12 ` [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ Christoph Hellwig 3 siblings, 2 replies; 16+ messages in thread From: Tetsuo Handa @ 2012-10-19 12:10 UTC (permalink / raw) To: yann.morin.1998, linux-kbuild, linux-kernel; +Cc: mmarek, bpoirier, yselkowitz Yann E. MORIN wrote: > Some systems (eg. Cygwin, FreeBSD) are missing the CIRCLEQ macros. > They were removed in Y2000 from FreeBSD: > http://svnweb.freebsd.org/base?view=revision&revision=70469 > > The reason was that TAILQ are perfectly capable of doing the exact > same things: > http://www.mavetju.org/mail/view_thread.php?list=freebsd-arch&id=915145&thread=yes > > (Thank Yaakov for the pointers!) > > So, switch to using TAILQ instead, which are more portable. > > Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> > Reported-by: Benjamin Poirier <bpoirier@suse.de> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> > Cc: Yaakov Selkowitz <yselkowitz@gmail.com> > --- > scripts/kconfig/expr.h | 4 ++-- > scripts/kconfig/mconf.c | 4 ++-- > scripts/kconfig/menu.c | 6 +++--- > 3 files changed, 7 insertions(+), 7 deletions(-) > Excuse me, but your patch does not solve my problem because kconfig started using macros which does not exist in "@(#)queue.h 8.3 (Berkeley) 12/13/93". Kconfig still fails after applying your patch: HOSTCC scripts/kconfig/mconf.o scripts/kconfig/mconf.c: In function `update_text': scripts/kconfig/mconf.c:326: warning: implicit declaration of function `TAILQ_FOREACH' scripts/kconfig/mconf.c:326: error: `entries' undeclared (first use in this function) scripts/kconfig/mconf.c:326: error: (Each undeclared identifier is reported only once scripts/kconfig/mconf.c:326: error: for each function it appears in.) scripts/kconfig/mconf.c:326: error: syntax error before '{' token scripts/kconfig/mconf.c:333: error: `header' undeclared (first use in this function) scripts/kconfig/mconf.c: At top level: scripts/kconfig/mconf.c:343: error: syntax error before '}' token scripts/kconfig/mconf.c: In function `search_conf': scripts/kconfig/mconf.c:378: warning: implicit declaration of function `TAILQ_HEAD_INITIALIZER' scripts/kconfig/mconf.c:378: error: invalid initializer make[1]: *** [scripts/kconfig/mconf.o] Error 1 make: *** [menuconfig] Error 2 So, would you add something which looks like "sed -e 's/CIRCLEQ/TAILQ/g'" upon https://lkml.org/lkml/2012/10/16/274 ? ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-19 12:10 ` Tetsuo Handa @ 2012-10-19 14:54 ` Michal Marek 2012-10-20 14:43 ` Tetsuo Handa 2012-10-19 22:52 ` Yann E. MORIN 1 sibling, 1 reply; 16+ messages in thread From: Michal Marek @ 2012-10-19 14:54 UTC (permalink / raw) To: Tetsuo Handa Cc: yann.morin.1998, linux-kbuild, linux-kernel, bpoirier, yselkowitz On 19.10.2012 14:10, Tetsuo Handa wrote: > Yann E. MORIN wrote: >> So, switch to using TAILQ instead, which are more portable. [...] > Excuse me, but your patch does not solve my problem because kconfig started > using macros which does not exist in "@(#)queue.h 8.3 (Berkeley) 12/13/93". > Kconfig still fails after applying your patch: > > HOSTCC scripts/kconfig/mconf.o > scripts/kconfig/mconf.c: In function `update_text': > scripts/kconfig/mconf.c:326: warning: implicit declaration of function `TAILQ_FOREACH' [...] > scripts/kconfig/mconf.c:378: warning: implicit declaration of function `TAILQ_HEAD_INITIALIZER' > > So, would you add something which looks like "sed -e 's/CIRCLEQ/TAILQ/g'" upon > https://lkml.org/lkml/2012/10/16/274 ? Could you reduce that patch to not copy all of queue.h? TAILQ_HEAD_INITIALIZER can be replaced by a TAILQ_INIT() call after variable definitions, and we do not need stuff like TAILQ_FOREACH_REVERSE. The other option is to reimplement the needed operations under a different name, so that people don't accidentally use other macros that are missing in old queue.h revisions. Michal ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-19 14:54 ` Michal Marek @ 2012-10-20 14:43 ` Tetsuo Handa 2012-10-20 16:58 ` Yann E. MORIN 0 siblings, 1 reply; 16+ messages in thread From: Tetsuo Handa @ 2012-10-20 14:43 UTC (permalink / raw) To: mmarek; +Cc: yann.morin.1998, linux-kbuild, linux-kernel, bpoirier, yselkowitz Michal Marek wrote: > On 19.10.2012 14:10, Tetsuo Handa wrote: > > Yann E. MORIN wrote: > >> So, switch to using TAILQ instead, which are more portable. > [...] > > Excuse me, but your patch does not solve my problem because kconfig started > > using macros which does not exist in "@(#)queue.h 8.3 (Berkeley) 12/13/93". > > Kconfig still fails after applying your patch: > > > > HOSTCC scripts/kconfig/mconf.o > > scripts/kconfig/mconf.c: In function `update_text': > > scripts/kconfig/mconf.c:326: warning: implicit declaration of function `TAILQ_FOREACH' > [...] > > scripts/kconfig/mconf.c:378: warning: implicit declaration of function `TAILQ_HEAD_INITIALIZER' > > > > So, would you add something which looks like "sed -e 's/CIRCLEQ/TAILQ/g'" upon > > https://lkml.org/lkml/2012/10/16/274 ? > > Could you reduce that patch to not copy all of queue.h? > TAILQ_HEAD_INITIALIZER can be replaced by a TAILQ_INIT() call after > variable definitions, and we do not need stuff like > TAILQ_FOREACH_REVERSE. The other option is to reimplement the needed > operations under a different name, so that people don't accidentally use > other macros that are missing in old queue.h revisions. > > Michal > I'm fine to manually add missing macros to /usr/include/sys/queue.h of "@(#)queue.h 8.3 (Berkeley) 12/13/93" in my environment instead of adding define-as-needed lines to scripts/kconfig/expr.h, for missing macros are available with that of "@(#)queue.h 8.5 (Berkeley) 8/20/94". ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-20 14:43 ` Tetsuo Handa @ 2012-10-20 16:58 ` Yann E. MORIN 0 siblings, 0 replies; 16+ messages in thread From: Yann E. MORIN @ 2012-10-20 16:58 UTC (permalink / raw) To: linux-kbuild; +Cc: Tetsuo Handa, mmarek, linux-kernel, bpoirier, yselkowitz Tetuso, All, On Saturday 20 October 2012 Tetsuo Handa wrote: > Michal Marek wrote: > > On 19.10.2012 14:10, Tetsuo Handa wrote: > > > Yann E. MORIN wrote: > > >> So, switch to using TAILQ instead, which are more portable. > > [...] > > > Excuse me, but your patch does not solve my problem because kconfig started > > > using macros which does not exist in "@(#)queue.h 8.3 (Berkeley) 12/13/93". > > > Kconfig still fails after applying your patch: > > > > > > HOSTCC scripts/kconfig/mconf.o > > > scripts/kconfig/mconf.c: In function `update_text': > > > scripts/kconfig/mconf.c:326: warning: implicit declaration of function `TAILQ_FOREACH' > > [...] > > > scripts/kconfig/mconf.c:378: warning: implicit declaration of function `TAILQ_HEAD_INITIALIZER' > > > > > > So, would you add something which looks like "sed -e 's/CIRCLEQ/TAILQ/g'" upon > > > https://lkml.org/lkml/2012/10/16/274 ? > > > > Could you reduce that patch to not copy all of queue.h? > > TAILQ_HEAD_INITIALIZER can be replaced by a TAILQ_INIT() call after > > variable definitions, and we do not need stuff like > > TAILQ_FOREACH_REVERSE. The other option is to reimplement the needed > > operations under a different name, so that people don't accidentally use > > other macros that are missing in old queue.h revisions. > > > > Michal > > > > I'm fine to manually add missing macros to /usr/include/sys/queue.h of > "@(#)queue.h 8.3 (Berkeley) 12/13/93" in my environment instead of adding > define-as-needed lines to scripts/kconfig/expr.h, for missing macros are > available with that of "@(#)queue.h 8.5 (Berkeley) 8/20/94". Are you OK with this s/CIRCLEQ/TAILQ/ patch, then? http://marc.info/?l=linux-kbuild&m=135058165015518&w=2 Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-19 12:10 ` Tetsuo Handa 2012-10-19 14:54 ` Michal Marek @ 2012-10-19 22:52 ` Yann E. MORIN 1 sibling, 0 replies; 16+ messages in thread From: Yann E. MORIN @ 2012-10-19 22:52 UTC (permalink / raw) To: linux-kbuild; +Cc: Tetsuo Handa, linux-kernel, mmarek, bpoirier, yselkowitz Tetsuo, Michal, All, On Friday 19 October 2012 Tetsuo Handa wrote: > Yann E. MORIN wrote: > > Some systems (eg. Cygwin, FreeBSD) are missing the CIRCLEQ macros. [--SNIP--] > > So, switch to using TAILQ instead, which are more portable. [--SNIP--] > Excuse me, but your patch does not solve my problem because kconfig started > using macros which does not exist in "@(#)queue.h 8.3 (Berkeley) 12/13/93". Whoa. That's old... :-/ Currently, kconfig uses (CIRCLEQ or TAILQ) > Kconfig still fails after applying your patch: [--SNIP--] > So, would you add something which looks like "sed -e 's/CIRCLEQ/TAILQ/g'" upon > https://lkml.org/lkml/2012/10/16/274 ? Sorry, I did not see you had posted a patch. Basically, I don't care what solution we choose. Using TAILQ looks like being not the solution. So, here are the known options: 1- Michal pointed to tools/firewire/list.h, but those are different from the CIRCLEQ/TAILQ, and switching is not easy (at least for me after a quick glance); 1b- note also that drivers/scsi/aic7xxx/queue.h has all of both the CIRCLEQ and TAILQ macros we're interested in, too, and it looks like it can be used out of the kernel (eg. for userland); 2- carry the parts of CIRCLEQ (or TAILQ) that we need, and use them if the system's sys/queue.h does not provide them, as Tetsuo proposed; 3- carry the parts of CIRCLEQ (or TAILQ) that we need, and do not rely on the system's sys/queue.h to provide them at all. Michal, what do you think would be the best route to go, to: 1- get a fix in 3.7 ? 2- if the fix for 3.7 is just a workaround, a proper fix for 3.8 ? Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists. 2012-10-18 17:33 [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ Yann E. MORIN 2012-10-18 17:55 ` Yaakov (Cygwin/X) 2012-10-19 12:10 ` Tetsuo Handa @ 2012-10-20 17:56 ` Benjamin Poirier 2012-10-20 21:22 ` Yann E. MORIN ` (2 more replies) 2012-10-23 13:12 ` [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ Christoph Hellwig 3 siblings, 3 replies; 16+ messages in thread From: Benjamin Poirier @ 2012-10-20 17:56 UTC (permalink / raw) To: Michal Marek Cc: Jean Sacren, Arnaud Lacombe, Wang YanQing, Paul Gortmaker, Davidlohr Bueso, linux-kbuild, linux-kernel, Yann E. MORIN, Tetsuo Handa, Yaakov Selkowitz From: Benjamin Poirier <bpoirier@suse.de> sys/queue.h and CIRCLEQ in particular have proven to cause portability problems (reported on Debian Sarge, Cygwin and FreeBSD) Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Benjamin Poirier <bpoirier@suse.de> --- scripts/kconfig/expr.h | 5 +-- scripts/kconfig/list.h | 90 +++++++++++++++++++++++++++++++++++++++++++ scripts/kconfig/lkc_proto.h | 4 +- scripts/kconfig/mconf.c | 6 +-- scripts/kconfig/menu.c | 14 ++++--- 5 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 scripts/kconfig/list.h diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index bd2e098..cdd4860 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -12,7 +12,7 @@ extern "C" { #include <assert.h> #include <stdio.h> -#include <sys/queue.h> +#include "list.h" #ifndef __cplusplus #include <stdbool.h> #endif @@ -175,12 +175,11 @@ struct menu { #define MENU_ROOT 0x0002 struct jump_key { - CIRCLEQ_ENTRY(jump_key) entries; + struct list_head entries; size_t offset; struct menu *target; int index; }; -CIRCLEQ_HEAD(jk_head, jump_key); #define JUMP_NB 9 diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h new file mode 100644 index 0000000..934bdba --- /dev/null +++ b/scripts/kconfig/list.h @@ -0,0 +1,90 @@ +#ifndef LIST_H +#define LIST_H + +/* + * Copied from include/linux/... + */ + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + + +struct list_head { + struct list_head *next, *prev; +}; + + +#define LIST_HEAD_INIT(name) { &(name), &(name) } + +#define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + +/** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + +/** + * list_for_each_entry - iterate over list of given type + * @pos: the type * to use as a loop cursor. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ +#define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member)) + +#endif + +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +static inline int list_empty(const struct list_head *head) +{ + return head->next == head; +} + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + +/** + * list_add_tail - add a new entry + * @new: new entry to be added + * @head: list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + */ +static inline void list_add_tail(struct list_head *new, struct list_head *head) +{ + __list_add(new, head->prev, head); +} diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 1d1c085..ef1a738 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -21,9 +21,9 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu)); P(menu_get_parent_menu,struct menu *,(struct menu *menu)); P(menu_has_help,bool,(struct menu *menu)); P(menu_get_help,const char *,(struct menu *menu)); -P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct jk_head +P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head *head)); -P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct jk_head +P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head *head)); P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 48f6744..53975cf 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -312,7 +312,7 @@ static void set_config_filename(const char *config_filename) struct search_data { - struct jk_head *head; + struct list_head *head; struct menu **targets; int *keys; }; @@ -323,7 +323,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data) struct jump_key *pos; int k = 0; - CIRCLEQ_FOREACH(pos, data->head, entries) { + list_for_each_entry(pos, data->head, entries) { if (pos->offset >= start && pos->offset < end) { char header[4]; @@ -375,7 +375,7 @@ again: sym_arr = sym_re_search(dialog_input); do { - struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head); + LIST_HEAD(head); struct menu *targets[JUMP_NB]; int keys[JUMP_NB + 1], i; struct search_data data = { diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index a3cade6..e98a05c 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -508,7 +508,7 @@ const char *menu_get_help(struct menu *menu) } static void get_prompt_str(struct gstr *r, struct property *prop, - struct jk_head *head) + struct list_head *head) { int i, j; struct menu *submenu[8], *menu, *location = NULL; @@ -544,12 +544,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop, } else jump->target = location; - if (CIRCLEQ_EMPTY(head)) + if (list_empty(head)) jump->index = 0; else - jump->index = CIRCLEQ_LAST(head)->index + 1; + jump->index = list_entry(head->prev, struct jump_key, + entries)->index + 1; - CIRCLEQ_INSERT_TAIL(head, jump, entries); + list_add_tail(&jump->entries, head); } if (i > 0) { @@ -573,7 +574,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop, /* * head is optional and may be NULL */ -void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) +void get_symbol_str(struct gstr *r, struct symbol *sym, + struct list_head *head) { bool hit; struct property *prop; @@ -612,7 +614,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) str_append(r, "\n\n"); } -struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head) +struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head) { struct symbol *sym; struct gstr res = str_new(); -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists. 2012-10-20 17:56 ` [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists Benjamin Poirier @ 2012-10-20 21:22 ` Yann E. MORIN 2012-10-21 1:21 ` Tetsuo Handa 2012-10-20 22:19 ` Yann E. MORIN 2012-10-21 1:54 ` Yaakov (Cygwin/X) 2 siblings, 1 reply; 16+ messages in thread From: Yann E. MORIN @ 2012-10-20 21:22 UTC (permalink / raw) To: Benjamin Poirier Cc: Michal Marek, Jean Sacren, Arnaud Lacombe, Wang YanQing, Paul Gortmaker, Davidlohr Bueso, linux-kbuild, linux-kernel, Tetsuo Handa, Yaakov Selkowitz Benjamin, All, On Saturday 20 October 2012 Benjamin Poirier wrote: > From: Benjamin Poirier <bpoirier@suse.de> > > sys/queue.h and CIRCLEQ in particular have proven to cause portability > problems (reported on Debian Sarge, Cygwin and FreeBSD) > > Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > Signed-off-by: Benjamin Poirier <bpoirier@suse.de> Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Thank you for this patch! I guess it is the best solution we can get. Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists. 2012-10-20 21:22 ` Yann E. MORIN @ 2012-10-21 1:21 ` Tetsuo Handa 0 siblings, 0 replies; 16+ messages in thread From: Tetsuo Handa @ 2012-10-21 1:21 UTC (permalink / raw) To: yann.morin.1998, benjamin.poirier Cc: mmarek, sakiwit, lacombar, udknight, paul.gortmaker, dave, linux-kbuild, linux-kernel, yselkowitz Yann E. MORIN wrote: > Benjamin, All, > > On Saturday 20 October 2012 Benjamin Poirier wrote: > > From: Benjamin Poirier <bpoirier@suse.de> > > > > sys/queue.h and CIRCLEQ in particular have proven to cause portability > > problems (reported on Debian Sarge, Cygwin and FreeBSD) > > > > Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > > Signed-off-by: Benjamin Poirier <bpoirier@suse.de> > > Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr> > > Thank you for this patch! I guess it is the best solution we can get. > > Regards, > Yann E. MORIN. This patch solves my problem on Debian Sarge. Thank you. Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists. 2012-10-20 17:56 ` [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists Benjamin Poirier 2012-10-20 21:22 ` Yann E. MORIN @ 2012-10-20 22:19 ` Yann E. MORIN 2012-10-21 1:54 ` Yaakov (Cygwin/X) 2 siblings, 0 replies; 16+ messages in thread From: Yann E. MORIN @ 2012-10-20 22:19 UTC (permalink / raw) To: linux-kbuild Cc: Benjamin Poirier, Michal Marek, Jean Sacren, Arnaud Lacombe, Wang YanQing, Paul Gortmaker, Davidlohr Bueso, linux-kernel, Tetsuo Handa, Yaakov Selkowitz Benjamin, All, On Saturday 20 October 2012 Benjamin Poirier wrote: > From: Benjamin Poirier <bpoirier@suse.de> > > sys/queue.h and CIRCLEQ in particular have proven to cause portability > problems (reported on Debian Sarge, Cygwin and FreeBSD) > > Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > Signed-off-by: Benjamin Poirier <bpoirier@suse.de> Sorry for my earlier optimistic reply, but... While menuconfig got fixed with this patch, xconfig is now broken: First issue: In file included from /home/ymorin/dev/linux/scripts/kconfig/expr.h:15, from /home/ymorin/dev/linux/scripts/kconfig/lkc.h:9, from /home/ymorin/dev/linux/scripts/kconfig/qconf.cc:45: /home/ymorin/dev/linux/scripts/kconfig/list.h:8:1: warning: "offsetof" redefined In file included from /usr/include/_G_config.h:15, from /usr/include/libio.h:32, from /usr/include/stdio.h:75, from /usr/include/qt4/QtCore/qtextstream.h:57, from /usr/include/qt4/Qt3Support/q3mainwindow.h:47, from /home/ymorin/dev/linux/scripts/kconfig/qconf.cc:19: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/include/stddef.h:411:1: warning: this is the location of the previous definition [--SNIP--] > diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h > new file mode 100644 > index 0000000..934bdba > --- /dev/null > +++ b/scripts/kconfig/list.h > @@ -0,0 +1,90 @@ > +#ifndef LIST_H > +#define LIST_H > + > +/* > + * Copied from include/linux/... > + */ > + > +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) We could #include <stddef.h>, but then we may end up with issues with old systems (which we are trying to fix!). I suggest we enclose the definition between a #ifndef offsetof ... #endif Second issue: We have further issues with some variable names: /home/ymorin/dev/linux/scripts/kconfig/list.h:69: error: expected ‘,’ or ‘...’ before ‘new’ [--SNIP--] > +static inline void __list_add(struct list_head *new, 'new' is a reserved key-word in C++, and xconfig is using qconf, which is written in C++. I 'd suggest to: 1- rename the variable 2- enclose the whole header in: #ifdef __cplusplus extern "C" { #endif [.....] #ifdef __cplusplus } #endif Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists. 2012-10-20 17:56 ` [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists Benjamin Poirier 2012-10-20 21:22 ` Yann E. MORIN 2012-10-20 22:19 ` Yann E. MORIN @ 2012-10-21 1:54 ` Yaakov (Cygwin/X) 2 siblings, 0 replies; 16+ messages in thread From: Yaakov (Cygwin/X) @ 2012-10-21 1:54 UTC (permalink / raw) To: Benjamin Poirier, Yann E. MORIN Cc: Michal Marek, Jean Sacren, Arnaud Lacombe, Wang YanQing, Paul Gortmaker, Davidlohr Bueso, linux-kbuild, linux-kernel, Tetsuo Handa On Sat, 2012-10-20 at 13:56 -0400, Benjamin Poirier wrote: > From: Benjamin Poirier <bpoirier@suse.de> > menuconfig: Replace CIRCLEQ by list_head-style lists > > sys/queue.h and CIRCLEQ in particular have proven to cause portability > problems (reported on Debian Sarge, Cygwin and FreeBSD) > > Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > Signed-off-by: Benjamin Poirier <bpoirier@suse.de> > From: "Yann E. MORIN" <yann.morin.1998@free.fr> > kconfig: fix building the qconf frontend > > Also, protect the whole file with the #ifdenf LIST_H, not only the > macros > defintions. > > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Squash these two together and all frontends build again on Cygwin. Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-18 17:33 [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ Yann E. MORIN ` (2 preceding siblings ...) 2012-10-20 17:56 ` [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists Benjamin Poirier @ 2012-10-23 13:12 ` Christoph Hellwig 2012-10-23 17:04 ` Yann E. MORIN 3 siblings, 1 reply; 16+ messages in thread From: Christoph Hellwig @ 2012-10-23 13:12 UTC (permalink / raw) To: Yann E. MORIN Cc: linux-kbuild, linux-kernel, Michal Marek, Tetsuo Handa, Benjamin Poirier, Yaakov Selkowitz On Thu, Oct 18, 2012 at 07:33:45PM +0200, Yann E. MORIN wrote: > Some systems (eg. Cygwin, FreeBSD) are missing the CIRCLEQ macros. > They were removed in Y2000 from FreeBSD: > http://svnweb.freebsd.org/base?view=revision&revision=70469 > > The reason was that TAILQ are perfectly capable of doing the exact > same things: > http://www.mavetju.org/mail/view_thread.php?list=freebsd-arch&id=915145&thread=yes > > (Thank Yaakov for the pointers!) > > So, switch to using TAILQ instead, which are more portable. Why not use the kernels list.h? ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ 2012-10-23 13:12 ` [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ Christoph Hellwig @ 2012-10-23 17:04 ` Yann E. MORIN 0 siblings, 0 replies; 16+ messages in thread From: Yann E. MORIN @ 2012-10-23 17:04 UTC (permalink / raw) To: linux-kbuild Cc: Christoph Hellwig, linux-kernel, Michal Marek, Tetsuo Handa, Benjamin Poirier, Yaakov Selkowitz Christoph, All, On Tuesday 23 October 2012 Christoph Hellwig wrote: > On Thu, Oct 18, 2012 at 07:33:45PM +0200, Yann E. MORIN wrote: > > Some systems (eg. Cygwin, FreeBSD) are missing the CIRCLEQ macros. > > They were removed in Y2000 from FreeBSD: > > http://svnweb.freebsd.org/base?view=revision&revision=70469 > > > > The reason was that TAILQ are perfectly capable of doing the exact > > same things: > > http://www.mavetju.org/mail/view_thread.php?list=freebsd-arch&id=915145&thread=yes > > > > (Thank Yaakov for the pointers!) > > > > So, switch to using TAILQ instead, which are more portable. > > Why not use the kernels list.h? First, we can't use linux/list.h because it can't be included from userspace. Second, it would not be convenient for those that use kconfig outside the Linux kernel (thiord-party projects, eg. buildroot, uClibc, busybox...): http://marc.info/?l=linux-kbuild&m=135065985609068&w=2 Also, this patch of mine is deprecated; Benjamin has posted another patch which makes use of a stripped-down list.h, partially copied from linux/list.h: http://marc.info/?t=135081179500001&r=1&w=4 Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2012-10-23 17:04 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-10-18 17:33 [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ Yann E. MORIN 2012-10-18 17:55 ` Yaakov (Cygwin/X) 2012-10-18 18:59 ` Yann E. MORIN 2012-10-19 8:59 ` Yaakov (Cygwin/X) 2012-10-19 12:10 ` Tetsuo Handa 2012-10-19 14:54 ` Michal Marek 2012-10-20 14:43 ` Tetsuo Handa 2012-10-20 16:58 ` Yann E. MORIN 2012-10-19 22:52 ` Yann E. MORIN 2012-10-20 17:56 ` [PATCH] menuconfig: Replace CIRCLEQ by list_head-style lists Benjamin Poirier 2012-10-20 21:22 ` Yann E. MORIN 2012-10-21 1:21 ` Tetsuo Handa 2012-10-20 22:19 ` Yann E. MORIN 2012-10-21 1:54 ` Yaakov (Cygwin/X) 2012-10-23 13:12 ` [PATCH] kconfig/menuconfig: use TAILQ instead of CIRCLEQ Christoph Hellwig 2012-10-23 17:04 ` Yann E. MORIN
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.