diff mbox

kconfig/menuconfig: use TAILQ instead of CIRCLEQ

Message ID 1350581625-23153-1-git-send-email-yann.morin.1998@free.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Yann E. MORIN Oct. 18, 2012, 5:33 p.m. UTC
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(-)

Comments

Yaakov (Cygwin/X) Oct. 18, 2012, 5:55 p.m. UTC | #1
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>


--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yann E. MORIN Oct. 18, 2012, 6:59 p.m. UTC | #2
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.
Yaakov (Cygwin/X) Oct. 19, 2012, 8:59 a.m. UTC | #3
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


--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tetsuo Handa Oct. 19, 2012, 12:10 p.m. UTC | #4
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 ?
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek Oct. 19, 2012, 2:54 p.m. UTC | #5
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yann E. MORIN Oct. 19, 2012, 10:52 p.m. UTC | #6
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.
Tetsuo Handa Oct. 20, 2012, 2:43 p.m. UTC | #7
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".
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yann E. MORIN Oct. 20, 2012, 4:58 p.m. UTC | #8
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.
Christoph Hellwig Oct. 23, 2012, 1:12 p.m. UTC | #9
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?

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yann E. MORIN Oct. 23, 2012, 5:04 p.m. UTC | #10
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.
diff mbox

Patch

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) {