From 9820b3897803c38f66f8515dc15cdb3e10c7ad20 Mon Sep 17 00:00:00 2001 From: Jerome Lambourg Date: Tue, 22 May 2018 13:26:49 +0000 Subject: [PATCH] [Ada] Fix retrieval of number of CPUs on QNX Although the sysconf SC_NPROCESSORS_ONLN is also defined by the API, the only documented way to retrieve the number of CPUs is by using the syspage. This also better organise the QNX-specific macros in adaint.c 2018-05-22 Jerome Lambourg gcc/ada/ * adaint.c: Reorganize QNX-specific macros, use syspage to retreive the number of CPUs. From-SVN: r260531 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/adaint.c | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 985f8766494..3805c22cbed 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-05-22 Jerome Lambourg + + * adaint.c: Reorganize QNX-specific macros, use syspage to retreive the + number of CPUs. + 2018-05-22 Jerome Lambourg * sigtramp-qnx.c: Properly restore link register in signal trampoline. diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 3b0aea92c05..9e0919e5dfa 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -39,7 +39,9 @@ #define _THREAD_SAFE /* Use 64 bit Large File API */ -#ifndef _LARGEFILE_SOURCE +#if defined (__QNX__) +#define _LARGEFILE64_SOURCE 1 +#elif !defined(_LARGEFILE_SOURCE) #define _LARGEFILE_SOURCE #endif #define _FILE_OFFSET_BITS 64 @@ -81,8 +83,8 @@ #define __BSD_VISIBLE 1 #endif -#if defined (__QNX__) -#define _LARGEFILE64_SOURCE 1 +#ifdef __QNX__ +#include #endif #ifdef IN_RTS @@ -2350,9 +2352,12 @@ __gnat_number_of_cpus (void) #if defined (__linux__) || defined (__sun__) || defined (_AIX) \ || defined (__APPLE__) || defined (__FreeBSD__) || defined (__OpenBSD__) \ - || defined (__DragonFly__) || defined (__NetBSD__) || defined (__QNX__) + || defined (__DragonFly__) || defined (__NetBSD__) cores = (int) sysconf (_SC_NPROCESSORS_ONLN); +#elif defined (__QNX__) + cores = (int) _syspage_ptr->num_cpu; + #elif defined (__hpux__) struct pst_dynamic psd; if (pstat_getdynamic (&psd, sizeof (psd), 1, 0) != -1) -- 2.30.2