https://gcc.gnu.org/g:bf9cb9140dc9b6e7298b85023315e2fb05d33a18

commit r16-2500-gbf9cb9140dc9b6e7298b85023315e2fb05d33a18
Author: Alexandre Oliva <ol...@adacore.com>
Date:   Wed Jul 16 02:01:59 2025 -0300

    ada: ppc-vx6: pthread clocks and headers for decls
    
    VxWorks 6 lacks pthread_condattr_setclock, so define CLOCK_RT_Ada to
    CLOCK_REALTIME to use the dummy definition of
    __gnat_pthread_condattr_setup in libgnarl/thread.c.
    
    socket.c and sysdep.c use FD_ZERO, that relies on bzero on VxWorks 6.
    We need to include strings.h to get a declaration for bzero, but don't
    require strings.h to exist, since it's nonstandard.
    
    gcc/ada/ChangeLog:
    
            * s-oscons-tmplt.c (CLOCK_RT_Ada) [__vxworks]: Define to
            CLOCK_REALTIME on VxWorks6.
            * gsocket.h [__vxworks]: Include strings.h if available.
            * sysdep.c [__vxworks]: Likewise.

Diff:
---
 gcc/ada/gsocket.h        | 6 ++++++
 gcc/ada/s-oscons-tmplt.c | 6 +++++-
 gcc/ada/sysdep.c         | 6 ++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/gsocket.h b/gcc/ada/gsocket.h
index 79836e8b5b91..5a553d121dde 100644
--- a/gcc/ada/gsocket.h
+++ b/gcc/ada/gsocket.h
@@ -64,6 +64,12 @@
 #include <ioLib.h>
 #include <hostLib.h>
 
+#if __has_include ("strings.h")
+/* On VxWorks6, FD_ZERO uses bzero, but since it's not a standard header, don't
+   require it.  */
+#include "strings.h"
+#endif
+
 #define SHUT_RD                0
 #define SHUT_WR                1
 #define SHUT_RDWR      2
diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c
index 97537ef5e940..7a5e987cefc4 100644
--- a/gcc/ada/s-oscons-tmplt.c
+++ b/gcc/ada/s-oscons-tmplt.c
@@ -1976,7 +1976,7 @@ CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU clock")
 #if defined(__linux__) || defined(__FreeBSD__) \
  || (defined(_AIX) && defined(_AIXVERSION_530)) \
  || defined(__DragonFly__) || defined(__QNX__) \
- || defined (__vxworks)
+ || (defined (__vxworks) && /* VxWorks7 */ defined (_VSB_CONFIG_FILE))
 /** On these platforms use system provided monotonic clock instead of
  ** the default CLOCK_REALTIME. We then need to set up cond var attributes
  ** appropriately (see thread.c).
@@ -1985,6 +1985,10 @@ CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU clock")
  ** pthread_cond_timedwait (and does not have pthread_condattr_setclock),
  ** hence the conditionalization on AIX version above). _AIXVERSION_530
  ** is defined in AIX 5.3 and more recent versions.
+ **
+ ** VxWorks6 lacks pthread_condattr_setclock, so define CLOCK_RT_Ada to
+ ** CLOCK_REALTIME to get the dummy definition of __gnat_pthread_condattr_setup
+ ** in libgnarl/thread.c.
  **/
 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
 
diff --git a/gcc/ada/sysdep.c b/gcc/ada/sysdep.c
index 3dc76f9ab1fd..afbb362dff09 100644
--- a/gcc/ada/sysdep.c
+++ b/gcc/ada/sysdep.c
@@ -40,6 +40,12 @@
    - either they are defined as ENOENT (vx7r2);
    - or the corresponding system includes are not provided (Helix Cert).  */
 
+#if __has_include ("strings.h")
+/* On VxWorks6, FD_ZERO uses bzero, and index is also declared in strings.h,
+   but since it's not a standard header, don't require it.  */
+#include "strings.h"
+#endif
+
 #if __has_include ("dosFsLib.h")
 /* On helix-cert, this include is only provided for RTPs.  */
 #include "dosFsLib.h"

Reply via email to