btrfs-progs: kernel-lib: make headers C++ compatible

The snapper build fails due to updates to kernel-lib files, the type
casts do not work the same way in C++. Simplify READ_ONCE/WRITE_ONCE
even more, drop use of 'new' as identifier.

Issue: https://github.com/openSUSE/snapper/issues/725
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-05-30 15:47:06 +02:00
parent a7ae6d5948
commit 63e0f3b39c
2 changed files with 19 additions and 26 deletions

View File

@ -538,29 +538,14 @@ struct __una_u64 { __le64 x; } __attribute__((__packed__));
* Changed:
* - __unqual_scalar_typeof: volatile cast to typeof()
* - compiletime_assert_rwonce_type: no word size compatibility checks
* - no const volatile cast
*/
/*
* Use __READ_ONCE() instead of READ_ONCE() if you do not require any
* atomicity. Note that this may result in tears!
*/
#ifndef __READ_ONCE
#define __READ_ONCE(x) (*(const volatile typeof(x) *)&(x))
#endif
#define READ_ONCE(x) \
({ \
__READ_ONCE(x); \
})
#define __WRITE_ONCE(x, val) \
do { \
*(volatile typeof(x) *)&(x) = (val); \
} while (0)
#define READ_ONCE(x) (x)
#define WRITE_ONCE(x, val) \
do { \
__WRITE_ONCE(x, val); \
(x) = (val); \
} while (0)
#endif

View File

@ -28,6 +28,10 @@
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define LIST_POISON1 ((void *) 0x00100100)
#define LIST_POISON2 ((void *) 0x00200200)
@ -187,8 +191,8 @@ static inline void __list_del_entry(struct list_head *entry)
static inline void list_del(struct list_head *entry)
{
__list_del_entry(entry);
entry->next = LIST_POISON1;
entry->prev = LIST_POISON2;
entry->next = (struct list_head *)LIST_POISON1;
entry->prev = (struct list_head *)LIST_POISON2;
}
/**
@ -901,8 +905,8 @@ static inline void __hlist_del(struct hlist_node *n)
static inline void hlist_del(struct hlist_node *n)
{
__hlist_del(n);
n->next = LIST_POISON1;
n->pprev = LIST_POISON2;
n->next = (struct hlist_node *)LIST_POISON1;
n->pprev = (struct hlist_node **)LIST_POISON2;
}
/**
@ -1012,11 +1016,11 @@ hlist_is_singular_node(struct hlist_node *n, struct hlist_head *h)
* reference of the first entry if it exists.
*/
static inline void hlist_move_list(struct hlist_head *old,
struct hlist_head *new)
struct hlist_head *xnew)
{
new->first = old->first;
if (new->first)
new->first->pprev = &new->first;
xnew->first = old->first;
if (xnew->first)
xnew->first->pprev = &xnew->first;
old->first = NULL;
}
@ -1076,4 +1080,8 @@ static inline void hlist_move_list(struct hlist_head *old,
pos && ({ n = pos->member.next; 1; }); \
pos = hlist_entry_safe(n, typeof(*pos), member))
#ifdef __cplusplus
}
#endif
#endif