openbsd-ports/lang/llvm-gcc4/patches/patch-gcc_config_host-openbsd_c
sthen cb6a8938ed Import llvm-gcc4, not yet linked to the build. This is a work in
progress, largely based on the gcc port in ports/lang/gcc/4.2.
Requested by jsg@.

It's somewhat usable on i386 (shared lib versions not yet properly
under control). Build on amd64 currently fails with -fPIC problems.

-- --
lvm-gcc is the LLVM C front end. It is a modified version of gcc
that compiles C/C++/ObjC programs into native objects, LLVM bitcode or
LLVM assembly language, depending upon the options.

By default, llvm-gcc compiles to native objects just like GCC does.
If the -emit-llvm option is given then it will generate LLVM bitcode
files instead. If -S (assembly) is also given, then it will generate
LLVM assembly.

Being derived from the GNU Compiler Collection, llvm-gcc has many of
gcc's features and accepts most of gcc's options. It handles a number
of gcc's extensions to the C programming language.
<sthen@zephyr:/usr/ports/mystuff/lang/llvm-gcc4:9>$CVS: ----------------------------------------------------------------------
2009-06-22 22:37:31 +00:00

112 lines
2.8 KiB
Plaintext

$OpenBSD: patch-gcc_config_host-openbsd_c,v 1.1.1.1 2009/06/22 22:37:32 sthen Exp $
--- gcc/config/host-openbsd.c.orig Wed Apr 23 07:42:45 2008
+++ gcc/config/host-openbsd.c Wed Apr 23 17:57:19 2008
@@ -0,0 +1,107 @@
+/* OpenBSD host-specific hook definitions.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA. */
+
+#include <limits.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "hosthooks.h"
+#include "hosthooks-def.h"
+
+#undef HOST_HOOKS_GT_PCH_GET_ADDRESS
+#define HOST_HOOKS_GT_PCH_GET_ADDRESS openbsd_gt_pch_get_address
+
+#undef HOST_HOOKS_GT_PCH_USE_ADDRESS
+#define HOST_HOOKS_GT_PCH_USE_ADDRESS openbsd_gt_pch_use_address
+
+/* Return the address of the PCH address space, if the PCH will fit in it. */
+
+void *
+openbsd_gt_pch_get_address (size_t size, int fd ATTRIBUTE_UNUSED)
+{
+ void *base, *addr;
+ size_t pgsz;
+
+ if (size > INT_MAX)
+ return NULL;
+
+ pgsz = sysconf(_SC_PAGESIZE);
+ if (pgsz == (size_t)-1)
+ return NULL;
+
+ base = sbrk(0);
+
+ /* round up to nearest page */
+ base = (void *)(((long)base + (pgsz - 1)) & ~(pgsz - 1));
+ if (brk(base) != 0)
+ return NULL;
+
+ /* attempt to allocate size */
+ addr = sbrk(size);
+ if (addr == (void *)-1)
+ return NULL;
+
+ /* deallocate the memory */
+ if (brk(base) != 0)
+ return NULL;
+
+ /* confirm addr is as expected */
+ if (addr != base)
+ return NULL;
+
+ return base;
+}
+
+/* Return 0 if we can reserve the PCH address space. */
+
+int
+openbsd_gt_pch_use_address (void *base, size_t size, int fd ATTRIBUTE_UNUSED, size_t off ATTRIBUTE_UNUSED)
+{
+ void *addr;
+
+ if (size == 0)
+ return -1;
+
+ /* sanity check base address */
+ addr = sbrk(0);
+ if (addr == (void *)-1 || base < addr)
+ return -1;
+
+ /* set base for sbrk */
+ if (brk(base) != 0)
+ return -1;
+
+ /* attempt to get the memory */
+ addr = sbrk(size);
+ if (addr == (void *)-1)
+ return -1;
+
+ /* sanity check the result */
+ if (addr != base) {
+ brk(base);
+ return -1;
+ }
+
+ return 0;
+}
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;