[libc-commits] [libc] 873431a - [libc] Add __FE_DENORM to the fenv macros (#91353)

via libc-commits libc-commits at lists.llvm.org
Tue May 7 10:57:58 PDT 2024


Author: Joseph Huber
Date: 2024-05-07T12:57:54-05:00
New Revision: 873431a68a3aa3ec4fed5d2dc98ef527230b0d21

URL: https://github.com/llvm/llvm-project/commit/873431a68a3aa3ec4fed5d2dc98ef527230b0d21
DIFF: https://github.com/llvm/llvm-project/commit/873431a68a3aa3ec4fed5d2dc98ef527230b0d21.diff

LOG: [libc] Add __FE_DENORM to the fenv macros (#91353)

Summary:
Some targets support denormals as floating point exceptions. This is
provided as an extension in the GNU headers as __FE_DENORM.

This provides it in our headers, however I'm unsure if we should make it
internal or external. I do not think it should be in all exception as it
doesn't represent an exceptional behavior as far as the standard is
concerned, but I'm not an expert.

Added: 
    

Modified: 
    libc/hdr/fenv_macros.h
    libc/include/llvm-libc-macros/fenv-macros.h

Removed: 
    


################################################################################
diff  --git a/libc/hdr/fenv_macros.h b/libc/hdr/fenv_macros.h
index 1ad28cc278a97b..041fca5f224b33 100644
--- a/libc/hdr/fenv_macros.h
+++ b/libc/hdr/fenv_macros.h
@@ -17,6 +17,11 @@
 
 #include <fenv.h>
 
+// If this is not provided by the system, define it for use internally.
+#ifndef __FE_DENORM
+#define __FE_DENORM (1 << 6)
+#endif
+
 #endif // LLVM_LIBC_FULL_BUILD
 
 #endif // LLVM_LIBC_HDR_FENV_MACROS_H

diff  --git a/libc/include/llvm-libc-macros/fenv-macros.h b/libc/include/llvm-libc-macros/fenv-macros.h
index 72ac660cd98cba..1826723f93490d 100644
--- a/libc/include/llvm-libc-macros/fenv-macros.h
+++ b/libc/include/llvm-libc-macros/fenv-macros.h
@@ -9,11 +9,12 @@
 #ifndef LLVM_LIBC_MACROS_FENV_MACROS_H
 #define LLVM_LIBC_MACROS_FENV_MACROS_H
 
-#define FE_DIVBYZERO 1
-#define FE_INEXACT 2
-#define FE_INVALID 4
-#define FE_OVERFLOW 8
-#define FE_UNDERFLOW 16
+#define FE_DIVBYZERO 0x1
+#define FE_INEXACT 0x2
+#define FE_INVALID 0x4
+#define FE_OVERFLOW 0x8
+#define FE_UNDERFLOW 0x10
+#define __FE_DENORM 0x20
 #define FE_ALL_EXCEPT                                                          \
   (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
 


        


More information about the libc-commits mailing list