Skip to contentSkip to conversation

Automatically generate syscalls.h

PATCH Superseded Andrea Cervesato 4 participants 11 messages Oct 31, 2024 – Nov 1, 2024

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v8 cover Automatically generate syscalls.h

The problem we have at the moment is that all syscalls input files must be changed by hand each time we need to test a new syscall. The idea is to simplify this process, providing a script that is able to read from kernel sources and to generate all syscalls files we need.

This patch set adds a new command inside the syscalls folder and it refactors the previous regen.sh code.
The new way we have to generate the syscalls.h file is the following:

include/lapi/syscalls/generate_arch.sh path/to/kernel/source
include/lapi/syscalls/generate_syscalls.sh path/to/syscalls.h

Scripts are independent and they can be run separately. generate_syscalls.sh is the equivalent of regen.sh, but its code has been cleaned up.

---
Changes in v8:
- use /bin/sh -eu
- support for dash and removed all bashism madness
- validation: https://github.com/acerv/ltp/actions/runs/11615377438
- Link to v7: https://lore.kernel.org/r/[email protected]

Changes in v7:
- check for errors in generate_syscalls.sh
- add documentation
- validation: https://github.com/acerv/ltp/actions/runs/11611080151
- Link to v6: https://lore.kernel.org/r/[email protected]

Changes in v6:
- aesthetic changes in the syscall generator
- fix fallback definitions in the syscalls.h file generator
- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- license SPDX inside scripts files
- quote shell variables inside scripts
- some generic code cleanup
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- remove blacklist file
- update syscalls files
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- fix generate_arch.sh to work properly for all architectures
- rename some arch .in files and handle renaming inside
generate_syscalls.sh using the right gcc directives
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- refactor regen.sh
- split syscalls.h and syscalls .in files creation
- updated syscalls .in files
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Andrea Cervesato (4):
Refactor regen.sh script to generate syscalls Add script to generate arch(s) dependant syscalls Delete obsolete strip_syscall.awk file Add documentation about syscalls.h generator

 configure.ac                                       |   2 +-
 doc/developers/test_case_tutorial.rst              |  27 +--
 include/lapi/syscalls/{aarch64.in => arm64.in}     |   0
 include/lapi/syscalls/generate_arch.sh             | 206 +++++++++++++++++++++
 include/lapi/syscalls/generate_syscalls.sh         | 109 +++++++++++
 .../lapi/syscalls/{loongarch.in => loongarch64.in} |   0
 include/lapi/syscalls/{mips_n64.in => mips64.in}   |   0
 .../lapi/syscalls/{mips_n32.in => mips64n32.in}    |   0
 include/lapi/syscalls/{mips_o32.in => mipso32.in}  |   0
 include/lapi/syscalls/{hppa.in => parisc.in}       |   0
 include/lapi/syscalls/regen.sh                     | 129 -------------
 include/lapi/syscalls/strip_syscall.awk            |  19 --
 .../lapi/syscalls/{order => supported-arch.txt}    |  12 +-
 13 files changed, 336 insertions(+), 168 deletions(-)

---
base-commit: 84e77afb3acc4bc69c434c430cc1c1d000427921
change-id: 20240923-generate_syscalls-780dc2227bdb

Best regards,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH v8 1/4 Refactor regen.sh script to generate syscalls

From: Andrea Cervesato <[email protected]>

Rename regen.sh into a more meaningful generate_syscalls.sh name, rename order into a more meaningful supported-syscalls.txt name and rewrite part of the regen.sh script code in order to execute it from anywhere in the filesystem, without need to be in its own folder. The new code is also more clear and concise, using native sh features which are simplifying the code.

---
 configure.ac                                       |   2 +-
 include/lapi/syscalls/generate_syscalls.sh         | 109 +++++++++++++++++
 include/lapi/syscalls/regen.sh                     | 129 ---------------------
 .../lapi/syscalls/{order => supported-arch.txt}    |   0
 4 files changed, 110 insertions(+), 130 deletions(-)
configure.ac +1 -1
index d327974efa71f263d7f7f5aec9d2c5831d53dd0e..cd1233d19fad376973fc880d6689859845613fb0 100644
@@ -386,7 +386,7 @@ else
     AC_SUBST([WITH_REALTIME_TESTSUITE],["no"])
 fi
 
-AC_CONFIG_COMMANDS([syscalls.h], [cd ${ac_top_srcdir}/include/lapi/syscalls; ./regen.sh; cd - >/dev/null])
+AC_CONFIG_COMMANDS([syscalls.h], [cd ${ac_top_srcdir}/include/lapi/syscalls; ./generate_syscalls.sh ../syscalls.h; cd - >/dev/null])
 
 # custom functions
 # NOTE: don't create custom functions for simple checks, put them into this file
include/lapi/syscalls/generate_syscalls.sh new file +109 -0

109 lines not on this page · raw message

include/lapi/syscalls/regen.sh deleted +0 -129

129 lines not on this page · raw message

include/lapi/syscalls/supported-arch.txt renamed from include/lapi/syscalls/order +0 -0
similarity index 100%
rename from include/lapi/syscalls/order
rename to include/lapi/syscalls/supported-arch.txt
Signature · 5 lines
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v8 1/4
#2 lore raw

Re: [LTP] [PATCH v8 1/4] Refactor regen.sh script to generate syscalls

Hi!

include/lapi/syscalls/generate_syscalls.sh line 77

Quoted 10 lines
include/lapi/syscalls/generate_syscalls.sh new file +10 -0
+while IFS= read -r arch; do
+	(
+		echo
+		case ${arch} in
+		sparc64) echo "#if defined(__sparc__) && defined(__arch64__)" ;;
+		sparc) echo "#if defined(__sparc__) && !defined(__arch64__)" ;;
+		s390) echo "#if defined(__s390__) && !defined(__s390x__)" ;;
+		mips64n32) echo "#if defined(__mips__) && defined(_ABIN32)" ;;
+		mips64) echo "#if defined(__mips__) && defined(_ABI64)" ;;
+		mipso32) echo "#if defined(__mips__) && defined(_ABIO32) && _MIPS_SZLONG == 32" ;;

It would be nice to get a confirmation from someone who knows mips that these changes in ifdefs are okay, otherwise:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH v8 1/4] Refactor regen.sh script to generate syscalls

Hi all,

Quoted 11 lines

Hi!

include/lapi/syscalls/generate_syscalls.sh line 77

Quoted 10 lines
include/lapi/syscalls/generate_syscalls.sh new file +10 -0
+while IFS= read -r arch; do
+	(
+		echo
+		case ${arch} in
+		sparc64) echo "#if defined(__sparc__) && defined(__arch64__)" ;;
+		sparc) echo "#if defined(__sparc__) && !defined(__arch64__)" ;;
+		s390) echo "#if defined(__s390__) && !defined(__s390x__)" ;;
+		mips64n32) echo "#if defined(__mips__) && defined(_ABIN32)" ;;
+		mips64) echo "#if defined(__mips__) && defined(_ABI64)" ;;
+		mipso32) echo "#if defined(__mips__) && defined(_ABIO32) && _MIPS_SZLONG == 32" ;;

The original code was:

- mips_n32) echo "#if defined(__mips__) && defined(_ABIN32)" ;;
- mips_n64) echo "#if defined(__mips__) && defined(_ABI64)" ;;
- mips_o32) echo "#if defined(__mips__) && defined(_ABIO32) && _MIPS_SZLONG == 32" ;;

ifdefs are the same, the only thing which changed are arch names. And these are also changed, see below. The only problem I see is that the change in supported-arch.txt below happens in the following commit. Shouldn't the rename happen in this commit already? syscalls.h file generated from the first commit is indeed different from the one generated in 2nd and 3rd (which are the same.

+++ b/include/lapi/syscalls/supported-arch.txt
@@ -1,13 +1,13 @@
-aarch64
arc
+arm64
arm
-hppa
i386
ia64
-loongarch
-mips_n32
-mips_n64
-mips_o32
+loongarch64
+mips64n32
+mips64
+mipso32
+parisc
powerpc64
powerpc
s390x

1st commit have (which is IMHO wrong)
#ifdef __mips_n32__

2nd and 3rd have:
#if defined(__mips__) && defined(_ABIN32)

The reason due postponed changes is, that some arch use

*) echo "#ifdef __${arch}__" ;;

Whoever will do bisecting, cannot use this commit on mips and other affected archs due broken syscalls.h. This problem appeared in v5. Previously (v3 and v4) old names were used in generate_syscalls.sh, and in second commit (when the generate_arch.sh archs was added) were new ones used.

IMHO clearest solution would be to move rename to 1st commit.

Quoted 2 lines

It would be nice to get a confirmation from someone who knows mips that these changes in ifdefs are okay, otherwise:

I guess we know the answer thus we don't have to bother mips folks. But very good catch.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH v8 1/4] Refactor regen.sh script to generate syscalls

Hi Petr,

Quoted 55 lines · Petr Vorel

Hi all,

Quoted 11 lines

Hi!

include/lapi/syscalls/generate_syscalls.sh line 77

Quoted 10 lines
include/lapi/syscalls/generate_syscalls.sh new file +10 -0
+while IFS= read -r arch; do
+	(
+		echo
+		case ${arch} in
+		sparc64) echo "#if defined(__sparc__) && defined(__arch64__)" ;;
+		sparc) echo "#if defined(__sparc__) && !defined(__arch64__)" ;;
+		s390) echo "#if defined(__s390__) && !defined(__s390x__)" ;;
+		mips64n32) echo "#if defined(__mips__) && defined(_ABIN32)" ;;
+		mips64) echo "#if defined(__mips__) && defined(_ABI64)" ;;
+		mipso32) echo "#if defined(__mips__) && defined(_ABIO32) && _MIPS_SZLONG == 32" ;;

The original code was:

include/lapi/syscalls/regen.sh deleted +0 -3
-		mips_n32) echo "#if defined(__mips__) && defined(_ABIN32)" ;;
-		mips_n64) echo "#if defined(__mips__) && defined(_ABI64)" ;;
-		mips_o32) echo "#if defined(__mips__) && defined(_ABIO32) && _MIPS_SZLONG == 32" ;;

ifdefs are the same, the only thing which changed are arch names. And these are also changed, see below. The only problem I see is that the change in supported-arch.txt below happens in the following commit. Shouldn't the rename happen in this commit already? syscalls.h file generated from the first commit is indeed different from the one generated in 2nd and 3rd (which are the same.

+++ b/include/lapi/syscalls/supported-arch.txt

(quoted diff) +6 -6
@@ -1,13 +1,13 @@
-aarch64
  arc
+arm64
  arm
-hppa
  i386
  ia64
-loongarch
-mips_n32
-mips_n64
-mips_o32
+loongarch64
+mips64n32
+mips64
+mipso32
+parisc
  powerpc64
  powerpc
  s390x

1st commit have (which is IMHO wrong)
#ifdef __mips_n32__

2nd and 3rd have:
#if defined(__mips__) && defined(_ABIN32)

The reason due postponed changes is, that some arch use

Quoted 8 lines

*) echo "#ifdef __${arch}__" ;;

Whoever will do bisecting, cannot use this commit on mips and other affected archs due broken syscalls.h. This problem appeared in v5. Previously (v3 and v4) old names were used in generate_syscalls.sh, and in second commit (when the generate_arch.sh archs was added) were new ones used.

IMHO clearest solution would be to move rename to 1st commit.

I agree with it. I'm going to fix it.

Quoted 8 lines
Quoted 3 lines

It would be nice to get a confirmation from someone who knows mips that these changes in ifdefs are okay, otherwise:

I guess we know the answer thus we don't have to bother mips folks. But very good catch.

Kind regards,
Petr

Andrea

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH v8 2/4 Add script to generate arch(s) dependant syscalls

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

Add generate_arch.sh script which can be used to generate arch(s) dependant syscalls file. The way it works is pretty simple: for each architecture defined into supported-arch.txt, compile kernel headers, extract the list of syscalls and generate a .in file containing all of them, associated with their own syscall's number.
The way syscalls files are generated, passes through a C application which is automatically checking the availability of the syscalls in the user space environment.

---
 include/lapi/syscalls/{aarch64.in => arm64.in}     |   0
 include/lapi/syscalls/generate_arch.sh             | 206 +++++++++++++++++++++
 .../lapi/syscalls/{loongarch.in => loongarch64.in} |   0
 include/lapi/syscalls/{mips_n64.in => mips64.in}   |   0
 .../lapi/syscalls/{mips_n32.in => mips64n32.in}    |   0
 include/lapi/syscalls/{mips_o32.in => mipso32.in}  |   0
 include/lapi/syscalls/{hppa.in => parisc.in}       |   0
 include/lapi/syscalls/supported-arch.txt           |  12 +-
 8 files changed, 212 insertions(+), 6 deletions(-)
include/lapi/syscalls/arm64.in renamed from include/lapi/syscalls/aarch64.in +0 -0
similarity index 100%
rename from include/lapi/syscalls/aarch64.in
rename to include/lapi/syscalls/arm64.in
include/lapi/syscalls/generate_arch.sh new file +206 -0

206 lines not on this page · raw message

include/lapi/syscalls/loongarch64.in renamed from include/lapi/syscalls/loongarch.in +0 -0
similarity index 100%
rename from include/lapi/syscalls/loongarch.in
rename to include/lapi/syscalls/loongarch64.in
include/lapi/syscalls/mips64.in renamed from include/lapi/syscalls/mips_n64.in +0 -0
similarity index 100%
rename from include/lapi/syscalls/mips_n64.in
rename to include/lapi/syscalls/mips64.in
include/lapi/syscalls/mips64n32.in renamed from include/lapi/syscalls/mips_n32.in +0 -0
similarity index 100%
rename from include/lapi/syscalls/mips_n32.in
rename to include/lapi/syscalls/mips64n32.in
include/lapi/syscalls/mipso32.in renamed from include/lapi/syscalls/mips_o32.in +0 -0
similarity index 100%
rename from include/lapi/syscalls/mips_o32.in
rename to include/lapi/syscalls/mipso32.in
include/lapi/syscalls/parisc.in renamed from include/lapi/syscalls/hppa.in +0 -0
similarity index 100%
rename from include/lapi/syscalls/hppa.in
rename to include/lapi/syscalls/parisc.in
include/lapi/syscalls/supported-arch.txt +6 -6
index c18aa38cf4546cdf3ac8c89a45bd1b202ffa7711..c5c5191ac08482d89f0a8c39dfae936538f58f7f 100644
@@ -1,13 +1,13 @@
-aarch64
 arc
+arm64
 arm
-hppa
 i386
 ia64
-loongarch
-mips_n32
-mips_n64
-mips_o32
+loongarch64
+mips64n32
+mips64
+mipso32
+parisc
 powerpc64
 powerpc
 s390x
Signature · 5 lines
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v8 2/4
#6 lore raw

Re: [LTP] [PATCH v8 2/4] Add script to generate arch(s) dependant syscalls

Hi Andrea,

the script works for me, great!

Few more comments, I promis the last one, feel free to just ignore them.

include/lapi/syscalls/generate_arch.sh line 2

Quoted 5 lines
include/lapi/syscalls/generate_arch.sh new file +2 -0
@@ -0,0 +1,206 @@
+#!/bin/sh -eu
+# SPDX-License-Identifier: GPL-2.0-or-later

I would put here your/SUSE/LTP copyright (2024) and the original author copyright:
# Copyright (c) Marcin Juszkiewicz, 2023-2024

The author does not have it in the script, but it has in LICENSE:
Copyright (c) Marcin Juszkiewicz

But I'm not a lawyer, maybe I'm wrong.

Quoted 4 lines
include/lapi/syscalls/generate_arch.sh new file +4 -0
+#
+# This is an adaptation of the update-tables.sh script, included in the
+# syscalls-table project (https://github.com/hrw/syscalls-table) and released
+# under the MIT license.

include/lapi/syscalls/generate_arch.sh line 16

Quoted 10 lines
include/lapi/syscalls/generate_arch.sh new file +10 -0
+#
+# Author: Andrea Cervesato <[email protected]>
+
+if [ "$#" -eq "0" ]; then
+	echo "Please provide kernel sources:"
+	echo ""
+	echo "$0 path/to/Linux/kernel/sources"
+	echo ""
+	exit 1
+fi

nit: use common syntax ($# is always defined, thus not need to be quoted, 0 as well, "" is empty string, thus can be omitted):
if [ $# -eq 0 ]; then
echo "Please provide kernel sources:"
echo
echo "$0 path/to/Linux/kernel/sources"
echo
exit 1
fi

...

include/lapi/syscalls/generate_arch.sh line 90

Quoted 2 lines
include/lapi/syscalls/generate_arch.sh new file +2 -0
+generate_list_syscalls_c() {
+	(

very nit: this first echo is probably not needed.

Quoted 19 lines
include/lapi/syscalls/generate_arch.sh new file +19 -0
+		echo
+		echo "
+		#include <stdio.h>
+		#include <asm/unistd.h>
+
+		int main(void)
+		{
+		"
+		for syscall in $(cat ${TEMP}/syscall-names.txt); do
+			echo "
+		#ifdef __NR_$syscall
+			printf(\"$syscall %d\\\n\", __NR_$syscall);
+		#endif
+		"
+		done
+		echo " return 0;
+		}"
+	) >${TEMP}/list-syscalls.c
+}

...

Quoted 4 lines
include/lapi/syscalls/generate_arch.sh new file +4 -0
+
+do_all_tables() {
+	for archdir in ${KERNELSRC}/arch/*; do
+		arch=$(basename $archdir)

...

include/lapi/syscalls/generate_arch.sh line 178

Quoted 6 lines
include/lapi/syscalls/generate_arch.sh new file +6 -0
+			arch=x86_64 extraflags=-D__LP64__ generate_table
+			bits=32
+			arch=i386 generate_table
+			arch=x32 extraflags=-D__ILP32__ generate_table
+			;;
+		arc | csky | hexagon | m68k | microblaze | nios2 | openrisc | sh | xtensa)

I've never seen spaces between '|' separator in shell case command. It should not cause anything, but it's just unusual (original code in
https://github.com/hrw/syscalls-table/blob/master/scripts/update-tables.sh
from which we diverged quite a lot now also does not have it).

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

PATCH v8 3/4 Delete obsolete strip_syscall.awk file

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

---
 include/lapi/syscalls/strip_syscall.awk | 19 -------------------
 1 file changed, 19 deletions(-)
include/lapi/syscalls/strip_syscall.awk deleted +0 -19
deleted file mode 100755
index e8dff422e2667745c144ed984a4d66461fcce0c6..0000000000000000000000000000000000000000
@@ -1,19 +0,0 @@
-#!/usr/bin/awk -f
-#
-# Dumb script that can be used to strip all of the syscall information from
-# the arch-respective unistd*.h.
-#
-# Examples:
-#
-# 1. Grab the i386 32-bit syscalls from unistd_32.h and put them in i386.in
-# strip_syscall.awk arch/x86/include/asm/unistd_32.h > i386.in
-#
-
-/^#define[[:space:]]+__NR_[0-9a-z]+/ {
-
-	sub (/#define[[:space:]]+__NR_/, "", $0);
-	sub (/[[:space:]]*(\/\*.*)/, "", $0);
-	sub (/[[:space:]]+/, " ", $0);
-
-	print
-}
Signature · 5 lines
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

PATCH v8 4/4 Add documentation about syscalls.h generator

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

---
 doc/developers/test_case_tutorial.rst | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
doc/developers/test_case_tutorial.rst +14 -13
index be9a0ea8bac1d690b4ed4879d110f87c3f2a381a..b48ea4a7a3594266466fcca364f5d0ff1e42d235 100644
@@ -302,24 +302,25 @@ for a distribution's C library version to be older than its kernel or it may use
 cut down C library in comparison to the GNU one. So we must call ``statx()``
 using the general ``syscall()`` interface.
 
-The LTP contains a library for dealing with the ``syscall`` interface, which is
+LTP contains a library for dealing with the ``syscall`` interface, which is
 located in :master:`include/lapi`. System call numbers are listed against the relevant
 call in the ``*.in`` files (e.g. ``x86_64.in``) which are used to generate
-``syscalls.h``, which is the header you should include. On rare occasions you
-may find the system call number is missing from the ``*.in`` files and will need
-to add it (see :master:`include/lapi/syscalls/strip_syscall.awk`).
+``syscalls.h``, the header you should include.
 
-System call numbers vary between architectures, hence there are multiple
-``*.in`` files for each architecture. You can find the various values for the
-``statx`` system call across a number of ``unistd.h`` files in the Linux kernel.
+On rare occasions, you may find that system call number is missing from ``*.in``
+files. In these cases, they will need to be updated using
+`include/lapi/syscalls/generate_arch.sh` script as following:
 
-Note that we don't use the system-call-identifier value available in
-``/usr/include/linux/uinstd.h`` because the kernel might be much newer than the
-user land development packages.
+.. code-block:: bash
+
+    $ include/lapi/syscalls/generate_arch.sh /path/of/linux/sources
+
+The script will generate all the needed ``*.in`` files according to the Linux
+source code which has been used. Make sure that your Linux source code has
+been updated to the latest version.
 
-For ``statx`` we had to add ``statx 332`` to :master:`include/lapi/syscalls/x86_64.in`,
-``statx 383`` to :master:`include/lapi/syscalls/powerpc.in`, etc.  Now lets look at
-the code, which I will explain in more detail further down.
+Once the new syscalls files have been updated, to rebuild our ``syscalls.h``
+file, please use ``./configure`` command.
 
 .. code-block:: c
 
Signature · 5 lines
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw

Re: [LTP] [PATCH v8 4/4] Add documentation about syscalls.h generator

Hi!

Quoted 14 lines
---
 doc/developers/test_case_tutorial.rst | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
doc/developers/test_case_tutorial.rst +0 -1
index be9a0ea8bac1d690b4ed4879d110f87c3f2a381a..b48ea4a7a3594266466fcca364f5d0ff1e42d235 100644
@@ -302,24 +302,25 @@ for a distribution's C library version to be older than its kernel or it may use
 cut down C library in comparison to the GNU one. So we must call ``statx()``
 using the general ``syscall()`` interface.
 
-The LTP contains a library for dealing with the ``syscall`` interface, which is

doc/developers/test_case_tutorial.rst for a distribution's C library version to be older than its kernel or it may use · line 313

Quoted 10 lines
doc/developers/test_case_tutorial.rst +2 -5
+LTP contains a library for dealing with the ``syscall`` interface, which is
 located in :master:`include/lapi`. System call numbers are listed against the relevant
 call in the ``*.in`` files (e.g. ``x86_64.in``) which are used to generate
-``syscalls.h``, which is the header you should include. On rare occasions you
-may find the system call number is missing from the ``*.in`` files and will need
-to add it (see :master:`include/lapi/syscalls/strip_syscall.awk`).
+``syscalls.h``, the header you should include.
 
-System call numbers vary between architectures, hence there are multiple
-``*.in`` files for each architecture.

I would keep this sentence in there, probably as a last sentence in the upper paragraph.

doc/developers/test_case_tutorial.rst for a distribution's C library version to be older than its kernel or it may use · line 312

Quoted 5 lines
doc/developers/test_case_tutorial.rst +3 -2
- You can find the various values for the
-``statx`` system call across a number of ``unistd.h`` files in the Linux kernel.
+On rare occasions, you may find that system call number is missing from ``*.in``
+files. In these cases, they will need to be updated using
+`include/lapi/syscalls/generate_arch.sh` script as following:

^
Just generate_arch.sh here, we list the full path in the code block, no need to repeat it here as well.

doc/developers/test_case_tutorial.rst for a distribution's C library version to be older than its kernel or it may use · line 316

Quoted 6 lines
doc/developers/test_case_tutorial.rst +3 -3
-Note that we don't use the system-call-identifier value available in
-``/usr/include/linux/uinstd.h`` because the kernel might be much newer than the
-user land development packages.
+.. code-block:: bash
+
+    $ include/lapi/syscalls/generate_arch.sh /path/of/linux/sources
                                                      ^
						      to

doc/developers/test_case_tutorial.rst for a distribution's C library version to be older than its kernel or it may use · line 318

Quoted 1 line
doc/developers/test_case_tutorial.rst +1 -0
+The script will generate all the needed ``*.in`` files according to the Linux
                                                            ^
							  accordingly

doc/developers/test_case_tutorial.rst for a distribution's C library version to be older than its kernel or it may use · line 323

Quoted 8 lines
doc/developers/test_case_tutorial.rst +4 -3
+source code which has been used. Make sure that your Linux source code has
+been updated to the latest version.
 
-For ``statx`` we had to add ``statx 332`` to :master:`include/lapi/syscalls/x86_64.in`,
-``statx 383`` to :master:`include/lapi/syscalls/powerpc.in`, etc.  Now lets look at
-the code, which I will explain in more detail further down.
+Once the new syscalls files have been updated, to rebuild our ``syscalls.h``
+file, please use ``./configure`` command.

^ ^
re-run script

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH v8 4/4] Add documentation about syscalls.h generator

HI Andrea, Cyril,

Quoted 14 lines
Quoted 13 lines

+++ b/doc/developers/test_case_tutorial.rst

doc/developers/test_case_tutorial.rst +2 -4
@@ -302,24 +302,25 @@ for a distribution's C library version to be older than its kernel or it may use
 cut down C library in comparison to the GNU one. So we must call ``statx()``
 using the general ``syscall()`` interface.
 
-The LTP contains a library for dealing with the ``syscall`` interface, which is
+LTP contains a library for dealing with the ``syscall`` interface, which is
 located in :master:`include/lapi`. System call numbers are listed against the relevant
 call in the ``*.in`` files (e.g. ``x86_64.in``) which are used to generate
-``syscalls.h``, which is the header you should include. On rare occasions you
-may find the system call number is missing from the ``*.in`` files and will need
-to add it (see :master:`include/lapi/syscalls/strip_syscall.awk`).
+``syscalls.h``, the header you should include.
Quoted 5 lines

Review for a distribution's C library version to be older than its kernel or it may use · line 312

Quoted 2 lines
(quoted diff) +0 -2
-System call numbers vary between architectures, hence there are multiple
-``*.in`` files for each architecture.

I would keep this sentence in there, probably as a last sentence in the upper paragraph.

+1

Quoted 8 lines

doc/developers/test_case_tutorial.rst for a distribution's C library version to be older than its kernel or it may use · line 312

Quoted 5 lines
doc/developers/test_case_tutorial.rst +3 -2
- You can find the various values for the
-``statx`` system call across a number of ``unistd.h`` files in the Linux kernel.
+On rare occasions, you may find that system call number is missing from ``*.in``
+files. In these cases, they will need to be updated using
+`include/lapi/syscalls/generate_arch.sh` script as following:

^
Just generate_arch.sh here, we list the full path in the code block, no need to repeat it here as well.

+1. BTW it should be either ``generate_arch.sh`` (double `` is used for other commands, e.g. ``make check`` or ``./configure``) or it could be a link to a source:

:master:include/lapi/syscalls/generate_arch.sh script as following:

I like links, because reader can see the script content. Also it can help to verify whether the script is still at the repository (was not moved/deleted).

Quoted 8 lines

doc/developers/test_case_tutorial.rst for a distribution's C library version to be older than its kernel or it may use · line 316

Quoted 6 lines
doc/developers/test_case_tutorial.rst +3 -3
-Note that we don't use the system-call-identifier value available in
-``/usr/include/linux/uinstd.h`` because the kernel might be much newer than the
-user land development packages.
+.. code-block:: bash
+
+    $ include/lapi/syscalls/generate_arch.sh /path/of/linux/sources
                                                      ^
						      to

very nit: "path/to/Linux/kernel/sources" (upper "L", which you use later, also it's used in the script).

Quoted 3 lines

doc/developers/test_case_tutorial.rst for a distribution's C library version to be older than its kernel or it may use · line 318

Quoted 1 line
doc/developers/test_case_tutorial.rst +1 -0
+The script will generate all the needed ``*.in`` files according to the Linux
                                                            ^
							  accordingly

+1

Quoted 10 lines

doc/developers/test_case_tutorial.rst for a distribution's C library version to be older than its kernel or it may use · line 323

Quoted 8 lines
doc/developers/test_case_tutorial.rst +4 -3
+source code which has been used. Make sure that your Linux source code has
+been updated to the latest version.
 
-For ``statx`` we had to add ``statx 332`` to :master:`include/lapi/syscalls/x86_64.in`,
-``statx 383`` to :master:`include/lapi/syscalls/powerpc.in`, etc.  Now lets look at
-the code, which I will explain in more detail further down.
+Once the new syscalls files have been updated, to rebuild our ``syscalls.h``
+file, please use ``./configure`` command.

^ ^
re-run script

+1

Otherwise LGTM, thanks a lot for bothering with the docs.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp