Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Unified Diff: fusl/arch/sh/src/__set_thread_area.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/arch/sh/src/__fpscr_values.c ('k') | fusl/arch/sh/src/__shcall.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/arch/sh/src/__set_thread_area.c
diff --git a/fusl/arch/sh/src/__set_thread_area.c b/fusl/arch/sh/src/__set_thread_area.c
new file mode 100644
index 0000000000000000000000000000000000000000..1d3e02258b622850b30a62e176d8b150a4596797
--- /dev/null
+++ b/fusl/arch/sh/src/__set_thread_area.c
@@ -0,0 +1,34 @@
+#include "pthread_impl.h"
+#include "libc.h"
+#include "sh_atomic.h"
+#include <elf.h>
+
+/* Also perform sh-specific init */
+
+#define CPU_HAS_LLSC 0x0040
+
+__attribute__((__visibility__("hidden"))) unsigned __sh_atomic_model, __sh_nommu;
+
+int __set_thread_area(void *p)
+{
+ size_t *aux;
+ __asm__ __volatile__ ( "ldc %0, gbr" : : "r"(p) : "memory" );
+#ifndef __SH4A__
+ if (__hwcap & CPU_HAS_LLSC) {
+ __sh_atomic_model = SH_A_LLSC;
+ return 0;
+ }
+#if !defined(__SH3__) && !defined(__SH4__)
+ for (aux=libc.auxv; *aux; aux+=2) {
+ if (*aux != AT_PLATFORM) continue;
+ const char *s = (void *)aux[1];
+ if (s[0]!='s' || s[1]!='h' || s[2]!='2' || s[3]-'0'<10u) break;
+ __sh_atomic_model = SH_A_IMASK;
+ __sh_nommu = 1;
+ return 0;
+ }
+#endif
+ /* __sh_atomic_model = SH_A_GUSA; */ /* 0, default */
+#endif
+ return 0;
+}
« no previous file with comments | « fusl/arch/sh/src/__fpscr_values.c ('k') | fusl/arch/sh/src/__shcall.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698