diff --git a/libraries/libmesosphere/source/libc/arch/arm64/memcmp.arch.arm64-broken.s b/libraries/libmesosphere/source/libc/arch/arm64/memcmp.arch.arm64.s
similarity index 100%
rename from libraries/libmesosphere/source/libc/arch/arm64/memcmp.arch.arm64-broken.s
rename to libraries/libmesosphere/source/libc/arch/arm64/memcmp.arch.arm64.s
diff --git a/libraries/libmesosphere/source/libc/arch/arm64/memcpy.arch.arm64-broken.s b/libraries/libmesosphere/source/libc/arch/arm64/memcpy.arch.arm64.s
similarity index 100%
rename from libraries/libmesosphere/source/libc/arch/arm64/memcpy.arch.arm64-broken.s
rename to libraries/libmesosphere/source/libc/arch/arm64/memcpy.arch.arm64.s
diff --git a/libraries/libmesosphere/source/libc/kern_libc_config.arch.arm64.h b/libraries/libmesosphere/source/libc/kern_libc_config.arch.arm64.h
new file mode 100644
index 000000000..155b013e1
--- /dev/null
+++ b/libraries/libmesosphere/source/libc/kern_libc_config.arch.arm64.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2018-2020 Atmosphère-NX
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+/* Definitions for libc genericity. */
+#define MESOSPHERE_LIBC_MEMCPY_GENERIC 0
+#define MESOSPHERE_LIBC_MEMCMP_GENERIC 0
+#define MESOSPHERE_LIBC_MEMMOVE_GENERIC 0
+#define MESOSPHERE_LIBC_MEMSET_GENERIC 1
+#define MESOSPHERE_LIBC_STRNCPY_GENERIC 1
+#define MESOSPHERE_LIBC_STRNCMP_GENERIC 1
\ No newline at end of file
diff --git a/libraries/libmesosphere/source/libc/kern_libc_config.h b/libraries/libmesosphere/source/libc/kern_libc_config.h
new file mode 100644
index 000000000..b391b9955
--- /dev/null
+++ b/libraries/libmesosphere/source/libc/kern_libc_config.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2018-2020 Atmosphère-NX
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#if defined(ATMOSPHERE_ARCH_ARM64)
+
+ #include "kern_libc_config.arch.arm64.h"
+
+#else
+
+ #error "Unknown architecture for libc"
+
+#endif
\ No newline at end of file
diff --git a/libraries/libmesosphere/source/libc/kern_libc_generic.c b/libraries/libmesosphere/source/libc/kern_libc_generic.c
index fb7e4cc79..d41caa551 100644
--- a/libraries/libmesosphere/source/libc/kern_libc_generic.c
+++ b/libraries/libmesosphere/source/libc/kern_libc_generic.c
@@ -16,6 +16,7 @@
#include
#include
#include
+#include "kern_libc_config.h"
/* Note: copied from newlib */
#ifdef __cplusplus
@@ -58,6 +59,8 @@ QUICKREF
#undef TOO_SMALL
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE)
+#if MESOSPHERE_LIBC_MEMMOVE_GENERIC
+
/*SUPPRESS 20*/
void *
//__inhibit_loop_to_libcall
@@ -147,6 +150,8 @@ memmove (void *dst_void,
#endif /* not PREFER_SIZE_OVER_SPEED */
}
+#endif /* MESOSPHERE_LIBC_MEMMOVE_GENERIC */
+
/*
FUNCTION
<>---copy memory regions
@@ -169,6 +174,8 @@ QUICKREF
memcpy ansi pure
*/
+#if MESOSPHERE_LIBC_MEMCPY_GENERIC
+
void *
__attribute__((weak))
memcpy (void * dst0,
@@ -229,6 +236,8 @@ memcpy (void * dst0,
#endif /* not PREFER_SIZE_OVER_SPEED */
}
+#endif /* MESOSPHERE_LIBC_MEMCPY_GENERIC */
+
/*
FUNCTION
<>---set an area of memory
@@ -260,6 +269,8 @@ QUICKREF
#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1))
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
+#if MESOSPHERE_LIBC_MEMSET_GENERIC
+
void *
__attribute__((weak))
memset (void *m,
@@ -322,6 +333,8 @@ memset (void *m,
return m;
}
+#endif /* MESOSPHERE_LIBC_MEMSET_GENERIC */
+
/*
FUNCTION
<>---compare two memory areas
@@ -359,6 +372,8 @@ QUICKREF
/* Threshhold for punting to the byte copier. */
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
+#if MESOSPHERE_LIBC_MEMCMP_GENERIC
+
int
__attribute__((weak))
memcmp (const void *m1,
@@ -421,6 +436,8 @@ memcmp (const void *m1,
#endif /* not PREFER_SIZE_OVER_SPEED */
}
+#endif /* MESOSPHERE_LIBC_MEMCMP_GENERIC */
+
/*
FUNCTION
<>---counted copy string
@@ -475,6 +492,8 @@ QUICKREF
#undef TOO_SMALL
#define TOO_SMALL(LEN) ((LEN) < sizeof (long))
+#if MESOSPHERE_LIBC_STRNCMP_GENERIC
+
char *
strncpy (char *__restrict dst0,
const char *__restrict src0,
@@ -534,6 +553,8 @@ strncpy (char *__restrict dst0,
#endif /* not PREFER_SIZE_OVER_SPEED */
}
+#endif /* MESOSPHERE_LIBC_STRNCPY_GENERIC */
+
/*
FUNCTION
<>---character string compare
@@ -581,6 +602,8 @@ QUICKREF
#error long int is not a 32bit or 64bit byte
#endif
+#if MESOSPHERE_LIBC_STRNCMP_GENERIC
+
int
strncmp (const char *s1,
const char *s2,
@@ -643,6 +666,8 @@ strncmp (const char *s1,
#endif /* not PREFER_SIZE_OVER_SPEED */
}
+#endif /* MESOSPHERE_LIBC_STRNCMP_GENERIC */
+
#ifdef __cplusplus
} /* extern "C" */
#endif