[2/3] tests: Use FE_UPWARD only if its defined in fenv.h

Message ID 20181130104506.4658-2-ross.burton@intel.com
State New
Headers show
Series
  • [1/3] cmake: use proper WAYLAND_INCLUDE_DIRS variable
Related show

Commit Message

Ross Burton Nov. 30, 2018, 10:45 a.m.
From: Khem Raj <raj.khem@gmail.com>

On ARM, musl does not define FE_* when arch does not have
VFP, (which is right interpretation), therefore check if
it is defined before using it.

Fixes errors like:

tests/general/roundmode-pixelstore.c:82:19: error: 'FE_UPWARD' undeclared (first use in this function)
  ret = fesetround(FE_UPWARD);
                   ^~~~~~~~~

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 tests/general/roundmode-getintegerv.c | 2 ++
 tests/general/roundmode-pixelstore.c  | 2 ++
 2 files changed, 4 insertions(+)

Comments

Eric Engestrom Nov. 30, 2018, 12:37 p.m. | #1
On Friday, 2018-11-30 10:45:05 +0000, Ross Burton wrote:
> From: Khem Raj <raj.khem@gmail.com>
> 
> On ARM, musl does not define FE_* when arch does not have
> VFP, (which is right interpretation), therefore check if
> it is defined before using it.
> 
> Fixes errors like:
> 
> tests/general/roundmode-pixelstore.c:82:19: error: 'FE_UPWARD' undeclared (first use in this function)
>   ret = fesetround(FE_UPWARD);
>                    ^~~~~~~~~
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  tests/general/roundmode-getintegerv.c | 2 ++
>  tests/general/roundmode-pixelstore.c  | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/tests/general/roundmode-getintegerv.c b/tests/general/roundmode-getintegerv.c
> index 28ecfaf55..5c275797b 100644
> --- a/tests/general/roundmode-getintegerv.c
> +++ b/tests/general/roundmode-getintegerv.c
> @@ -81,7 +81,9 @@ piglit_init(int argc, char **argv)
>  {
>  	int ret;
>  	bool pass = true;
> +#ifdef FE_UPWARD
>  	ret = fesetround(FE_UPWARD);
> +#endif
>  	if (ret != 0) {

You'll need a #else that sets ret, otherwise you're pretty obviously
going to jump based on an uninitialised variable here :/

>  		printf("Couldn't set rounding mode\n");
>  		piglit_report_result(PIGLIT_SKIP);
> diff --git a/tests/general/roundmode-pixelstore.c b/tests/general/roundmode-pixelstore.c
> index 8a029b257..51951a0d9 100644
> --- a/tests/general/roundmode-pixelstore.c
> +++ b/tests/general/roundmode-pixelstore.c
> @@ -81,7 +81,9 @@ piglit_init(int argc, char **argv)
>  {
>  	int ret;
>  	bool pass = true;
> +#ifdef FE_UPWARD
>  	ret = fesetround(FE_UPWARD);
> +#endif
>  	if (ret != 0) {
>  		printf("Couldn't set rounding mode\n");
>  		piglit_report_result(PIGLIT_SKIP);
> -- 
> 2.11.0
> 
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
Ross Burton Nov. 30, 2018, 3:54 p.m. | #2
Erm, yeah, sorry about that.  Grabbing a patch that we've been
shipping without actually looking at it.

Ross
On Fri, 30 Nov 2018 at 12:37, Eric Engestrom <eric.engestrom@intel.com> wrote:
>
> On Friday, 2018-11-30 10:45:05 +0000, Ross Burton wrote:
> > From: Khem Raj <raj.khem@gmail.com>
> >
> > On ARM, musl does not define FE_* when arch does not have
> > VFP, (which is right interpretation), therefore check if
> > it is defined before using it.
> >
> > Fixes errors like:
> >
> > tests/general/roundmode-pixelstore.c:82:19: error: 'FE_UPWARD' undeclared (first use in this function)
> >   ret = fesetround(FE_UPWARD);
> >                    ^~~~~~~~~
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
> >  tests/general/roundmode-getintegerv.c | 2 ++
> >  tests/general/roundmode-pixelstore.c  | 2 ++
> >  2 files changed, 4 insertions(+)
> >
> > diff --git a/tests/general/roundmode-getintegerv.c b/tests/general/roundmode-getintegerv.c
> > index 28ecfaf55..5c275797b 100644
> > --- a/tests/general/roundmode-getintegerv.c
> > +++ b/tests/general/roundmode-getintegerv.c
> > @@ -81,7 +81,9 @@ piglit_init(int argc, char **argv)
> >  {
> >       int ret;
> >       bool pass = true;
> > +#ifdef FE_UPWARD
> >       ret = fesetround(FE_UPWARD);
> > +#endif
> >       if (ret != 0) {
>
> You'll need a #else that sets ret, otherwise you're pretty obviously
> going to jump based on an uninitialised variable here :/
>
> >               printf("Couldn't set rounding mode\n");
> >               piglit_report_result(PIGLIT_SKIP);
> > diff --git a/tests/general/roundmode-pixelstore.c b/tests/general/roundmode-pixelstore.c
> > index 8a029b257..51951a0d9 100644
> > --- a/tests/general/roundmode-pixelstore.c
> > +++ b/tests/general/roundmode-pixelstore.c
> > @@ -81,7 +81,9 @@ piglit_init(int argc, char **argv)
> >  {
> >       int ret;
> >       bool pass = true;
> > +#ifdef FE_UPWARD
> >       ret = fesetround(FE_UPWARD);
> > +#endif
> >       if (ret != 0) {
> >               printf("Couldn't set rounding mode\n");
> >               piglit_report_result(PIGLIT_SKIP);
> > --
> > 2.11.0
> >
> > _______________________________________________
> > Piglit mailing list
> > Piglit@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/piglit
Ross Burton Nov. 30, 2018, 4:40 p.m. | #3
Okay, revised patch submitted, which hopefully does the right thing this time.

Ross
On Fri, 30 Nov 2018 at 15:54, Burton, Ross <ross.burton@intel.com> wrote:
>
> Erm, yeah, sorry about that.  Grabbing a patch that we've been
> shipping without actually looking at it.
>
> Ross
> On Fri, 30 Nov 2018 at 12:37, Eric Engestrom <eric.engestrom@intel.com> wrote:
> >
> > On Friday, 2018-11-30 10:45:05 +0000, Ross Burton wrote:
> > > From: Khem Raj <raj.khem@gmail.com>
> > >
> > > On ARM, musl does not define FE_* when arch does not have
> > > VFP, (which is right interpretation), therefore check if
> > > it is defined before using it.
> > >
> > > Fixes errors like:
> > >
> > > tests/general/roundmode-pixelstore.c:82:19: error: 'FE_UPWARD' undeclared (first use in this function)
> > >   ret = fesetround(FE_UPWARD);
> > >                    ^~~~~~~~~
> > >
> > > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > > ---
> > >  tests/general/roundmode-getintegerv.c | 2 ++
> > >  tests/general/roundmode-pixelstore.c  | 2 ++
> > >  2 files changed, 4 insertions(+)
> > >
> > > diff --git a/tests/general/roundmode-getintegerv.c b/tests/general/roundmode-getintegerv.c
> > > index 28ecfaf55..5c275797b 100644
> > > --- a/tests/general/roundmode-getintegerv.c
> > > +++ b/tests/general/roundmode-getintegerv.c
> > > @@ -81,7 +81,9 @@ piglit_init(int argc, char **argv)
> > >  {
> > >       int ret;
> > >       bool pass = true;
> > > +#ifdef FE_UPWARD
> > >       ret = fesetround(FE_UPWARD);
> > > +#endif
> > >       if (ret != 0) {
> >
> > You'll need a #else that sets ret, otherwise you're pretty obviously
> > going to jump based on an uninitialised variable here :/
> >
> > >               printf("Couldn't set rounding mode\n");
> > >               piglit_report_result(PIGLIT_SKIP);
> > > diff --git a/tests/general/roundmode-pixelstore.c b/tests/general/roundmode-pixelstore.c
> > > index 8a029b257..51951a0d9 100644
> > > --- a/tests/general/roundmode-pixelstore.c
> > > +++ b/tests/general/roundmode-pixelstore.c
> > > @@ -81,7 +81,9 @@ piglit_init(int argc, char **argv)
> > >  {
> > >       int ret;
> > >       bool pass = true;
> > > +#ifdef FE_UPWARD
> > >       ret = fesetround(FE_UPWARD);
> > > +#endif
> > >       if (ret != 0) {
> > >               printf("Couldn't set rounding mode\n");
> > >               piglit_report_result(PIGLIT_SKIP);
> > > --
> > > 2.11.0
> > >
> > > _______________________________________________
> > > Piglit mailing list
> > > Piglit@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/piglit

Patch

diff --git a/tests/general/roundmode-getintegerv.c b/tests/general/roundmode-getintegerv.c
index 28ecfaf55..5c275797b 100644
--- a/tests/general/roundmode-getintegerv.c
+++ b/tests/general/roundmode-getintegerv.c
@@ -81,7 +81,9 @@  piglit_init(int argc, char **argv)
 {
 	int ret;
 	bool pass = true;
+#ifdef FE_UPWARD
 	ret = fesetround(FE_UPWARD);
+#endif
 	if (ret != 0) {
 		printf("Couldn't set rounding mode\n");
 		piglit_report_result(PIGLIT_SKIP);
diff --git a/tests/general/roundmode-pixelstore.c b/tests/general/roundmode-pixelstore.c
index 8a029b257..51951a0d9 100644
--- a/tests/general/roundmode-pixelstore.c
+++ b/tests/general/roundmode-pixelstore.c
@@ -81,7 +81,9 @@  piglit_init(int argc, char **argv)
 {
 	int ret;
 	bool pass = true;
+#ifdef FE_UPWARD
 	ret = fesetround(FE_UPWARD);
+#endif
 	if (ret != 0) {
 		printf("Couldn't set rounding mode\n");
 		piglit_report_result(PIGLIT_SKIP);