* [PATCH v2] add __builtin functions for isinf_sign, isfinite and isnan
@ 2017-11-16 23:08 Logan Gunthorpe
2017-11-17 0:02 ` Christopher Li
2017-11-17 8:13 ` Luc Van Oostenryck
0 siblings, 2 replies; 6+ messages in thread
From: Logan Gunthorpe @ 2017-11-16 23:08 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Logan Gunthorpe
These bultins are defined by in gcc since 4.4. They are also now
used by the isinf, isfinite and isnan macros. So using them with a
newer gcc causes 'undefined identifier' errors.
Add the builtin definitions and some validation checks for these
functions.
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
Changes since v1:
* Remove math.h dependancy from validation tests. As a consequnce
we don't test that the math functions work. (Per a request from
Christopher.)
lib.c | 3 +++
validation/builtin_inf.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/lib.c b/lib.c
index 4602cf8..cc740e9 100644
--- a/lib.c
+++ b/lib.c
@@ -1105,6 +1105,9 @@ void declare_builtin_functions(void)
add_pre_buffer("extern double __builtin_nan(const char *);\n");
add_pre_buffer("extern float __builtin_nanf(const char *);\n");
add_pre_buffer("extern long double __builtin_nanl(const char *);\n");
+ add_pre_buffer("extern int __builtin_isinf_sign(float);\n");
+ add_pre_buffer("extern int __builtin_isfinite(float);\n");
+ add_pre_buffer("extern int __builtin_isnan(float);\n");
/* And some __FORTIFY_SOURCE ones.. */
add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(const void *, int);\n");
diff --git a/validation/builtin_inf.c b/validation/builtin_inf.c
index 48546e4..f09f53f 100644
--- a/validation/builtin_inf.c
+++ b/validation/builtin_inf.c
@@ -7,6 +7,9 @@ static long double li = __builtin_infl();
static double dn = __builtin_nan("");
static float fn = __builtin_nanf("");
static long double ln = __builtin_nanl("");
+static int inf = __builtin_isinf_sign(0.0);
+static int fin = __builtin_isfinite(0.0);
+static int nan = __builtin_isnan(0.0);
/*
* check-name: __builtin INFINITY / nan()
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] add __builtin functions for isinf_sign, isfinite and isnan
2017-11-16 23:08 [PATCH v2] add __builtin functions for isinf_sign, isfinite and isnan Logan Gunthorpe
@ 2017-11-17 0:02 ` Christopher Li
2017-11-17 1:04 ` Logan Gunthorpe
2017-11-17 8:13 ` Luc Van Oostenryck
1 sibling, 1 reply; 6+ messages in thread
From: Christopher Li @ 2017-11-17 0:02 UTC (permalink / raw)
To: Logan Gunthorpe; +Cc: Linux-Sparse
On Fri, Nov 17, 2017 at 7:08 AM, Logan Gunthorpe <logang@deltatee.com> wrote:
> These bultins are defined by in gcc since 4.4. They are also now
> used by the isinf, isfinite and isnan macros. So using them with a
> newer gcc causes 'undefined identifier' errors.
>
> Add the builtin definitions and some validation checks for these
> functions.
>
Thanks, applied and push to master.
>
> Changes since v1:
> * Remove math.h dependancy from validation tests. As a consequnce
> we don't test that the math functions work. (Per a request from
> Christopher.)
Just to clarify. The "make check" is a quick smoke test for sparse to
expose regression etc. It does not mean to be a complete system test.
It is more like a test to be run on before every commit.
In the history we are having header file issue with cygwin and other compile
environment due to sparse don't understand other system macros. It is
better to have sparse able to run the validations test without have to fix
every single system macro define. It is kind of expect to be broken on new
and untested platform. There for, best to have no system header in the
validation test.
Chris
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] add __builtin functions for isinf_sign, isfinite and isnan
2017-11-17 0:02 ` Christopher Li
@ 2017-11-17 1:04 ` Logan Gunthorpe
0 siblings, 0 replies; 6+ messages in thread
From: Logan Gunthorpe @ 2017-11-17 1:04 UTC (permalink / raw)
To: Christopher Li; +Cc: Linux-Sparse
On 11/16/2017 5:02 PM, Christopher Li wrote:
> In the history we are having header file issue with cygwin and other compile
> environment due to sparse don't understand other system macros. It is
> better to have sparse able to run the validations test without have to fix
> every single system macro define. It is kind of expect to be broken on new
> and untested platform. There for, best to have no system header in the
> validation test.
Fair enough,
Thanks.
Logan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] add __builtin functions for isinf_sign, isfinite and isnan
2017-11-16 23:08 [PATCH v2] add __builtin functions for isinf_sign, isfinite and isnan Logan Gunthorpe
2017-11-17 0:02 ` Christopher Li
@ 2017-11-17 8:13 ` Luc Van Oostenryck
2017-11-17 23:28 ` Luc Van Oostenryck
1 sibling, 1 reply; 6+ messages in thread
From: Luc Van Oostenryck @ 2017-11-17 8:13 UTC (permalink / raw)
To: Logan Gunthorpe; +Cc: linux-sparse, Christopher Li
On Thu, Nov 16, 2017 at 04:08:17PM -0700, Logan Gunthorpe wrote:
> These bultins are defined by in gcc since 4.4. They are also now
> used by the isinf, isfinite and isnan macros. So using them with a
> newer gcc causes 'undefined identifier' errors.
>
> Add the builtin definitions and some validation checks for these
> functions.
>
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>
> Changes since v1:
> * Remove math.h dependancy from validation tests. As a consequnce
> we don't test that the math functions work. (Per a request from
> Christopher.)
It would only have tested if your <math.h> doesn't have errors.
-- Luc
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] add __builtin functions for isinf_sign, isfinite and isnan
2017-11-17 8:13 ` Luc Van Oostenryck
@ 2017-11-17 23:28 ` Luc Van Oostenryck
2017-11-17 23:39 ` Logan Gunthorpe
0 siblings, 1 reply; 6+ messages in thread
From: Luc Van Oostenryck @ 2017-11-17 23:28 UTC (permalink / raw)
To: Logan Gunthorpe; +Cc: Linux-Sparse, Christopher Li
On Fri, Nov 17, 2017 at 9:13 AM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> On Thu, Nov 16, 2017 at 04:08:17PM -0700, Logan Gunthorpe wrote:
>> These bultins are defined by in gcc since 4.4. They are also now
>> used by the isinf, isfinite and isnan macros. So using them with a
>> newer gcc causes 'undefined identifier' errors.
>>
>> Add the builtin definitions and some validation checks for these
>> functions.
>>
>> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
>
> Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Hmmm, looking at this closer, I only notice now that those builtins
are of the type-generic kind. Declaring them with a prototype as if
taking a float won't play nicely once you use them with a double or
a long double. Alas, there is not yet real support for type-generic
builtins. One solution would be:
extern int __builtin_isfinite(long double);
Another one would be to use:
extern int __builtin_isfinite(...);
but that is not C99 compliant (not sure if sparse complain).
Note, that there is also a few more builtins of the same family.
-- Luc Van Oostenryck
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] add __builtin functions for isinf_sign, isfinite and isnan
2017-11-17 23:28 ` Luc Van Oostenryck
@ 2017-11-17 23:39 ` Logan Gunthorpe
0 siblings, 0 replies; 6+ messages in thread
From: Logan Gunthorpe @ 2017-11-17 23:39 UTC (permalink / raw)
To: Luc Van Oostenryck; +Cc: Linux-Sparse, Christopher Li
On 17/11/17 04:28 PM, Luc Van Oostenryck wrote:
> Hmmm, looking at this closer, I only notice now that those builtins
> are of the type-generic kind. Declaring them with a prototype as if
> taking a float won't play nicely once you use them with a double or
> a long double. Alas, there is not yet real support for type-generic
> builtins. One solution would be:
> extern int __builtin_isfinite(long double);
> Another one would be to use:
> extern int __builtin_isfinite(...);
> but that is not C99 compliant (not sure if sparse complain).
This is true, but when I test with the validation suite sparse does not
seem to complain if it's a long double, double or float. So I don't
really see an actual issue.
> Note, that there is also a few more builtins of the same family.
Yes, though GCC's documentation is less than clear on all that are
available... I only added ones I knew to exist based on the code I'm
working on and examining the system headers.
Logan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-11-17 23:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-16 23:08 [PATCH v2] add __builtin functions for isinf_sign, isfinite and isnan Logan Gunthorpe
2017-11-17 0:02 ` Christopher Li
2017-11-17 1:04 ` Logan Gunthorpe
2017-11-17 8:13 ` Luc Van Oostenryck
2017-11-17 23:28 ` Luc Van Oostenryck
2017-11-17 23:39 ` Logan Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox