From 2fcffe26e815b7125a357c83b59617ab93c16b41 Mon Sep 17 00:00:00 2001 From: Guo Ren Date: Sun, 15 Oct 2017 20:59:34 +0800 Subject: csky: port to uclibc-ng Follow the steps to build c-sky uclibc linux system: 1. git clone https://github.com/c-sky/buildroot.git 2. cd buildroot 3. make qemu_csky_ck810_uclibc_defconfig 4. make Follow the buildroot/board/qemu/csky/readme.txt to run. This buildroot toolchain is pre-build, But you can rebuild the c-sky uclibc-ng alone and install it to the buildroot sysroot manually. We'll try our best to improve the uclibc-ng continuously. Signed-off-by: Guo Ren --- libc/sysdeps/linux/csky/bits/atomic.h | 93 +++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 libc/sysdeps/linux/csky/bits/atomic.h (limited to 'libc/sysdeps/linux/csky/bits/atomic.h') diff --git a/libc/sysdeps/linux/csky/bits/atomic.h b/libc/sysdeps/linux/csky/bits/atomic.h new file mode 100644 index 000000000..231d58f30 --- /dev/null +++ b/libc/sysdeps/linux/csky/bits/atomic.h @@ -0,0 +1,93 @@ +#ifndef __CSKY_ATOMIC_H_ +#define __CSKY_ATOMIC_H_ + +#include +#include + +typedef int8_t atomic8_t; +typedef uint8_t uatomic8_t; +typedef int_fast8_t atomic_fast8_t; +typedef uint_fast8_t uatomic_fast8_t; + +typedef int16_t atomic16_t; +typedef uint16_t uatomic16_t; +typedef int_fast16_t atomic_fast16_t; +typedef uint_fast16_t uatomic_fast16_t; + +typedef int32_t atomic32_t; +typedef uint32_t uatomic32_t; +typedef int_fast32_t atomic_fast32_t; +typedef uint_fast32_t uatomic_fast32_t; + +typedef int64_t atomic64_t; +typedef uint64_t uatomic64_t; +typedef int_fast64_t atomic_fast64_t; +typedef uint_fast64_t uatomic_fast64_t; + +typedef intptr_t atomicptr_t; +typedef uintptr_t uatomicptr_t; +typedef intmax_t atomic_max_t; +typedef uintmax_t uatomic_max_t; + +# define __arch_compare_and_exchange_bool_8_int(mem, newval, oldval) \ + (abort (), 0) + +# define __arch_compare_and_exchange_bool_16_int(mem, newval, oldval) \ + (abort (), 0) + +# define __arch_compare_and_exchange_bool_32_int(mem, newval, oldval) \ + ({ __typeof(mem) _mem = (mem); \ + __typeof(oldval) _oldval = oldval; \ + __typeof(newval) _newval = newval; \ + register __typeof(oldval) _a0 __asm__ ("a0") = _oldval; \ + register __typeof(newval) _a1 __asm__ ("a1") = _newval; \ + register __typeof(mem) _a2 __asm__ ("a2") = _mem; \ + __asm__ __volatile__ ("trap 2;" \ + : "+r" (_a0) : "r" (_a1) , "r" (_a2) \ + : "a3", "memory"); \ + _a0; }) + +# define __arch_compare_and_exchange_bool_64_int(mem, newval, oldval) \ + (abort (), 0) + +#define __arch_compare_and_exchange_val_8_int(mem, newval, oldval) \ + (abort (), 0) + +#define __arch_compare_and_exchange_val_16_int(mem, newval, oldval) \ + (abort (), 0) + +#define __arch_compare_and_exchange_val_32_int(mem, newval, oldval) \ + ({ __typeof (mem) _mem = (mem); \ + __typeof (*mem) __gret = *_mem; \ + unsigned int _tmp = 0; \ + __typeof (oldval) _oldval = oldval; \ + __typeof (newval) _newval = newval; \ + register __typeof (oldval) _a0 __asm__ ("a0") = _oldval; \ + register __typeof (newval) _a1 __asm__ ("a1") = _newval; \ + register __typeof (mem) _a2 __asm__ ("a2") = _mem; \ + __asm__ __volatile__ ("1:\n\t" \ + "ldw %1, (%4, 0x0)\n\t" \ + "cmpne %1, %0\n\t" \ + "bt 2f\n\t" \ + "mov %2, %0\n\t" \ + "trap 2\n\t" \ + "cmpnei %0, 0\n\t" \ + "mov %0, %2\n\t" \ + "bt 1b\n\t" \ + "2: \n\t" \ + :"+r" (_a0), "+r"(__gret), "+r" (_tmp) :"r" (_a1) , "r" (_a2) \ + : "a3", "memory"); \ + __gret; }) + +# define __arch_compare_and_exchange_val_64_int(mem, newval, oldval) \ + (abort (), 0) + +# define atomic_compare_and_exchange_bool_acq(mem, new, old) \ + __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \ + mem, new, old) + +# define atomic_compare_and_exchange_val_acq(mem, new, old) \ + __atomic_val_bysize (__arch_compare_and_exchange_val, int, \ + mem, new, old) + +#endif -- cgit v1.2.3