From patchwork Thu Feb 7 00:28:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1037801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-495418-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SRyLWYav"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hMq9CvYf"; 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 43vzgc0Ptyz9sLw for ; Thu, 7 Feb 2019 11:28:23 +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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=SypI7Z/lVDFNYg6PhKdmnCjGqgRnXm6QDJmW/fUrL2x+ldc0OK /zei47bY6XD1WwHRq7w/Ya/9i5Qgw6O0t6yw7osssyCgDZsWuxoRlYydmfAVUr1W Qw1H02/JeEGVif5lUSjFKJGcHzZszaIwymacECx8oO9UZ/sjLgWcyVFcI= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=BwNTQMoZjTqfEJy8ADqUAyuBN1Q=; b=SRyLWYavC6v8EsqK/EqS rqF1dNoxeljLaeM4K2nfvt0H6WbrB8N+HaDnaHvXknw868WQ1/sN3a/zpib7IbMy hfrNfvwnlK5ssIQzZB1Ns/ujcUqPuvkOFim7F5GHu9oW471Q59xBpaR+p0+Ghyck 6MTth1iY5HQc2YjpDkYMNSU= Received: (qmail 26075 invoked by alias); 7 Feb 2019 00:28:16 -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 26062 invoked by uid 89); 7 Feb 2019 00:28:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt1-f180.google.com Received: from mail-qt1-f180.google.com (HELO mail-qt1-f180.google.com) (209.85.160.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Feb 2019 00:28:14 +0000 Received: by mail-qt1-f180.google.com with SMTP id o6so3763784qtk.6 for ; Wed, 06 Feb 2019 16:28:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=p500BcPlizAr6xowvxDja7/N8ls43pJMCpYd6CPwe34=; b=hMq9CvYfdAGT84gtwYNaa28GYETKeibQXA6dysvn8Uty6DVCscn0EktLO7D0boOuOu FUjzdsfGa9AumvdRfbTc/Ri9fsUGHY/i0/nIypuQWGOdaGlDYyx99zeyrfEDtmmuSsLd /5G80yTSeXeG6rB+Sg2qhgNfPlMGZrm08Eb8r0VJayZoTcvNzqHgoPHKjrlQYSRqK50+ Wyq/7uWgDktj6B8ZalcrW2/XGhfnx5QqljDm3Juv62YT97S+IlWR0jAR+Uu4I3DjOktZ cKMb4XSo8YMOgXuBX/jds4/Tzggn8D4w26nj1jmCvrFdkoPEu8LoAsCG45F675MGYO1D 6bdA== Received: from [192.168.0.106] (97-118-121-10.hlrn.qwest.net. [97.118.121.10]) by smtp.gmail.com with ESMTPSA id e21sm4356808qkj.90.2019.02.06.16.28.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Feb 2019 16:28:11 -0800 (PST) To: "gcc-patches@gcc.gnu.org" From: Martin Sebor Subject: [PATCH] correct __clear_cache signature Message-ID: <66fe11a5-62b2-3016-c9d6-9ccf28858528@gmail.com> Date: Wed, 6 Feb 2019 17:28:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 X-IsSubscribed: yes Recent libgcc builds have been triggering -Wbuiltin-declaration-mismatch due to the declaration of the __clear_cache built-in being incompatible with how GCC declares it internally. The attached patch adjusts the libgcc declaration and the one in the manual to match what GCC expects. Tested on x86_64-linux. Martin libgcc/ChangeLog: * libgcc2.h (__clear_cache): Correct signature. * libgcc2.c (__clear_cache): Same. gcc/ChangeLog: * doc/extend.texi (__clear_cache): Correct signature. gcc/testsuite/ChangeLog: * gcc.dg/Wbuiltin-declaration-mismatch-12.c: New test. Index: libgcc/libgcc2.h =================================================================== --- libgcc/libgcc2.h (revision 268583) +++ libgcc/libgcc2.h (working copy) @@ -30,7 +30,7 @@ see the files COPYING3 and COPYING.RUNTIME respect #endif extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t); -extern void __clear_cache (char *, char *); +extern void __clear_cache (void *, void *); extern void __eprintf (const char *, const char *, unsigned int, const char *) __attribute__ ((__noreturn__)); Index: libgcc/libgcc2.c =================================================================== --- libgcc/libgcc2.c (revision 268583) +++ libgcc/libgcc2.c (working copy) @@ -2162,11 +2162,14 @@ __eprintf (const char *string, const char *express /* Clear part of an instruction cache. */ void -__clear_cache (char *beg __attribute__((__unused__)), - char *end __attribute__((__unused__))) +__clear_cache (void *beg __attribute__((__unused__)), + void *end __attribute__((__unused__))) { #ifdef CLEAR_INSN_CACHE - CLEAR_INSN_CACHE (beg, end); + /* Cast the void* pointers to char* as some implementations + of the macro assume the pointers can be subtracted from + one another. */ + CLEAR_INSN_CACHE ((char *) beg, (char *) end); #endif /* CLEAR_INSN_CACHE */ } Index: gcc/doc/extend.texi =================================================================== --- gcc/doc/extend.texi (revision 268583) +++ gcc/doc/extend.texi (working copy) @@ -13073,7 +13073,7 @@ void foo (void) @end deftypefn -@deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end}) +@deftypefn {Built-in Function} void __builtin___clear_cache (void *@var{begin}, void *@var{end}) This function is used to flush the processor's instruction cache for the region of memory between @var{begin} inclusive and @var{end} exclusive. Some targets require that the instruction cache be Index: gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-12.c =================================================================== --- gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-12.c (nonexistent) +++ gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-12.c (working copy) @@ -0,0 +1,8 @@ +/* Verify that declaring the __clear_cache and __builtin_prefetch + intrinsic functions with the wrong signature is diagnosed. + { dg-do compile } + { dg-options "-Wbuiltin-declaration-mismatch -Wextra" } */ + +extern void __clear_cache (char*, char*); /* { dg-warning "mismatch in argument 1 type of built-in function .__clear_cache.; expected .void \\\*." } */ + +void __builtin_prefetch (const char *, ...); /* { dg-warning "mismatch in argument 1 type of built-in function .__builtin_prefetch.; expected .const void \\\*." } */