From patchwork Sun Sep 4 16:57:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andris_Pav=C4=93nis?= X-Patchwork-Id: 665530 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3sRzbc1Dprz9sDG for ; Mon, 5 Sep 2016 02:59:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=yVdtTpso; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=P3mAeK86K5nJUIhCC ijuGSs43x8x++IF6JHQ7pWf2iZO4wGnvTCTr1u88OoNK8NTh5MBIAeIQcvnQKiPL mLaF/U45Sf3lk7fob18KmQc4BVrkVz74x4ivN5A9kek+VzqQL5qIUz9s0XrjpdnE H1Qdip3NnCNg2xQul5LEWFH1vU= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=Gy+OtvS7MeNarlH+F8lFY5f +8Qo=; b=yVdtTpso/VChE0BZHGyVm6+fMTmUlJj0S+igk4V0lMN+GIVJeQgimls Zb65RtIbN1+c58veyHvtDW2j6XsD3XyJ7gYccLEH4nIsZy8eFK5tWO+/fk8kNV+g se+wxuyzkqf3itTNt4TusHQrECnMh0M69HWVZuHQ0e5Pwf9DCyI0= Received: (qmail 106378 invoked by alias); 4 Sep 2016 16:58:57 -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 106363 invoked by uid 89); 4 Sep 2016 16:58:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=D*fi, D*iki.fi, H*Ad:D*fi, HTo:U*charlet X-HELO: julia1.inet.fi Received: from mta-out1.inet.fi (HELO julia1.inet.fi) (62.71.2.232) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 04 Sep 2016 16:58:45 +0000 Received: from ap.localhost.localdomain (80.223.182.110) by julia1.inet.fi (9.0.002.03-2-gbe5d057) (authenticated as pavean-2) id 5782991C015332DD; Sun, 4 Sep 2016 19:56:22 +0300 Subject: Re: [PATCH 2/4][Ada,DJGPP] Ada support for DJGPP To: Arnaud Charlet References: <2d4dc1ad-30d6-bb43-fd44-2ae9d7f32bef@iki.fi> <20160818094013.GA1929@adacore.com> <89aaa9c5-ede8-e673-30b6-a7718dfcb5e8@iki.fi> <20160825091737.GA26847@adacore.com> Cc: GCC Patches , DJ Delorie From: Andris Pavenis Message-ID: <6280d83e-ee2b-89a6-5fc5-3482895428c0@iki.fi> Date: Sun, 4 Sep 2016 19:57:34 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160825091737.GA26847@adacore.com> On 08/25/2016 12:17 PM, Arnaud Charlet wrote: >> -#if defined (__MINGW32__) >> +#if defined (__DJGPP__) >> + >> +/* FIXME: this is draft version only. Fix me if that is not correct */ >> +/* or not complete (AP) */ > This FIXME needs to be addressed. DJGPP special implementation was actually not required. SImple use of localtime_r is sufficient > The rest of the patch is OK. One additional new change is for file env.c (use of unsetenv for DJGPP). Updated ChangeLog entry is in the attachment. Testing changes took more time than I expected as native bootstrap for DJGPP did not work with current trunk version. There is no problems with building Linux to DJGPP cross-compiler including Ada compiler. All was OK with r238675 but no more with r239639 and some later revisions (of course with DJGPP related patches applied). gnat1 fails when building Ada libraries (all-target-libada). I'll try to find which change has caused the error (unfortunately I have not saved the message). Andris From 83fe70a17d811ebdec7ca70509e3c2521657d8f2 Mon Sep 17 00:00:00 2001 From: Andris Pavenis Date: Sun, 28 Aug 2016 08:02:11 +0300 Subject: [PATCH 2/4] [DJGPP, Ada] DJGPP support * ada/ctrl_c.c: Do not use macro SA_RESTART for DJGPP. * ada/gsocket.h: Do not support sockets for DJGPP. * ada/init.c (__gnat_install_handler): Implememt for DJGPP * ada/sysdep.c: Include for DJGPP (_setmode): Define to setmode for DJGPP (__gnat_set_mode): Add implementation for DJGPP (__gnat_localtime_tzoff): Use localtime_r for DJGPP * ada/terminals.c: Add DJGPP to list of unsupported platforms. * ada/env.c (__gnat_clearenv): use _gnat_unsetenv on all entries for DJGPP --- gcc/ada/ctrl_c.c | 4 ++-- gcc/ada/env.c | 2 +- gcc/ada/gsocket.h | 2 +- gcc/ada/init.c | 8 ++++++++ gcc/ada/sysdep.c | 35 +++++++++++++++++++++++++++++++++-- gcc/ada/terminals.c | 2 +- 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/gcc/ada/ctrl_c.c b/gcc/ada/ctrl_c.c index 7f8d177..d4fc551 100644 --- a/gcc/ada/ctrl_c.c +++ b/gcc/ada/ctrl_c.c @@ -92,8 +92,8 @@ __gnat_install_int_handler (void (*proc) (void)) if (sigint_intercepted == 0) { act.sa_handler = __gnat_int_handler; -#if defined (__Lynx__) || defined (VMS) - /* LynxOS and VMS do not support SA_RESTART. */ +#if defined (__Lynx__) || defined (VMS) || defined(__DJGPP__) + /* LynxOS, VMS or DJGPP do not support SA_RESTART. */ act.sa_flags = 0; #else act.sa_flags = SA_RESTART; diff --git a/gcc/ada/env.c b/gcc/ada/env.c index 8469876..da6b7b0 100644 --- a/gcc/ada/env.c +++ b/gcc/ada/env.c @@ -302,7 +302,7 @@ void __gnat_clearenv (void) #elif defined (__MINGW32__) || defined (__FreeBSD__) || defined (__APPLE__) \ || (defined (__vxworks) && defined (__RTP__)) || defined (__CYGWIN__) \ || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__rtems__) \ - || defined (__DragonFly__) + || defined (__DragonFly__) || defined (__DJGPP__) /* On Windows, FreeBSD and MacOS there is no function to clean all the environment but there is a "clean" way to unset a variable. So go through the environ table and call __gnat_unsetenv on all entries */ diff --git a/gcc/ada/gsocket.h b/gcc/ada/gsocket.h index 31a3ccf..a979d3a 100644 --- a/gcc/ada/gsocket.h +++ b/gcc/ada/gsocket.h @@ -29,7 +29,7 @@ * * ****************************************************************************/ -#if defined(VTHREADS) || defined(__PikeOS__) +#if defined(VTHREADS) || defined(__PikeOS__) || defined(__DJGPP__) /* Sockets not supported on these platforms. */ #undef HAVE_SOCKETS diff --git a/gcc/ada/init.c b/gcc/ada/init.c index 6d51896..cec968b 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -2516,6 +2516,14 @@ __gnat_install_handler (void) __gnat_handler_installed = 1; } +#elif defined (__DJGPP__) + +void +__gnat_install_handler () +{ + __gnat_handler_installed = 1; +} + #elif defined(__ANDROID__) /*******************/ diff --git a/gcc/ada/sysdep.c b/gcc/ada/sysdep.c index 465007e..5390209 100644 --- a/gcc/ada/sysdep.c +++ b/gcc/ada/sysdep.c @@ -126,7 +126,7 @@ extern struct tm *localtime_r(const time_t *, struct tm *); */ -#if defined (WINNT) || defined (__CYGWIN__) +#if defined (WINNT) || defined (__CYGWIN__) || defined(__DJGPP__) const char __gnat_text_translation_required = 1; @@ -137,6 +137,11 @@ const char __gnat_text_translation_required = 1; #define WIN_SETMODE _setmode #endif +#if defined(__DJGPP__) +#include +#define _setmode setmode +#endif /* __DJGPP__ */ + void __gnat_set_binary_mode (int handle) { @@ -149,6 +154,30 @@ __gnat_set_text_mode (int handle) WIN_SETMODE (handle, O_TEXT); } +#ifdef __DJGPP__ +void +__gnat_set_mode (int handle, int mode) +{ + /* the values here must be synchronized with + System.File_Control_Block.Content_Encodding: + + None = 0 + Default_Text = 1 + Text = 2 + U8text = 3 + Wtext = 4 + U16text = 5 */ + + switch (mode) { + case 0 : setmode(handle, O_BINARY); break; + case 1 : setmode(handle, O_TEXT); break; + case 2 : setmode(handle, O_TEXT); break; + case 3 : setmode(handle, O_TEXT); break; + case 4 : setmode(handle, O_BINARY); break; + case 5 : setmode(handle, O_BINARY); break; + } +} +#else void __gnat_set_mode (int handle, int mode) { @@ -171,6 +200,7 @@ __gnat_set_mode (int handle, int mode) case 5 : WIN_SETMODE (handle, _O_U16TEXT); break; } } +#endif #ifdef __CYGWIN__ @@ -795,7 +825,8 @@ __gnat_localtime_tzoff (const time_t *timer ATTRIBUTE_UNUSED, struct tm */ #elif defined (__APPLE__) || defined (__FreeBSD__) || defined (__linux__) \ - || defined (__GLIBC__) || defined (__DragonFly__) || defined (__OpenBSD__) + || defined (__GLIBC__) || defined (__DragonFly__) || defined (__OpenBSD__) \ + || defined(__DJGPP__) { localtime_r (timer, &tp); *off = tp.tm_gmtoff; diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c index d72eb09..7b14997 100644 --- a/gcc/ada/terminals.c +++ b/gcc/ada/terminals.c @@ -32,7 +32,7 @@ /* First all usupported platforms. Add stubs for exported routines. */ #if defined (VMS) || defined (__vxworks) || defined (__Lynx__) \ - || defined (__ANDROID__) || defined (__PikeOS__) + || defined (__ANDROID__) || defined (__PikeOS__) || defined(__DJGPP__) #define ATTRIBUTE_UNUSED __attribute__((unused)) -- 2.7.4