Hello.

Thank you for your insights.

The
```
diff --git a/newlib/libm/machine/aarch64/fenv.c 
b/newlib/libm/machine/aarch64/fenv.c
index 3ffe23441..fb6a67dcc 100644
--- a/newlib/libm/machine/aarch64/fenv.c
+++ b/newlib/libm/machine/aarch64/fenv.c
@@ -27,6 +27,9 @@
  * $FreeBSD$
  */
 
+/* Enable all fenv-related functions.  */
+#define __BSD_VISIBLE
+
 #define        __fenv_static
 #include <fenv.h>
 #include <machine/fenv-fp.h>
```
patch has no effect because `__BSD_VISIBLE` is already set to `1` in 
`newlib/libc/include/sys/features.h`. I don't know what is the semantics of 
this macro but I added it to my patch just to make the code consistent with 
`newlib/libc/machine/mips/machine/fenv-fp.h` because it seems that this file is 
solving the same problem.

I've checked that for every object of Cygwin build, only the 
`newlib/libc/machine/aarch64/sys/fenv.h` gets included and the 
`newlib/libc/include/sys/fenv.h` header is never included.

I am attaching the pre-processed `fenv.c`.

Radek
# 0 "../../../code/cygwin/newlib/libm/machine/aarch64/fenv.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "../../../code/cygwin/newlib/libm/machine/aarch64/fenv.c"
# 31 "../../../code/cygwin/newlib/libm/machine/aarch64/fenv.c"
# 1 "/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/fenv.h" 
1 3 4
# 15 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/fenv.h" 3 4
# 1 
"/home/blackhex/mingw-woarm64-build/build-aarch64/aarch64-pc-cygwin/newlib/targ-include/sys/fenv.h"
 1 3 4
# 32 
"/home/blackhex/mingw-woarm64-build/build-aarch64/aarch64-pc-cygwin/newlib/targ-include/sys/fenv.h"
 3 4
# 1 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 1 3 4
# 24 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 3 4
# 1 
"/home/blackhex/cross-aarch64-pc-cygwin-msvcrt/lib/gcc/aarch64-pc-cygwin/15/include/stddef.h"
 1 3 4
# 214 
"/home/blackhex/cross-aarch64-pc-cygwin-msvcrt/lib/gcc/aarch64-pc-cygwin/15/include/stddef.h"
 3 4

# 214 
"/home/blackhex/cross-aarch64-pc-cygwin-msvcrt/lib/gcc/aarch64-pc-cygwin/15/include/stddef.h"
 3 4
typedef long unsigned int size_t;
# 359 
"/home/blackhex/cross-aarch64-pc-cygwin-msvcrt/lib/gcc/aarch64-pc-cygwin/15/include/stddef.h"
 3 4
typedef unsigned int wint_t;
# 25 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 2 3 4
# 1 "./newlib.h" 1 3 4
# 10 "./newlib.h" 3 4
# 1 "./_newlib_version.h" 1 3 4
# 11 "./newlib.h" 2 3 4
# 26 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 2 3 4
# 1 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/config.h"
 1 3 4



# 1 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/ieeefp.h"
 1 3 4
# 5 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/config.h"
 2 3 4
# 1 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/features.h"
 1 3 4
# 6 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/config.h"
 2 3 4
# 238 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/config.h"
 3 4
# 1 
"/home/blackhex/mingw-woarm64-build/code/cygwin/winsup/cygwin/include/cygwin/config.h"
 1 3 4
# 35 
"/home/blackhex/mingw-woarm64-build/code/cygwin/winsup/cygwin/include/cygwin/config.h"
 3 4
__attribute__((__gnu_inline__))
extern inline struct _reent *__getreent (void)
{
  register char *ret;






  __asm __volatile__ ("ldr %0, [x18, #0x8]" : "=r" (ret));



  return (struct _reent *) (ret - 12800);
}
# 239 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/config.h"
 2 3 4
# 27 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 2 3 4
# 1 
"/home/blackhex/mingw-woarm64-build/code/cygwin/winsup/cygwin/include/machine/_types.h"
 1 3 4





# 1 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 1 3 4
# 41 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 3 4
typedef signed char __int8_t;

typedef unsigned char __uint8_t;
# 55 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 3 4
typedef short int __int16_t;

typedef short unsigned int __uint16_t;
# 77 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 3 4
typedef int __int32_t;

typedef unsigned int __uint32_t;
# 103 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 3 4
typedef long int __int64_t;

typedef long unsigned int __uint64_t;
# 134 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 3 4
typedef signed char __int_least8_t;

typedef unsigned char __uint_least8_t;
# 160 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 3 4
typedef short int __int_least16_t;

typedef short unsigned int __uint_least16_t;
# 182 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 3 4
typedef int __int_least32_t;

typedef unsigned int __uint_least32_t;
# 200 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 3 4
typedef long int __int_least64_t;

typedef long unsigned int __uint_least64_t;
# 214 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/machine/_default_types.h"
 3 4
typedef long int __intmax_t;







typedef long unsigned int __uintmax_t;







typedef long int __intptr_t;

typedef long unsigned int __uintptr_t;
# 7 
"/home/blackhex/mingw-woarm64-build/code/cygwin/winsup/cygwin/include/machine/_types.h"
 2 3 4


typedef __int64_t __blkcnt_t;


typedef __int32_t __blksize_t;


typedef __uint32_t __dev_t;


typedef unsigned long __fsblkcnt_t;


typedef unsigned long __fsfilcnt_t;


typedef __uint32_t __uid_t;


typedef __uint32_t __gid_t;


typedef __uint64_t __ino_t;


typedef long long __key_t;


typedef __uint16_t __sa_family_t;



typedef int __socklen_t;
# 28 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 2 3 4
# 46 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 3 4
typedef long _off_t;





typedef int __pid_t;
# 67 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 3 4
typedef __uint32_t __id_t;
# 90 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 3 4
typedef __uint32_t __mode_t;





__extension__ typedef long long _off64_t;





typedef _off_t __off_t;


typedef _off64_t __loff_t;
# 116 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 3 4
typedef long _fpos_t;
# 131 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 3 4
typedef long unsigned int __size_t;
# 147 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 3 4
typedef long signed int _ssize_t;
# 158 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 3 4
typedef _ssize_t __ssize_t;



typedef struct
{
  int __count;
  union
  {
    wint_t __wch;
    unsigned char __wchb[4];
  } __value;
} _mbstate_t;




typedef void *_iconv_t;






typedef unsigned long __clock_t;






typedef long __time_t;





typedef unsigned long __clockid_t;


typedef long __daddr_t;



typedef unsigned long __timer_t;
# 212 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/sys/_types.h"
 3 4
typedef int __nl_item;
typedef unsigned short __nlink_t;
typedef long __suseconds_t;
typedef unsigned long __useconds_t;







typedef __builtin_va_list __va_list;
# 33 
"/home/blackhex/mingw-woarm64-build/build-aarch64/aarch64-pc-cygwin/newlib/targ-include/sys/fenv.h"
 2 3 4





typedef __uint64_t fenv_t;
typedef __uint64_t fexcept_t;
# 67 
"/home/blackhex/mingw-woarm64-build/build-aarch64/aarch64-pc-cygwin/newlib/targ-include/sys/fenv.h"
 3 4
extern const fenv_t *_fe_dfl_env;
# 85 
"/home/blackhex/mingw-woarm64-build/build-aarch64/aarch64-pc-cygwin/newlib/targ-include/sys/fenv.h"
 3 4
static inline int
feenableexcept(int __mask)
{
 fenv_t __old_r, __new_r;

 __asm __volatile("mrs %0, fpcr" : "=r" (__old_r));
 __new_r = __old_r | ((__mask & (0x00000002 | 0x00000010 | 0x00000001 | 
0x00000004 | 0x00000008)) << 8);
 __asm __volatile("msr fpcr, %0" : : "r" (__new_r));
 return ((__old_r >> 8) & (0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 
0x00000008));
}

static inline int
fedisableexcept(int __mask)
{
 fenv_t __old_r, __new_r;

 __asm __volatile("mrs %0, fpcr" : "=r" (__old_r));
 __new_r = __old_r & ~((__mask & (0x00000002 | 0x00000010 | 0x00000001 | 
0x00000004 | 0x00000008)) << 8);
 __asm __volatile("msr fpcr, %0" : : "r" (__new_r));
 return ((__old_r >> 8) & (0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 
0x00000008));
}

static inline int
fegetexcept(void)
{
 fenv_t __r;

 __asm __volatile("mrs %0, fpcr" : "=r" (__r));
 return ((__r & ((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 
0x00000008) << 8)) >> 8);
}
# 16 
"/home/blackhex/mingw-woarm64-build/code/cygwin/newlib/libc/include/fenv.h" 2 3 
4






int feclearexcept(int excepts);
int fegetexceptflag(fexcept_t *flagp, int excepts);
int feraiseexcept(int excepts);
int fesetexceptflag(const fexcept_t *flagp, int excepts);
int fetestexcept(int excepts);


int fegetround(void);
int fesetround(int rounding_mode);


int fegetenv(fenv_t *envp);
int feholdexcept(fenv_t *envp);
int fesetenv(const fenv_t *envp);
int feupdateenv(const fenv_t *envp);
# 32 "../../../code/cygwin/newlib/libm/machine/aarch64/fenv.c" 2
# 1 
"/home/blackhex/mingw-woarm64-build/build-aarch64/aarch64-pc-cygwin/newlib/targ-include/machine/fenv-fp.h"
 1 3 4
# 30 
"/home/blackhex/mingw-woarm64-build/build-aarch64/aarch64-pc-cygwin/newlib/targ-include/machine/fenv-fp.h"
 3 4
 __inline int
feclearexcept(int __excepts)
{
 fexcept_t __r;

 __asm __volatile("mrs %0, fpsr" : "=r" (__r));
 __r &= ~__excepts;
 __asm __volatile("msr fpsr, %0" : : "r" (__r));
 return (0);
}

 inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
 fexcept_t __r;

 __asm __volatile("mrs %0, fpsr" : "=r" (__r));
 *__flagp = __r & __excepts;
 return (0);
}

 inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
 fexcept_t __r;

 __asm __volatile("mrs %0, fpsr" : "=r" (__r));
 __r &= ~__excepts;
 __r |= *__flagp & __excepts;
 __asm __volatile("msr fpsr, %0" : : "r" (__r));
 return (0);
}

 inline int
feraiseexcept(int __excepts)
{
 fexcept_t __r;

 __asm __volatile("mrs %0, fpsr" : "=r" (__r));
 __r |= __excepts;
 __asm __volatile("msr fpsr, %0" : : "r" (__r));
 return (0);
}

 inline int
fetestexcept(int __excepts)
{
 fexcept_t __r;

 __asm __volatile("mrs %0, fpsr" : "=r" (__r));
 return (__r & __excepts);
}

 inline int
fegetround(void)
{
 fenv_t __r;

 __asm __volatile("mrs %0, fpcr" : "=r" (__r));
 return ((__r >> 22) & (0x0 | 0x2 | 0x1 | 0x3));
}

 inline int
fesetround(int __round)
{
 fenv_t __r;

 if (__round & ~(0x0 | 0x2 | 0x1 | 0x3))
  return (-1);
 __asm __volatile("mrs %0, fpcr" : "=r" (__r));
 __r &= ~((0x0 | 0x2 | 0x1 | 0x3) << 22);
 __r |= __round << 22;
 __asm __volatile("msr fpcr, %0" : : "r" (__r));
 return (0);
}

 inline int
fegetenv(fenv_t *__envp)
{
 fenv_t __r;

 __asm __volatile("mrs %0, fpcr" : "=r" (__r));
 *__envp = __r & ((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 
0x00000008) << 8);

 __asm __volatile("mrs %0, fpsr" : "=r" (__r));
 *__envp |= __r & ((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 
0x00000008) | ((0x0 | 0x2 | 0x1 | 0x3) << 22));

 return (0);
}

 inline int
feholdexcept(fenv_t *__envp)
{
 fenv_t __r;

 __asm __volatile("mrs %0, fpcr" : "=r" (__r));
 *__envp = __r & ((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 
0x00000008) << 8);
 __r &= ~(((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008) << 
8));
 __asm __volatile("msr fpcr, %0" : : "r" (__r));

 __asm __volatile("mrs %0, fpsr" : "=r" (__r));
 *__envp |= __r & ((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 
0x00000008) | ((0x0 | 0x2 | 0x1 | 0x3) << 22));
 __r &= ~(((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008) << 
8));
 __asm __volatile("msr fpsr, %0" : : "r" (__r));
 return (0);
}

 inline int
fesetenv(const fenv_t *__envp)
{

 __asm __volatile("msr fpcr, %0" : : "r" ((*__envp) & ((0x00000002 | 0x00000010 
| 0x00000001 | 0x00000004 | 0x00000008) << 8)));
 __asm __volatile("msr fpsr, %0" : : "r" ((*__envp) & ((0x00000002 | 0x00000010 
| 0x00000001 | 0x00000004 | 0x00000008) | ((0x0 | 0x2 | 0x1 | 0x3) << 22))));
 return (0);
}

 inline int
feupdateenv(const fenv_t *__envp)
{
 fexcept_t __r;

 __asm __volatile("mrs %0, fpsr" : "=r" (__r));
 fesetenv(__envp);
 feraiseexcept(__r & (0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 
0x00000008));
 return (0);
}
# 33 "../../../code/cygwin/newlib/libm/machine/aarch64/fenv.c" 2
# 44 "../../../code/cygwin/newlib/libm/machine/aarch64/fenv.c"

# 44 "../../../code/cygwin/newlib/libm/machine/aarch64/fenv.c"
extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
extern inline int feraiseexcept(int __excepts);
extern inline int fetestexcept(int __excepts);
extern inline int fegetround(void);
extern inline int fesetround(int __round);
extern inline int fegetenv(fenv_t *__envp);
extern inline int feholdexcept(fenv_t *__envp);
extern inline int fesetenv(const fenv_t *__envp);
extern inline int feupdateenv(const fenv_t *__envp);
extern inline int feenableexcept(int __mask);
extern inline int fedisableexcept(int __mask);
extern inline int fegetexcept(void);

Reply via email to