This patch converts finite/__finite to builtin functions so that it will be inlined by compiler.
Details
Diff Detail
Event Timeline
"finite()" is a BSD function, not a C standard function, so ALL_LANGUAGES isn't appropriate.
I can't seem to find documentation for "__finite()"; where is it defined?
Thanks for the comment. I'm not quite familiar with BSD function. Could you suggest which flag I should use here? C_LANG?
I can't seem to find documentation for "__finite()"; where is it defined?
It's just that if I include <math.h> and use isfinite(), it will automatically expand to finite() instead of finite(). But if I call finite() directly, it will expand to finite(). Thus I think I need to handle both finite and finite. Any suggestions on this?
Thanks,
Dehao
GNU_LANG is the flag you're looking for.
"it will automatically expand to finite()"
What exactly is your build configuration (operating system, compiler, libc version if applicable)?
Also, this is missing a test (see test/CodeGen/builtins.c).
I'm running on ubuntu with clang 4.0.
I found that the __finite is expanded from math.h:
define isfinite(x) \
(sizeof (x) == sizeof (float) \ ? __finitef (x) \ : sizeof (x) == sizeof (double) \ ? __finite (x) : __finitel (x))
finite() is expanded from /usr/include/x86_64-linux-gnu/bits/mathcalls.h
/* Return nonzero if VALUE is finite and not NaN. */
MATHDECL_1 (int,finite,, (_Mdouble_ value)) attribute ((const));
which is expanded to:
extern int finite (double value) throw () attribute__ ((const));
Not sure what is the right thing to do here...
Thanks,
Dehao
Also, this is missing a test (see test/CodeGen/builtins.c).
added
Oh, I see...
It's probably worth adding a comment explaining where __finite comes from, since it isn't obvious. Also, should be okay to mark it ALL_LANGUAGES (since it has a double-underscore prefix).
Thanks for the review, Eli. Do you have other comments about this patch?
Thanks,
Dehao
LGTM after you change the comment.
include/clang/Basic/Builtins.def | ||
---|---|---|
922 | This comment isn't really clear... maybe something more like "glibc's math.h generates calls to __finite"? |
This comment isn't really clear... maybe something more like "glibc's math.h generates calls to __finite"?