@@ -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
similarity index 100%
rename from include/lapi/syscalls/aarch64.in
rename to include/lapi/syscalls/arm64.in
new file mode 100755
@@ -0,0 +1,109 @@
+#!/bin/sh -eu
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Generate the syscalls.h file, merging all architectures syscalls input file
+# which are in the current folder and defined inside supported-arch.txt file.
+
+SYSCALLS_FILE="$1"
+
+if [ -z "${SYSCALLS_FILE}" ]; then
+ echo "Please provide the syscalls.h directory:"
+ echo ""
+ echo "$0 path/of/syscalls.h"
+ echo ""
+ exit 1
+fi
+
+SCRIPT_DIR="$(realpath $(dirname "$0"))"
+SUPPORTED_ARCH="${SCRIPT_DIR}/supported-arch.txt"
+
+echo '// SPDX-License-Identifier: GPL-2.0-or-later
+/************************************************
+ * GENERATED FILE: DO NOT EDIT/PATCH THIS FILE *
+ * change your arch specific .in file instead *
+ ************************************************/
+
+/*
+ * Here we stick all the ugly *fallback* logic for linux
+ * system call numbers (those __NR_ thingies).
+ */
+
+#ifndef LAPI_SYSCALLS_H__
+#define LAPI_SYSCALLS_H__
+
+#include <errno.h>
+#include <sys/syscall.h>
+#include <asm/unistd.h>
+
+#ifdef TST_TEST_H__
+#define TST_SYSCALL_BRK__(NR, SNR) ({ \
+tst_brk(TCONF, \
+ "syscall(%d) " SNR " not supported on your arch", NR); \
+})
+#else
+inline static void dummy_cleanup(void) {}
+
+#define TST_SYSCALL_BRK__(NR, SNR) ({ \
+tst_brkm(TCONF, dummy_cleanup, \
+ "syscall(%d) " SNR " not supported on your arch", NR); \
+})
+#endif
+
+#define tst_syscall(NR, ...) ({ \
+intptr_t tst_ret; \
+if (NR == __LTP__NR_INVALID_SYSCALL) { \
+ errno = ENOSYS; \
+ tst_ret = -1; \
+} else { \
+ tst_ret = syscall(NR, ##__VA_ARGS__); \
+} \
+if (tst_ret == -1 && errno == ENOSYS) { \
+ TST_SYSCALL_BRK__(NR, #NR); \
+} \
+tst_ret; \
+})
+
+#define __LTP__NR_INVALID_SYSCALL -1' >${SYSCALLS_FILE}
+
+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" ;;
+ parisc) echo "#ifdef __hppa__" ;;
+ loongarch64) echo "#ifdef __loongarch__" ;;
+ arm64) echo "#ifdef __aarch64__" ;;
+ *) echo "#ifdef __${arch}__" ;;
+ esac
+
+ while read -r line; do
+ set -- ${line}
+ syscall_nr="__NR_$1"
+ shift
+
+ echo "# ifndef ${syscall_nr}"
+ echo "# define ${syscall_nr} $*"
+ echo "# endif"
+ done <"${SCRIPT_DIR}/${arch}.in"
+ echo "#endif"
+ echo
+ ) >>${SYSCALLS_FILE}
+done <${SUPPORTED_ARCH}
+
+(
+ echo
+ echo "/* Common stubs */"
+ for num in $(awk '{print $1}' "${SCRIPT_DIR}/"*.in | sort -u); do
+ syscall_nr="__NR_${num}"
+
+ echo "# ifndef ${syscall_nr}"
+ echo "# define ${syscall_nr} __LTP__NR_INVALID_SYSCALL"
+ echo "# endif"
+ done
+ echo "#endif"
+) >>${SYSCALLS_FILE}
similarity index 100%
rename from include/lapi/syscalls/loongarch.in
rename to include/lapi/syscalls/loongarch64.in
similarity index 100%
rename from include/lapi/syscalls/mips_n64.in
rename to include/lapi/syscalls/mips64.in
similarity index 100%
rename from include/lapi/syscalls/mips_n32.in
rename to include/lapi/syscalls/mips64n32.in
similarity index 100%
rename from include/lapi/syscalls/mips_o32.in
rename to include/lapi/syscalls/mipso32.in
similarity index 100%
rename from include/lapi/syscalls/hppa.in
rename to include/lapi/syscalls/parisc.in
deleted file mode 100755
@@ -1,129 +0,0 @@
-#!/bin/sh
-
-output="syscalls.h"
-rm -f "${output}".[1-9]*
-output_pid="${output}.$$"
-
-max_jobs=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
-: ${max_jobs:=1}
-
-srcdir=${0%/*}
-
-err() {
- echo "$*" 1>&2
- exit 1
-}
-
-cat << EOF > "${output_pid}"
-/************************************************
- * GENERATED FILE: DO NOT EDIT/PATCH THIS FILE *
- * change your arch specific .in file instead *
- ************************************************/
-
-/*
- * Here we stick all the ugly *fallback* logic for linux
- * system call numbers (those __NR_ thingies).
- *
- * Licensed under the GPLv2 or later, see the COPYING file.
- */
-
-#ifndef LAPI_SYSCALLS_H__
-#define LAPI_SYSCALLS_H__
-
-#include <errno.h>
-#include <sys/syscall.h>
-#include <asm/unistd.h>
-
-#ifdef TST_TEST_H__
-#define TST_SYSCALL_BRK__(NR, SNR) ({ \\
- tst_brk(TCONF, \\
- "syscall(%d) " SNR " not supported on your arch", NR); \\
-})
-#else
-inline static void dummy_cleanup(void) {}
-
-#define TST_SYSCALL_BRK__(NR, SNR) ({ \\
- tst_brkm(TCONF, dummy_cleanup, \\
- "syscall(%d) " SNR " not supported on your arch", NR); \\
-})
-#endif
-
-#define tst_syscall(NR, ...) ({ \\
- intptr_t tst_ret; \\
- if (NR == __LTP__NR_INVALID_SYSCALL) { \\
- errno = ENOSYS; \\
- tst_ret = -1; \\
- } else { \\
- tst_ret = syscall(NR, ##__VA_ARGS__); \\
- } \\
- if (tst_ret == -1 && errno == ENOSYS) { \\
- TST_SYSCALL_BRK__(NR, #NR); \\
- } \\
- tst_ret; \\
-})
-
-EOF
-
-jobs=0
-for arch in $(cat "${srcdir}/order") ; do
- (
- echo "Generating data for arch $arch ... "
-
- (
- 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__)" ;;
- 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" ;;
- *) echo "#ifdef __${arch}__" ;;
- esac
- while read line ; do
- set -- ${line}
- nr="__NR_$1"
- shift
- if [ $# -eq 0 ] ; then
- err "invalid line found: $line"
- fi
- echo "# ifndef ${nr}"
- echo "# define ${nr} $*"
- echo "# endif"
- done < "${srcdir}/${arch}.in"
- echo "#endif"
- echo
- ) >> "${output_pid}.${arch}"
-
- ) &
-
- jobs=$(( jobs + 1 ))
- if [ ${jobs} -ge ${max_jobs} ] ; then
- wait || exit 1
- jobs=0
- fi
-done
-
-echo "Generating stub list ... "
-(
-echo
-echo "/* Common stubs */"
-echo "#define __LTP__NR_INVALID_SYSCALL -1" >> "${output_pid}"
-for nr in $(awk '{print $1}' "${srcdir}/"*.in | sort -u) ; do
- nr="__NR_${nr}"
- echo "# ifndef ${nr}"
- echo "# define ${nr} __LTP__NR_INVALID_SYSCALL"
- echo "# endif"
-done
-echo "#endif"
-) >> "${output_pid}._footer"
-
-wait || exit 1
-
-printf "Combining them all ... "
-for arch in $(cat "${srcdir}/order") _footer ; do
- cat "${output_pid}.${arch}"
-done >> "${output_pid}"
-mv "${output_pid}" "../${output}"
-rm -f "${output_pid}"*
-echo "OK!"
similarity index 58%
rename from include/lapi/syscalls/order
rename to 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