| rculfqueue.h | | rculfqueue.h | |
| | | | |
| skipping to change at line 26 | | skipping to change at line 26 | |
| * This library is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * Lesser General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
| * You should have received a copy of the GNU Lesser General Public | | * You should have received a copy of the GNU Lesser General Public | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| */ | | */ | |
| | | | |
|
| #include <urcu/urcu_ref.h> | | #include <urcu/ref.h> | |
| #include <assert.h> | | #include <assert.h> | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /* | | /* | |
| * Lock-free RCU queue using reference counting. Enqueue and dequeue operat
ions | | * Lock-free RCU queue using reference counting. Enqueue and dequeue operat
ions | |
| * hold a RCU read lock to deal with cmpxchg ABA problem. This implementati
on | | * hold a RCU read lock to deal with cmpxchg ABA problem. This implementati
on | |
| * keeps a dummy head node to ensure we can always update the queue lockles
sly. | | * keeps a dummy head node to ensure we can always update the queue lockles
sly. | |
| * Given that this is a queue, the dummy head node must always advance as w
e | | * Given that this is a queue, the dummy head node must always advance as w
e | |
| * dequeue entries. Therefore, we keep a reference count on each entry we a
re | | * dequeue entries. Therefore, we keep a reference count on each entry we a
re | |
| * dequeueing, so they can be kept as dummy head node until the next dequeu
e, at | | * dequeueing, so they can be kept as dummy head node until the next dequeu
e, at | |
| * which point their reference count will be decremented. | | * which point their reference count will be decremented. | |
| */ | | */ | |
| | | | |
|
| | | struct cds_lfq_queue_rcu; | |
| | | | |
| struct cds_lfq_node_rcu { | | struct cds_lfq_node_rcu { | |
| struct cds_lfq_node_rcu *next; | | struct cds_lfq_node_rcu *next; | |
| struct urcu_ref ref; | | struct urcu_ref ref; | |
|
| | | struct cds_lfq_queue_rcu *queue; | |
| | | struct rcu_head rcu_head; | |
| }; | | }; | |
| | | | |
| struct cds_lfq_queue_rcu { | | struct cds_lfq_queue_rcu { | |
| struct cds_lfq_node_rcu *head, *tail; | | struct cds_lfq_node_rcu *head, *tail; | |
| struct cds_lfq_node_rcu init; /* Dummy initialization node */ | | struct cds_lfq_node_rcu init; /* Dummy initialization node */ | |
|
| | | void (*release)(struct urcu_ref *ref); | |
| }; | | }; | |
| | | | |
| #ifdef _LGPL_SOURCE | | #ifdef _LGPL_SOURCE | |
| | | | |
|
| #include <urcu/rculfqueue-static.h> | | #include <urcu/static/rculfqueue.h> | |
| | | | |
|
| #define cds_lfq_node_init_rcu _cds_lfq_node_init_rcu | | #define cds_lfq_node_init_rcu _cds_lfq_node_init_rcu | |
| #define cds_lfq_init_rcu _cds_lfq_init_rcu | | #define cds_lfq_init_rcu _cds_lfq_init_rcu | |
| #define cds_lfq_enqueue_rcu _cds_lfq_enqueue_rcu | | #define cds_lfq_enqueue_rcu _cds_lfq_enqueue_rcu | |
| #define cds_lfq_dequeue_rcu _cds_lfq_dequeue_rcu | | #define cds_lfq_dequeue_rcu _cds_lfq_dequeue_rcu | |
| | | | |
| #else /* !_LGPL_SOURCE */ | | #else /* !_LGPL_SOURCE */ | |
| | | | |
| extern void cds_lfq_node_init_rcu(struct cds_lfq_node_rcu *node); | | extern void cds_lfq_node_init_rcu(struct cds_lfq_node_rcu *node); | |
|
| extern void cds_lfq_init_rcu(struct cds_lfq_queue_rcu *q); | | extern void cds_lfq_init_rcu(struct cds_lfq_queue_rcu *q, | |
| extern void cds_lfq_enqueue_rcu(struct cds_lfq_queue_rcu *q, struct cds_lfq | | void (*release)(struct urcu_ref *ref)); | |
| _node_rcu *node); | | | |
| | | /* | |
| | | * Should be called under rcu read lock critical section. | |
| | | */ | |
| | | extern void cds_lfq_enqueue_rcu(struct cds_lfq_queue_rcu *q, | |
| | | struct cds_lfq_node_rcu *node); | |
| | | | |
| /* | | /* | |
|
| * The entry returned by dequeue must be taken care of by doing a urcu_ref_ | | * Should be called under rcu read lock critical section. | |
| put, | | * | |
| * which calls the release primitive when the reference count drops to zero | | * The entry returned by dequeue must be taken care of by doing a | |
| . A | | * sequence of urcu_ref_put which release handler should do a call_rcu. | |
| * grace period must be waited after execution of the release callback befo | | * | |
| re | | | |
| * performing the actual memory reclamation or modifying the cds_lfq_node_r | | | |
| cu | | | |
| * structure. | | | |
| * In other words, the entry lfq node returned by dequeue must not be | | * In other words, the entry lfq node returned by dequeue must not be | |
| * modified/re-used/freed until the reference count reaches zero and a grac
e | | * modified/re-used/freed until the reference count reaches zero and a grac
e | |
| * period has elapsed (after the refcount reached 0). | | * period has elapsed (after the refcount reached 0). | |
| */ | | */ | |
|
| extern struct cds_lfq_node_rcu * | | extern | |
| cds_lfq_dequeue_rcu(struct cds_lfq_queue_rcu *q, void (*release)(struct urc | | struct cds_lfq_node_rcu *cds_lfq_dequeue_rcu(struct cds_lfq_queue_rcu *q); | |
| u_ref *)); | | | |
| | | | |
| #endif /* !_LGPL_SOURCE */ | | #endif /* !_LGPL_SOURCE */ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* _URCU_RCULFQUEUE_H */ | | #endif /* _URCU_RCULFQUEUE_H */ | |
| | | | |
End of changes. 9 change blocks. |
| 18 lines changed or deleted | | 23 lines changed or added | |
|
| rculfstack.h | | rculfstack.h | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 40 | |
| struct cds_lfs_node_rcu { | | struct cds_lfs_node_rcu { | |
| struct cds_lfs_node_rcu *next; | | struct cds_lfs_node_rcu *next; | |
| }; | | }; | |
| | | | |
| struct cds_lfs_stack_rcu { | | struct cds_lfs_stack_rcu { | |
| struct cds_lfs_node_rcu *head; | | struct cds_lfs_node_rcu *head; | |
| }; | | }; | |
| | | | |
| #ifdef _LGPL_SOURCE | | #ifdef _LGPL_SOURCE | |
| | | | |
|
| #include <urcu/rculfstack-static.h> | | #include <urcu/static/rculfstack.h> | |
| | | | |
| #define cds_lfs_node_init_rcu _cds_lfs_node_init_rcu | | #define cds_lfs_node_init_rcu _cds_lfs_node_init_rcu | |
| #define cds_lfs_init_rcu _cds_lfs_init_rcu | | #define cds_lfs_init_rcu _cds_lfs_init_rcu | |
| #define cds_lfs_push_rcu _cds_lfs_push_rcu | | #define cds_lfs_push_rcu _cds_lfs_push_rcu | |
| #define cds_lfs_pop_rcu _cds_lfs_pop_rcu | | #define cds_lfs_pop_rcu _cds_lfs_pop_rcu | |
| | | | |
| #else /* !_LGPL_SOURCE */ | | #else /* !_LGPL_SOURCE */ | |
| | | | |
| extern void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node); | | extern void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node); | |
| extern void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s); | | extern void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s); | |
| extern void cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, struct cds_lfs_no
de_rcu *node); | | extern void cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, struct cds_lfs_no
de_rcu *node); | |
| | | | |
| /* | | /* | |
|
| | | * Should be called under rcu read lock critical section. | |
| | | * | |
| * The caller must wait for a grace period to pass before freeing the retur
ned | | * The caller must wait for a grace period to pass before freeing the retur
ned | |
| * node or modifying the cds_lfs_node_rcu structure. | | * node or modifying the cds_lfs_node_rcu structure. | |
| * Returns NULL if stack is empty. | | * Returns NULL if stack is empty. | |
| */ | | */ | |
| extern struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s
); | | extern struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s
); | |
| | | | |
| #endif /* !_LGPL_SOURCE */ | | #endif /* !_LGPL_SOURCE */ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 3 lines changed or added | |
|
| uatomic_arch.h | | uatomic_arch.h | |
|
| #ifndef _URCU_ARCH_UATOMIC_X86_H | | #warning "urcu/uatomic_arch.h is deprecated. Please include urcu/uatomic.h | |
| #define _URCU_ARCH_UATOMIC_X86_H | | instead." | |
| | | #include <urcu/uatomic.h> | |
| /* | | | |
| * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. | | | |
| * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. | | | |
| * Copyright (c) 1999-2004 Hewlett-Packard Development Company, L.P. | | | |
| * Copyright (c) 2009 Mathieu Desnoyers | | | |
| * | | | |
| * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED | | | |
| * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | | | |
| * | | | |
| * Permission is hereby granted to use or copy this program | | | |
| * for any purpose, provided the above notices are retained on all copies. | | | |
| * Permission to modify the code and to distribute modified code is granted | | | |
| , | | | |
| * provided the above notices are retained, and a notice that the code was | | | |
| * modified is included with the above copyright notice. | | | |
| * | | | |
| * Code inspired from libuatomic_ops-1.2, inherited in part from the | | | |
| * Boehm-Demers-Weiser conservative garbage collector. | | | |
| */ | | | |
| | | | |
| #include <urcu/compiler.h> | | | |
| #include <urcu/system.h> | | | |
| | | | |
| #define UATOMIC_HAS_ATOMIC_BYTE | | | |
| #define UATOMIC_HAS_ATOMIC_SHORT | | | |
| | | | |
| #ifdef __cplusplus | | | |
| extern "C" { | | | |
| #endif | | | |
| | | | |
| /* | | | |
| * Derived from AO_compare_and_swap() and AO_test_and_set_full(). | | | |
| */ | | | |
| | | | |
| struct __uatomic_dummy { | | | |
| unsigned long v[10]; | | | |
| }; | | | |
| #define __hp(x) ((struct __uatomic_dummy *)(x)) | | | |
| | | | |
| #define _uatomic_set(addr, v) CMM_STORE_SHARED(*(addr), (v)) | | | |
| | | | |
| /* cmpxchg */ | | | |
| | | | |
| static inline __attribute__((always_inline)) | | | |
| unsigned long __uatomic_cmpxchg(void *addr, unsigned long old, | | | |
| unsigned long _new, int len) | | | |
| { | | | |
| switch (len) { | | | |
| case 1: | | | |
| { | | | |
| unsigned char result = old; | | | |
| | | | |
| __asm__ __volatile__( | | | |
| "lock; cmpxchgb %2, %1" | | | |
| : "+a"(result), "+m"(*__hp(addr)) | | | |
| : "q"((unsigned char)_new) | | | |
| : "memory"); | | | |
| return result; | | | |
| } | | | |
| case 2: | | | |
| { | | | |
| unsigned short result = old; | | | |
| | | | |
| __asm__ __volatile__( | | | |
| "lock; cmpxchgw %2, %1" | | | |
| : "+a"(result), "+m"(*__hp(addr)) | | | |
| : "r"((unsigned short)_new) | | | |
| : "memory"); | | | |
| return result; | | | |
| } | | | |
| case 4: | | | |
| { | | | |
| unsigned int result = old; | | | |
| | | | |
| __asm__ __volatile__( | | | |
| "lock; cmpxchgl %2, %1" | | | |
| : "+a"(result), "+m"(*__hp(addr)) | | | |
| : "r"((unsigned int)_new) | | | |
| : "memory"); | | | |
| return result; | | | |
| } | | | |
| #if (CAA_BITS_PER_LONG == 64) | | | |
| case 8: | | | |
| { | | | |
| unsigned long result = old; | | | |
| | | | |
| __asm__ __volatile__( | | | |
| "lock; cmpxchgq %2, %1" | | | |
| : "+a"(result), "+m"(*__hp(addr)) | | | |
| : "r"((unsigned long)_new) | | | |
| : "memory"); | | | |
| return result; | | | |
| } | | | |
| #endif | | | |
| } | | | |
| /* generate an illegal instruction. Cannot catch this with linker tr | | | |
| icks | | | |
| * when optimizations are disabled. */ | | | |
| __asm__ __volatile__("ud2"); | | | |
| return 0; | | | |
| } | | | |
| | | | |
| #define _uatomic_cmpxchg(addr, old, _new) | | | |
| \ | | | |
| ((__typeof__(*(addr))) __uatomic_cmpxchg((addr), (unsigned long)(old | | | |
| ),\ | | | |
| (unsigned long)(_new), | | | |
| \ | | | |
| sizeof(*(addr)))) | | | |
| | | | |
| /* xchg */ | | | |
| | | | |
| static inline __attribute__((always_inline)) | | | |
| unsigned long __uatomic_exchange(void *addr, unsigned long val, int len) | | | |
| { | | | |
| /* Note: the "xchg" instruction does not need a "lock" prefix. */ | | | |
| switch (len) { | | | |
| case 1: | | | |
| { | | | |
| unsigned char result; | | | |
| __asm__ __volatile__( | | | |
| "xchgb %0, %1" | | | |
| : "=q"(result), "+m"(*__hp(addr)) | | | |
| : "0" ((unsigned char)val) | | | |
| : "memory"); | | | |
| return result; | | | |
| } | | | |
| case 2: | | | |
| { | | | |
| unsigned short result; | | | |
| __asm__ __volatile__( | | | |
| "xchgw %0, %1" | | | |
| : "=r"(result), "+m"(*__hp(addr)) | | | |
| : "0" ((unsigned short)val) | | | |
| : "memory"); | | | |
| return result; | | | |
| } | | | |
| case 4: | | | |
| { | | | |
| unsigned int result; | | | |
| __asm__ __volatile__( | | | |
| "xchgl %0, %1" | | | |
| : "=r"(result), "+m"(*__hp(addr)) | | | |
| : "0" ((unsigned int)val) | | | |
| : "memory"); | | | |
| return result; | | | |
| } | | | |
| #if (CAA_BITS_PER_LONG == 64) | | | |
| case 8: | | | |
| { | | | |
| unsigned long result; | | | |
| __asm__ __volatile__( | | | |
| "xchgq %0, %1" | | | |
| : "=r"(result), "+m"(*__hp(addr)) | | | |
| : "0" ((unsigned long)val) | | | |
| : "memory"); | | | |
| return result; | | | |
| } | | | |
| #endif | | | |
| } | | | |
| /* generate an illegal instruction. Cannot catch this with linker tr | | | |
| icks | | | |
| * when optimizations are disabled. */ | | | |
| __asm__ __volatile__("ud2"); | | | |
| return 0; | | | |
| } | | | |
| | | | |
| #define _uatomic_xchg(addr, v) | | | |
| \ | | | |
| ((__typeof__(*(addr))) __uatomic_exchange((addr), (unsigned long)(v) | | | |
| , \ | | | |
| sizeof(*(addr)))) | | | |
| | | | |
| /* uatomic_add_return */ | | | |
| | | | |
| static inline __attribute__((always_inline)) | | | |
| unsigned long __uatomic_add_return(void *addr, unsigned long val, | | | |
| int len) | | | |
| { | | | |
| switch (len) { | | | |
| case 1: | | | |
| { | | | |
| unsigned char result = val; | | | |
| | | | |
| __asm__ __volatile__( | | | |
| "lock; xaddb %1, %0" | | | |
| : "+m"(*__hp(addr)), "+q" (result) | | | |
| : | | | |
| : "memory"); | | | |
| return result + (unsigned char)val; | | | |
| } | | | |
| case 2: | | | |
| { | | | |
| unsigned short result = val; | | | |
| | | | |
| __asm__ __volatile__( | | | |
| "lock; xaddw %1, %0" | | | |
| : "+m"(*__hp(addr)), "+r" (result) | | | |
| : | | | |
| : "memory"); | | | |
| return result + (unsigned short)val; | | | |
| } | | | |
| case 4: | | | |
| { | | | |
| unsigned int result = val; | | | |
| | | | |
| __asm__ __volatile__( | | | |
| "lock; xaddl %1, %0" | | | |
| : "+m"(*__hp(addr)), "+r" (result) | | | |
| : | | | |
| : "memory"); | | | |
| return result + (unsigned int)val; | | | |
| } | | | |
| #if (CAA_BITS_PER_LONG == 64) | | | |
| case 8: | | | |
| { | | | |
| unsigned long result = val; | | | |
| | | | |
| __asm__ __volatile__( | | | |
| "lock; xaddq %1, %0" | | | |
| : "+m"(*__hp(addr)), "+r" (result) | | | |
| : | | | |
| : "memory"); | | | |
| return result + (unsigned long)val; | | | |
| } | | | |
| #endif | | | |
| } | | | |
| /* generate an illegal instruction. Cannot catch this with linker tr | | | |
| icks | | | |
| * when optimizations are disabled. */ | | | |
| __asm__ __volatile__("ud2"); | | | |
| return 0; | | | |
| } | | | |
| | | | |
| #define _uatomic_add_return(addr, v) \ | | | |
| ((__typeof__(*(addr))) __uatomic_add_return((addr), \ | | | |
| (unsigned long)(v), \ | | | |
| sizeof(*(addr)))) | | | |
| | | | |
| /* uatomic_add */ | | | |
| | | | |
| static inline __attribute__((always_inline)) | | | |
| void __uatomic_add(void *addr, unsigned long val, int len) | | | |
| { | | | |
| switch (len) { | | | |
| case 1: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; addb %1, %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : "iq" ((unsigned char)val) | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| case 2: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; addw %1, %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : "ir" ((unsigned short)val) | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| case 4: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; addl %1, %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : "ir" ((unsigned int)val) | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| #if (CAA_BITS_PER_LONG == 64) | | | |
| case 8: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; addq %1, %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : "er" ((unsigned long)val) | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| #endif | | | |
| } | | | |
| /* generate an illegal instruction. Cannot catch this with linker tr | | | |
| icks | | | |
| * when optimizations are disabled. */ | | | |
| __asm__ __volatile__("ud2"); | | | |
| return; | | | |
| } | | | |
| | | | |
| #define _uatomic_add(addr, v) \ | | | |
| (__uatomic_add((addr), (unsigned long)(v), sizeof(*(addr)))) | | | |
| | | | |
| /* uatomic_inc */ | | | |
| | | | |
| static inline __attribute__((always_inline)) | | | |
| void __uatomic_inc(void *addr, int len) | | | |
| { | | | |
| switch (len) { | | | |
| case 1: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; incb %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| case 2: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; incw %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| case 4: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; incl %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| #if (CAA_BITS_PER_LONG == 64) | | | |
| case 8: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; incq %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| #endif | | | |
| } | | | |
| /* generate an illegal instruction. Cannot catch this with linker tr | | | |
| icks | | | |
| * when optimizations are disabled. */ | | | |
| __asm__ __volatile__("ud2"); | | | |
| return; | | | |
| } | | | |
| | | | |
| #define _uatomic_inc(addr) (__uatomic_inc((addr), sizeof(*(addr)))) | | | |
| | | | |
| /* uatomic_dec */ | | | |
| | | | |
| static inline __attribute__((always_inline)) | | | |
| void __uatomic_dec(void *addr, int len) | | | |
| { | | | |
| switch (len) { | | | |
| case 1: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; decb %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| case 2: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; decw %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| case 4: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; decl %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| #if (CAA_BITS_PER_LONG == 64) | | | |
| case 8: | | | |
| { | | | |
| __asm__ __volatile__( | | | |
| "lock; decq %0" | | | |
| : "=m"(*__hp(addr)) | | | |
| : | | | |
| : "memory"); | | | |
| return; | | | |
| } | | | |
| #endif | | | |
| } | | | |
| /* generate an illegal instruction. Cannot catch this with linker tr | | | |
| icks | | | |
| * when optimizations are disabled. */ | | | |
| __asm__ __volatile__("ud2"); | | | |
| return; | | | |
| } | | | |
| | | | |
| #define _uatomic_dec(addr) (__uatomic_dec((addr), sizeof(*(addr)))) | | | |
| | | | |
| #if ((CAA_BITS_PER_LONG != 64) && defined(CONFIG_RCU_COMPAT_ARCH)) | | | |
| extern int __rcu_cas_avail; | | | |
| extern int __rcu_cas_init(void); | | | |
| | | | |
| #define UATOMIC_COMPAT(insn) | | | |
| \ | | | |
| ((likely(__rcu_cas_avail > 0)) | | | |
| \ | | | |
| ? (_uatomic_##insn) | | | |
| \ | | | |
| : ((unlikely(__rcu_cas_avail < 0) | | | |
| \ | | | |
| ? ((__rcu_cas_init() > 0) | | | |
| \ | | | |
| ? (_uatomic_##insn) | | | |
| \ | | | |
| : (compat_uatomic_##insn)) | | | |
| \ | | | |
| : (compat_uatomic_##insn)))) | | | |
| | | | |
| extern unsigned long _compat_uatomic_set(void *addr, | | | |
| unsigned long _new, int len); | | | |
| #define compat_uatomic_set(addr, _new) | | | |
| \ | | | |
| ((__typeof__(*(addr))) _compat_uatomic_set((addr), | | | |
| \ | | | |
| (unsigned long)(_new), | | | |
| \ | | | |
| sizeof(*(addr)))) | | | |
| | | | |
| extern unsigned long _compat_uatomic_xchg(void *addr, | | | |
| unsigned long _new, int len); | | | |
| #define compat_uatomic_xchg(addr, _new) | | | |
| \ | | | |
| ((__typeof__(*(addr))) _compat_uatomic_xchg((addr), | | | |
| \ | | | |
| (unsigned long)(_new), | | | |
| \ | | | |
| sizeof(*(addr)))) | | | |
| | | | |
| extern unsigned long _compat_uatomic_cmpxchg(void *addr, unsigned long old, | | | |
| unsigned long _new, int len); | | | |
| #define compat_uatomic_cmpxchg(addr, old, _new) | | | |
| \ | | | |
| ((__typeof__(*(addr))) _compat_uatomic_cmpxchg((addr), | | | |
| \ | | | |
| (unsigned long)(old), | | | |
| \ | | | |
| (unsigned long)(_new), | | | |
| \ | | | |
| sizeof(*(addr)))) | | | |
| | | | |
| extern unsigned long _compat_uatomic_xchg(void *addr, | | | |
| unsigned long _new, int len); | | | |
| #define compat_uatomic_add_return(addr, v) | | | |
| \ | | | |
| ((__typeof__(*(addr))) _compat_uatomic_add_return((addr), | | | |
| \ | | | |
| (unsigned long)(v), | | | |
| \ | | | |
| sizeof(*(addr)))) | | | |
| | | | |
| #define compat_uatomic_add(addr, v) | | | |
| \ | | | |
| ((void)compat_uatomic_add_return((addr), (v))) | | | |
| #define compat_uatomic_inc(addr) | | | |
| \ | | | |
| (compat_uatomic_add((addr), 1)) | | | |
| #define compat_uatomic_dec(addr) | | | |
| \ | | | |
| (compat_uatomic_add((addr), -1)) | | | |
| | | | |
| #else | | | |
| #define UATOMIC_COMPAT(insn) (_uatomic_##insn) | | | |
| #endif | | | |
| | | | |
| /* Read is atomic even in compat mode */ | | | |
| #define uatomic_set(addr, v) \ | | | |
| UATOMIC_COMPAT(set(addr, v)) | | | |
| | | | |
| #define uatomic_cmpxchg(addr, old, _new) \ | | | |
| UATOMIC_COMPAT(cmpxchg(addr, old, _new)) | | | |
| #define uatomic_xchg(addr, v) \ | | | |
| UATOMIC_COMPAT(xchg(addr, v)) | | | |
| #define uatomic_add_return(addr, v) \ | | | |
| UATOMIC_COMPAT(add_return(addr, v)) | | | |
| | | | |
| #define uatomic_add(addr, v) UATOMIC_COMPAT(add(addr, v)) | | | |
| #define uatomic_inc(addr) UATOMIC_COMPAT(inc(addr)) | | | |
| #define uatomic_dec(addr) UATOMIC_COMPAT(dec(addr)) | | | |
| | | | |
| #ifdef __cplusplus | | | |
| } | | | |
| #endif | | | |
| | | | |
| #include <urcu/uatomic_generic.h> | | | |
| | | | |
| #endif /* _URCU_ARCH_UATOMIC_X86_H */ | | | |
| | | | |
End of changes. 1 change blocks. |
| lines changed or deleted | | lines changed or added | |
|
| urcu-bp.h | | urcu-bp.h | |
| | | | |
| skipping to change at line 41 | | skipping to change at line 41 | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| * | | * | |
| * IBM's contributions to this file may be relicensed under LGPLv2 or later
. | | * IBM's contributions to this file may be relicensed under LGPLv2 or later
. | |
| */ | | */ | |
| | | | |
| #include <stdlib.h> | | #include <stdlib.h> | |
| #include <pthread.h> | | #include <pthread.h> | |
| | | | |
| /* | | /* | |
|
| * See urcu-pointer.h and urcu-pointer-static.h for pointer publication hea | | * See urcu-pointer.h and urcu/static/urcu-pointer.h for pointer | |
| ders. | | * publication headers. | |
| */ | | */ | |
| #include <urcu-pointer.h> | | #include <urcu-pointer.h> | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| | | #include <urcu/map/urcu-bp.h> | |
| | | | |
| /* | | /* | |
| * Important ! | | * Important ! | |
| * | | * | |
| * Each thread containing read-side critical sections must be registered | | * Each thread containing read-side critical sections must be registered | |
| * with rcu_register_thread() before calling rcu_read_lock(). | | * with rcu_register_thread() before calling rcu_read_lock(). | |
| * rcu_unregister_thread() should be called before the thread exits. | | * rcu_unregister_thread() should be called before the thread exits. | |
| */ | | */ | |
| | | | |
| #ifdef _LGPL_SOURCE | | #ifdef _LGPL_SOURCE | |
| | | | |
|
| #include <urcu-bp-static.h> | | #include <urcu/static/urcu-bp.h> | |
| | | | |
| /* | | /* | |
| * Mappings for static use of the userspace RCU library. | | * Mappings for static use of the userspace RCU library. | |
| * Should only be used in LGPL-compatible code. | | * Should only be used in LGPL-compatible code. | |
| */ | | */ | |
| | | | |
| /* | | /* | |
| * rcu_read_lock() | | * rcu_read_lock() | |
| * rcu_read_unlock() | | * rcu_read_unlock() | |
| * | | * | |
| * Mark the beginning and end of a read-side critical section. | | * Mark the beginning and end of a read-side critical section. | |
| */ | | */ | |
|
| #define rcu_read_lock() _rcu_read_lock() | | #define rcu_read_lock_bp _rcu_read_lock | |
| #define rcu_read_unlock() _rcu_read_unlock() | | #define rcu_read_unlock_bp _rcu_read_unlock | |
| | | | |
| #else /* !_LGPL_SOURCE */ | | #else /* !_LGPL_SOURCE */ | |
| | | | |
| /* | | /* | |
| * library wrappers to be used by non-LGPL compatible source code. | | * library wrappers to be used by non-LGPL compatible source code. | |
|
| * See LGPL-only urcu-pointer-static.h for documentation. | | * See LGPL-only urcu/static/urcu-pointer.h for documentation. | |
| */ | | */ | |
| | | | |
| extern void rcu_read_lock(void); | | extern void rcu_read_lock(void); | |
| extern void rcu_read_unlock(void); | | extern void rcu_read_unlock(void); | |
| | | | |
| #endif /* !_LGPL_SOURCE */ | | #endif /* !_LGPL_SOURCE */ | |
| | | | |
| extern void synchronize_rcu(void); | | extern void synchronize_rcu(void); | |
| | | | |
| /* | | /* | |
| | | | |
| skipping to change at line 118 | | skipping to change at line 121 | |
| } | | } | |
| | | | |
| static inline void rcu_init(void) | | static inline void rcu_init(void) | |
| { | | { | |
| } | | } | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
|
| | | #include <urcu-call-rcu.h> | |
| | | #include <urcu-defer.h> | |
| | | | |
| #endif /* _URCU_BP_H */ | | #endif /* _URCU_BP_H */ | |
| | | | |
End of changes. 6 change blocks. |
| 6 lines changed or deleted | | 11 lines changed or added | |
|
| urcu-futex.h | | urcu-futex.h | |
|
| #ifndef _URCU_FUTEX_H | | #warning "urcu/urcu-futex.h is deprecated. Please include urcu/futex.h inst | |
| #define _URCU_FUTEX_H | | ead." | |
| | | #include <urcu/futex.h> | |
| /* | | | |
| * urcu-futex.h | | | |
| * | | | |
| * Userspace RCU - sys_futex/compat_futex header. | | | |
| * | | | |
| * This library is free software; you can redistribute it and/or | | | |
| * modify it under the terms of the GNU Lesser General Public | | | |
| * License as published by the Free Software Foundation; either | | | |
| * version 2.1 of the License, or (at your option) any later version. | | | |
| * | | | |
| * This library is distributed in the hope that it will be useful, | | | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | | |
| * Lesser General Public License for more details. | | | |
| * | | | |
| * You should have received a copy of the GNU Lesser General Public | | | |
| * License along with this library; if not, write to the Free Software | | | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | | | |
| USA | | | |
| */ | | | |
| | | | |
| #include <urcu/config.h> | | | |
| | | | |
| #ifdef __cplusplus | | | |
| extern "C" { | | | |
| #endif | | | |
| | | | |
| #define FUTEX_WAIT 0 | | | |
| #define FUTEX_WAKE 1 | | | |
| | | | |
| /* | | | |
| * sys_futex compatibility header. | | | |
| * Use *only* *either of* futex_noasync OR futex_async on a given address. | | | |
| * | | | |
| * futex_noasync cannot be executed in signal handlers, but ensures that | | | |
| * it will be put in a wait queue even in compatibility mode. | | | |
| * | | | |
| * futex_async is signal-handler safe for the wakeup. It uses polling | | | |
| * on the wait-side in compatibility mode. | | | |
| */ | | | |
| | | | |
| #ifdef CONFIG_RCU_HAVE_FUTEX | | | |
| #include <sys/syscall.h> | | | |
| #define futex(...) syscall(__NR_futex, __VA_ARGS__) | | | |
| #define futex_noasync(uaddr, op, val, timeout, uaddr2, val3) \ | | | |
| futex(uaddr, op, val, timeout, uaddr2, val3) | | | |
| #define futex_async(uaddr, op, val, timeout, uaddr2, val3) \ | | | |
| futex(uaddr, op, val, timeout, uaddr2, val3) | | | |
| #else | | | |
| extern int compat_futex_noasync(int *uaddr, int op, int val, | | | |
| const struct timespec *timeout, int *uaddr2, int val3); | | | |
| #define futex_noasync(uaddr, op, val, timeout, uaddr2, val3) \ | | | |
| compat_futex_noasync(uaddr, op, val, timeout, uaddr2, val3) | | | |
| extern int compat_futex_async(int *uaddr, int op, int val, | | | |
| const struct timespec *timeout, int *uaddr2, int val3); | | | |
| #define futex_async(uaddr, op, val, timeout, uaddr2, val3) \ | | | |
| compat_futex_async(uaddr, op, val, timeout, uaddr2, val3) | | | |
| #endif | | | |
| | | | |
| #ifdef __cplusplus | | | |
| } | | | |
| #endif | | | |
| | | | |
| #endif /* _URCU_FUTEX_H */ | | | |
| | | | |
End of changes. 1 change blocks. |
| lines changed or deleted | | lines changed or added | |
|
| urcu-qsbr.h | | urcu-qsbr.h | |
| | | | |
| skipping to change at line 35 | | skipping to change at line 35 | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| * | | * | |
| * IBM's contributions to this file may be relicensed under LGPLv2 or later
. | | * IBM's contributions to this file may be relicensed under LGPLv2 or later
. | |
| */ | | */ | |
| | | | |
| #include <stdlib.h> | | #include <stdlib.h> | |
| #include <pthread.h> | | #include <pthread.h> | |
| | | | |
| /* | | /* | |
|
| * See urcu-pointer.h and urcu-pointer-static.h for pointer publication hea | | * See urcu-pointer.h and urcu/static/urcu-pointer.h for pointer | |
| ders. | | * publication headers. | |
| */ | | */ | |
| #include <urcu-pointer.h> | | #include <urcu-pointer.h> | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| | | #include <urcu/map/urcu-qsbr.h> | |
| | | | |
| /* | | /* | |
| * Important ! | | * Important ! | |
| * | | * | |
| * Each thread containing read-side critical sections must be registered | | * Each thread containing read-side critical sections must be registered | |
| * with rcu_register_thread() before calling rcu_read_lock(). | | * with rcu_register_thread() before calling rcu_read_lock(). | |
| * rcu_unregister_thread() should be called before the thread exits. | | * rcu_unregister_thread() should be called before the thread exits. | |
| */ | | */ | |
| | | | |
| #ifdef _LGPL_SOURCE | | #ifdef _LGPL_SOURCE | |
| | | | |
|
| #include <urcu-qsbr-static.h> | | #include <urcu/static/urcu-qsbr.h> | |
| | | | |
| /* | | /* | |
| * Mappings for static use of the userspace RCU library. | | * Mappings for static use of the userspace RCU library. | |
| * Should only be used in LGPL-compatible code. | | * Should only be used in LGPL-compatible code. | |
| */ | | */ | |
| | | | |
| /* | | /* | |
| * rcu_read_lock() | | * rcu_read_lock() | |
| * rcu_read_unlock() | | * rcu_read_unlock() | |
| * | | * | |
| * Mark the beginning and end of a read-side critical section. | | * Mark the beginning and end of a read-side critical section. | |
|
| * DON'T FORGET TO USE rcu_register_thread/rcu_unregister_thread() FOR EACH | | * DON'T FORGET TO USE rcu_register_thread/rcu_unregister_thread() | |
| * THREAD WITH READ-SIDE CRITICAL SECTION. | | * FOR EACH THREAD WITH READ-SIDE CRITICAL SECTION. | |
| */ | | */ | |
|
| #define rcu_read_lock() _rcu_read_lock() | | #define rcu_read_lock_qsbr _rcu_read_lock | |
| #define rcu_read_unlock() _rcu_read_unlock() | | #define rcu_read_unlock_qsbr _rcu_read_unlock | |
| | | | |
|
| #define rcu_quiescent_state() _rcu_quiescent_state() | | #define rcu_quiescent_state_qsbr _rcu_quiescent_state | |
| #define rcu_thread_offline() _rcu_thread_offline() | | #define rcu_thread_offline_qsbr _rcu_thread_offline | |
| #define rcu_thread_online() _rcu_thread_online() | | #define rcu_thread_online_qsbr _rcu_thread_online | |
| | | | |
| #else /* !_LGPL_SOURCE */ | | #else /* !_LGPL_SOURCE */ | |
| | | | |
| /* | | /* | |
| * library wrappers to be used by non-LGPL compatible source code. | | * library wrappers to be used by non-LGPL compatible source code. | |
| */ | | */ | |
| | | | |
| /* | | /* | |
| * QSBR read lock/unlock are guaranteed to be no-ops. Therefore, we expose
them | | * QSBR read lock/unlock are guaranteed to be no-ops. Therefore, we expose
them | |
| * in the LGPL header for any code to use. However, the debug version is no
t | | * in the LGPL header for any code to use. However, the debug version is no
t | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 99 | |
| * best trade-off between license/performance/code triviality and | | * best trade-off between license/performance/code triviality and | |
| * library debugging & tracing features we could come up with. | | * library debugging & tracing features we could come up with. | |
| */ | | */ | |
| | | | |
| #if (!defined(BUILD_QSBR_LIB) && defined(RCU_DEBUG)) | | #if (!defined(BUILD_QSBR_LIB) && defined(RCU_DEBUG)) | |
| | | | |
| static inline void rcu_read_lock(void) | | static inline void rcu_read_lock(void) | |
| { | | { | |
| } | | } | |
| | | | |
|
| static inline void rcu_read_lock(void) | | static inline void rcu_read_unlock(void) | |
| { | | { | |
| } | | } | |
| | | | |
| #else /* !RCU_DEBUG */ | | #else /* !RCU_DEBUG */ | |
| | | | |
| extern void rcu_read_lock(void); | | extern void rcu_read_lock(void); | |
| extern void rcu_read_unlock(void); | | extern void rcu_read_unlock(void); | |
| | | | |
| #endif /* !RCU_DEBUG */ | | #endif /* !RCU_DEBUG */ | |
| | | | |
| | | | |
| skipping to change at line 125 | | skipping to change at line 128 | |
| /* | | /* | |
| * Reader thread registration. | | * Reader thread registration. | |
| */ | | */ | |
| extern void rcu_register_thread(void); | | extern void rcu_register_thread(void); | |
| extern void rcu_unregister_thread(void); | | extern void rcu_unregister_thread(void); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
|
| | | #include <urcu-call-rcu.h> | |
| | | #include <urcu-defer.h> | |
| | | | |
| #endif /* _URCU_QSBR_H */ | | #endif /* _URCU_QSBR_H */ | |
| | | | |
End of changes. 8 change blocks. |
| 11 lines changed or deleted | | 16 lines changed or added | |
|
| urcu.h | | urcu.h | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA | |
| * | | * | |
| * IBM's contributions to this file may be relicensed under LGPLv2 or later
. | | * IBM's contributions to this file may be relicensed under LGPLv2 or later
. | |
| */ | | */ | |
| | | | |
| #include <stdlib.h> | | #include <stdlib.h> | |
| #include <pthread.h> | | #include <pthread.h> | |
| | | | |
| /* | | /* | |
|
| * See urcu-pointer.h and urcu-pointer-static.h for pointer publication hea | | * See urcu-pointer.h and urcu/static/urcu-pointer.h for pointer | |
| ders. | | * publication headers. | |
| */ | | */ | |
| #include <urcu-pointer.h> | | #include <urcu-pointer.h> | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| | | #include <urcu/map/urcu.h> | |
| | | | |
| /* | | /* | |
| * Important ! | | * Important ! | |
| * | | * | |
| * Each thread containing read-side critical sections must be registered | | * Each thread containing read-side critical sections must be registered | |
|
| * with rcu_register_thread() before calling rcu_read_lock(). | | * with rcu_register_thread_mb() before calling rcu_read_lock_mb(). | |
| * rcu_unregister_thread() should be called before the thread exits. | | * rcu_unregister_thread_mb() should be called before the thread exits. | |
| */ | | */ | |
| | | | |
| #ifdef _LGPL_SOURCE | | #ifdef _LGPL_SOURCE | |
| | | | |
|
| #include <urcu-static.h> | | #include <urcu/static/urcu.h> | |
| | | | |
| /* | | /* | |
| * Mappings for static use of the userspace RCU library. | | * Mappings for static use of the userspace RCU library. | |
| * Should only be used in LGPL-compatible code. | | * Should only be used in LGPL-compatible code. | |
| */ | | */ | |
| | | | |
| /* | | /* | |
| * rcu_read_lock() | | * rcu_read_lock() | |
| * rcu_read_unlock() | | * rcu_read_unlock() | |
| * | | * | |
| * Mark the beginning and end of a read-side critical section. | | * Mark the beginning and end of a read-side critical section. | |
| * DON'T FORGET TO USE RCU_REGISTER/UNREGISTER_THREAD() FOR EACH THREAD WIT
H | | * DON'T FORGET TO USE RCU_REGISTER/UNREGISTER_THREAD() FOR EACH THREAD WIT
H | |
| * READ-SIDE CRITICAL SECTION. | | * READ-SIDE CRITICAL SECTION. | |
| */ | | */ | |
|
| #define rcu_read_lock() _rcu_read_lock() | | #ifdef RCU_MEMBARRIER | |
| #define rcu_read_unlock() _rcu_read_unlock() | | #define rcu_read_lock_memb _rcu_read_lock | |
| | | #define rcu_read_unlock_memb _rcu_read_unlock | |
| | | #elif defined(RCU_SIGNAL) | |
| | | #define rcu_read_lock_sig _rcu_read_lock | |
| | | #define rcu_read_unlock_sig _rcu_read_unlock | |
| | | #elif defined(RCU_MB) | |
| | | #define rcu_read_lock_mb _rcu_read_lock | |
| | | #define rcu_read_unlock_mb _rcu_read_unlock | |
| | | #endif | |
| | | | |
| #else /* !_LGPL_SOURCE */ | | #else /* !_LGPL_SOURCE */ | |
| | | | |
| /* | | /* | |
| * library wrappers to be used by non-LGPL compatible source code. | | * library wrappers to be used by non-LGPL compatible source code. | |
|
| * See LGPL-only urcu-pointer-static.h for documentation. | | * See LGPL-only urcu/static/urcu-pointer.h for documentation. | |
| */ | | */ | |
| | | | |
| extern void rcu_read_lock(void); | | extern void rcu_read_lock(void); | |
| extern void rcu_read_unlock(void); | | extern void rcu_read_unlock(void); | |
| | | | |
| #endif /* !_LGPL_SOURCE */ | | #endif /* !_LGPL_SOURCE */ | |
| | | | |
| extern void synchronize_rcu(void); | | extern void synchronize_rcu(void); | |
| | | | |
| /* | | /* | |
| | | | |
| skipping to change at line 103 | | skipping to change at line 114 | |
| | | | |
| /* | | /* | |
| * Explicit rcu initialization, for "early" use within library constructors
. | | * Explicit rcu initialization, for "early" use within library constructors
. | |
| */ | | */ | |
| extern void rcu_init(void); | | extern void rcu_init(void); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
|
| | | #include <urcu-call-rcu.h> | |
| | | #include <urcu-defer.h> | |
| | | | |
| #endif /* _URCU_H */ | | #endif /* _URCU_H */ | |
| | | | |
End of changes. 7 change blocks. |
| 8 lines changed or deleted | | 21 lines changed or added | |
|