public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 2/4][Ada,DJGPP] Ada support for DJGPP
@ 2016-07-30  5:45 Andris Pavenis
  2016-08-18  9:40 ` Arnaud Charlet
  0 siblings, 1 reply; 6+ messages in thread
From: Andris Pavenis @ 2016-07-30  5:45 UTC (permalink / raw)
  To: GCC Patches; +Cc: DJ Delorie

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]

This patch (2nd of 4) includes various changes to Ada related C files required for DJGPP support

ChangeLog entry:

2016-07-30 Andris Pavenis <andris.pavenis@iki.fi>

     * ada/ctrl_c.c: Do not use macro SA_RESTART for DJGPP.

     * ada/gsocket.h: Do not support sockets for DJGPP.

     * ada/init.c (timestruct_t): Define for DJGPP.
       (nanosleep): Implement for DJGPP using usleep().
       (__gnat_install_handler): Implememt for DJGPP

     * ada/sysdep.c: Include <io.h> for DJGPP
       (_setmode): Define to setmode for DJGPP
       (__gnat_set_mode): Add implementation for DJGPP
       (__gnat_localtime_tzoff): Add implementation for DJGPP

     * ada/terminals.c: Add DJGPP to list of unsupported platforms.


Andris



[-- Attachment #2: 0002-DJGPP-Ada-DJGPP-support.patch --]
[-- Type: text/x-patch, Size: 5596 bytes --]

From 935f11dbb31a46358a5927ad41cc6877683c13aa Mon Sep 17 00:00:00 2001
From: Andris Pavenis <andris.pavenis@iki.fi>
Date: Mon, 25 Jul 2016 19:37:55 +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 (timestruct_t): Define for DJGPP.
  (nanosleep): Implement for DJGPP using usleep().
  (__gnat_install_handler): Implememt for DJGPP

* ada/sysdep.c: Include <io.h> for DJGPP
  (_setmode): Define to setmode for DJGPP
  (__gnat_set_mode): Add implementation for DJGPP
  (__gnat_localtime_tzoff): Add implementation for DJGPP

* ada/terminals.c: Add DJGPP to list of unsupported platforms.
---
 gcc/ada/ctrl_c.c    |  4 ++--
 gcc/ada/gsocket.h   |  2 +-
 gcc/ada/init.c      | 25 ++++++++++++++++++++++++
 gcc/ada/sysdep.c    | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 gcc/ada/terminals.c |  2 +-
 5 files changed, 83 insertions(+), 6 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/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..eed212c 100644
--- a/gcc/ada/init.c
+++ b/gcc/ada/init.c
@@ -2516,6 +2516,31 @@ __gnat_install_handler (void)
   __gnat_handler_installed = 1;
 }
 
+#elif defined (__DJGPP__)
+
+struct timestruc_t
+{
+   time_t  tv_sec;
+   long    tv_nsec;
+};
+
+int
+nanosleep (struct timestruc_t *Rqtp, struct timestruc_t *Rmtp);
+
+int
+nanosleep (struct timestruc_t *Rqtp, struct timestruc_t *Rmtp)
+{
+    usleep (1000000*Rqtp->tv_sec+Rqtp->tv_nsec/1000);
+    if (Rmtp) { Rmtp->tv_sec = Rmtp->tv_nsec=0; }
+    return 0;
+}
+
+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..bfabf30 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 <io.h>
+#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__
 
@@ -603,7 +633,29 @@ long __gnat_invalid_tzoff = 259273;
 
 /* Definition of __gnat_localtime_r used by a-calend.adb */
 
-#if defined (__MINGW32__)
+#if defined (__DJGPP__)
+
+/* FIXME: this is draft version only. Fix me if that is not correct  */
+/*        or not complete (AP)                                       */
+
+extern void
+__gnat_localtime_tzoff (const time_t *, long *);
+
+void
+__gnat_localtime_tzoff (const time_t *timer, long *off)
+{
+  struct tm *tmp;
+
+  tmp = localtime (timer);
+  *off = (long) -tmp->tm_gmtoff;
+
+  /* Correct the offset if Daylight Saving Time is in effect */
+
+  if (tmp->tm_isdst > 0)
+    *off = *off + 3600;
+}
+
+#elif defined (__MINGW32__)
 
 /* Reentrant localtime for Windows. */
 
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




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/4][Ada,DJGPP] Ada support for DJGPP
  2016-07-30  5:45 [PATCH 2/4][Ada,DJGPP] Ada support for DJGPP Andris Pavenis
@ 2016-08-18  9:40 ` Arnaud Charlet
  2016-08-22  4:01   ` Andris Pavenis
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaud Charlet @ 2016-08-18  9:40 UTC (permalink / raw)
  To: Andris Pavenis; +Cc: GCC Patches, DJ Delorie

> This patch (2nd of 4) includes various changes to Ada related C files
> required for DJGPP support
> 
> ChangeLog entry:
> 
> 2016-07-30 Andris Pavenis <andris.pavenis@iki.fi>
> 
>     * ada/ctrl_c.c: Do not use macro SA_RESTART for DJGPP.
> 
>     * ada/gsocket.h: Do not support sockets for DJGPP.
> 
>     * ada/init.c (timestruct_t): Define for DJGPP.
>       (nanosleep): Implement for DJGPP using usleep().

Why do you need to define nanosleep() here? I suspect this is no longer
needed. If it is, would be good to know why.

Arno

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/4][Ada,DJGPP] Ada support for DJGPP
  2016-08-18  9:40 ` Arnaud Charlet
@ 2016-08-22  4:01   ` Andris Pavenis
  2016-08-25  9:17     ` Arnaud Charlet
  0 siblings, 1 reply; 6+ messages in thread
From: Andris Pavenis @ 2016-08-22  4:01 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: GCC Patches, DJ Delorie

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

On 08/18/2016 12:40 PM, Arnaud Charlet wrote:
>> This patch (2nd of 4) includes various changes to Ada related C files
>> required for DJGPP support
>>
>> ChangeLog entry:
>>
>> 2016-07-30 Andris Pavenis <andris.pavenis@iki.fi>
>>
>>      * ada/ctrl_c.c: Do not use macro SA_RESTART for DJGPP.
>>
>>      * ada/gsocket.h: Do not support sockets for DJGPP.
>>
>>      * ada/init.c (timestruct_t): Define for DJGPP.
>>        (nanosleep): Implement for DJGPP using usleep().
> Why do you need to define nanosleep() here? I suspect this is no longer
> needed. If it is, would be good to know why.
>
> Arno

Thanks for notice. It is really no more needed.

Updated patch is in attachment. New changelog entry is also there

Andris





[-- Attachment #2: 0002-DJGPP-Ada-DJGPP-support.patch --]
[-- Type: text/x-patch, Size: 5151 bytes --]

From 6cf25bcc18b4c0b8945af55bb1d9d0719f7ee8a8 Mon Sep 17 00:00:00 2001
From: Andris Pavenis <andris.pavenis@iki.fi>
Date: Sun, 21 Aug 2016 11:15: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): Implement for DJGPP

* ada/sysdep.c: Include <io.h> for DJGPP
  (_setmode): Define to setmode for DJGPP
  (__gnat_set_mode): Add implementation for DJGPP
  (__gnat_localtime_tzoff): Add implementation for DJGPP

* ada/terminals.c: Add DJGPP to list of unsupported platforms.
---
 gcc/ada/ctrl_c.c    |  4 ++--
 gcc/ada/gsocket.h   |  2 +-
 gcc/ada/init.c      |  8 ++++++++
 gcc/ada/sysdep.c    | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 gcc/ada/terminals.c |  2 +-
 5 files changed, 66 insertions(+), 6 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/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..bfabf30 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 <io.h>
+#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__
 
@@ -603,7 +633,29 @@ long __gnat_invalid_tzoff = 259273;
 
 /* Definition of __gnat_localtime_r used by a-calend.adb */
 
-#if defined (__MINGW32__)
+#if defined (__DJGPP__)
+
+/* FIXME: this is draft version only. Fix me if that is not correct  */
+/*        or not complete (AP)                                       */
+
+extern void
+__gnat_localtime_tzoff (const time_t *, long *);
+
+void
+__gnat_localtime_tzoff (const time_t *timer, long *off)
+{
+  struct tm *tmp;
+
+  tmp = localtime (timer);
+  *off = (long) -tmp->tm_gmtoff;
+
+  /* Correct the offset if Daylight Saving Time is in effect */
+
+  if (tmp->tm_isdst > 0)
+    *off = *off + 3600;
+}
+
+#elif defined (__MINGW32__)
 
 /* Reentrant localtime for Windows. */
 
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/4][Ada,DJGPP] Ada support for DJGPP
  2016-08-22  4:01   ` Andris Pavenis
@ 2016-08-25  9:17     ` Arnaud Charlet
  2016-09-04 17:02       ` Andris Pavenis
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaud Charlet @ 2016-08-25  9:17 UTC (permalink / raw)
  To: Andris Pavenis; +Cc: GCC Patches, DJ Delorie

> -#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.

The rest of the patch is OK.

Arno

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/4][Ada,DJGPP] Ada support for DJGPP
  2016-08-25  9:17     ` Arnaud Charlet
@ 2016-09-04 17:02       ` Andris Pavenis
  2016-09-04 19:49         ` Arnaud Charlet
  0 siblings, 1 reply; 6+ messages in thread
From: Andris Pavenis @ 2016-09-04 17:02 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: GCC Patches, DJ Delorie

[-- Attachment #1: Type: text/plain, Size: 1046 bytes --]

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


[-- Attachment #2: 0002-DJGPP-Ada-DJGPP-support.patch --]
[-- Type: text/x-patch, Size: 5616 bytes --]

From 83fe70a17d811ebdec7ca70509e3c2521657d8f2 Mon Sep 17 00:00:00 2001
From: Andris Pavenis <andris.pavenis@iki.fi>
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 <io.h> 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 <io.h>
+#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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/4][Ada,DJGPP] Ada support for DJGPP
  2016-09-04 17:02       ` Andris Pavenis
@ 2016-09-04 19:49         ` Arnaud Charlet
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaud Charlet @ 2016-09-04 19:49 UTC (permalink / raw)
  To: Andris Pavenis; +Cc: GCC Patches, DJ Delorie, Arnaud Charlet

This patch is OK

> From 83fe70a17d811ebdec7ca70509e3c2521657d8f2 Mon Sep 17 00:00:00 2001
> From: Andris Pavenis <andris.pavenis@iki.fi>
> 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 <io.h> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-04 18:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-30  5:45 [PATCH 2/4][Ada,DJGPP] Ada support for DJGPP Andris Pavenis
2016-08-18  9:40 ` Arnaud Charlet
2016-08-22  4:01   ` Andris Pavenis
2016-08-25  9:17     ` Arnaud Charlet
2016-09-04 17:02       ` Andris Pavenis
2016-09-04 19:49         ` Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).