From patchwork Thu Feb 14 21:25:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1042424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-496176-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gdcproject.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DMYhgThr"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 440qFl51jqz9s7h for ; Fri, 15 Feb 2019 08:26:18 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:cc:content-type; q=dns; s=default; b=TlhyFOW653lAK0qzvPcJchplkf8pTYwrRHiPyVUgiKh 5qHP8pzlVQxEm/LR/Yh8unVWe/TXEGwBBwE1k1XblF9yUXTieVJopqAZJBf0Qu4q 5a43H2udaIuCMXph2PnpA1XcFYjyRAtHUN1G67tT/UF3MNymHb93jOZaykiqWA0w = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:cc:content-type; s=default; bh=/3VPHbHFpzzKxRJnilz7w1fT/4U=; b=DMYhgThrI8EkjCtH7 CSf8JRNJoxnjWxZTvKYGkqWNflaoa+Rivld64g40e6RBTlFkRfiUfKAWqTAXRgnH UHZBj2l0e/5iz/XYvhYPhuRPXm4cLxLrO7eHC0H6bQUk/H6+j+74+BgzNt3SyRxy xOQBKOc8FKwvS033ALhdY0cLv8= Received: (qmail 27785 invoked by alias); 14 Feb 2019 21:26:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27769 invoked by uid 89); 14 Feb 2019 21:26:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=confirms X-HELO: mail-qt1-f169.google.com Received: from mail-qt1-f169.google.com (HELO mail-qt1-f169.google.com) (209.85.160.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Feb 2019 21:26:06 +0000 Received: by mail-qt1-f169.google.com with SMTP id y20so8557649qtm.13 for ; Thu, 14 Feb 2019 13:26:06 -0800 (PST) MIME-Version: 1.0 From: Iain Buclaw Date: Thu, 14 Feb 2019 22:25:53 +0100 Message-ID: Subject: [PATCH, d] Committed Add netbsd support to GDC To: gcc-patches Cc: Maya Rashish X-IsSubscribed: yes Hi, This is a combine of netbsd patches sent by Maya, and related upstream druntime changes. Bootstrapped and regression tested on x86_64-linux-gnu, which only confirms that the scoping is correct. I trust that Maya tested the netbsd-d.c part, nothing looks out of place there anyway. Committed to trunk as r268905. diff --git a/gcc/config.gcc b/gcc/config.gcc index 31b47c51b7b..3ee31c5993d 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -839,6 +839,7 @@ case ${target} in tm_p_file="${tm_p_file} netbsd-protos.h" tmake_file="t-netbsd t-slibgcc" extra_objs="${extra_objs} netbsd.o" + d_target_objs="${d_target_objs} netbsd-d.o" gas=yes gnu_ld=yes use_gcc_stdint=wrap @@ -847,6 +848,7 @@ case ${target} in esac nbsd_tm_file="netbsd.h netbsd-stdint.h netbsd-elf.h" default_use_cxa_atexit=yes + target_has_targetdm=yes ;; *-*-openbsd*) tmake_file="t-openbsd" diff --git a/gcc/config/netbsd-d.c b/gcc/config/netbsd-d.c new file mode 100644 index 00000000000..76342aacae3 --- /dev/null +++ b/gcc/config/netbsd-d.c @@ -0,0 +1,41 @@ +/* Functions for generic NetBSD as target machine for GNU D compiler. + Copyright (C) 2019 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 3, 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 COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "varasm.h" +#include "netbsd-protos.h" +#include "tm_p.h" +#include "d/d-target.h" +#include "d/d-target-def.h" + +static void +netbsd_d_os_builtins (void) +{ + d_add_builtin_version ("Posix"); + d_add_builtin_version ("NetBSD"); +} + +#undef TARGET_D_OS_VERSIONS +#define TARGET_D_OS_VERSIONS netbsd_d_os_builtins + +struct gcc_targetdm targetdm = TARGETDM_INITIALIZER; diff --git a/gcc/config/t-netbsd b/gcc/config/t-netbsd index 4626e963ebf..716a94f86c6 100644 --- a/gcc/config/t-netbsd +++ b/gcc/config/t-netbsd @@ -19,3 +19,7 @@ netbsd.o: $(srcdir)/config/netbsd.c $(COMPILE) $< $(POSTCOMPILE) + +netbsd-d.o: $(srcdir)/config/netbsd-d.c + $(COMPILE) $< + $(POSTCOMPILE) diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h index cd59b827812..c32825d4ad1 100644 --- a/gcc/d/d-system.h +++ b/gcc/d/d-system.h @@ -24,7 +24,8 @@ /* Used by the dmd front-end to determine if we have POSIX-style IO. */ #define POSIX (__linux__ || __GLIBC__ || __gnu_hurd__ || __APPLE__ \ - || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun) + || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ \ + || __sun) /* Forward assert invariants to gcc_assert. */ #undef assert diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt index 2b2a9746811..0471bfd816b 100644 --- a/libphobos/configure.tgt +++ b/libphobos/configure.tgt @@ -30,6 +30,8 @@ case "${target}" in ;; x86_64-*-linux* | i?86-*-linux*) ;; + x86_64-*-netbsd* | i?86-*-netbsd*) + ;; *) UNSUPPORTED=1 ;; diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 921b954aafb..09ce8d03566 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -2fd957307d94b5ce89eb173910cc7f1995d99031 +fb4bda91b0b43b5a18e1c143943c101ad4e17667 The first line of this file holds the git revision number of the last merge done from the dlang/druntime repository. diff --git a/libphobos/libdruntime/core/stdc/assert_.d b/libphobos/libdruntime/core/stdc/assert_.d index ead9c05f35c..ca7afe93b1e 100644 --- a/libphobos/libdruntime/core/stdc/assert_.d +++ b/libphobos/libdruntime/core/stdc/assert_.d @@ -53,6 +53,13 @@ else version (FreeBSD) */ void __assert(const(char)* exp, const(char)* file, uint line); } +else version (NetBSD) +{ + /*** + * Assert failure function in the NetBSD C library. + */ + void __assert(const(char)* file, int line, const(char)* exp); +} else version (DragonFlyBSD) { /*** diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d index c0223b5c776..c04b9c41228 100644 --- a/libphobos/libdruntime/core/stdc/stdio.d +++ b/libphobos/libdruntime/core/stdc/stdio.d @@ -198,12 +198,6 @@ else version (FreeBSD) ubyte *_base; int _size; } - - union __mbstate_t // - { - char[128] _mbstate8; - long _mbstateL; - } } else version (NetBSD) { @@ -228,12 +222,6 @@ else version (NetBSD) ubyte *_base; int _size; } - - union __mbstate_t // - { - char[128] _mbstate8; - long _mbstateL; - } } else version (OpenBSD) { @@ -258,12 +246,6 @@ else version (OpenBSD) ubyte *_base; int _size; } - - union __mbstate_t // - { - char[128] __mbstate8; - long __mbstateL; - } } else version (DragonFlyBSD) { @@ -297,12 +279,6 @@ else version (DragonFlyBSD) SBUF_DYNSTRUCT = 0x00080000, // sbuf must be freed SBUF_INSECTION = 0x00100000, // set by sbuf_start_section() } - - union __mbstate_t // - { - char[128] _mbstate8; - long _mbstateL; - } } else version (Solaris) { @@ -518,6 +494,9 @@ else version (Darwin) } else version (FreeBSD) { + // Need to import wchar_ now since __mbstate_t now resides there + import core.stdc.wchar_ : mbstate_t; + /// alias off_t fpos_t; @@ -554,7 +533,7 @@ else version (FreeBSD) pthread_t _fl_owner; int _fl_count; int _orientation; - __mbstate_t _mbstate; + mbstate_t _mbstate; } /// @@ -664,10 +643,7 @@ else version (DragonFlyBSD) } else version (Solaris) { - import core.stdc.wchar_ : __mbstate_t; - - /// - alias mbstate_t = __mbstate_t; + import core.stdc.wchar_ : mbstate_t; /// alias c_long fpos_t; diff --git a/libphobos/libdruntime/core/stdc/wchar_.d b/libphobos/libdruntime/core/stdc/wchar_.d index 3bdaf824b80..05c3ad862bc 100644 --- a/libphobos/libdruntime/core/stdc/wchar_.d +++ b/libphobos/libdruntime/core/stdc/wchar_.d @@ -43,13 +43,52 @@ version (CRuntime_Glibc) ___value __value; } } +else version (FreeBSD) +{ + /// + union __mbstate_t // + { + char[128] _mbstate8 = 0; + long _mbstateL; + } + + /// + alias mbstate_t = __mbstate_t; +} +else version (NetBSD) +{ + /// + union __mbstate_t + { + int64_t __mbstateL; + char[128] __mbstate8; + } + + /// + alias mbstate_t = __mbstate_t; +} else version (OpenBSD) { + /// union __mbstate_t { char[128] __mbstate8; int64_t __mbstateL; } + + /// + alias mbstate_t = __mbstate_t; +} +else version (DragonFlyBSD) +{ + /// + union __mbstate_t // + { + char[128] _mbstate8 = 0; + long _mbstateL; + } + + /// alias mbstate_t = __mbstate_t; } else version (Solaris) @@ -66,6 +105,9 @@ else version (Solaris) int[6] __filler; } } + + /// + alias mbstate_t = __mbstate_t; } else version (CRuntime_UClibc) { diff --git a/libphobos/libdruntime/core/sys/netbsd/dlfcn.d b/libphobos/libdruntime/core/sys/netbsd/dlfcn.d index e56b5f58c68..88eb94bf20e 100644 --- a/libphobos/libdruntime/core/sys/netbsd/dlfcn.d +++ b/libphobos/libdruntime/core/sys/netbsd/dlfcn.d @@ -103,7 +103,7 @@ static if (__BSD_VISIBLE) //void* fdlopen(int, int); int dladdr(const(void)*, Dl_info*); //dlfunc_t dlfunc(void*, const(char)*); - //int dlinfo(void*, int, void*); + int dlinfo(void*, int, void*); /+void dllockinit(void* _context, void* function(void* _context) _lock_create, void function(void* _lock) _rlock_acquire,