[PATCH] Make silo work with recent kernel headers and gcc 4.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
    Fix includes to work with linux headers >= 2.6.25
    
    Signed-off-by: Friedrich Oslage <bluebird@xxxxxxxxxx>
---
 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

    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@xxxxxxxxxx>
---
 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@xxxxxx>. 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: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux