From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19122 invoked by alias); 16 Nov 2013 05:13:25 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 19080 invoked by uid 89); 16 Nov 2013 05:13:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL,BAYES_40,RDNS_NONE,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ob0-f172.google.com Received: from Unknown (HELO mail-ob0-f172.google.com) (209.85.214.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 16 Nov 2013 05:13:23 +0000 Received: by mail-ob0-f172.google.com with SMTP id wm4so4898928obc.3 for ; Fri, 15 Nov 2013 21:13:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=6g/nvydaQGKLwZt2og78TSl4r+Vma3gjeKnIdxsr/lE=; b=arzSZS/VfXX+Rm2bBhfMaLGgyNtnPscdkl3eF9xPh1WBiEIMdTP2E8gJHNye0KQt0r JxSh7ExBkILc6OcFASYH6+94bLztwRDl1GBuGdL9FHgkxIEy5ypuR/fh3ec5t5llGHeL SG1JDq5m+exgy1nw4ualSZet+bCeVt0rcNNrmu8fQ2izWdbeu8jfnHpACwXKNtneB5/V R9KHNeSKHcFfRUTArEEMo72xOfJkTiZ5uJX2lAHk1GVKvQxPBMaXykZbnT6Ha6P8jVXc XC7V3lvjaJuGvqyBg9MyVkbIuOxfOthqNc8s1jufZZ+SxyGZkmeahHewScoudyLeJylA PYmw== X-Gm-Message-State: ALoCoQmIKqrmeGy16KWnPELigM6NkbK77lPlaWhkSqm2SZLXYciVpPmoWXoNLOrZl9AlDSv3IalpUFvEHM7yoY/L68VDE9QOZ5L3VWPWhLoksF5QeS7xBUf6yhFuQxfXLVGfcmfiLFCmF74WL/ObQd4QNGPEv8uHmT8iWuAAJAIkiUOANBJYZqgEnx5OUV88a7vnF1Oz0KaK MIME-Version: 1.0 X-Received: by 10.182.149.168 with SMTP id ub8mr5226124obb.74.1384578795963; Fri, 15 Nov 2013 21:13:15 -0800 (PST) Received: by 10.60.145.144 with HTTP; Fri, 15 Nov 2013 21:13:15 -0800 (PST) In-Reply-To: <1384545814980-985730.post@n5.nabble.com> References: <1384545814980-985730.post@n5.nabble.com> Date: Sat, 16 Nov 2013 08:19:00 -0000 Message-ID: Subject: Re: How do I assign an attribute to a function From: Ian Lance Taylor To: ballsystemlord Cc: "gcc-help@gcc.gnu.org" Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00112.txt.bz2 On Fri, Nov 15, 2013 at 12:03 PM, ballsystemlord wrote: > I'm using C and I decided to read the whole gcc info manual on the subject. > How do I apply an __attribute__ to the function as apposed to what it > returns? > Yes, I've read the docs and am looking for examples. > I want to apply the cold __attribute__ to all the perror statements in my > program, the perror function is declared in the GNU C library so how do I > change it without effecting every other program that's compiled against the > GNU C library? In general, you can't. In GCC 4.8 or later you can use the cold attribute on a label. Then you can turn your calls to perror into a goto to that label. Otherwise you can use __builtin_expect, as in if (__builtin_expect (ok, true)) { // Normal case. } else perror ("error"); Ian