Ticket #1141: x86_64-buildtools-haikutrunk.2.patch

File x86_64-buildtools-haikutrunk.2.patch, 11.6 KB (added by nmentley, 12 years ago)

added a few header files in haiku/headers/posix/arch that'll allow for an x86_64 haiku target to be compiled. Also edited ./configure to support x86_64 arch when running build-cross-tools-gcc4

  • build/jam/BuildSetup

     
    187187# analyze the gcc machine spec to determine HAIKU_CPU
    188188switch $(HAIKU_GCC_MACHINE) {
    189189    case i?86-*     : HAIKU_CPU = x86 ;
     190    case x86_64-*       : HAIKU_CPU = x86_64 ;
    190191    case powerpc-*  : HAIKU_CPU = ppc ;
    191192    case m68k-*     : HAIKU_CPU = m68k ;
    192193    case mipsel-*   : HAIKU_CPU = mipsel ;
     
    243244            Exit "HAIKU_YASM not set. Please re-run configure." ;
    244245        }
    245246    }
     247    case x86_64 :
     248    {
     249        HAIKU_DEFINES += __x86_64__ ;
     250        HAIKU_BOOT_PLATFORM = bios_x86-64 ;
     251        HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB
     252        # offset in floppy image (>= sizeof(haiku_loader))
     253        HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 300 ; # in kB
     254
     255        # yasm is required for target arch x86_64
     256        if ! $(HAIKU_YASM) {
     257            Exit "HAIKU_YASM not set. Please re-run configure." ;
     258        }
     259    }
    246260    case m68k :
    247261    {
    248262        HAIKU_DEFINES += __M68K__ ;
     
    321335        HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ;
    322336        HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ;
    323337    }
    324 
    325338    case m68k :
    326339    {
    327340        # We don't want to have to handle emulating missing FPU opcodes for 040
     
    341354        # available with gcc 2, but the header will take care of that.
    342355        HAIKU_DEFINES += B_USE_BUILTIN_ATOMIC_FUNCTIONS ;
    343356    }
     357    case x86_64 :
     358    {
     359    # TODO: Find a nice safe MARCH for all x86_64 cpus
     360        # HAIKU_CCFLAGS += -march=pentium ;
     361        # HAIKU_C++FLAGS += -march=pentium ;
     362        # HAIKU_KERNEL_CCFLAGS += -march=pentium ;
     363        # HAIKU_KERNEL_C++FLAGS += -march=pentium ;
     364    }
    344365}
    345366
    346367# If the environment variable HAIKU_INCLUDE_PATENTED_CODE is defined, we
  • configure

     
    381381            buildCrossToolsScript="${buildCrossToolsScript}_gcc4"
    382382            case "$2" in
    383383                x86)    HAIKU_GCC_MACHINE=i586-pc-haiku;;
     384                x86_64) HAIKU_GCC_MACHINE=x86_64-pc-haiku; targetArch=x86_64;;
    384385                ppc)    HAIKU_GCC_MACHINE=powerpc-apple-haiku; targetArch=ppc;;
    385386                m68k)   HAIKU_GCC_MACHINE=m68k-unknown-haiku; targetArch=m86k;;
    386387                arm)    HAIKU_GCC_MACHINE=arm-unknown-haiku; targetArch=arm;;
  • headers/build/config_build/HaikuConfig.h

     
    1414   __HAIKU_BIG_ENDIAN   - defined to 1 on big endian architectures
    1515*/
    1616#ifdef __INTEL__
    17 #   ifdef HAIKU_HOST_PLATFORM_64_BIT
    18 #       define __HAIKU_ARCH         x86_64
    19 #       define __HAIKU_ARCH_X86_64  1
    20 #       define __HAIKU_ARCH_64_BIT  1
    21 #   else
    22 #       define __HAIKU_ARCH         x86
    23 #       define __HAIKU_ARCH_X86     1
    24 #   endif
     17#   define __HAIKU_ARCH         x86
     18#   define __HAIKU_ARCH_X86     1
     19#elif __x86_64__
     20#   define __HAIKU_ARCH         x86_64
     21#   define __HAIKU_ARCH_X86_64  1
     22#   define __HAIKU_ARCH_64_BIT  1
    2523#elif __POWERPC__
    2624#   define __HAIKU_ARCH             ppc
    2725#   define __HAIKU_ARCH_PPC         1
  • headers/posix/fenv.h

     
    33
    44#if defined(_X86_)
    55#  include <arch/x86/fenv.h>
     6#if defined(_x86_64_)
     7#  include <arch/x86_64/fenv.h>
    68#elif defined(__ARM__)
    79#  include <arch/arm/fenv.h>
    810#elif defined(__POWERPC__)
  • headers/posix/arch/x86_64/signal.h

     
     1/*
     2 * Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _ARCH_SIGNAL_H_
     6#define _ARCH_SIGNAL_H_
     7
     8/*
     9 * Architecture-specific structure passed to signal handlers
     10 */
     11
     12#if __x86_64__
     13
     14struct vregs {
     15    unsigned long           rax;    /* gp regs */
     16    unsigned long           rdx;
     17    unsigned long           rcx;
     18    unsigned long           rbx;
     19    unsigned long           rsi;
     20    unsigned long           rdi;
     21    unsigned long           rbp;
     22    unsigned long           rsp;
     23
     24    unsigned long           r8; /* egp regs */
     25    unsigned long           r9;
     26    unsigned long           r10;
     27    unsigned long           r11;
     28    unsigned long           r12;
     29    unsigned long           r13;
     30    unsigned long           r14;
     31    unsigned long           r15;
     32
     33    unsigned long           rip;
     34
     35/*TODO: add
     36*   Floatpoint
     37*   MMX
     38*   SSE
     39*/
     40
     41};
     42 
     43#endif /* __x86_64__ */
     44
     45#endif /* _ARCH_SIGNAL_H_ */
  • headers/posix/arch/x86_64/fenv.h

     
     1/*-
     2 * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 *
     14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     24 * SUCH DAMAGE.
     25 *
     26 * $FreeBSD$
     27 */
     28
     29#ifndef _FENV_H_
     30#define _FENV_H_
     31
     32#include <sys/cdefs.h>
     33#include <sys/_types.h>
     34
     35typedef struct {
     36    struct {
     37        __uint32_t  __control;
     38        __uint32_t  __status;
     39        __uint32_t  __tag;
     40        char        __other[16];
     41    } __x87;
     42    __uint32_t      __mxcsr;
     43} fenv_t;
     44
     45typedef __uint16_t  fexcept_t;
     46
     47/* Exception flags */
     48#define FE_INVALID  0x01
     49#define FE_DENORMAL 0x02
     50#define FE_DIVBYZERO    0x04
     51#define FE_OVERFLOW 0x08
     52#define FE_UNDERFLOW    0x10
     53#define FE_INEXACT  0x20
     54#define FE_ALL_EXCEPT   (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
     55             FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
     56
     57/* Rounding modes */
     58#define FE_TONEAREST    0x0000
     59#define FE_DOWNWARD 0x0400
     60#define FE_UPWARD   0x0800
     61#define FE_TOWARDZERO   0x0c00
     62#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
     63             FE_UPWARD | FE_TOWARDZERO)
     64
     65/*
     66 * As compared to the x87 control word, the SSE unit's control word
     67 * has the rounding control bits offset by 3 and the exception mask
     68 * bits offset by 7.
     69 */
     70#define _SSE_ROUND_SHIFT    3
     71#define _SSE_EMASK_SHIFT    7
     72
     73__BEGIN_DECLS
     74
     75/* Default floating-point environment */
     76extern const fenv_t __fe_dfl_env;
     77#define FE_DFL_ENV  (&__fe_dfl_env)
     78
     79#define __fldcw(__cw)       __asm __volatile("fldcw %0" : : "m" (__cw))
     80#define __fldenv(__env)     __asm __volatile("fldenv %0" : : "m" (__env))
     81#define __fldenvx(__env)    __asm __volatile("fldenv %0" : : "m" (__env)  \
     82                : "st", "st(1)", "st(2)", "st(3)", "st(4)",   \
     83                "st(5)", "st(6)", "st(7)")
     84#define __fnclex()      __asm __volatile("fnclex")
     85#define __fnstenv(__env)    __asm __volatile("fnstenv %0" : "=m" (*(__env)))
     86#define __fnstcw(__cw)      __asm __volatile("fnstcw %0" : "=m" (*(__cw)))
     87#define __fnstsw(__sw)      __asm __volatile("fnstsw %0" : "=am" (*(__sw)))
     88#define __fwait()       __asm __volatile("fwait")
     89#define __ldmxcsr(__csr)    __asm __volatile("ldmxcsr %0" : : "m" (__csr))
     90#define __stmxcsr(__csr)    __asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
     91
     92static __inline int
     93feclearexcept(int __excepts)
     94{
     95    fenv_t __env;
     96
     97    if (__excepts == FE_ALL_EXCEPT) {
     98        __fnclex();
     99    } else {
     100        __fnstenv(&__env.__x87);
     101        __env.__x87.__status &= ~__excepts;
     102        __fldenv(__env.__x87);
     103    }
     104    __stmxcsr(&__env.__mxcsr);
     105    __env.__mxcsr &= ~__excepts;
     106    __ldmxcsr(__env.__mxcsr);
     107    return (0);
     108}
     109
     110static __inline int
     111fegetexceptflag(fexcept_t *__flagp, int __excepts)
     112{
     113    int __mxcsr, __status;
     114
     115    __stmxcsr(&__mxcsr);
     116    __fnstsw(&__status);
     117    *__flagp = (__mxcsr | __status) & __excepts;
     118    return (0);
     119}
     120
     121int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
     122int feraiseexcept(int __excepts);
     123
     124static __inline int
     125fetestexcept(int __excepts)
     126{
     127    int __mxcsr, __status;
     128
     129    __stmxcsr(&__mxcsr);
     130    __fnstsw(&__status);
     131    return ((__status | __mxcsr) & __excepts);
     132}
     133
     134static __inline int
     135fegetround(void)
     136{
     137    int __control;
     138
     139    /*
     140     * We assume that the x87 and the SSE unit agree on the
     141     * rounding mode.  Reading the control word on the x87 turns
     142     * out to be about 5 times faster than reading it on the SSE
     143     * unit on an Opteron 244.
     144     */
     145    __fnstcw(&__control);
     146    return (__control & _ROUND_MASK);
     147}
     148
     149static __inline int
     150fesetround(int __round)
     151{
     152    int __mxcsr, __control;
     153
     154    if (__round & ~_ROUND_MASK)
     155        return (-1);
     156
     157    __fnstcw(&__control);
     158    __control &= ~_ROUND_MASK;
     159    __control |= __round;
     160    __fldcw(__control);
     161
     162    __stmxcsr(&__mxcsr);
     163    __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
     164    __mxcsr |= __round << _SSE_ROUND_SHIFT;
     165    __ldmxcsr(__mxcsr);
     166
     167    return (0);
     168}
     169
     170int fegetenv(fenv_t *__envp);
     171int feholdexcept(fenv_t *__envp);
     172
     173static __inline int
     174fesetenv(const fenv_t *__envp)
     175{
     176
     177    /*
     178     * XXX Using fldenvx() instead of fldenv() tells the compiler that this
     179     * instruction clobbers the i387 register stack.  This happens because
     180     * we restore the tag word from the saved environment.  Normally, this
     181     * would happen anyway and we wouldn't care, because the ABI allows
     182     * function calls to clobber the i387 regs.  However, fesetenv() is
     183     * inlined, so we need to be more careful.
     184     */
     185    __fldenvx(__envp->__x87);
     186    __ldmxcsr(__envp->__mxcsr);
     187    return (0);
     188}
     189
     190int feupdateenv(const fenv_t *__envp);
     191
     192#if __BSD_VISIBLE
     193
     194int feenableexcept(int __mask);
     195int fedisableexcept(int __mask);
     196
     197static __inline int
     198fegetexcept(void)
     199{
     200    int __control;
     201
     202    /*
     203     * We assume that the masks for the x87 and the SSE unit are
     204     * the same.
     205     */
     206    __fnstcw(&__control);
     207    return (~__control & FE_ALL_EXCEPT);
     208}
     209
     210#endif /* __BSD_VISIBLE */
     211
     212__END_DECLS
     213
     214#endif  /* !_FENV_H_ */
  • headers/posix/arch/x86_64/arch_setjmp.h

     
     1/*
     2 * Copyright 2005, Haiku, Inc.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _ARCH_SETJMP_H_
     6#define _ARCH_SETJMP_H_
     7
     8#define _SETJMP_BUF_SZ (12)
     9typedef int __jmp_buf[_SETJMP_BUF_SZ];
     10
     11#endif  /* _ARCH_SETJMP_H_ */
  • headers/config/HaikuConfig.h

     
    1414   __HAIKU_BIG_ENDIAN   - defined to 1 on big endian architectures
    1515*/
    1616#ifdef __INTEL__
    17 #   ifdef __x86_64__
    18 #       define __HAIKU_ARCH         x86_64
    19 #       define __HAIKU_ARCH_X86_64  1
    20 #       define __HAIKU_ARCH_64_BIT  1
    21 #   else
    22 #       define __HAIKU_ARCH         x86
    23 #       define __HAIKU_ARCH_X86     1
    24 #   endif
     17#   define __HAIKU_ARCH         x86
     18#   define __HAIKU_ARCH_X86     1
     19#elif __x86_64__
     20#   define __HAIKU_ARCH         x86_64
     21#   define __HAIKU_ARCH_X86_64  1
     22#   define __HAIKU_ARCH_64_BIT  1
    2523#elif __POWERPC__
    2624#   define __HAIKU_ARCH             ppc
    2725#   define __HAIKU_ARCH_PPC         1