All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Make silo work with recent kernel headers and gcc 4.3
@ 2008-08-19 23:07 Friedrich Oslage
  2008-08-19 23:28 ` Ben Collins
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Friedrich Oslage @ 2008-08-19 23:07 UTC (permalink / raw)
  To: sparclinux


[-- Attachment #1.1: Type: text/plain, Size: 266 bytes --]

These are the patches we(Gentoo) are using to compile silo with recent
linux kernel headers(>=2.6.25) and gcc 4.3.

I only checked Debian SID, but probably all other distributions out
there would benefit from this.

Please apply them :)

Thanks,
Friedrich

[-- Attachment #1.2: silo.patch --]
[-- Type: text/x-patch, Size: 948 bytes --]

    Fix includes to work with linux headers >= 2.6.25
    
    Signed-off-by: Friedrich Oslage <bluebird@gentoo.org>
---
 include/ext2fs/ext2fs.h |    2 +-
 second/main.c           |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/ext2fs/ext2fs.h b/include/ext2fs/ext2fs.h
index 55aed7d..6973caa 100644
--- a/include/ext2fs/ext2fs.h
+++ b/include/ext2fs/ext2fs.h
@@ -39,7 +39,7 @@ extern "C" {
  */
 #define EXT2_LIB_CURRENT_REV	0
 
-#ifdef HAVE_SYS_TYPES_H
+#if defined(HAVE_SYS_TYPES_H) && !defined(_LINUX_TYPES_H)
 #include <sys/types.h>
 #endif
 
diff --git a/second/main.c b/second/main.c
index 4f753b0..182b263 100644
--- a/second/main.c
+++ b/second/main.c
@@ -25,8 +25,7 @@
 /* TODO: This file is a good candidate for rewrite from scratch.  */
 
 #include <silo.h>
-#include <asm/page.h>
-#include <linux/elf.h>
+#include <elf.h>
 #include <stringops.h>
 
 #ifndef NULL


[-- Attachment #1.3: silo2.patch --]
[-- Type: text/x-patch, Size: 5349 bytes --]

    Include libgcc.a to get __ffssi2 and add a simple sprintf function to fix these undefined references when compiling with GCC-4.3:
    
    /usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_next_bit_set':
    (.text+0x4f8): undefined reference to `__ffssi2'
    /usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_next_bit_set':
    (.text+0x518): undefined reference to `__ffssi2'
    /usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_next_bit_set':
    (.text+0x544): undefined reference to `__ffssi2'
    /usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_first_bit_set':
    (.text+0x5a8): undefined reference to `__ffssi2'
    /usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_first_bit_set':
    (.text+0x5d8): undefined reference to `__ffssi2'
    /usr/bin/../lib/libext2fs.a(rw_bitmaps.o): In function `read_bitmaps':
    (.text+0x46c): undefined reference to `sprintf'
    /usr/bin/../lib/libext2fs.a(rw_bitmaps.o): In function `read_bitmaps':
    (.text+0x664): undefined reference to `sprintf'
    
    Signed-off-by: Friedrich Oslage <bluebird@gentoo.org>
---
 common/printf.c |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/silo.h  |    2 +
 second/Makefile |    8 ++--
 3 files changed, 95 insertions(+), 4 deletions(-)

diff --git a/common/printf.c b/common/printf.c
index eed5da2..0d6d84c 100644
--- a/common/printf.c
+++ b/common/printf.c
@@ -21,6 +21,7 @@
    USA.  */
 
 #include "promlib.h"
+#include <stringops.h>
 
 /*
  * This part is rewritten by Igor Timkin <ivt@msu.su>. Than I
@@ -147,3 +148,91 @@ void prom_printf (char *fmt,...)
     vprintf (fmt, x1);
     va_end (x1);
 }
+
+static int sprintn (char *str, long long n, int b)
+{
+    static char prbuf[33];
+    register char *cp;
+    int count = 0;
+
+    if (b == 10 && n < 0) {
+	memset (str + count, '-', 1);
+	count++;
+	n = -n;
+    }
+    cp = prbuf;
+    do
+	*cp++ = "0123456789ABCDEF"[(unsigned int) (((unsigned long)n) % b)];
+    while ((n = ((unsigned long long)n) / b & 0x0FFFFFFFFFFFFFFFULL));
+    do {
+	memset (str + count, *--cp, 1);
+	count++;
+    } while (cp > prbuf);
+
+    return count;
+}
+
+int vsprintf (char *str, char *fmt, va_list adx)
+{
+    register int c;
+    char *s;
+    int count = 0;
+
+    for (;;) {
+	while ((c = *fmt++) != '%') {
+	    memset (str + count, c, 1);
+	    if (c == '\0') {
+		return count;
+	    }
+	}
+	c = *fmt++;
+	if (c == 'd' || c == 'o' || c == 'x' || c == 'X') {
+	    count += sprintn (str + count, (long long) va_arg (adx, unsigned),
+			     c == 'o' ? 8 : (c == 'd' ? 10 : 16));
+	} else if (c == 'c') {
+	    memset (str + count, va_arg (adx, unsigned), 1);
+	    count++;
+	} else if (c == 's') {
+	    if ((s = va_arg (adx, char *)) == NULL)
+		s = (char *)"(null)";
+	    while ((c = *s++)) {
+		memset (str + count, c, 1);
+		count++;
+	    }
+	} else if (c == 'l' || c == 'O') {
+	    count += sprintn (str + count, (long long) va_arg (adx, long), c == 'l' ? 10 : 8);
+	} else if (c == 'L') {
+	    int hex = 0;
+	    if (*fmt == 'x') {
+		fmt++;
+		hex = 1;
+	    }
+	    count += sprintn (str + count, (long long) va_arg (adx, long long), hex ? 16 : 10);
+	} else {
+	    /* This is basically what libc's printf does */
+	    memset (str + count, '%', 1);
+	    count++;
+	    memset (str + count, c, 1);
+	    count++;
+	}
+    }
+
+    return count;
+}
+
+/*
+ * Scaled down version of C Library sprintf.
+ * Only %c %s %d (==%u) %o %x %X %l %O are recognized.
+ */
+
+int sprintf (char *s, char *format, ...)
+{
+    va_list arg;
+    int done;
+
+    va_start (arg, format);
+    done = vsprintf (s, format, arg);
+    va_end (arg);
+
+    return done;
+}
diff --git a/include/silo.h b/include/silo.h
index 51c62e7..fe5adcb 100644
--- a/include/silo.h
+++ b/include/silo.h
@@ -87,6 +87,8 @@ int silo_disk_partitionable(void);
 void silo_disk_close(void);
 /* printf.c */
 int vprintf (char *, va_list);
+int vsprintf (char *str, char *fmt, va_list adx);
+int sprintf (char *s, char *format, ...);
 int putchar (int);
 /* malloc.c */
 void *malloc (int);
diff --git a/second/Makefile b/second/Makefile
index 3a7763d..ff4c8b5 100644
--- a/second/Makefile
+++ b/second/Makefile
@@ -58,13 +58,13 @@ fs/libfs.a: $(FS_OBJS)
 	$(AR) rc $@ $(FS_OBJS)
 
 second: $(OBJS) mark.o
-	$(LD) $(LDFLAGS_SMALL) -Bstatic -o second $(OBJS) -lext2fs mark.o
-	$(LD) $(LDFLAGS_LARGE) -Bstatic -o second2 $(OBJS) -lext2fs mark.o
+	$(LD) $(LDFLAGS_SMALL) -Bstatic -o second $(OBJS) -lext2fs mark.o `$(CC) -print-libgcc-file-name`
+	$(LD) $(LDFLAGS_LARGE) -Bstatic -o second2 $(OBJS) -lext2fs mark.o `$(CC) -print-libgcc-file-name`
 	$(NM) second | grep -v '*ABS*' | sort > second.map
 
 silotftp: $(OBJSNET) mark.o
-	$(LD) $(LDFLAGS_SMALL) -Bstatic -o silotftp $(OBJSNET) -lext2fs mark.o
-	$(LD) $(LDFLAGS_LARGE) -Bstatic -o silotftp2 $(OBJSNET) -lext2fs mark.o
+	$(LD) $(LDFLAGS_SMALL) -Bstatic -o silotftp $(OBJSNET) -lext2fs mark.o `$(CC) -print-libgcc-file-name`
+	$(LD) $(LDFLAGS_LARGE) -Bstatic -o silotftp2 $(OBJSNET) -lext2fs mark.o `$(CC) -print-libgcc-file-name`
 	$(NM) silotftp | grep -v '*ABS*' | sort > silotftp.map
 
 second.l: second


[-- Attachment #2: Dies ist ein digital signierter Nachrichtenteil --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Make silo work with recent kernel headers and gcc 4.3
  2008-08-19 23:07 [PATCH] Make silo work with recent kernel headers and gcc 4.3 Friedrich Oslage
@ 2008-08-19 23:28 ` Ben Collins
  2008-08-19 23:37 ` David Miller
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ben Collins @ 2008-08-19 23:28 UTC (permalink / raw)
  To: sparclinux

On Wed, 2008-08-20 at 01:07 +0200, Friedrich Oslage wrote:
> These are the patches we(Gentoo) are using to compile silo with recent
> linux kernel headers(>=2.6.25) and gcc 4.3.
> 
> I only checked Debian SID, but probably all other distributions out
> there would benefit from this.
> 
> Please apply them :)

I'll check the rest of it, but on initial glance, wouldn't it be better
to just do -lgcc instead of the `gcc -print...` mess?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Make silo work with recent kernel headers and gcc 4.3
  2008-08-19 23:07 [PATCH] Make silo work with recent kernel headers and gcc 4.3 Friedrich Oslage
  2008-08-19 23:28 ` Ben Collins
@ 2008-08-19 23:37 ` David Miller
  2008-08-20  0:42 ` Ben Collins
  2008-08-21 14:29 ` Ben Collins
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2008-08-19 23:37 UTC (permalink / raw)
  To: sparclinux

From: Ben Collins <ben.collins@canonical.com>
Date: Tue, 19 Aug 2008 19:28:37 -0400

> On Wed, 2008-08-20 at 01:07 +0200, Friedrich Oslage wrote:
> > These are the patches we(Gentoo) are using to compile silo with recent
> > linux kernel headers(>=2.6.25) and gcc 4.3.
> > 
> > I only checked Debian SID, but probably all other distributions out
> > there would benefit from this.
> > 
> > Please apply them :)
> 
> I'll check the rest of it, but on initial glance, wouldn't it be better
> to just do -lgcc instead of the `gcc -print...` mess?

We do the link by hand using $(LD), so that might be part of
the issue.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Make silo work with recent kernel headers and gcc 4.3
  2008-08-19 23:07 [PATCH] Make silo work with recent kernel headers and gcc 4.3 Friedrich Oslage
  2008-08-19 23:28 ` Ben Collins
  2008-08-19 23:37 ` David Miller
@ 2008-08-20  0:42 ` Ben Collins
  2008-08-21 14:29 ` Ben Collins
  3 siblings, 0 replies; 5+ messages in thread
From: Ben Collins @ 2008-08-20  0:42 UTC (permalink / raw)
  To: sparclinux

On Tue, 2008-08-19 at 16:37 -0700, David Miller wrote:
> From: Ben Collins <ben.collins@canonical.com>
> Date: Tue, 19 Aug 2008 19:28:37 -0400
> 
> > On Wed, 2008-08-20 at 01:07 +0200, Friedrich Oslage wrote:
> > > These are the patches we(Gentoo) are using to compile silo with recent
> > > linux kernel headers(>=2.6.25) and gcc 4.3.
> > > 
> > > I only checked Debian SID, but probably all other distributions out
> > > there would benefit from this.
> > > 
> > > Please apply them :)
> > 
> > I'll check the rest of it, but on initial glance, wouldn't it be better
> > to just do -lgcc instead of the `gcc -print...` mess?
> 
> We do the link by hand using $(LD), so that might be part of
> the issue.

Right, libgcc.a isn't in a standard libdir. Ok, looks good, so I'll
check it in later this week and do a new release.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Make silo work with recent kernel headers and gcc 4.3
  2008-08-19 23:07 [PATCH] Make silo work with recent kernel headers and gcc 4.3 Friedrich Oslage
                   ` (2 preceding siblings ...)
  2008-08-20  0:42 ` Ben Collins
@ 2008-08-21 14:29 ` Ben Collins
  3 siblings, 0 replies; 5+ messages in thread
From: Ben Collins @ 2008-08-21 14:29 UTC (permalink / raw)
  To: sparclinux

Friedrich Oslage wrote:
> These are the patches we(Gentoo) are using to compile silo with recent
> linux kernel headers(>=2.6.25) and gcc 4.3.
> 
> I only checked Debian SID, but probably all other distributions out
> there would benefit from this.
> 
> Please apply them :)
> 

Applied, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-21 14:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-19 23:07 [PATCH] Make silo work with recent kernel headers and gcc 4.3 Friedrich Oslage
2008-08-19 23:28 ` Ben Collins
2008-08-19 23:37 ` David Miller
2008-08-20  0:42 ` Ben Collins
2008-08-21 14:29 ` Ben Collins

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.