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:
parent
a7ae6d5948
commit
63e0f3b39c
21
kerncompat.h
21
kerncompat.h
|
@ -538,29 +538,14 @@ struct __una_u64 { __le64 x; } __attribute__((__packed__));
|
||||||
* Changed:
|
* Changed:
|
||||||
* - __unqual_scalar_typeof: volatile cast to typeof()
|
* - __unqual_scalar_typeof: volatile cast to typeof()
|
||||||
* - compiletime_assert_rwonce_type: no word size compatibility checks
|
* - compiletime_assert_rwonce_type: no word size compatibility checks
|
||||||
|
* - no const volatile cast
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
#define READ_ONCE(x) (x)
|
||||||
* 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 WRITE_ONCE(x, val) \
|
#define WRITE_ONCE(x, val) \
|
||||||
do { \
|
do { \
|
||||||
__WRITE_ONCE(x, val); \
|
(x) = (val); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,6 +28,10 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LIST_POISON1 ((void *) 0x00100100)
|
#define LIST_POISON1 ((void *) 0x00100100)
|
||||||
#define LIST_POISON2 ((void *) 0x00200200)
|
#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)
|
static inline void list_del(struct list_head *entry)
|
||||||
{
|
{
|
||||||
__list_del_entry(entry);
|
__list_del_entry(entry);
|
||||||
entry->next = LIST_POISON1;
|
entry->next = (struct list_head *)LIST_POISON1;
|
||||||
entry->prev = LIST_POISON2;
|
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)
|
static inline void hlist_del(struct hlist_node *n)
|
||||||
{
|
{
|
||||||
__hlist_del(n);
|
__hlist_del(n);
|
||||||
n->next = LIST_POISON1;
|
n->next = (struct hlist_node *)LIST_POISON1;
|
||||||
n->pprev = LIST_POISON2;
|
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.
|
* reference of the first entry if it exists.
|
||||||
*/
|
*/
|
||||||
static inline void hlist_move_list(struct hlist_head *old,
|
static inline void hlist_move_list(struct hlist_head *old,
|
||||||
struct hlist_head *new)
|
struct hlist_head *xnew)
|
||||||
{
|
{
|
||||||
new->first = old->first;
|
xnew->first = old->first;
|
||||||
if (new->first)
|
if (xnew->first)
|
||||||
new->first->pprev = &new->first;
|
xnew->first->pprev = &xnew->first;
|
||||||
old->first = NULL;
|
old->first = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1076,4 +1080,8 @@ static inline void hlist_move_list(struct hlist_head *old,
|
||||||
pos && ({ n = pos->member.next; 1; }); \
|
pos && ({ n = pos->member.next; 1; }); \
|
||||||
pos = hlist_entry_safe(n, typeof(*pos), member))
|
pos = hlist_entry_safe(n, typeof(*pos), member))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue