From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80384 invoked by alias); 26 May 2017 10:28:32 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 80370 invoked by uid 89); 26 May 2017 10:28:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-yb0-f180.google.com Received: from mail-yb0-f180.google.com (HELO mail-yb0-f180.google.com) (209.85.213.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 May 2017 10:28:29 +0000 Received: by mail-yb0-f180.google.com with SMTP id p143so1372249yba.2 for ; Fri, 26 May 2017 03:28:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=0oVEPdL9/93T8dF+7H9FXjovm3Zzt5ZnOdYxWtNnQgk=; b=ASyxCiMMn5FeCe/RFttrBIFQWKVnJbKS2Ba2Pf9dFu9CsEjZYl9OrXRAKGsetMjSSe Q2a+w1Bnk6SYhsfm9LGauO7FLqyzefyE7MLrqL9radrCwyYIVZ4R1bhEU/A/0OSVSha6 NyaXwtxMGWVCFEagCtNWvb+k498hZ7TbqvoumRP5pa+T35v/KcRFJI8PuIX2gUZlsnOU Hdkk/roChddiuuoRxRHVIDXzE70LBydPyUafozAca9SWTgQX9Wxm7yjsHk6BgHbnglxM VdZNIx0y+Y+/Dy7R/K5eoAvxz7agw5Gxc6t7f3HIW9CPp3S4zKIrsutVWtJiIn2rMa+8 BXKA== X-Gm-Message-State: AODbwcCYKVXw2ZvbBeTLNUfB8XL/CwosNBQTo712F3dA6ljF1yR31eI0 6Q46DtXF0biw1Bk6+xSa6nyePqps6Z8V X-Received: by 10.37.180.154 with SMTP id o26mr10089552ybj.10.1495794511607; Fri, 26 May 2017 03:28:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.164.34 with HTTP; Fri, 26 May 2017 03:28:31 -0700 (PDT) In-Reply-To: References: <6f28f46906804c6f8f6b4b861e202492@CASMBX02.oslo.ngi.no> From: Erik Bray Date: Fri, 26 May 2017 12:05:00 -0000 Message-ID: Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64] To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00436.txt.bz2 On Wed, May 24, 2017 at 6:57 PM, Eric Blake wrote: > On 05/24/2017 11:53 AM, Erik Bray wrote: > >>>> dropping down to assembly; it could very well be that the assembly code >>>> is incorrectly truncating things at 32 bits (where it is just fine for >>>> 32-bit Cygwin, but wrong for 64-bit): >>>> >>>> long lrint (double x) >>>> { >>>> long retval = 0L; >>>> #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || >>>> defined(__i386__) >>>> __asm__ __volatile__ ("fistpl %0" : "=m" (retval) : "t" (x) : "st"); > >> Actually, I take it back. gdb/objdump (and presumably binutils in >> general) was being deceptive to me about the nature of that mov >> instruction. And in fact the fistpl should be fistpq. That fixes it. > > Is fistpq right on 32-bit, or is this a case where we need different > assembly for 32-bit (fistpl) vs. 64-bit (fistql) to match the size of > long that we are converting to? Right. I didn't read that pre-processer line past the first couple defines. Really this should be fistpq on 64-bit and fistpl on 32-bit. And if llrint has the same bug then it should be fixed there too. The discussion about printf format specifiers is orthogonal to this. I can submit a patch for l(l)rint if you'd like. Erik -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple