public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: linux-kernel@vger.kernel.org, Willy Tarreau <w@1wt.eu>
Subject: [PATCH v2 04/22] tools/nolibc: remove local definitions of O_* flags for open/fcntl
Date: Tue, 10 Jan 2023 08:24:16 +0100	[thread overview]
Message-ID: <20230110072434.3863-5-w@1wt.eu> (raw)
In-Reply-To: <20230110072434.3863-1-w@1wt.eu>

The historic nolibc code did not include asm/fcntl.h and had to define
the various O_RDWR etc macros in each arch-specific file (since such
values differ between certain archs). This was found at least once to
induce bugs due to wrong definitions. Let's get rid of all of them and
include asm/nolibc.h from sys.h instead. This was verified to work
properly on all supported architectures.

Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 tools/include/nolibc/arch-aarch64.h | 12 ------------
 tools/include/nolibc/arch-arm.h     | 12 ------------
 tools/include/nolibc/arch-i386.h    | 12 ------------
 tools/include/nolibc/arch-mips.h    | 12 ------------
 tools/include/nolibc/arch-riscv.h   | 12 ------------
 tools/include/nolibc/arch-s390.h    | 12 ------------
 tools/include/nolibc/arch-x86_64.h  | 12 ------------
 tools/include/nolibc/sys.h          |  1 +
 8 files changed, 1 insertion(+), 84 deletions(-)

diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h
index 4d263661411f..f480993159ec 100644
--- a/tools/include/nolibc/arch-aarch64.h
+++ b/tools/include/nolibc/arch-aarch64.h
@@ -7,18 +7,6 @@
 #ifndef _NOLIBC_ARCH_AARCH64_H
 #define _NOLIBC_ARCH_AARCH64_H
 
-/* O_* macros for fcntl/open are architecture-specific */
-#define O_RDONLY            0
-#define O_WRONLY            1
-#define O_RDWR              2
-#define O_CREAT          0x40
-#define O_EXCL           0x80
-#define O_NOCTTY        0x100
-#define O_TRUNC         0x200
-#define O_APPEND        0x400
-#define O_NONBLOCK      0x800
-#define O_DIRECTORY    0x4000
-
 /* The struct returned by the newfstatat() syscall. Differs slightly from the
  * x86_64's stat one by field ordering, so be careful.
  */
diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h
index ef94df2d93d5..48bd95492c87 100644
--- a/tools/include/nolibc/arch-arm.h
+++ b/tools/include/nolibc/arch-arm.h
@@ -7,18 +7,6 @@
 #ifndef _NOLIBC_ARCH_ARM_H
 #define _NOLIBC_ARCH_ARM_H
 
-/* O_* macros for fcntl/open are architecture-specific */
-#define O_RDONLY            0
-#define O_WRONLY            1
-#define O_RDWR              2
-#define O_CREAT          0x40
-#define O_EXCL           0x80
-#define O_NOCTTY        0x100
-#define O_TRUNC         0x200
-#define O_APPEND        0x400
-#define O_NONBLOCK      0x800
-#define O_DIRECTORY    0x4000
-
 /* The struct returned by the stat() syscall, 32-bit only, the syscall returns
  * exactly 56 bytes (stops before the unused array). In big endian, the format
  * differs as devices are returned as short only.
diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h
index b1bed2d87f74..ef2a836ee667 100644
--- a/tools/include/nolibc/arch-i386.h
+++ b/tools/include/nolibc/arch-i386.h
@@ -7,18 +7,6 @@
 #ifndef _NOLIBC_ARCH_I386_H
 #define _NOLIBC_ARCH_I386_H
 
-/* O_* macros for fcntl/open are architecture-specific */
-#define O_RDONLY            0
-#define O_WRONLY            1
-#define O_RDWR              2
-#define O_CREAT          0x40
-#define O_EXCL           0x80
-#define O_NOCTTY        0x100
-#define O_TRUNC         0x200
-#define O_APPEND        0x400
-#define O_NONBLOCK      0x800
-#define O_DIRECTORY   0x10000
-
 /* The struct returned by the stat() syscall, 32-bit only, the syscall returns
  * exactly 56 bytes (stops before the unused array).
  */
diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
index 11270ef25ea5..a3764f6d267e 100644
--- a/tools/include/nolibc/arch-mips.h
+++ b/tools/include/nolibc/arch-mips.h
@@ -7,18 +7,6 @@
 #ifndef _NOLIBC_ARCH_MIPS_H
 #define _NOLIBC_ARCH_MIPS_H
 
-/* O_* macros for fcntl/open are architecture-specific */
-#define O_RDONLY            0
-#define O_WRONLY            1
-#define O_RDWR              2
-#define O_APPEND       0x0008
-#define O_NONBLOCK     0x0080
-#define O_CREAT        0x0100
-#define O_TRUNC        0x0200
-#define O_EXCL         0x0400
-#define O_NOCTTY       0x0800
-#define O_DIRECTORY   0x10000
-
 /* The struct returned by the stat() syscall. 88 bytes are returned by the
  * syscall.
  */
diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h
index bee769e6885c..c2b5db383d96 100644
--- a/tools/include/nolibc/arch-riscv.h
+++ b/tools/include/nolibc/arch-riscv.h
@@ -7,18 +7,6 @@
 #ifndef _NOLIBC_ARCH_RISCV_H
 #define _NOLIBC_ARCH_RISCV_H
 
-/* O_* macros for fcntl/open are architecture-specific */
-#define O_RDONLY            0
-#define O_WRONLY            1
-#define O_RDWR              2
-#define O_CREAT          0x40
-#define O_EXCL           0x80
-#define O_NOCTTY        0x100
-#define O_TRUNC         0x200
-#define O_APPEND        0x400
-#define O_NONBLOCK      0x800
-#define O_DIRECTORY   0x10000
-
 struct sys_stat_struct {
 	unsigned long	st_dev;		/* Device.  */
 	unsigned long	st_ino;		/* File serial number.  */
diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h
index 2c0b8847c050..b58f64d47b82 100644
--- a/tools/include/nolibc/arch-s390.h
+++ b/tools/include/nolibc/arch-s390.h
@@ -7,18 +7,6 @@
 #define _NOLIBC_ARCH_S390_H
 #include <asm/unistd.h>
 
-/* O_* macros for fcntl/open are architecture-specific */
-#define O_RDONLY            0
-#define O_WRONLY            1
-#define O_RDWR              2
-#define O_CREAT          0x40
-#define O_EXCL           0x80
-#define O_NOCTTY        0x100
-#define O_TRUNC         0x200
-#define O_APPEND        0x400
-#define O_NONBLOCK      0x800
-#define O_DIRECTORY   0x10000
-
 /* The struct returned by the stat() syscall, equivalent to stat64(). The
  * syscall returns 116 bytes and stops in the middle of __unused.
  */
diff --git a/tools/include/nolibc/arch-x86_64.h b/tools/include/nolibc/arch-x86_64.h
index c70a84612a9e..8d482505c347 100644
--- a/tools/include/nolibc/arch-x86_64.h
+++ b/tools/include/nolibc/arch-x86_64.h
@@ -7,18 +7,6 @@
 #ifndef _NOLIBC_ARCH_X86_64_H
 #define _NOLIBC_ARCH_X86_64_H
 
-/* O_* macros for fcntl/open are architecture-specific */
-#define O_RDONLY            0
-#define O_WRONLY            1
-#define O_RDWR              2
-#define O_CREAT          0x40
-#define O_EXCL           0x80
-#define O_NOCTTY        0x100
-#define O_TRUNC         0x200
-#define O_APPEND        0x400
-#define O_NONBLOCK      0x800
-#define O_DIRECTORY   0x10000
-
 /* The struct returned by the stat() syscall, equivalent to stat64(). The
  * syscall returns 116 bytes and stops in the middle of __unused.
  */
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index a42d7c405bdc..47bf67668860 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -11,6 +11,7 @@
 #include "std.h"
 
 /* system includes */
+#include <asm/fcntl.h>   // for O_*
 #include <asm/unistd.h>
 #include <asm/signal.h>  // for SIGCHLD
 #include <asm/ioctls.h>
-- 
2.17.5


  parent reply	other threads:[~2023-01-10  7:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10  7:24 [PATCH v2 00/22] nolibc: usability improvements (errno, environ, auxv) Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 01/22] tools/nolibc: make compiler and assembler agree on the section around _start Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 02/22] tools/nolibc: enable support for thumb1 mode for ARM Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 03/22] tools/nolibc: support thumb mode with frame pointers on ARM Willy Tarreau
2023-01-10  7:24 ` Willy Tarreau [this message]
2023-01-10  7:24 ` [PATCH v2 05/22] tools/nolibc: make errno a weak symbol instead of a static one Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 06/22] tools/nolibc: export environ as a weak symbol on x86_64 Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 07/22] tools/nolibc: export environ as a weak symbol on i386 Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 08/22] tools/nolibc: export environ as a weak symbol on arm64 Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 09/22] tools/nolibc: export environ as a weak symbol on arm Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 10/22] tools/nolibc: export environ as a weak symbol on mips Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 11/22] tools/nolibc: export environ as a weak symbol on riscv Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 12/22] tools/nolibc: export environ as a weak symbol on s390 Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 13/22] tools/nolibc: add auxiliary vector retrieval for i386 Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 14/22] tools/nolibc: add auxiliary vector retrieval for x86_64 Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 15/22] tools/nolibc: add auxiliary vector retrieval for arm64 Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 16/22] tools/nolibc: add auxiliary vector retrieval for arm Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 17/22] tools/nolibc: add auxiliary vector retrieval for riscv Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 18/22] tools/nolibc: add auxiliary vector retrieval for mips Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 19/22] tools/nolibc: add auxiliary vector retrieval for s390 Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 20/22] nolibc/stdlib: Implement `getauxval(3)` function Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 21/22] nolibc/sys: Implement `getpagesize(2)` function Willy Tarreau
2023-01-10  7:24 ` [PATCH v2 22/22] selftests/nolibc: Add `getpagesize(2)` selftest Willy Tarreau
2023-01-10 22:21 ` [PATCH v2 00/22] nolibc: usability improvements (errno, environ, auxv) Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230110072434.3863-5-w@1wt.eu \
    --to=w@1wt.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox