Changeset 7137f74c in mainline
- Timestamp:
- 2018-07-19T21:02:13Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 514d561
- Parents:
- 5a50430
- Location:
- uspace/lib
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r5a50430 r7137f74c 51 51 generic/libc.c \ 52 52 generic/ddi.c \ 53 generic/atomic.c \ 53 54 generic/as.c \ 54 55 generic/bd.c \ -
uspace/lib/c/arch/arm32/include/libarch/atomic.h
r5a50430 r7137f74c 52 52 /* 53 53 * The following instructions between labels 1 and 2 constitute a 54 * Restartable Atomic Seq eunce. Should the sequence be non-atomic,54 * Restartable Atomic Sequence. Should the sequence be non-atomic, 55 55 * the kernel will restart it. 56 56 */ -
uspace/lib/c/generic/atomic.c
r5a50430 r7137f74c 1 1 /* 2 * Copyright (c) 2018 Jaroslav Jindrak2 * Copyright (c) 2018 CZ.NIC, z.s.p.o. 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** 30 * This file contains glue code that makes different 31 * architectures pass. 32 */ 29 #include <atomic.h> 33 30 34 31 #ifdef PLATFORM_arm32 35 32 36 /** 37 * ARM32 does not have GCC atomic operations inlined by 38 * the compiler, so we need to define stubs for our library 39 * to compile on this architecture. 40 * TODO: make this synchronized 33 /* 34 * Older ARMs don't have atomic instructions, so we need to define a bunch 35 * of symbols for GCC to use. 41 36 */ 42 extern "C" 37 38 unsigned __sync_add_and_fetch_4(volatile void *vptr, unsigned val) 43 39 { 44 #define LIBCPP_GLUE_OP_AND_FETCH(NAME, OP, TYPE, SIZE) \ 45 TYPE __sync_##NAME##_and_fetch_##SIZE (volatile void* vptr, TYPE val) \ 46 { \ 47 TYPE* ptr = (TYPE*)vptr; \ 48 *ptr = *ptr OP val; \ 49 return *ptr; \ 50 } 40 return atomic_add((atomic_t *)vptr, val); 41 } 51 42 52 LIBCPP_GLUE_OP_AND_FETCH(add, +, unsigned, 4) 53 LIBCPP_GLUE_OP_AND_FETCH(sub, -, unsigned, 4) 43 unsigned __sync_sub_and_fetch_4(volatile void *vptr, unsigned val) 44 { 45 return atomic_add((atomic_t *)vptr, -(atomic_signed_t)val); 46 } 54 47 55 #define LIBCPP_GLUE_CMP_AND_SWAP(TYPE, SIZE) \ 56 TYPE __sync_val_compare_and_swap_##SIZE (TYPE* ptr, TYPE old_val, TYPE new_val) \ 57 { \ 58 if (*ptr == old_val) \ 59 *ptr = new_val; \ 60 return *ptr; \ 61 } 48 bool __sync_bool_compare_and_swap_4(volatile void *ptr, unsigned old_val, unsigned new_val) 49 { 50 return cas((atomic_t *)ptr, old_val, new_val); 51 } 62 52 63 LIBCPP_GLUE_CMP_AND_SWAP(unsigned, 4) 53 unsigned __sync_val_compare_and_swap_4(volatile void *ptr, unsigned old_val, unsigned new_val) 54 { 55 while (true) { 56 if (__sync_bool_compare_and_swap_4(ptr, old_val, new_val)) { 57 return old_val; 58 } 59 60 unsigned current = *(volatile unsigned *)ptr; 61 if (current != old_val) 62 return current; 63 64 /* If the current value is the same as old_val, retry. */ 65 } 64 66 } 67 65 68 #endif -
uspace/lib/cpp/Makefile
r5a50430 r7137f74c 53 53 src/typeindex.cpp \ 54 54 src/typeinfo.cpp \ 55 src/__bits/glue.cpp \56 55 src/__bits/runtime.cpp \ 57 56 src/__bits/trycatch.cpp \
Note:
See TracChangeset
for help on using the changeset viewer.