[1/4] tools/nolibc: add stdint.h

Message ID 20230304142606.5995-2-w@1wt.eu
State New
Headers
Series [1/4] tools/nolibc: add stdint.h |

Commit Message

Willy Tarreau March 4, 2023, 2:26 p.m. UTC
  From: Vincent Dagonneau <v@vda.io>

Nolibc works fine for small and limited program however most program
expect integer types to be defined in stdint.h rather than std.h.

This is a quick fix that moves the existing integer definitions in std.h
to stdint.h.

Signed-off-by: Vincent Dagonneau <v@vda.io>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 tools/include/nolibc/Makefile |  4 ++--
 tools/include/nolibc/std.h    | 15 +--------------
 tools/include/nolibc/stdint.h | 24 ++++++++++++++++++++++++
 3 files changed, 27 insertions(+), 16 deletions(-)
 create mode 100644 tools/include/nolibc/stdint.h
  

Comments

Paul E. McKenney March 5, 2023, 12:47 a.m. UTC | #1
On Sat, Mar 04, 2023 at 03:26:03PM +0100, Willy Tarreau wrote:
> From: Vincent Dagonneau <v@vda.io>
> 
> Nolibc works fine for small and limited program however most program
> expect integer types to be defined in stdint.h rather than std.h.
> 
> This is a quick fix that moves the existing integer definitions in std.h
> to stdint.h.
> 
> Signed-off-by: Vincent Dagonneau <v@vda.io>
> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
> Signed-off-by: Willy Tarreau <w@1wt.eu>

I queued all three serieses, and it does look good, thank you!

make[1]: Leaving directory '/home/git/linux-rcu'
125 test(s) passed.

I am figuring on pushing these into the v6.4 merge window, that is,
the one after the current just-now-closing merge window.

						Thanx, Paul

> ---
>  tools/include/nolibc/Makefile |  4 ++--
>  tools/include/nolibc/std.h    | 15 +--------------
>  tools/include/nolibc/stdint.h | 24 ++++++++++++++++++++++++
>  3 files changed, 27 insertions(+), 16 deletions(-)
>  create mode 100644 tools/include/nolibc/stdint.h
> 
> diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
> index cfd06764b5ae..ec57d3932506 100644
> --- a/tools/include/nolibc/Makefile
> +++ b/tools/include/nolibc/Makefile
> @@ -25,8 +25,8 @@ endif
>  
>  nolibc_arch := $(patsubst arm64,aarch64,$(ARCH))
>  arch_file := arch-$(nolibc_arch).h
> -all_files := ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h string.h \
> -             sys.h time.h types.h unistd.h
> +all_files := ctype.h errno.h nolibc.h signal.h std.h stdint.h stdio.h stdlib.h \
> +             string.h sys.h time.h types.h unistd.h
>  
>  # install all headers needed to support a bare-metal compiler
>  all: headers
> diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
> index 1747ae125392..933bc0be7e1c 100644
> --- a/tools/include/nolibc/std.h
> +++ b/tools/include/nolibc/std.h
> @@ -18,20 +18,7 @@
>  #define NULL ((void *)0)
>  #endif
>  
> -/* stdint types */
> -typedef unsigned char       uint8_t;
> -typedef   signed char        int8_t;
> -typedef unsigned short     uint16_t;
> -typedef   signed short      int16_t;
> -typedef unsigned int       uint32_t;
> -typedef   signed int        int32_t;
> -typedef unsigned long long uint64_t;
> -typedef   signed long long  int64_t;
> -typedef unsigned long        size_t;
> -typedef   signed long       ssize_t;
> -typedef unsigned long     uintptr_t;
> -typedef   signed long      intptr_t;
> -typedef   signed long     ptrdiff_t;
> +#include "stdint.h"
>  
>  /* those are commonly provided by sys/types.h */
>  typedef unsigned int          dev_t;
> diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h
> new file mode 100644
> index 000000000000..4ba264031df9
> --- /dev/null
> +++ b/tools/include/nolibc/stdint.h
> @@ -0,0 +1,24 @@
> +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
> +/*
> + * Standard definitions and types for NOLIBC
> + * Copyright (C) 2023 Vincent Dagonneau <v@vda.io>
> + */
> +
> +#ifndef _NOLIBC_STDINT_H
> +#define _NOLIBC_STDINT_H
> +
> +typedef unsigned char       uint8_t;
> +typedef   signed char        int8_t;
> +typedef unsigned short     uint16_t;
> +typedef   signed short      int16_t;
> +typedef unsigned int       uint32_t;
> +typedef   signed int        int32_t;
> +typedef unsigned long long uint64_t;
> +typedef   signed long long  int64_t;
> +typedef unsigned long        size_t;
> +typedef   signed long       ssize_t;
> +typedef unsigned long     uintptr_t;
> +typedef   signed long      intptr_t;
> +typedef   signed long     ptrdiff_t;
> +
> +#endif /* _NOLIBC_STDINT_H */
> -- 
> 2.17.5
>
  
Willy Tarreau March 5, 2023, 4:27 a.m. UTC | #2
Hello Paul,

On Sat, Mar 04, 2023 at 04:47:34PM -0800, Paul E. McKenney wrote:
> On Sat, Mar 04, 2023 at 03:26:03PM +0100, Willy Tarreau wrote:
> > From: Vincent Dagonneau <v@vda.io>
> > 
> > Nolibc works fine for small and limited program however most program
> > expect integer types to be defined in stdint.h rather than std.h.
> > 
> > This is a quick fix that moves the existing integer definitions in std.h
> > to stdint.h.
> > 
> > Signed-off-by: Vincent Dagonneau <v@vda.io>
> > Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
> > Signed-off-by: Willy Tarreau <w@1wt.eu>
> 
> I queued all three serieses, and it does look good, thank you!
> 
> make[1]: Leaving directory '/home/git/linux-rcu'
> 125 test(s) passed.
> 
> I am figuring on pushing these into the v6.4 merge window, that is,
> the one after the current just-now-closing merge window.

Yes that was the intent, so that we still have time to make some
adjustments if any would be needed. Many thanks!

Willy
  

Patch

diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index cfd06764b5ae..ec57d3932506 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -25,8 +25,8 @@  endif
 
 nolibc_arch := $(patsubst arm64,aarch64,$(ARCH))
 arch_file := arch-$(nolibc_arch).h
-all_files := ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h string.h \
-             sys.h time.h types.h unistd.h
+all_files := ctype.h errno.h nolibc.h signal.h std.h stdint.h stdio.h stdlib.h \
+             string.h sys.h time.h types.h unistd.h
 
 # install all headers needed to support a bare-metal compiler
 all: headers
diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
index 1747ae125392..933bc0be7e1c 100644
--- a/tools/include/nolibc/std.h
+++ b/tools/include/nolibc/std.h
@@ -18,20 +18,7 @@ 
 #define NULL ((void *)0)
 #endif
 
-/* stdint types */
-typedef unsigned char       uint8_t;
-typedef   signed char        int8_t;
-typedef unsigned short     uint16_t;
-typedef   signed short      int16_t;
-typedef unsigned int       uint32_t;
-typedef   signed int        int32_t;
-typedef unsigned long long uint64_t;
-typedef   signed long long  int64_t;
-typedef unsigned long        size_t;
-typedef   signed long       ssize_t;
-typedef unsigned long     uintptr_t;
-typedef   signed long      intptr_t;
-typedef   signed long     ptrdiff_t;
+#include "stdint.h"
 
 /* those are commonly provided by sys/types.h */
 typedef unsigned int          dev_t;
diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h
new file mode 100644
index 000000000000..4ba264031df9
--- /dev/null
+++ b/tools/include/nolibc/stdint.h
@@ -0,0 +1,24 @@ 
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Standard definitions and types for NOLIBC
+ * Copyright (C) 2023 Vincent Dagonneau <v@vda.io>
+ */
+
+#ifndef _NOLIBC_STDINT_H
+#define _NOLIBC_STDINT_H
+
+typedef unsigned char       uint8_t;
+typedef   signed char        int8_t;
+typedef unsigned short     uint16_t;
+typedef   signed short      int16_t;
+typedef unsigned int       uint32_t;
+typedef   signed int        int32_t;
+typedef unsigned long long uint64_t;
+typedef   signed long long  int64_t;
+typedef unsigned long        size_t;
+typedef   signed long       ssize_t;
+typedef unsigned long     uintptr_t;
+typedef   signed long      intptr_t;
+typedef   signed long     ptrdiff_t;
+
+#endif /* _NOLIBC_STDINT_H */