]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Simplify handling of VxWorks-specific error codes for ENOENT
authorJerome Guitton <guitton@adacore.com>
Fri, 10 May 2024 13:16:17 +0000 (13:16 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 14 Jun 2024 07:34:20 +0000 (09:34 +0200)
These error codes were defined on older versions of VxWorks (5, 6, 7
SR0540) and now they are either not defined or they fallback to
ENOENT. To handle these cases without using complex tests against
vxworks versions, leverage on __has_include and provide a fallback to
ENOENT if these error codes are not defined.

gcc/ada/

* sysdep.c (S_dosFsLib_FILE_NOT_FOUND, S_nfsLib_NFSERR_NOENT):
New macros, falback to ENOENT when not already defined.
(__gnat_is_file_not_found_error): Use these new macros to remove
tests against VxWorks flavors.

gcc/ada/sysdep.c

index 443b11f430236a68ffdb50ac3f090a339b9c22dc..254c736bec433f2c6b76f044b3f8fca0bd150641 100644 (file)
 #ifdef __vxworks
 #include "vxWorks.h"
 #include "ioLib.h"
-#if ! defined (VTHREADS)
+/* VxWorks 5, 6 and 7 SR0540 expose error codes that need to be handled
+   as ENOENT. On later versions:
+   - either they are defined as ENOENT (vx7r2);
+   - or the corresponding system includes are not provided (Helix Cert).  */
+
+#if __has_include ("dosFsLib.h")
+/* On helix-cert, this include is only provided for RTPs.  */
 #include "dosFsLib.h"
 #endif
-#if ! defined (__RTP__) && (! defined (VTHREADS) || defined (__VXWORKSMILS__))
+
+#ifndef S_dosFsLib_FILE_NOT_FOUND
+#define S_dosFsLib_FILE_NOT_FOUND ENOENT
+#endif
+
+#if __has_include ("nfsLib.h")
+/* This include is not provided for RTPs or on helix-cert.  */
 # include "nfsLib.h"
 #endif
+
+#ifndef S_nfsLib_NFSERR_NOENT
+#define S_nfsLib_NFSERR_NOENT ENOENT
+#endif
+
 #include "selectLib.h"
 #include "version.h"
 #if defined (__RTP__)
 #  include "vwModNum.h"
 #endif /* __RTP__ */
-#endif
+#endif /* __vxworks */
 
 #ifdef __ANDROID__
 #undef __linux__
@@ -912,14 +929,10 @@ __gnat_is_file_not_found_error (int errno_val)
     /* In the case of VxWorks, we also have to take into account various
      * filesystem-specific variants of this error.
      */
-#if ! defined (VTHREADS) && (_WRS_VXWORKS_MAJOR < 7)
     else if (errno_val == S_dosFsLib_FILE_NOT_FOUND)
       return 1;
-#endif
-#if ! defined (__RTP__) && (! defined (VTHREADS) || defined (__VXWORKSMILS__))
     else if (errno_val ==  S_nfsLib_NFSERR_NOENT)
       return 1;
-#endif
 #if defined (__RTP__)
     /* An RTP can return an NFS file not found, and the NFS bits must
        first be masked on to check the errno.  */