aboutsummaryrefslogtreecommitdiff
path: root/circuitpython/lib/libm/libm.h
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2022-06-19 19:47:51 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2022-06-19 19:47:51 +0530
commit4fd287655a72b9aea14cdac715ad5b90ed082ed2 (patch)
tree65d393bc0e699dd12d05b29ba568e04cea666207 /circuitpython/lib/libm/libm.h
parent0150f70ce9c39e9e6dd878766c0620c85e47bed0 (diff)
add circuitpython code
Diffstat (limited to 'circuitpython/lib/libm/libm.h')
-rw-r--r--circuitpython/lib/libm/libm.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/circuitpython/lib/libm/libm.h b/circuitpython/lib/libm/libm.h
new file mode 100644
index 0000000..f782249
--- /dev/null
+++ b/circuitpython/lib/libm/libm.h
@@ -0,0 +1,54 @@
+/*****************************************************************************/
+/*****************************************************************************/
+// portions extracted from musl-0.9.15 libm.h
+/*****************************************************************************/
+/*****************************************************************************/
+
+/* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <stdint.h>
+#include <math.h>
+
+#define FLT_EVAL_METHOD 0
+
+#define FORCE_EVAL(x) do { \
+ if (sizeof(x) == sizeof(float)) { \
+ volatile float __x; \
+ __x = (x); \
+ (void)__x; \
+ } else if (sizeof(x) == sizeof(double)) { \
+ volatile double __x; \
+ __x = (x); \
+ (void)__x; \
+ } else { \
+ volatile long double __x; \
+ __x = (x); \
+ (void)__x; \
+ } \
+} while(0)
+
+/* Get a 32 bit int from a float. */
+#define GET_FLOAT_WORD(w,d) \
+do { \
+ union {float f; uint32_t i;} __u; \
+ __u.f = (d); \
+ (w) = __u.i; \
+} while (0)
+
+/* Set a float from a 32 bit int. */
+#define SET_FLOAT_WORD(d,w) \
+do { \
+ union {float f; uint32_t i;} __u; \
+ __u.i = (w); \
+ (d) = __u.f; \
+} while (0)