Add __riscv_flush_icache() to <sys/cachectl.h>.
The obsolete mips header rides again!
The most interesting part of this change is that I've removed the hack
that meant that all system call wrappers starting with `__` defaulted to
being hidden symbols. That's no longer useful given our linker scripts,
and it actively got in the way here because the public libc symbol
actually starts with `__` in glibc, and it would be weird and annoying
for developers if we chose a different name.
Test: strace
Change-Id: I230479787895e8e34f566ade36346a8241eea998
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 08017f1..5f49c8c 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -356,7 +356,7 @@
int cacheflush:__ARM_NR_cacheflush(long start, long end, long flags) arm
# riscv64-specific
-int _flush_icache:riscv_flush_icache(void*, void*, unsigned long) riscv64
+int __riscv_flush_icache:riscv_flush_icache(void*, void*, unsigned long) riscv64
# x86-specific
int __set_thread_area:set_thread_area(void*) x86
diff --git a/libc/include/sys/cachectl.h b/libc/include/sys/cachectl.h
index 5ec295d..fd775ee 100644
--- a/libc/include/sys/cachectl.h
+++ b/libc/include/sys/cachectl.h
@@ -28,6 +28,27 @@
#pragma once
+/*
+ * @file sys/cachectl.h
+ * @brief Architecture-specific cache control.
+ */
+
#include <sys/cdefs.h>
-/* This header file is obsolete. */
+__BEGIN_DECLS
+
+/**
+ * Flag for __riscv_flush_icache() to indicate that only the current
+ * thread's instruction cache needs to be flushed (rather than the
+ * default of all threads).
+ */
+#define SYS_RISCV_FLUSH_ICACHE_LOCAL 1UL
+
+/**
+ * __riscv_flush_icache(2) flushes the instruction cache for the given range of addresses.
+ *
+ * Returns 0 on success, and returns -1 and sets `errno` on failure.
+ */
+int __riscv_flush_icache(void* __start, void* __end, unsigned long __flags);
+
+__END_DECLS
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index c69e609..41d18a6 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1589,6 +1589,7 @@
localtime_rz;
mbsrtowcs_l;
mktime_z;
+ __riscv_flush_icache; # riscv64
timespec_getres;
tzalloc;
tzfree;
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index 4f33777..8c457c8 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -227,11 +227,6 @@
aliases = syscall["aliases"]
for alias in aliases:
stub += "\nALIAS_SYMBOL(%s, %s)\n" % (alias, syscall["func"])
-
- # Use hidden visibility on LP64 for any functions beginning with underscores.
- if pointer_length == 64 and syscall["func"].startswith("__"):
- stub += '.hidden ' + syscall["func"] + '\n'
-
return stub