$OpenBSD: patch-include_private_gcconfig_h,v 1.23 2020/08/24 21:31:13 gkoehler Exp $

- use mmap, not sbrk, on OpenBSD
- All OpenBSD mips platforms are 64-bit, so correct the wordsize and alignment
- use __data_start instead of _fdata on OpenBSD/mips64
- add support for OpenBSD/aarch64 and powerpc64

Index: include/private/gcconfig.h
--- include/private/gcconfig.h.orig
+++ include/private/gcconfig.h
@@ -76,6 +76,10 @@
 /* And one for OpenBSD: */
 # if defined(__OpenBSD__)
 #    define OPENBSD
+#    ifndef USE_MMAP
+#      define USE_MMAP
+#    endif
+#    define USE_MMAP_ANON
 # endif
 
 /* And one for FreeBSD: */
@@ -102,7 +106,8 @@
 # endif
 # if defined(__aarch64__)
 #    define AARCH64
-#    if !defined(LINUX) && !defined(DARWIN) && !defined(FREEBSD)
+#    if !defined(LINUX) && !defined(DARWIN) && !defined(FREEBSD) \
+	&& !defined(OPENBSD)
 #      define NOSYS
 #      define mach_type_known
 #    endif
@@ -137,6 +142,10 @@
 #    define ARM32
 #    define mach_type_known
 # endif
+# if defined(OPENBSD) && defined(__aarch64__)
+#    define AARCH64
+#    define mach_type_known
+# endif
 # if defined(OPENBSD) && defined(__sh__)
 #    define SH
 #    define mach_type_known
@@ -962,7 +971,12 @@
 #   endif
 #   ifdef OPENBSD
 #     define OS_TYPE "OPENBSD"
-#     define ALIGNMENT 4
+#     if defined(__powerpc64__)
+#       define ALIGNMENT 8
+#       define CPP_WORDSZ 64
+#     else
+#       define ALIGNMENT 4
+#     endif
 #     ifndef GC_OPENBSD_THREADS
 #       include <sys/param.h>
 #       include <uvm/uvm_extern.h>
@@ -1712,14 +1726,15 @@
 #  endif
 #  ifdef OPENBSD
 #    define OS_TYPE "OPENBSD"
-#    define ALIGNMENT 4
+#    define CPP_WORDSZ 64
+#    define ALIGNMENT 8
 #     ifndef GC_OPENBSD_THREADS
 #      include <sys/param.h>
 #      include <uvm/uvm_extern.h>
 #      define STACKBOTTOM ((ptr_t)USRSTACK)
 #    endif
-     extern int _fdata[];
-#    define DATASTART ((ptr_t)_fdata)
+     extern int __data_start[];
+#    define DATASTART ((ptr_t)__data_start)
      extern int _end[];
 #    define DATAEND ((ptr_t)(&_end))
 #    define DYNAMIC_LOADING
@@ -2165,6 +2180,19 @@
       extern char etext[];
 #     define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
 #     define DATASTART_USES_BSDGETDATASTART
+#   endif
+#   ifdef OPENBSD
+#     define OS_TYPE "OPENBSD"
+#     ifndef GC_OPENBSD_THREADS
+#       include <sys/param.h>
+#       include <uvm/uvm_extern.h>
+#       define STACKBOTTOM ((ptr_t)USRSTACK)
+#     endif
+      extern int __data_start[];
+#     define DATASTART ((ptr_t)__data_start)
+      extern int _end[];
+#     define DATAEND ((ptr_t)(&_end))
+#     define DYNAMIC_LOADING
 #   endif
 #   ifdef NOSYS
       /* __data_start is usually defined in the target linker script.   */
