Fix Ada bootstrap for Darwin9 and earlier.

Message ID 47A1758D-86A8-414F-B76A-502A0FE68362@sandoe.co.uk
State New
Headers show
Series
  • Fix Ada bootstrap for Darwin9 and earlier.
Related show

Commit Message

Iain Sandoe Dec. 23, 2018, 11:26 a.m.
Hi,

This is a bootstrap regression on 7,8 and trunk for Ada on [X86 and PowerPC] Darwin9 (and earlier, although I don’t test much there).

Changes were made to __gnat_lwp_self to use a facility that’s only available from Darwin10 onwards.

The patch makes this conditional on the target Darwin version.

OK for trunk?
Open branches?

Iain

gcc/ada/

	* adaint.c (__gnat_lwp_self): Ensure that the system interface used
	is available on the target.

 gcc/ada/adaint.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

-- 
2.8.1

Comments

Eric Botcazou Dec. 23, 2018, 12:27 p.m. | #1
> 	* adaint.c (__gnat_lwp_self): Ensure that the system interface used

> 	is available on the target.


OK for all active branches, modulo the couple of following nits:

The ChangeLog must make it clear that this is for Darwin only:

	* adaint.c [__APPLE__] (__gnat_lwp_self): Ensure that the system
	interface used is available on the target.

> +#else

> +    return (void *)pthread_mach_thread_np (pthread_self ());

> +#endif


Wrong indentation.

-- 
Eric Botcazou

Patch

diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 54a1d6e..0af8ca4 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -3174,9 +3174,13 @@  __gnat_lwp_self (void)
 #endif
 
 #if defined (__APPLE__)
-#include <mach/thread_info.h>
-#include <mach/mach_init.h>
-#include <mach/thread_act.h>
+# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
+#  include <mach/thread_info.h>
+#  include <mach/mach_init.h>
+#  include <mach/thread_act.h>
+# else
+#  include <pthread.h>
+# endif
 
 /* System-wide thread identifier.  Note it could be truncated on 32 bit
    hosts.
@@ -3184,6 +3188,7 @@  __gnat_lwp_self (void)
 void *
 __gnat_lwp_self (void)
 {
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
   thread_identifier_info_data_t data;
   mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
   kern_return_t kret;
@@ -3194,6 +3199,9 @@  __gnat_lwp_self (void)
     return (void *)(uintptr_t)data.thread_id;
   else
     return 0;
+#else
+    return (void *)pthread_mach_thread_np (pthread_self ());
+#endif
 }
 #endif