@@ -263,6 +263,12 @@
runtime_mem_file = runtime/mem_posix_memalign.c
endif
+if LIBGO_IS_RTEMS
+rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
+else
+rtems_task_variable_add_file =
+endif
+
runtime_files = \
runtime/go-bad-index.c \
runtime/go-byte-array-to-string.c \
@@ -351,6 +357,7 @@
runtime/msize.c \
runtime/proc.c \
runtime/thread.c \
+ $(rtems_task_variable_add_file) \
chan.c \
iface.c \
malloc.c \
@@ -10,6 +10,7 @@
#include <pthread.h>
#include "config.h"
+#include "go-panic.h"
#include "go-alloc.h"
#include "runtime.h"
@@ -33,6 +34,11 @@
void (*pfn) (void *);
void *arg;
+#ifdef __rtems__
+ __wrap_rtems_task_variable_add ((void **) &m);
+ __wrap_rtems_task_variable_add ((void **) &__go_panic_defer);
+#endif
+
pfn = pc->pfn;
arg = pc->arg;
m = pc->m;
@@ -6,4 +6,8 @@
#include "go-panic.h"
+#ifdef __rtems__
+#define __thread
+#endif
+
__thread struct __go_panic_defer_struct *__go_panic_defer;
@@ -50,8 +50,16 @@
_Bool __is_foreign;
};
+#ifdef __rtems__
+#define __thread
+#endif
+
extern __thread struct __go_panic_defer_struct *__go_panic_defer;
+#ifdef __rtems__
+#undef __thread
+#endif
+
extern void __go_panic (struct __go_interface *)
__attribute__ ((noreturn));
@@ -9,4 +9,8 @@
M m0;
+#ifdef __rtems__
+#define __thread
+#endif
+
__thread M *m = &m0;
@@ -0,0 +1,21 @@
+/* rtems-task-variable-add.c -- adding a task specific variable in RTEMS OS.
+
+ Copyright 2010 The Go Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style
+ license that can be found in the LICENSE file. */
+
+#include <rtems/error.h>
+#include <rtems/system.h>
+#include <rtems/rtems/tasks.h>
+
+/* RTEMS does not support GNU TLS extension __thread. */
+void
+__wrap_rtems_task_variable_add (void **var)
+{
+ rtems_status_code sc = rtems_task_variable_add (RTEMS_SELF, var, NULL);
+ if (sc != RTEMS_SUCCESSFUL)
+ {
+ rtems_error (sc, "rtems_task_variable_add failed");
+ }
+}
+
@@ -66,8 +66,16 @@
/* Per CPU declarations. */
+#ifdef __rtems__
+#define __thread
+#endif
+
extern __thread M* m;
+#ifdef __rtems__
+#undef __thread
+#endif
+
/* Constants. */
enum
@@ -131,3 +139,7 @@
void addfinalizer(void*, void(*fn)(void*), int32);
#define runtime_mmap mmap
#define cas(pval, old, new) __sync_bool_compare_and_swap (pval, old, new)
+
+#ifdef __rtems__
+void __wrap_rtems_task_variable_add(void **);
+#endif