From patchwork Fri Dec 13 16:25:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Hainque X-Patchwork-Id: 1209266 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515907-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QY8tz3Nu"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47ZGHf5PFRz9sPn for ; Sat, 14 Dec 2019 03:25:49 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:subject:date:message-id:cc:to:mime-version; q=dns; s=default; b=jcQjBPQyrzpsL/QpvYhx29sZM2UfWjjF7Sj4E00i5Cr8PtLM+s 8dxETfRiWJzZ2D2uKZAdVzOwBXIVnZX2PtEv+ciMSv3LjerTL4eQks5uCqh3t5bF gVIOaQsVsP0svi1scOzJ2ZbWQ5tqsUTlqebagctpxSr2YckH8x2mv/zag= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:subject:date:message-id:cc:to:mime-version; s= default; bh=pWFQ0OhVUH6Jkz1v3Le+I2njsXs=; b=QY8tz3NurW2J4tz6Y2JD nSpEcT+7Eyb9/J30D0zRLQsWfZV48PK/XlVusvwRODL33L3Z23BmDIwsLr9UDta8 luFfa9kF5+uGdiu0Gqqxg+Ea0UH2YK0kRx013fPsJk4V/3GyRrR25GcsOjWQFM6p KThPOcrwP7KB0mmM624lYu4= Received: (qmail 100704 invoked by alias); 13 Dec 2019 16:25:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 100685 invoked by uid 89); 13 Dec 2019 16:25:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=69, sk:delete_, bare, gthread X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Dec 2019 16:25:39 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 155D881354; Fri, 13 Dec 2019 17:25:37 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EFXXWZQlPK05; Fri, 13 Dec 2019 17:25:37 +0100 (CET) Received: from [192.168.0.12] (bny92-4-82-228-126-192.fbx.proxad.net [82.228.126.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 87B638134C; Fri, 13 Dec 2019 17:25:36 +0100 (CET) From: Olivier Hainque Subject: [patch] Introduce an internal API for VxWorks version checks Date: Fri, 13 Dec 2019 17:25:35 +0100 Message-Id: Cc: Olivier Hainque , =?utf-8?b?SsOpcsO0bWUgTGFtYm91?= =?utf-8?q?rg?= , Douglas B Rupp , Corentin Gay , Joel Brobecker To: GCC Patches Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) This changes introduces an internal API for VxWorks version checks within runtime files, a prerequisite to a few fixes coming up for libstdc++ builds on more recent versions of the OS. Tested in accordance with the description in https://gcc.gnu.org/ml/gcc-patches/2019-12/msg00911.html Committing to mainline. Olivier 2019-12-13 Olivier Hainque gcc/ * config/vxworks/_vxworks-versions.h: New file. * config.gcc (*-*-vxworks*): Add it to extra_headers. libgcc/ * config/gthr-vxworks.h: Use _vxworks-versions.h. * config/gthr-vxworks-tls.c: Likewise. gcc/config.gcc | 7 ++++ gcc/config/vxworks/_vxworks-versions.h | 54 ++++++++++++++++++++++++++ libgcc/config/gthr-vxworks-tls.c | 10 +++-- libgcc/config/gthr-vxworks.h | 12 ++---- 4 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 gcc/config/vxworks/_vxworks-versions.h diff --git a/gcc/config.gcc b/gcc/config.gcc index cf73a853e11..b09a3656be8 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -961,6 +961,13 @@ case ${target} in target_has_targetcm="yes" use_gcc_stdint=provide tm_file="${tm_file} vxworks-stdint.h" + + # This private header exposes a consistent interface for checks on + # the VxWorks version our runtime header files need to perform, based on + # what the system headers adverstise: + + extra_headers="${extra_headers} ../vxworks/_vxworks-versions.h" + case ${enable_threads} in no) ;; "" | yes | vxworks) thread_file='vxworks' ;; diff --git a/gcc/config/vxworks/_vxworks-versions.h b/gcc/config/vxworks/_vxworks-versions.h new file mode 100644 index 00000000000..728e7262a72 --- /dev/null +++ b/gcc/config/vxworks/_vxworks-versions.h @@ -0,0 +1,54 @@ +/* This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#ifndef _VXWORKS_VERSIONS_H +#define _VXWORKS_VERSIONS_H 1 + +/* All we need is access to the bare _WRS_VXWORKS_MAJOR/MINOR macros + exposed by version.h. Cheat a bit to make sure we don't drag additional + header files, which can easily cause #include ordering nightmares. */ + +#pragma push_macro("_WRS_KERNEL") +#undef _WRS_KERNEL +#include +#pragma pop_macro("_WRS_KERNEL") + +#if !defined(_WRS_VXWORKS_MAJOR) +#error "VxWorks version macros needed but not defined" +#endif + +#define _VXWORKS_MAJOR_GT(MAJOR) (_WRS_VXWORKS_MAJOR > (MAJOR)) +#define _VXWORKS_MAJOR_GE(MAJOR) (_WRS_VXWORKS_MAJOR >= (MAJOR)) +#define _VXWORKS_MAJOR_LT(MAJOR) (_WRS_VXWORKS_MAJOR < (MAJOR)) +#define _VXWORKS_MAJOR_LE(MAJOR) (_WRS_VXWORKS_MAJOR <= (MAJOR)) +#define _VXWORKS_MAJOR_EQ(MAJOR) (_WRS_VXWORKS_MAJOR == (MAJOR)) + +#define _VXWORKS_MINOR_GT(MINOR) (_WRS_VXWORKS_MINOR > (MINOR)) +#define _VXWORKS_MINOR_GE(MINOR) (_WRS_VXWORKS_MINOR >= (MINOR)) +#define _VXWORKS_MINOR_LT(MINOR) (_WRS_VXWORKS_MINOR < (MINOR)) +#define _VXWORKS_MINOR_LE(MINOR) (_WRS_VXWORKS_MINOR <= (MINOR)) +#define _VXWORKS_MINOR_EQ(MINOR) (_WRS_VXWORKS_MINOR == (MINOR)) + +#define _VXWORKS_PRE(MAJOR,MINOR) \ + (_VXWORKS_MAJOR_LT(MAJOR) \ + || (_VXWORKS_MAJOR_EQ(MAJOR) && _VXWORKS_MINOR_LT(MINOR))) + +#endif diff --git a/libgcc/config/gthr-vxworks-tls.c b/libgcc/config/gthr-vxworks-tls.c index 96b6bfbdbe6..63715e65eb8 100644 --- a/libgcc/config/gthr-vxworks-tls.c +++ b/libgcc/config/gthr-vxworks-tls.c @@ -45,6 +45,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include #endif +#include <_vxworks-versions.h> + /* Thread-local storage. A gthread TLS key is simply an offset in an array, the address of which @@ -91,10 +93,10 @@ static int self_owner; it is only removed when unloading this module. */ static volatile int delete_hook_installed; -/* TLS data access internal API. A straight __thread variable on VxWorks 7, - a pointer returned by kernel provided routines otherwise. */ +/* TLS data access internal API. A straight __thread variable starting with + VxWorks 7, a pointer returned by kernel provided routines otherwise. */ -#ifdef __VXWORKS7__ +#if _VXWORKS_MAJOR_GE(7) static __thread struct tls_data *__gthread_tls_data; @@ -118,7 +120,7 @@ extern void __gthread_leave_tls_dtor_context (void); #define VX_ENTER_TLS_DTOR() __gthread_enter_tls_dtor_context () #define VX_LEAVE_TLS_DTOR() __gthread_leave_tls_dtor_context () -#endif /* __VXWORKS7__ */ +#endif /* This is a global structure which records all of the active keys. diff --git a/libgcc/config/gthr-vxworks.h b/libgcc/config/gthr-vxworks.h index 2d2860a36dd..2d033ab7678 100644 --- a/libgcc/config/gthr-vxworks.h +++ b/libgcc/config/gthr-vxworks.h @@ -35,13 +35,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #else #include -#include - -/* Conditional compilation directives are easier to read when they fit on a - single line, which is helped by macros with shorter names. */ -#define _VXW_MAJOR _WRS_VXWORKS_MAJOR -#define _VXW_MINOR _WRS_VXWORKS_MINOR -#define _VXW_PRE_69 (_VXW_MAJOR < 6 || (_VXW_MAJOR == 6 && _VXW_MINOR < 9)) +#include <_vxworks-versions.h> /* Some VxWorks headers profusely use typedefs of a pointer to a function with undefined number of arguments. */ @@ -62,7 +56,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* RTP, pre 6.9. */ -#if defined(__RTP__) && _VXW_PRE_69 +#if defined(__RTP__) && _VXWORKS_PRE(6,9) #define __TAS(x) vxCas ((x), 0, 1) typedef volatile unsigned char __vx_tas_t; @@ -71,7 +65,7 @@ typedef volatile unsigned char __vx_tas_t; /* RTP, 6.9 and beyond. */ -#if defined(__RTP__) && !_VXW_PRE_69 +#if defined(__RTP__) && !_VXWORKS_PRE(6,9) #define __TAS(x) vxAtomicCas ((x), 0, 1) typedef atomic_t __vx_tas_t;