diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2016-11-11 21:52:05 -0600 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2016-11-11 23:06:21 -0500 |
commit | 15094943050eb9a564f409323070e50b40f78816 (patch) | |
tree | f9af42d3369ee9a6ebd08bf416a99159193217a8 /src/fenv/s390x/fenv.c | |
parent | 54482898abe8d6d937ee67ea5974cd8eae859c37 (diff) | |
download | musl-15094943050eb9a564f409323070e50b40f78816.tar.gz |
add s390x port
Diffstat (limited to 'src/fenv/s390x/fenv.c')
-rw-r--r-- | src/fenv/s390x/fenv.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/fenv/s390x/fenv.c b/src/fenv/s390x/fenv.c new file mode 100644 index 00000000..9a3488d7 --- /dev/null +++ b/src/fenv/s390x/fenv.c @@ -0,0 +1,55 @@ +#include <fenv.h> + +static inline unsigned get_fpc(void) +{ + unsigned fpc; + __asm__ __volatile__("efpc %0" : "=r"(fpc)); + return fpc; +} + +static inline void set_fpc(unsigned fpc) +{ + __asm__ __volatile__("sfpc %0" :: "r"(fpc)); +} + +int feclearexcept(int mask) +{ + mask &= FE_ALL_EXCEPT; + set_fpc(get_fpc() & ~mask); + return 0; +} + +int feraiseexcept(int mask) +{ + mask &= FE_ALL_EXCEPT; + set_fpc(get_fpc() | mask); + return 0; +} + +int fetestexcept(int mask) +{ + return get_fpc() & mask & FE_ALL_EXCEPT; +} + +int fegetround(void) +{ + return get_fpc() & 3; +} + +int __fesetround(int r) +{ + set_fpc(get_fpc() & ~3L | r); + return 0; +} + +int fegetenv(fenv_t *envp) +{ + *envp = get_fpc(); + return 0; +} + +int fesetenv(const fenv_t *envp) +{ + set_fpc(envp != FE_DFL_ENV ? *envp : 0); + return 0; +} |