Skip to content

Commit b4b31f6

Browse files
amlutoH. Peter Anvin
authored andcommitted
x86/vdso: Add PUT_LE to store little-endian values
Add PUT_LE() by analogy with GET_LE() to write littleendian values in addition to reading them. Signed-off-by: Andy Lutomirski <luto@amacapital.net> Link: http://lkml.kernel.org/r/3d9b27e92745b27b6fda1b9a98f70dc9c1246c7a.1402620737.git.luto@amacapital.net Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1 parent 4ebbefd commit b4b31f6

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

arch/x86/vdso/vdso2c.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,32 @@ static void fail(const char *format, ...)
5454
}
5555

5656
/*
57-
* Evil macros to do a little-endian read.
57+
* Evil macros for little-endian reads and writes
5858
*/
5959
#define GLE(x, bits, ifnot) \
6060
__builtin_choose_expr( \
6161
(sizeof(*(x)) == bits/8), \
6262
(__typeof__(*(x)))get_unaligned_le##bits(x), ifnot)
6363

6464
extern void bad_get_le(void);
65-
#define LAST_LE(x) \
65+
#define LAST_GLE(x) \
6666
__builtin_choose_expr(sizeof(*(x)) == 1, *(x), bad_get_le())
6767

6868
#define GET_LE(x) \
69-
GLE(x, 64, GLE(x, 32, GLE(x, 16, LAST_LE(x))))
69+
GLE(x, 64, GLE(x, 32, GLE(x, 16, LAST_GLE(x))))
70+
71+
#define PLE(x, val, bits, ifnot) \
72+
__builtin_choose_expr( \
73+
(sizeof(*(x)) == bits/8), \
74+
put_unaligned_le##bits((val), (x)), ifnot)
75+
76+
extern void bad_put_le(void);
77+
#define LAST_PLE(x, val) \
78+
__builtin_choose_expr(sizeof(*(x)) == 1, *(x) = (val), bad_put_le())
79+
80+
#define PUT_LE(x, val) \
81+
PLE(x, val, 64, PLE(x, val, 32, PLE(x, val, 16, LAST_PLE(x, val))))
82+
7083

7184
#define NSYMS (sizeof(required_syms) / sizeof(required_syms[0]))
7285

0 commit comments

Comments
 (0)