Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJgzZorc5=ByA--O7gLUazJctm+V5NEh_Hz3-4yg5Oiu7k1w7w@mail.gmail.com>
Date: Tue, 25 Jun 2024 18:28:52 -0400
From: enh <enh@...gle.com>
To: musl@...ts.openwall.com
Subject: Re: roundf() (and round(), and ...)

i don't know about gcc, but iirc for clang you don't even need to do
that. it assumes it knows what various functions mean, and inlines
trivial stuff like this anyway...

/tmp$ cat x.c
#include <math.h>

double foo(double x) { return fabs(x); }
/tmp$ cc -O2 -S -o - x.c
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 14, 0 sdk_version 14, 4
.globl _foo                            ; -- Begin function foo
.p2align 2
_foo:                                   ; @foo
.cfi_startproc
; %bb.0:
fabs d0, d0
ret
.cfi_endproc
                                        ; -- End function
.subsections_via_symbols
/tmp$

(the same is true even at -O0, there's just more boilerplate around it
that way.)

bionic actually uses __builtin_fabs() [and friends] to _implement_
these functions, should someone be foolish enough to be using a
function pointer to call them, but we don't actually expect these
functions to ever be called.

On Tue, Jun 25, 2024 at 6:24 PM Damian McGuckin <damianm@....com.au> wrote:
>
> On Tue, 25 Jun 2024, Markus Wichmann wrote:
>
> > #define fabs(x) __builtin_fabs(x)
> >
> > But as far as I can tell, this hasn't happened yet.
>
> Thanks for the insight - Damian

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.