atomic64.c (dafd95053611aa14dda40266857608d12ddce658) | atomic64.c (d73415a315471ac0b127ed3fad45c8ec5d711de1) |
---|---|
1/* 2 * Copyright (C) 2018, Emilio G. Cota <cota@braap.org> 3 * 4 * License: GNU GPL, version 2 or later. 5 * See the COPYING file in the top-level directory. 6 */ 7#include "qemu/osdep.h" 8#include "qemu/atomic.h" --- 37 unchanged lines hidden (view full) --- 46 type ret; \ 47 \ 48 qemu_spin_lock(lock); \ 49 ret = *ptr; \ 50 qemu_spin_unlock(lock); \ 51 return ret; \ 52 } 53 | 1/* 2 * Copyright (C) 2018, Emilio G. Cota <cota@braap.org> 3 * 4 * License: GNU GPL, version 2 or later. 5 * See the COPYING file in the top-level directory. 6 */ 7#include "qemu/osdep.h" 8#include "qemu/atomic.h" --- 37 unchanged lines hidden (view full) --- 46 type ret; \ 47 \ 48 qemu_spin_lock(lock); \ 49 ret = *ptr; \ 50 qemu_spin_unlock(lock); \ 51 return ret; \ 52 } 53 |
54GEN_READ(atomic_read_i64, int64_t) 55GEN_READ(atomic_read_u64, uint64_t) | 54GEN_READ(qatomic_read_i64, int64_t) 55GEN_READ(qatomic_read_u64, uint64_t) |
56#undef GEN_READ 57 58#define GEN_SET(name, type) \ 59 void name(type *ptr, type val) \ 60 { \ 61 QemuSpin *lock = addr_to_lock(ptr); \ 62 \ 63 qemu_spin_lock(lock); \ 64 *ptr = val; \ 65 qemu_spin_unlock(lock); \ 66 } 67 | 56#undef GEN_READ 57 58#define GEN_SET(name, type) \ 59 void name(type *ptr, type val) \ 60 { \ 61 QemuSpin *lock = addr_to_lock(ptr); \ 62 \ 63 qemu_spin_lock(lock); \ 64 *ptr = val; \ 65 qemu_spin_unlock(lock); \ 66 } 67 |
68GEN_SET(atomic_set_i64, int64_t) 69GEN_SET(atomic_set_u64, uint64_t) | 68GEN_SET(qatomic_set_i64, int64_t) 69GEN_SET(qatomic_set_u64, uint64_t) |
70#undef GEN_SET 71 | 70#undef GEN_SET 71 |
72void atomic64_init(void) | 72void qatomic64_init(void) |
73{ 74 int i; 75 76 lock_size = ROUND_UP(sizeof(QemuSpin), qemu_dcache_linesize); 77 lock_array = qemu_memalign(qemu_dcache_linesize, lock_size * NR_LOCKS); 78 for (i = 0; i < NR_LOCKS; i++) { 79 QemuSpin *lock = lock_array + i * lock_size; 80 81 qemu_spin_init(lock); 82 } 83} | 73{ 74 int i; 75 76 lock_size = ROUND_UP(sizeof(QemuSpin), qemu_dcache_linesize); 77 lock_array = qemu_memalign(qemu_dcache_linesize, lock_size * NR_LOCKS); 78 for (i = 0; i < NR_LOCKS; i++) { 79 QemuSpin *lock = lock_array + i * lock_size; 80 81 qemu_spin_init(lock); 82 } 83} |