aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/sys/arm/sysconf.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2022-09-16 16:04:21 -0400
committerJeff Johnston <jjohnstn@redhat.com>2022-09-19 15:35:55 -0400
commit5230eb7f8c6b43c71d7e38d138935c48de930b76 (patch)
treef2a00763fe3edead63c1e6adcce4417a2c0ba359 /newlib/libc/sys/arm/sysconf.c
parenteb5c631ead537ac5640d7e4b1ea0edbef344d6d9 (diff)
downloadnewlib-5230eb7f8c6b43c71d7e38d138935c48de930b76.zip
newlib-5230eb7f8c6b43c71d7e38d138935c48de930b76.tar.gz
newlib-5230eb7f8c6b43c71d7e38d138935c48de930b76.tar.bz2
Implement sysconf for Arm
- add support for using sysconf to get page size in _mallocr.c via HAVE_SYSCONF_PAGESIZE flag set in configure.host - set flag in configure.host for arm and add a default sysconf implementation in libc/sys/arm that returns the page size - the default implementation can be overridden outside newlib to allow a different page size to improve malloc on devices with a small footprint without needing to rebuild newlib - this patch is based on a contribution from Torbjorn Svensson and Niklas Dahlquist (https://ecos.sourceware.org/ml/newlib/current/017616.html)
Diffstat (limited to 'newlib/libc/sys/arm/sysconf.c')
-rw-r--r--newlib/libc/sys/arm/sysconf.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/newlib/libc/sys/arm/sysconf.c b/newlib/libc/sys/arm/sysconf.c
new file mode 100644
index 0000000..0fbbe31
--- /dev/null
+++ b/newlib/libc/sys/arm/sysconf.c
@@ -0,0 +1,34 @@
+/* libc/sys/arm/sysconf.c - The sysconf function */
+
+/* Copyright 2020, STMicroelectronics
+ *
+ * All rights reserved.
+ *
+ * Redistribution, modification, and use in source and binary forms is permitted
+ * provided that the above copyright notice and following paragraph are
+ * duplicated in all such forms.
+ *
+ * This file is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+long sysconf(int name)
+{
+ switch (name)
+ {
+ case _SC_PAGESIZE:
+#ifdef SMALL_MEMORY
+ return 128;
+#else
+ return 4096;
+#endif
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ return -1; /* Can't get here */
+}