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

Vincent Dagonneau posted 4 patches 2 years, 6 months ago
[PATCH v7 1/4] tools/nolibc: add stdint.h
Posted by Vincent Dagonneau 2 years, 6 months ago
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>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
---
 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.39.2

Re: [PATCH v7 1/4] tools/nolibc: add stdint.h
Posted by Thomas Weißschuh 2 years, 6 months ago
On Mon, Feb 27, 2023 at 09:11:33PM -0500, Vincent Dagonneau wrote:
> 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>
> Signed-off-by: Willy Tarreau <w@1wt.eu>
> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>

One more nitpick (applies to all patches):

The correct order of trailers would be:

Signed-off-by: Willy Tarreau <w@1wt.eu>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Vincent Dagonneau <v@vda.io>

In chronological order.

First Willy submitted something, then I reviewed it and then you
submitted it.
Your previous submissions/Signed-off-by are superseeded by the last one.

See Documentation/process/submitting-patches.rst.
(Especially search for "chronological")

Willy can probably fix this up when applying the series, so a new
revision may not be necessary.

> ---
>  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
Re: [PATCH v7 1/4] tools/nolibc: add stdint.h
Posted by Willy Tarreau 2 years, 6 months ago
On Tue, Feb 28, 2023 at 02:24:15AM +0000, Thomas Weißschuh wrote:
> On Mon, Feb 27, 2023 at 09:11:33PM -0500, Vincent Dagonneau wrote:
> > 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>
> > Signed-off-by: Willy Tarreau <w@1wt.eu>
> > Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
> 
> One more nitpick (applies to all patches):
> 
> The correct order of trailers would be:
> 
> Signed-off-by: Willy Tarreau <w@1wt.eu>
> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
> Signed-off-by: Vincent Dagonneau <v@vda.io>
> 
> In chronological order.
> 
> First Willy submitted something, then I reviewed it and then you
> submitted it.
> Your previous submissions/Signed-off-by are superseeded by the last one.
> 
> See Documentation/process/submitting-patches.rst.
> (Especially search for "chronological")
> 
> Willy can probably fix this up when applying the series, so a new
> revision may not be necessary.

Yeah absolutely. In fact I'll just drop my initial sob since I only
slightly re-adjusted some of Vincent's patches to illustrate what I
meant and not at all as something sensitive.

Thanks to you both!
Willy