compiler: add ASSIGN_TYPED and ASSIGN_MEMBER

Looks like it's the most appropriate place for those hooks.
Didn't know about those helpers - maybe I should have used
them in my code more widely instead of casts.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Dmitry Safonov 2016-06-17 17:47:00 +03:00 committed by Pavel Emelyanov
parent e1d7ff8f0d
commit 4f0fdb463e
5 changed files with 3 additions and 12 deletions

View file

@ -54,9 +54,6 @@ typedef struct {
typedef struct user_pt_regs user_regs_struct_t;
#define ASSIGN_TYPED(a, b) do { a = (typeof(a))b; } while (0)
#define ASSIGN_MEMBER(a,b,m) do { ASSIGN_TYPED((a)->m, (b)->m); } while (0)
#define REG_RES(regs) ((u64)(regs).regs[0])
#define REG_IP(regs) ((u64)(regs).pc)
#define REG_SYSCALL_NR(regs) ((u64)(regs).regs[8])

View file

@ -89,9 +89,6 @@ struct user_vfp_exc {
unsigned long fpinst2;
};
#define ASSIGN_TYPED(a, b) do { a = (typeof(a))b; } while (0)
#define ASSIGN_MEMBER(a,b,m) do { ASSIGN_TYPED((a)->m, (b)->m); } while (0)
#define REG_RES(regs) ((regs).ARM_r0)
#define REG_IP(regs) ((regs).ARM_pc)
#define REG_SYSCALL_NR(regs) ((regs).ARM_r7)

View file

@ -72,9 +72,6 @@ typedef UserPpc64RegsEntry UserRegsEntry;
#define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__PPC64
#define ASSIGN_TYPED(a, b) do { a = (typeof(a))b; } while (0)
#define ASSIGN_MEMBER(a,b,m) do { ASSIGN_TYPED((a)->m, (b)->m); } while (0)
#define REG_RES(regs) ((u64)(regs).gpr[3])
#define REG_IP(regs) ((u64)(regs).nip)
#define REG_SYSCALL_NR(regs) ((u64)(regs).gpr[0])

View file

@ -105,9 +105,6 @@ typedef struct {
u32 padding[24];
} user_fpregs_struct_t;
#define ASSIGN_TYPED(a, b) do { a = (typeof(a))b; } while (0)
#define ASSIGN_MEMBER(a,b,m) do { ASSIGN_TYPED((a)->m, (b)->m); } while (0)
#ifdef CONFIG_X86_64
# define TASK_SIZE ((1UL << 47) - PAGE_SIZE)
#else

View file

@ -10,6 +10,9 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
#define ASSIGN_TYPED(a, b) do { (a) = (typeof(a))(b); } while (0)
#define ASSIGN_MEMBER(a, b, m) do { ASSIGN_TYPED((a)->m, (b)->m); } while (0)
#define __stringify_1(x...) #x
#define __stringify(x...) __stringify_1(x)