Skip to content

Commit a8de130

Browse files
masahir0yrobherring
authored andcommitted
libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h
The DTC v1.5.1 added references to (U)INT32_MAX. This is no problem for user-space programs since <stdint.h> defines (U)INT32_MAX along with (u)int32_t. For the kernel space, libfdt_env.h needs to be adjusted before we pull in the changes. In the kernel, we usually use s/u32 instead of (u)int32_t for the fixed-width types. Accordingly, we already have S/U32_MAX for their max values. So, we should not add (U)INT32_MAX to <linux/limits.h> any more. Instead, add them to the in-kernel libfdt_env.h to compile the latest libfdt. Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Rob Herring <[email protected]>
1 parent 30a3e01 commit a8de130

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

arch/arm/boot/compressed/libfdt_env.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
#ifndef _ARM_LIBFDT_ENV_H
33
#define _ARM_LIBFDT_ENV_H
44

5+
#include <linux/limits.h>
56
#include <linux/types.h>
67
#include <linux/string.h>
78
#include <asm/byteorder.h>
89

9-
#define INT_MAX ((int)(~0U>>1))
10+
#define INT32_MAX S32_MAX
11+
#define UINT32_MAX U32_MAX
1012

1113
typedef __be16 fdt16_t;
1214
typedef __be32 fdt32_t;

arch/powerpc/boot/libfdt_env.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <string.h>
77

88
#define INT_MAX ((int)(~0U>>1))
9+
#define UINT32_MAX ((u32)~0U)
10+
#define INT32_MAX ((s32)(UINT32_MAX >> 1))
911

1012
#include "of.h"
1113

include/linux/libfdt_env.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
#include <asm/byteorder.h>
99

10+
#define INT32_MAX S32_MAX
11+
#define UINT32_MAX U32_MAX
12+
1013
typedef __be16 fdt16_t;
1114
typedef __be32 fdt32_t;
1215
typedef __be64 fdt64_t;

0 commit comments

Comments
 (0)