Skip to contentSkip to conversation

JOBS: fix klibc DEBUG compilation

PATCH In review maximilian attems 2 participants 3 messages Jun 3, 2011 – Jun 4, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 JOBS: fix klibc DEBUG compilation

dash didn't compile in DEBUG mode against klibc for all long time. Now it fails at link stage for not having setlinebuf(3).

Fixes:

usr/dash/show.o: In function `opentrace':
show.c:(.text+0x86): undefined reference to `setlinebuf'

---

the last open error, looks more like a klibc bug to me, will fix it there:
show.c:(.text+0x36): undefined reference to `freopen'

 src/show.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
src/show.c +2 -0
index 14dbef3..b4160e1 100644
@@ -394,7 +394,9 @@ opentrace(void)
 	if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0)
 		fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND);
 #endif
+#ifndef SMALL
 	setlinebuf(tracefile);
+#endif /* SMALL */
 	fputs("\nTracing started.\n", tracefile);
 }
 #endif /* DEBUG */
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 5 lines · maximilian attems

dash didn't compile in DEBUG mode against klibc for all long time. Now it fails at link stage for not having setlinebuf(3).

Fixes:

Quoted 8 lines

usr/dash/show.o: In function `opentrace':
show.c:(.text+0x86): undefined reference to `setlinebuf'

---

the last open error, looks more like a klibc bug to me, will fix it there:
show.c:(.text+0x36): undefined reference to `freopen'

So it seems, freopen() is a perfectly valid standard C function.

Quoted 8 lines
 src/show.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
src/show.c +0 -0
index 14dbef3..b4160e1 100644

src/show.c opentrace(void) · line 402

Quoted 9 lines
src/show.c +2 -0
@@ -394,7 +394,9 @@ opentrace(void)
 	if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0)
 		fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND);
 #endif
+#ifndef SMALL
 	setlinebuf(tracefile);
+#endif /* SMALL */
 	fputs("\nTracing started.\n", tracefile);
 }
 #endif /* DEBUG */

Why not just replace the non-standard setlinebuf() call with the standard setvbuf(tracefile, NULL, _IOLBF, 0); ? This appears to work just as well on FreeBSD and is C99 compliant (no POSIX needed here).

The #define SMALL is only for disabling line editing and history (using libedit). Setting the trace file line buffered is useful regardless of that.

Signature · 1 line
Jilles Tjoelker
#2 lore raw
Quoted 22 lines · Jilles Tjoelker
Quoted 8 lines
 src/show.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
src/show.c +0 -0
index 14dbef3..b4160e1 100644

src/show.c opentrace(void) · line 402

Quoted 9 lines
src/show.c +2 -0
@@ -394,7 +394,9 @@ opentrace(void)
 	if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0)
 		fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND);
 #endif
+#ifndef SMALL
 	setlinebuf(tracefile);
+#endif /* SMALL */
 	fputs("\nTracing started.\n", tracefile);
 }
 #endif /* DEBUG */

Why not just replace the non-standard setlinebuf() call with the standard setvbuf(tracefile, NULL, _IOLBF, 0); ? This appears to work just as well on FreeBSD and is C99 compliant (no POSIX needed here).

Quoted 3 lines

The #define SMALL is only for disabling line editing and history (using libedit). Setting the trace file line buffered is useful regardless of that.

If one doesn't support libedit one is assumed to define SMALL and klibc does such.
http://www.spinics.net/lists/dash/msg00311.html

oh and I seem to not have recieved Herbert's answer from last Sept.
http://www.spinics.net/lists/dash/msg00367.html

I'll respin the patch based on it, thank you.

Signature · 1 line
maks