mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: fix dm_list pointer arithmentic for new gcc 10 optimization
This commit is contained in:
parent
212cf8efbd
commit
b3fa71fbd8
@ -1,6 +1,8 @@
|
|||||||
#ifndef BASE_DATA_STRUCT_LIST_H
|
#ifndef BASE_DATA_STRUCT_LIST_H
|
||||||
#define BASE_DATA_STRUCT_LIST_H
|
#define BASE_DATA_STRUCT_LIST_H
|
||||||
|
|
||||||
|
#include <stddef.h> /* offsetof */
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -98,7 +100,7 @@ struct dm_list *dm_list_next(const struct dm_list *head, const struct dm_list *e
|
|||||||
* contained in a structure of type t, return the containing structure.
|
* contained in a structure of type t, return the containing structure.
|
||||||
*/
|
*/
|
||||||
#define dm_list_struct_base(v, t, head) \
|
#define dm_list_struct_base(v, t, head) \
|
||||||
((t *)((const char *)(v) - (const char *)&((t *) 0)->head))
|
((t *)((const char *)(v) - offsetof(t, head)))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given the address v of an instance of 'struct dm_list list' contained in
|
* Given the address v of an instance of 'struct dm_list list' contained in
|
||||||
@ -111,7 +113,7 @@ struct dm_list *dm_list_next(const struct dm_list *head, const struct dm_list *e
|
|||||||
* return another element f.
|
* return another element f.
|
||||||
*/
|
*/
|
||||||
#define dm_struct_field(v, t, e, f) \
|
#define dm_struct_field(v, t, e, f) \
|
||||||
(((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
|
(((t *)((uintptr_t)(v) - offsetof(t, e)))->f)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given the address v of a known element e in a known structure of type t,
|
* Given the address v of a known element e in a known structure of type t,
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stddef.h> /* offsetof */
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
# define __typeof__ typeof
|
# define __typeof__ typeof
|
||||||
@ -2470,7 +2471,7 @@ struct dm_list *dm_list_next(const struct dm_list *head, const struct dm_list *e
|
|||||||
* contained in a structure of type t, return the containing structure.
|
* contained in a structure of type t, return the containing structure.
|
||||||
*/
|
*/
|
||||||
#define dm_list_struct_base(v, t, head) \
|
#define dm_list_struct_base(v, t, head) \
|
||||||
((t *)((const char *)(v) - (const char *)&((t *) 0)->head))
|
((t *)((const char *)(v) - offsetof(t, head)))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given the address v of an instance of 'struct dm_list list' contained in
|
* Given the address v of an instance of 'struct dm_list list' contained in
|
||||||
@ -2483,7 +2484,7 @@ struct dm_list *dm_list_next(const struct dm_list *head, const struct dm_list *e
|
|||||||
* return another element f.
|
* return another element f.
|
||||||
*/
|
*/
|
||||||
#define dm_struct_field(v, t, e, f) \
|
#define dm_struct_field(v, t, e, f) \
|
||||||
(((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
|
(((t *)((uintptr_t)(v) - offsetof(t, e))->f)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given the address v of a known element e in a known structure of type t,
|
* Given the address v of a known element e in a known structure of type t,
|
||||||
|
Loading…
Reference in New Issue
Block a user