Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1M7eFM-0001JR-Ci for mharc-grub-devel@gnu.org; Fri, 22 May 2009 19:33:52 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M7eFK-0001HV-98 for grub-devel@gnu.org; Fri, 22 May 2009 19:33:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M7eFF-0001FF-Jf for grub-devel@gnu.org; Fri, 22 May 2009 19:33:49 -0400 Received: from [199.232.76.173] (port=39890 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M7eFF-0001FB-93 for grub-devel@gnu.org; Fri, 22 May 2009 19:33:45 -0400 Received: from c60.cesmail.net ([216.154.195.49]:56994) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1M7eFE-0007eO-Kc for grub-devel@gnu.org; Fri, 22 May 2009 19:33:45 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 22 May 2009 19:33:41 -0400 Received: from mj.roinet.com (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id D7C2634C6A for ; Fri, 22 May 2009 19:35:14 -0400 (EDT) From: Pavel Roskin To: grub-devel@gnu.org Date: Fri, 22 May 2009 19:33:40 -0400 Message-ID: <20090522233339.16268.62568.stgit@mj.roinet.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH] RFC: allow compilation without target libc X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2009 23:33:50 -0000 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 +#else +#include +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 . */ -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include 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 . */ -#include #include #include #include @@ -28,6 +27,7 @@ #include #include #include +#include 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 . */ -#include #include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include grub_dl_t my_mod;