Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "libm/libmcs"]
path = libm/libmcs
url = https://github.com/phoenix-rtos/libmcs.git
branch = phoenix
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ include ctype/Makefile
include err/Makefile
include errno/Makefile
include locale/Makefile
include math/Makefile
include libm/Makefile
include misc/Makefile
include net/Makefile
include netinet/Makefile
Expand Down Expand Up @@ -86,7 +86,8 @@ install: install-headers install-libs
install-headers: $(SRCHEADERS)
@echo INSTALL "$(HEADERS_INSTALL_DIR)/*"; \
mkdir -p "$(HEADERS_INSTALL_DIR)"; \
cp -a include/* "$(HEADERS_INSTALL_DIR)";
cp -a include/* "$(HEADERS_INSTALL_DIR)"; \
cp -a libm/libmcs/libm/include/* "$(HEADERS_INSTALL_DIR)";
Comment on lines +89 to +90

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the libm/libmcs submodule is not checked out or initialized, the directory libm/libmcs/libm/include will not exist, causing the cp -a command to fail and halt the installation. It is safer to conditionally copy the headers only if the directory exists.

	cp -a include/* "$(HEADERS_INSTALL_DIR)"; \
	if [ -d libm/libmcs/libm/include ]; then cp -a libm/libmcs/libm/include/. "$(HEADERS_INSTALL_DIR)"; fi


# TODO: remove `rm crt0.o` when we will be sure it's not a symlink to libphoenix.a anymore
install-libs: $(LIB_TARGETS)
Expand All @@ -108,4 +109,4 @@ clean:
ifneq ($(filter clean,$(MAKECMDGOALS)),)
$(shell rm -rf $(BUILD_DIR))
$(shell rm -f string/*.inc)
endif
endif
40 changes: 0 additions & 40 deletions include/arch/aarch64/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,6 @@
#define __MEMSET
#define __MEMMOVE

#ifndef __SOFTFP__
/* clang-format off */
#define __IEEE754_SQRT
#define __ieee754_sqrt(x) ({ double a = (x); __asm__ ("fsqrt %d0, %d1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_SQRTF
#define __ieee754_sqrtf(x) ({ float a = (x); __asm__ ("fsqrt %s0, %s1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_FABS
#define __ieee754_fabs(x) ({ double a = (x); __asm__ ("fabs %d0, %d1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_FABSF
#define __ieee754_fabsf(x) ({ float a = (x); __asm__ ("fabs %s0, %s1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_CEIL
#define __ieee754_ceil(x) ({ double a = (x); __asm__ ("frintp %d0, %d1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_CEILF
#define __ieee754_ceilf(x) ({ float a = (x); __asm__ ("frintp %s0, %s1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_FLOOR
#define __ieee754_floor(x) ({ double a = (x); __asm__ ("frintm %d0, %d1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_FLOORF
#define __ieee754_floorf(x) ({ float a = (x); __asm__ ("frintm %s0, %s1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_ROUND
#define __ieee754_round(x) ({ double a = (x); __asm__ ("frinta %d0, %d1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_ROUNDF
#define __ieee754_roundf(x) ({ float a = (x); __asm__ ("frinta %s0, %s1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_TRUNC
#define __ieee754_trunc(x) ({ double a = (x); __asm__ ("frintz %d0, %d1" : "=w"(a) : "w"(a)); a; })

#define __IEEE754_TRUNCF
#define __ieee754_truncf(x) ({ float a = (x); __asm__ ("frintz %s0, %s1" : "=w"(a) : "w"(a)); a; })
/* clang-format on */
#endif

#define __LIBPHOENIX_ARCH_TLS_SUPPORTED

#endif
15 changes: 2 additions & 13 deletions include/arch/armv7a/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#ifndef _LIBPHOENIX_ARCH_ARMV7A_ARCH_H_
#define _LIBPHOENIX_ARCH_ARMV7A_ARCH_H_

#define __ARCH_STDINT <arch/armv7a/stdint.h>
#define __ARCH_LIMITS <arch/armv7a/limits.h>
#define __ARCH_STDINT <arch/armv7a/stdint.h>
#define __ARCH_LIMITS <arch/armv7a/limits.h>

#define __MEMCPY
#define __MEMCMP
Expand All @@ -30,17 +30,6 @@
#define __STRNCPY
#define __MEMMOVE


#if defined(__ARM_PCS_VFP) || (defined(__VFP_FP__) && !defined(__SOFTFP__))
#if defined(__ARM_FP) && (__ARM_FP & 8) != 0
#define __IEEE754_SQRT
#define __ieee754_sqrt(x) ({ double a = (x); __asm__ volatile ("vsqrt.f64 %P0, %P1" : "=w"(a) : "w"(a)); a; })
#endif

#define __IEEE754_SQRTF
#define __ieee754_sqrtf(x) ({ float a = (x); __asm__ volatile ("vsqrt.f32 %0, %1" : "=t"(a) : "t"(a)); a; })
#endif

#define __LIBPHOENIX_ARCH_TLS_SUPPORTED

#endif
11 changes: 0 additions & 11 deletions include/arch/armv8r/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@
#define __STRNCPY
#define __MEMMOVE


#if defined(__ARM_PCS_VFP) || (defined(__VFP_FP__) && !defined(__SOFTFP__))
#if defined(__ARM_FP) && (__ARM_FP & 8) != 0
#define __IEEE754_SQRT
#define __ieee754_sqrt(x) ({ double a = (x); __asm__ volatile ("vsqrt.f64 %P0, %P1" : "=w"(a) : "w"(a)); a; })
#endif

#define __IEEE754_SQRTF
#define __ieee754_sqrtf(x) ({ float a = (x); __asm__ volatile ("vsqrt.f32 %0, %1" : "=t"(a) : "t"(a)); a; })
#endif

#define __LIBPHOENIX_ARCH_TLS_SUPPORTED

#endif
28 changes: 0 additions & 28 deletions include/arch/ia32/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,6 @@
#define __MEMCPY
#define __MEMSET

#ifndef __SOFTFP__
#define __IEEE754_SQRT

static inline double __ieee754_sqrt(double x)
{
unsigned short newcw, savecw;
unsigned short register reg;

/* clang-format off */
__asm__ volatile (
"fstcw %w[savecw]\n\t" /* save control word */
"mov %w[savecw], %w[reg]\n\t" /* reg <- (memptr) */
"and $0xf0ff, %w[reg]\n\t" /* inherit exception mask and infinity */
"or $0x200, %w[reg]\n\t" /* set double precision, round to nearest-even */
"mov %w[reg], %w[newcw]\n\t" /* (memptr) <- reg */
"fldcw %w[newcw]\n\t" /* and apply (memptr) new control word */
"fsqrt\n\t" /* calculate double precision sqrt */
"fldcw %w[savecw]" /* restore control word */
: "+t" (x), [reg] "=&r" (reg)
: [newcw] "m" (newcw), [savecw] "m" (savecw)
: "cc", "memory");
/* clang-format on */

return x;
}

#endif

#define __LIBPHOENIX_ARCH_TLS_SUPPORTED

#endif
Loading
Loading