[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] RFC: allow compilation without target libc
From: |
Pavel Roskin |
Subject: |
[PATCH] RFC: allow compilation without target libc |
Date: |
Fri, 22 May 2009 19:33:40 -0400 |
User-agent: |
StGIT/0.14.3 |
ChangeLog:
* configure.ac: Define GRUB_SOURCE to identify GRUB sources
in include/multiboot2.h. Use "-nostdlib" when testing target
compiler.
* include/multiboot2.h: Use GRUB types and definitions. Provide
compatibility layer when GRUB_SOURCE is not defined.
* loader/i386/pc/multiboot2.c: Include multiboot2.h last to make
sure that config.h was included first.
* loader/multiboot2.c: Likewise.
* loader/multiboot_loader.c: Likewise.
---
configure.ac | 3 ++-
include/multiboot2.h | 24 +++++++++++++++---------
loader/i386/pc/multiboot2.c | 2 +-
loader/multiboot2.c | 2 +-
loader/multiboot_loader.c | 2 +-
5 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/configure.ac b/configure.ac
index 98cd841..af60603 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,6 +161,7 @@ test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
AC_GNU_SOURCE
AC_SYS_LARGEFILE
+AC_DEFINE([GRUB_SOURCE], [1], [Define when compiling GRUB sources.])
# Identify characteristics of the host architecture.
AC_C_BIGENDIAN
@@ -366,7 +367,7 @@ AC_SUBST(TARGET_LDFLAGS)
# Set them to their new values for the tests below.
CC="$TARGET_CC"
-CFLAGS="$TARGET_CFLAGS"
+CFLAGS="$TARGET_CFLAGS -nostdlib"
CPPFLAGS="$TARGET_CPPFLAGS"
LDFLAGS="$TARGET_LDFLAGS"
diff --git a/include/multiboot2.h b/include/multiboot2.h
index 0f2b0cf..e8fe425 100644
--- a/include/multiboot2.h
+++ b/include/multiboot2.h
@@ -34,25 +34,31 @@
#ifndef ASM_FILE
-#include "stdint.h"
+#ifdef GRUB_SOURCE
+#include <grub/types.h>
+#else
+#include <stdint.h>
+typedef uint32_t grub_uint32_t;
+typedef uint64_t grub_uint64_t;
+#define GRUB_TARGET_SIZEOF_VOID_P (__WORDSIZE / 8)
+#endif
-/* XXX not portable? */
-#if __WORDSIZE == 64
-typedef uint64_t multiboot_word;
+#if GRUB_TARGET_SIZEOF_VOID_P == 8
+typedef grub_uint64_t multiboot_word;
#else
-typedef uint32_t multiboot_word;
+typedef grub_uint32_t multiboot_word;
#endif
struct multiboot_header
{
- uint32_t magic;
- uint32_t flags;
+ grub_uint32_t magic;
+ grub_uint32_t flags;
};
struct multiboot_tag_header
{
- uint32_t key;
- uint32_t len;
+ grub_uint32_t key;
+ grub_uint32_t len;
};
#define MULTIBOOT2_TAG_RESERVED1 0
diff --git a/loader/i386/pc/multiboot2.c b/loader/i386/pc/multiboot2.c
index 2c14ee2..25ef150 100644
--- a/loader/i386/pc/multiboot2.c
+++ b/loader/i386/pc/multiboot2.c
@@ -17,7 +17,6 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <multiboot2.h>
#include <grub/multiboot2.h>
#include <grub/elf.h>
#include <grub/err.h>
@@ -25,6 +24,7 @@
#include <grub/mm.h>
#include <grub/multiboot.h>
#include <grub/cpu/multiboot.h>
+#include <multiboot2.h>
grub_err_t
grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr, UNUSED grub_addr_t *addr)
diff --git a/loader/multiboot2.c b/loader/multiboot2.c
index fd82828..34e42c1 100644
--- a/loader/multiboot2.c
+++ b/loader/multiboot2.c
@@ -17,7 +17,6 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <multiboot2.h>
#include <grub/loader.h>
#include <grub/machine/loader.h>
#include <grub/multiboot2.h>
@@ -28,6 +27,7 @@
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/gzio.h>
+#include <multiboot2.h>
static grub_addr_t entry;
extern grub_dl_t my_mod;
diff --git a/loader/multiboot_loader.c b/loader/multiboot_loader.c
index 11ba666..654508e 100644
--- a/loader/multiboot_loader.c
+++ b/loader/multiboot_loader.c
@@ -17,7 +17,6 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <multiboot2.h>
#include <grub/machine/machine.h>
#include <grub/multiboot.h>
#include <grub/multiboot2.h>
@@ -29,6 +28,7 @@
#include <grub/misc.h>
#include <grub/gzio.h>
#include <grub/command.h>
+#include <multiboot2.h>
grub_dl_t my_mod;
- [PATCH] RFC: allow compilation without target libc,
Pavel Roskin <=