Skip to content

Commit

Permalink
x86/vdso: Add PUT_LE to store little-endian values
Browse files Browse the repository at this point in the history
Add PUT_LE() by analogy with GET_LE() to write littleendian values in
addition to reading them.

Signed-off-by: Andy Lutomirski <[email protected]>
Link: http://lkml.kernel.org/r/3d9b27e92745b27b6fda1b9a98f70dc9c1246c7a.1402620737.git.luto@amacapital.net
Signed-off-by: H. Peter Anvin <[email protected]>
  • Loading branch information
amluto authored and H. Peter Anvin committed Jun 13, 2014
1 parent 4ebbefd commit b4b31f6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions arch/x86/vdso/vdso2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,32 @@ static void fail(const char *format, ...)
}

/*
* Evil macros to do a little-endian read.
* Evil macros for little-endian reads and writes
*/
#define GLE(x, bits, ifnot) \
__builtin_choose_expr( \
(sizeof(*(x)) == bits/8), \
(__typeof__(*(x)))get_unaligned_le##bits(x), ifnot)

extern void bad_get_le(void);
#define LAST_LE(x) \
#define LAST_GLE(x) \
__builtin_choose_expr(sizeof(*(x)) == 1, *(x), bad_get_le())

#define GET_LE(x) \
GLE(x, 64, GLE(x, 32, GLE(x, 16, LAST_LE(x))))
GLE(x, 64, GLE(x, 32, GLE(x, 16, LAST_GLE(x))))

#define PLE(x, val, bits, ifnot) \
__builtin_choose_expr( \
(sizeof(*(x)) == bits/8), \
put_unaligned_le##bits((val), (x)), ifnot)

extern void bad_put_le(void);
#define LAST_PLE(x, val) \
__builtin_choose_expr(sizeof(*(x)) == 1, *(x) = (val), bad_put_le())

#define PUT_LE(x, val) \
PLE(x, val, 64, PLE(x, val, 32, PLE(x, val, 16, LAST_PLE(x, val))))


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

Expand Down

0 comments on commit b4b31f6

Please sign in to comment.