Skip to content

Commit

Permalink
types: add C99-style constructors to <asm-generic/int-*.h>
Browse files Browse the repository at this point in the history
Add C99-style constructor macros for fixed types to
<asm-generic/int-*.h>.  Since Linux uses names like "u64" instead of
"uint64_t", the constructor macros are called U64_C() instead of
UINT64_C() and so forth.

These macros allow specific sizes to be specified as
U64_C(0x123456789abcdef), without gcc issuing warnings as it will if
one writes (u64)0x123456789abcdef.

When used from assembly, these macros pass their argument unchanged.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
H. Peter Anvin committed May 2, 2008
1 parent 4cf63c8 commit c25bd29
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/asm-generic/int-l64.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ typedef unsigned int u32;
typedef signed long s64;
typedef unsigned long u64;

#define S8_C(x) x
#define U8_C(x) x ## U
#define S16_C(x) x
#define U16_C(x) x ## U
#define S32_C(x) x
#define U32_C(x) x ## U
#define S64_C(x) x ## L
#define U64_C(x) x ## UL

#else /* __ASSEMBLY__ */

#define S8_C(x) x
#define U8_C(x) x
#define S16_C(x) x
#define U16_C(x) x
#define S32_C(x) x
#define U32_C(x) x
#define S64_C(x) x
#define U64_C(x) x

#endif /* __ASSEMBLY__ */

#endif /* __KERNEL__ */
Expand Down
20 changes: 20 additions & 0 deletions include/asm-generic/int-ll64.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;

#define S8_C(x) x
#define U8_C(x) x ## U
#define S16_C(x) x
#define U16_C(x) x ## U
#define S32_C(x) x
#define U32_C(x) x ## U
#define S64_C(x) x ## LL
#define U64_C(x) x ## ULL

#else /* __ASSEMBLY__ */

#define S8_C(x) x
#define U8_C(x) x
#define S16_C(x) x
#define U16_C(x) x
#define S32_C(x) x
#define U32_C(x) x
#define S64_C(x) x
#define U64_C(x) x

#endif /* __ASSEMBLY__ */

#endif /* __KERNEL__ */
Expand Down

0 comments on commit c25bd29

Please sign in to comment.