Subject: bug#41264: bug#49985: Bootstrap packages fail to build due to mes-libc lacking 'stat64' etc. syscalls

From: Jan Nieuwenhuizen <[email-masked]>
Date: Mon, 13 Feb 2023 12:28:54 +0100

Jan Nieuwenhuizen writes:

Hello!

> Mathieu Othacehe writes:
[..]
>> lib/linux/stat.c should be modified this way:
>>
>> #if __i386__
>> #define STAT_SYSCALL SYS_stat64
>> #else
>> #define STAT_SYSCALL SYS_stat
>> #endif
>
> Ah...the stat64 syscall is meant for i386; now it at starts making at
> least some sense to me.
[..]
>> This way, we would replicate the glibc behavior.
>
> Beautiful, thanks for getting to the bottom of this.  Now that you
> already have gone this far, would you like to whip-up a full patch for
> GNU Mes?
[..]

To use stat64 and friends on 32bit, I created the attached patch for GNU
Mes and hope to create a 0.24.2 release from

    https://gitlab.com/janneke/mes/-/tree/wip-stat64

Also, I have update my core-updates branch with preliminary 0.24.2 mes
and mes-boot packages here

    https://gitlab.com/janneke/guix/-/tree/core-updates

Greetings,
Janneke

From bc1fa57851d360abb161c54dce5339ad9d7af7aa Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <[email-masked]>
Date: Sat, 29 Oct 2022 13:17:58 +0200
Subject: [PATCH] lib: stat: Use SYS_stat64 for 32bit platforms.

This fixes <https://debbugs.gnu.org/41264>.

* include/linux/arm/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/linux/x86/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/sys/stat.h (struct stat): Move definition to...
* include/linux/arm/kernel-stat.h,
include/linux/m2/kernel-stat.h,
include/linux/x86/kernel-stat.h,
include/linux/x86_64/kernel-stat.h: These new files.
* include/gnu/x86/kernel-stat.h: New file.
* configure (main): Copy <srcdest>include/<kernel>/<arch>/*.h to
include/.
* configure.sh: Likewise.
* .gitignore: Ignore them.  Add copyright header.
* build-aux/GNUmakefile.in (X86_ARCH_HEADERS, ARCH_HEADERS): New
variables.
(build): Use them.
(include/arch/%.h, arch-dir): New targets.
* build-aux/bootstrap.sh.in (AM_CPPFLAGS): Replace
<srcdest>include/<kernel>/<cpu> with built ../include.
* build-aux/build.sh.in (AM_CPPFLAGS): Likewise.
* build-aux/install.sh.in: Also install built include.
* include/m2/types.h: New file.
* kaem.run: Use it.
* simple.sh: Copy kernel-stat.h, syscall.h for kernel/cpu to
include/arch.
---
 .gitignore                         |  19 ++++
 build-aux/GNUmakefile.in           |  11 ++-
 build-aux/bootstrap.sh.in          |   4 +-
 build-aux/build.sh.in              |  11 ++-
 build-aux/install.sh.in            |   3 +-
 configure                          |   7 ++
 configure.sh                       |   4 +
 include/gnu/x86/kernel-stat.h      |  25 ++++++
 include/linux/arm/kernel-stat.h    |  79 +++++++++++++++++
 include/linux/arm/syscall.h        |  19 ++++
 include/linux/m2/kernel-stat.h     |  47 ++++++++++
 include/linux/x86/kernel-stat.h    |  79 +++++++++++++++++
 include/linux/x86/syscall.h        |  20 ++++-
 include/linux/x86_64/kernel-stat.h |  51 +++++++++++
 include/m2/types.h                 | 138 +++++++++++++++++++++++++++++
 include/sys/stat.h                 |  51 +----------
 kaem.run                           |   3 +
 lib/linux/_getcwd.c                |   4 +-
 lib/linux/_open3.c                 |   2 +-
 lib/linux/_read.c                  |   4 +-
 lib/linux/access.c                 |   4 +-
 lib/linux/brk.c                    |   4 +-
 lib/linux/chdir.c                  |   4 +-
 lib/linux/chmod.c                  |   4 +-
 lib/linux/clock_gettime.c          |   4 +-
 lib/linux/close.c                  |   4 +-
 lib/linux/dup.c                    |   4 +-
 lib/linux/dup2.c                   |   4 +-
 lib/linux/execve.c                 |   4 +-
 lib/linux/fcntl.c                  |   4 +-
 lib/linux/fork.c                   |   4 +-
 lib/linux/fstat.c                  |   4 +-
 lib/linux/fsync.c                  |   4 +-
 lib/linux/getdents.c               |   4 +-
 lib/linux/getegid.c                |   4 +-
 lib/linux/geteuid.c                |   4 +-
 lib/linux/getgid.c                 |   4 +-
 lib/linux/getpid.c                 |   4 +-
 lib/linux/getppid.c                |   4 +-
 lib/linux/getrusage.c              |   4 +-
 lib/linux/gettimeofday.c           |   4 +-
 lib/linux/getuid.c                 |   4 +-
 lib/linux/ioctl.c                  |   2 +-
 lib/linux/ioctl3.c                 |   2 +-
 lib/linux/kill.c                   |   4 +-
 lib/linux/link.c                   |   4 +-
 lib/linux/lseek.c                  |   2 +-
 lib/linux/lstat.c                  |   4 +-
 lib/linux/mkdir.c                  |   4 +-
 lib/linux/mknod.c                  |   4 +-
 lib/linux/nanosleep.c              |   4 +-
 lib/linux/pipe.c                   |   4 +-
 lib/linux/read.c                   |   2 +-
 lib/linux/readlink.c               |   4 +-
 lib/linux/rename.c                 |   4 +-
 lib/linux/rmdir.c                  |   4 +-
 lib/linux/setgid.c                 |   4 +-
 lib/linux/settimer.c               |   4 +-
 lib/linux/setuid.c                 |   4 +-
 lib/linux/signal.c                 |   4 +-
 lib/linux/sigprogmask.c            |   4 +-
 lib/linux/stat.c                   |   4 +-
 lib/linux/symlink.c                |   4 +-
 lib/linux/time.c                   |   2 +-
 lib/linux/unlink.c                 |   4 +-
 lib/linux/waitpid.c                |   2 +-
 lib/m2/execve.c                    |   4 +-
 lib/m2/open.c                      |   2 +
 lib/m2/time.c                      |   2 +-
 lib/m2/waitpid.c                   |   2 +-
 simple.sh                          |  12 ++-
 71 files changed, 617 insertions(+), 158 deletions(-)
 create mode 100644 include/gnu/x86/kernel-stat.h
 create mode 100644 include/linux/arm/kernel-stat.h
 create mode 100644 include/linux/m2/kernel-stat.h
 create mode 100644 include/linux/x86/kernel-stat.h
 create mode 100644 include/linux/x86_64/kernel-stat.h
 create mode 100644 include/m2/types.h

diff --git a/.gitignore b/.gitignore
index 58cb2afb..72ba34d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,21 @@
+# GNU Mes --- Maxwell Equations of Software
+# Copyright © 2016,2017,2019,2020,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
+#
+# This file is part of GNU Mes.
+#
+# GNU Mes is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Mes is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
+
 *-
 *~
 .#*
@@ -117,6 +135,7 @@
 /doc/images/gcc-mesboot-graph.pdf
 /doc/web/
 /config.sh
+/include/arch
 /include/mes/config.h
 /gcc-lib
 /mescc-lib
diff --git a/build-aux/GNUmakefile.in b/build-aux/GNUmakefile.in
index d74e9f99..c3304192 100644
--- a/build-aux/GNUmakefile.in
+++ b/build-aux/GNUmakefile.in
@@ -85,17 +85,26 @@ PHONY_TARGETS:=\
 
 .PHONY: $(PHONY_TARGETS)
 
+X86_ARCH_HEADERS = $(wildcard $(scrdest)include/linux/x86/*.h)
+ARCH_HEADERS = $(X86_ARCH_HEADERS:$(srcdest)include/linux/x86/%=include/arch/%)
+
 default: all
 
 all: doc
 
 doc: build
 
-build:
+build: | $(ARCH_HEADERS)
 	$(SHELL) build.sh
 
 src/${program_prefix}mes: build
 
+include/arch/%.h: $(srcdest)include/$(mes_kernel)/$(mes_cpu)/%.h | arch-dir
+	cp -f $< $@
+
+arch-dir:
+	mkdir -p include/arch
+
 clean:
 	rm -f *.o *.s bin/mes bin/mes-gcc bin/mes-mescc
 	rm -f mes.{aux,cp,cps,fn,info,log,tmp,toc,vr,vrs}
diff --git a/build-aux/bootstrap.sh.in b/build-aux/bootstrap.sh.in
index b2d56c50..a2451d02 100644
--- a/build-aux/bootstrap.sh.in
+++ b/build-aux/bootstrap.sh.in
@@ -50,7 +50,7 @@ srcdest=../${srcdest}
 ln -sf ${srcdest}mes .
 ln -sf ${srcdest}module .
 ln -sf ${srcdest}src .
-AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_kernel/$mes_cpu"
+AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ../include -I include"
 AM_CFLAGS="-L ${srcdest}lib"
 
 mkdir -p $mes_cpu-mes
@@ -108,7 +108,7 @@ $AR crD $mes_cpu-mes/libc+tcc.a $objects
 
 cd ..
 srcdest=
-CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_kernel/$mes_cpu"
+AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ../include -I include"
 AM_CFLAGS="-L ${srcdest}lib"
 
 objects=
diff --git a/build-aux/build.sh.in b/build-aux/build.sh.in
index f4a6a264..3f356e10 100644
--- a/build-aux/build.sh.in
+++ b/build-aux/build.sh.in
@@ -66,9 +66,8 @@ fi
         AM_CPPFLAGS="
 -D HAVE_CONFIG_H=1
 -I ${srcdest}lib
--I include
 -I ${srcdest}include
--I ${srcdest}include/$mes_kernel/$mes_cpu
+-I ../include
 "
         if test $mes_kernel = gnu; then
             AM_CPPFLAGS="$AM_CPPFLAGS
@@ -93,9 +92,9 @@ fi
     AM_CPPFLAGS="
 -D HAVE_CONFIG_H=1
 -I ${srcdest}lib
--I include
 -I ${srcdest}include
--I ${srcdest}include/$mes_kernel/$mes_cpu
+-I ../include
+-I include
 "
     if test "$compiler" != bootstrap; then
         ${SHELL} ${srcdest}build-aux/build-mes.sh
@@ -137,9 +136,9 @@ fi
     AM_CPPFLAGS="
 -D HAVE_CONFIG_H=1
 -I ${srcdest}lib
--I include
 -I ${srcdest}include
--I ${srcdest}include/$mes_kernel/$mes_cpu
+-I ../include
+-I include
 "
     compiler=mescc
     AR=${MESAR-"${srcdest}pre-inst-env mesar"}
diff --git a/build-aux/install.sh.in b/build-aux/install.sh.in
index 340faf5f..f3a69229 100644
--- a/build-aux/install.sh.in
+++ b/build-aux/install.sh.in
@@ -1,7 +1,7 @@
 #! @SHELL@
 
 # GNU Mes --- Maxwell Equations of Software
-# Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+# Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
 #
 # This file is part of GNU Mes.
 #
@@ -99,6 +99,7 @@ mkdir -p $DESTDIR$includedir
 mkdir -p $DESTDIR$libdir
 mkdir -p $DESTDIR$pkgdatadir
 tar -cf- -C ${srcdir}/include . | tar -${v}xf- -C $DESTDIR$includedir
+tar -cf- -C include . | tar -${v}xf- -C $DESTDIR$includedir
 tar -cf- -C ${srcdir}/lib $mes_cpu-mes | tar -${v}xf- -C $DESTDIR$libdir
 tar -cf- -C ${srcdir}/lib $mes_kernel/$mes_cpu-mes | tar -${v}xf- -C $DESTDIR$libdir
 if test -z "$srcdest"; then
diff --git a/configure b/configure
index b02e75bf..98467094 100755
--- a/configure
+++ b/configure
@@ -707,6 +707,13 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
 #define MES_VERSION \"" VERSION "\"
 ")))))
         (substitute (string-append srcdest "build-aux/config.make.in") pairs #:target ".config.make"))
+      (let ((arch-dir (string-append srcdest "include/" mes-kernel "/" mes-cpu)))
+        (define (copy-header file-name)
+          (system* "cp" "-f" "-v"
+                   (string-append arch-dir "/" file-name)
+                   (string-append "include/arch/" file-name)))
+        (system* "mkdir" "-p" "include/arch")
+        (for-each copy-header '("kernel-stat.h" "syscall.h")))
 
       (let ((make (and=> (file-name "make" deps) basename)))
         (display (string-append "
diff --git a/configure.sh b/configure.sh
index 51d99b6f..f182530e 100755
--- a/configure.sh
+++ b/configure.sh
@@ -271,6 +271,10 @@ cat >> include/mes/config.h <<EOF
 #define MES_VERSION "$VERSION"
 EOF
 
+mkdir -p include/arch
+cp -f -v ${srcdest}include/${mes_kernel}/${mes_cpu}/kernel-stat.h include/arch
+cp -f -v ${srcdest}include/${mes_kernel}/${mes_cpu}/syscall.h include/arch
+
 cat <<EOF
 GNU Mes is configured for
    compiler:   $compiler
diff --git a/include/gnu/x86/kernel-stat.h b/include/gnu/x86/kernel-stat.h
new file mode 100644
index 00000000..7b49efe9
--- /dev/null
+++ b/include/gnu/x86/kernel-stat.h
@@ -0,0 +1,25 @@
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ *
+ * This file is part of GNU Mes.
+ *
+ * GNU Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * GNU Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __MES_GNU_X86_KERNEL_STAT_H
+#define __MES_GNU_X86_KERNEL_STAT_H 1
+
+#include <arch/syscall.h>
+
+#endif // __MES_GNU_X86_KERNEL_STAT_H
diff --git a/include/linux/arm/kernel-stat.h b/include/linux/arm/kernel-stat.h
new file mode 100644
index 00000000..79dc48ec
--- /dev/null
+++ b/include/linux/arm/kernel-stat.h
@@ -0,0 +1,79 @@
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ *
+ * This file is part of GNU Mes.
+ *
+ * GNU Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * GNU Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __MES_LINUX_ARM_KERNEL_STAT_H
+#define __MES_LINUX_ARM_KERNEL_STAT_H 1
+
+// https://github.com/torvalds/linux/blob/master/arch/arm/include/uapi/asm/stat.h
+
+#include <arch/syscall.h>
+
+#if __SIZEOF_LONG_LONG__ != 8
+
+// *INDENT-OFF*
+struct stat
+{
+  unsigned long  st_dev;
+  unsigned long  st_ino;
+  unsigned short st_mode;
+  unsigned short st_nlink;
+  unsigned short st_uid;
+  unsigned short st_gid;
+  unsigned long  st_rdev;
+  unsigned long  st_size;
+  unsigned long  st_blksize;
+  unsigned long  st_blocks;
+  unsigned long  st_atime;
+  unsigned long  st_atime_usec;
+  unsigned long  st_mtime;
+  unsigned long  st_mtime_usec;
+  unsigned long  st_ctime;
+  unsigned long  st_ctime_usec;
+  unsigned long  __pad0;
+  unsigned long  __pad1;
+};
+
+#else // __SIZEOF_LONG_LONG__ == 8
+
+struct stat
+{
+  unsigned long long st_dev;
+  unsigned char __pad0[4];
+  unsigned long __st_ino;
+  unsigned int st_mode;
+  unsigned int st_nlink;
+  unsigned long st_uid;
+  unsigned long st_gid;
+  unsigned long long st_rdev;
+  unsigned char __pad3[4];
+  long long st_size;
+  unsigned long st_blksize;
+  unsigned long long st_blocks;
+  unsigned long st_atime;
+  unsigned long st_atime_nsec;
+  unsigned long st_mtime;
+  unsigned int st_mtime_nsec;
+  unsigned long st_ctime;
+  unsigned long st_ctime_nsec;
+  unsigned long long st_ino;
+};
+
+#endif // __SIZEOF_LONG_LONG__ == 8
+
+#endif // __MES_LINUX_ARM_KERNEL_STAT_H
diff --git a/include/linux/arm/syscall.h b/include/linux/arm/syscall.h
index b04ff039..ca9f1f97 100644
--- a/include/linux/arm/syscall.h
+++ b/include/linux/arm/syscall.h
@@ -109,4 +109,23 @@
 #define SYS_readlink  0x55
 #define SYS_mknod     0x0e
 
+#if __SIZEOF_LONG_LONG__ == 8
+
+#define SYS_stat64     0xc3
+#define SYS_lstat64    0xc4
+#define SYS_fstat64    0xc5
+#define SYS_fcntl64    0xdd
+#define SYS_getdents64 0xdc
+
+#undef SYS_stat
+#define SYS_stat SYS_stat64
+
+#undef SYS_lstat
+#define SYS_lstat SYS_lstat64
+
+#undef SYS_fstat
+#define SYS_fstat SYS_fstat64
+
+#endif  // __SIZEOF_LONG_LONG__ == 8
+
 #endif /* __MES_LINUX_ARM_SYSCALL_H */
diff --git a/include/linux/m2/kernel-stat.h b/include/linux/m2/kernel-stat.h
new file mode 100644
index 00000000..c446bdbc
--- /dev/null
+++ b/include/linux/m2/kernel-stat.h
@@ -0,0 +1,47 @@
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * Copyright © 2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ *
+ * This file is part of GNU Mes.
+ *
+ * GNU Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * GNU Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __LINUX_M2_KERNEL_STAT_H
+#define __LINUX_M2_KERNEL_STAT_H
+
+/* https://github.com/torvalds/linux/blob/master/arch/x86/include/uapi/asm/stat.h */
+
+/* *INDENT-OFF* */
+struct stat
+{
+  unsigned st_dev;
+  unsigned st_ino;
+  char st_mode[2];
+  char st_nlink[2];
+  char st_uid[2];
+  char st_gid[2];
+  unsigned st_rdev;
+  unsigned st_size;
+  unsigned st_blksize;
+  unsigned st_blocks;
+  unsigned st_atime;
+  unsigned st_atime_usec;
+  unsigned st_mtime;
+  unsigned st_mtime_usec;
+  unsigned st_ctime;
+  unsigned st_ctime_usec;
+  unsigned __pad0;
+  unsigned __pad1;
+};
+#endif /* __LINUX_M2_KERNEL_STAT_H */
diff --git a/include/linux/x86/kernel-stat.h b/include/linux/x86/kernel-stat.h
new file mode 100644
index 00000000..997fadc7
--- /dev/null
+++ b/include/linux/x86/kernel-stat.h
@@ -0,0 +1,79 @@
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ *
+ * This file is part of GNU Mes.
+ *
+ * GNU Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * GNU Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __MES_LINUX_X86_KERNEL_STAT_H
+#define __MES_LINUX_X86_KERNEL_STAT_H 1
+
+// https://github.com/torvalds/linux/blob/master/arch/x86/include/uapi/asm/stat.h
+
+#include <arch/syscall.h>
+
+#if __SIZEOF_LONG_LONG__ != 8
+
+// *INDENT-OFF*
+struct stat
+{
+  unsigned long  st_dev;
+  unsigned long  st_ino;
+  unsigned short st_mode;
+  unsigned short st_nlink;
+  unsigned short st_uid;
+  unsigned short st_gid;
+  unsigned long  st_rdev;
+  unsigned long  st_size;
+  unsigned long  st_blksize;
+  unsigned long  st_blocks;
+  unsigned long  st_atime;
+  unsigned long  st_atime_usec;
+  unsigned long  st_mtime;
+  unsigned long  st_mtime_usec;
+  unsigned long  st_ctime;
+  unsigned long  st_ctime_usec;
+  unsigned long  __pad0;
+  unsigned long  __pad1;
+};
+
+#else // __SIZEOF_LONG_LONG__ == 8
+
+struct stat
+{
+  unsigned long long st_dev;
+  unsigned char __pad0[4];
+  unsigned long __st_ino;
+  unsigned int st_mode;
+  unsigned int st_nlink;
+  unsigned long st_uid;
+  unsigned long st_gid;
+  unsigned long long st_rdev;
+  unsigned char __pad3[4];
+  long long st_size;
+  unsigned long st_blksize;
+  unsigned long long st_blocks;
+  unsigned long st_atime;
+  unsigned long st_atime_nsec;
+  unsigned long st_mtime;
+  unsigned int st_mtime_nsec;
+  unsigned long st_ctime;
+  unsigned long st_ctime_nsec;
+  unsigned long long st_ino;
+};
+
+#endif // __SIZEOF_LONG_LONG__ == 8
+
+#endif // __MES_LINUX_X86_KERNEL_STAT_H
diff --git a/include/linux/x86/syscall.h b/include/linux/x86/syscall.h
index 01c46a35..d849c175 100644
--- a/include/linux/x86/syscall.h
+++ b/include/linux/x86/syscall.h
@@ -75,7 +75,6 @@
 #define SYS_stat   0x6a
 
 /* libc+gnu */
-
 #define SYS_chdir     0x0c
 #define SYS_link      0x09
 #define SYS_getpid    0x14
@@ -112,4 +111,23 @@
 #define SYS_readlink  0x55
 #define SYS_mknod     0x0e
 
+#if __SIZEOF_LONG_LONG__ == 8
+
+#define SYS_stat64     0xc3
+#define SYS_lstat64    0xc4
+#define SYS_fstat64    0xc5
+#define SYS_fcntl64    0xdd
+#define SYS_getdents64 0xdc
+
+#undef SYS_stat
+#define SYS_stat SYS_stat64
+
+#undef SYS_lstat
+#define SYS_lstat SYS_lstat64
+
+#undef SYS_fstat
+#define SYS_fstat SYS_fstat64
+
+#endif  // __SIZEOF_LONG_LONG__ == 8
+
 #endif /* __MES_LINUX_X86_SYSCALL_H */
diff --git a/include/linux/x86_64/kernel-stat.h b/include/linux/x86_64/kernel-stat.h
new file mode 100644
index 00000000..fdb15946
--- /dev/null
+++ b/include/linux/x86_64/kernel-stat.h
@@ -0,0 +1,51 @@
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ *
+ * This file is part of GNU Mes.
+ *
+ * GNU Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * GNU Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __MES_LINUX_X86_64_KERNEL_STAT_H
+#define __MES_LINUX_X86_64_KERNEL_STAT_H 1
+
+// https://github.com/torvalds/linux/blob/master/arch/x86/include/uapi/asm/stat.h
+
+// *INDENT-OFF*
+struct stat
+{
+  unsigned long	st_dev;
+  unsigned long	st_ino;
+  unsigned long	st_nlink;
+  unsigned int	st_mode;
+  unsigned int	st_uid;
+  unsigned int	st_gid;
+  unsigned int	__pad0;
+  unsigned long	st_rdev;
+  unsigned long	st_size;
+  unsigned long	st_atime;
+  unsigned long	st_atime_nsec;
+  unsigned long	st_mtime;
+  unsigned long	st_mtime_nsec;
+  unsigned long	st_ctime;
+  unsigned long	st_ctime_nsec;
+  unsigned long	st_blksize;
+  long		st_blocks;
+  unsigned long	__pad1;
+  unsigned long	__pad2;
+  unsigned long	__pad3;
+  unsigned long	__pad4;
+};
+
+#endif // __MES_LINUX_X86_64_KERNEL_STAT_H
diff --git a/include/m2/types.h b/include/m2/types.h
new file mode 100644
index 00000000..c5547f5c
--- /dev/null
+++ b/include/m2/types.h
@@ -0,0 +1,138 @@
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * Copyright © 2017,2022,2023 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ *
+ * This file is part of GNU Mes.
+ *
+ * GNU Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * GNU Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __M2_TYPES_H
+#define __M2_TYPES_H 1
+
+/*
+#ifndef __MES_CLOCK_T
+#define __MES_CLOCK_T
+#undef clock_t
+typedef long clock_t;
+#endif
+*/
+
+#ifndef __MES_DEV_T
+#define __MES_DEV_T
+#undef dev_t
+typedef long dev_t;
+#endif
+
+/*
+#if !defined (__MES_FILE_T) && ! defined (_FILE_T)
+#define __MES_FILE_T
+#define _FILE_T
+typedef long FILE;
+#endif
+*/
+
+#ifndef __MES_GID_T
+#define __MES_GID_T
+#undef gid_t
+typedef unsigned gid_t;
+#endif
+
+#ifndef __MES_INO_T
+#define __MES_INO_T
+#undef ino_t
+typedef unsigned ino_t;
+#endif
+
+#if __SIZEOF_LONG_LONG__ == 8
+#ifndef __MES_INO64_T
+#define __MES_INO64_T
+#undef ino64_t
+typedef unsigned ino64_t;
+#endif
+#endif // __SIZEOF_LONG_LONG__ == 8
+
+#if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined)
+#define __MES_INTPTR_T
+#define __intptr_t_defined
+#undef intptr_t
+typedef long intptr_t;
+#undef uintptr_t
+typedef unsigned uintptr_t;
+#endif
+
+#ifndef __MES_OFF_T
+#define __MES_OFF_T
+#undef off_t
+typedef long off_t;
+#endif
+
+#if __SIZEOF_LONG_LONG__ == 8
+#ifndef __MES_OFF64_T
+#define __MES_OFF64_T
+#undef off64_t
+typedef unsigned off64_t;
+#endif
+#endif // __SIZEOF_LONG_LONG__ == 8
+
+#ifndef __MES_PID_T
+#define __MES_PID_T
+#undef pid_t
+typedef int pid_t;
+#endif
+
+#ifndef __PTRDIFF_T
+#define __PTRDIFF_T
+#ifndef __MES_PTRDIFF_T
+#define __MES_PTRDIFF_T
+#undef ptrdiff_t
+typedef long ptrdiff_t;
+#endif
+#endif
+
+#ifndef __MES_SIGVAL_T
+#define __MES_SIGVAL_T
+#undef clock_t
+typedef long sigval_t;
+#endif
+
+#ifndef __SIZE_T
+#define __SIZE_T
+#ifndef __MES_SIZE_T
+#define __MES_SIZE_T
+typedef unsigned size_t;
+#endif
+#endif
+
+#ifndef __MES_SSIZE_T
+#define __MES_SSIZE_T
+#undef ssize_t
+typedef long ssize_t;
+#endif
+
+#ifndef __MES_UID_T
+#define __MES_UID_T
+#undef uid_t
+typedef unsigned uid_t;
+#endif
+
+#ifndef __WCHAR_T
+#define __WCHAR_T
+#ifndef __MES_WCHAR_T
+#define __MES_WCHAR_T
+#undef wchar_t
+typedef int wchar_t;
+#endif
+#endif
+
+#endif // __M2_TYPES_H
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 0aefa286..fbcee2f1 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -19,7 +19,7 @@
  * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
  */
 #ifndef __MES_SYS_STAT_H
-#define __MES_SYS_STAT_H 1lei
+#define __MES_SYS_STAT_H 1
 
 #if SYSTEM_LIBC
 #undef __MES_SYS_STAT_H
@@ -29,60 +29,13 @@
 
 #include <time.h>
 #include <sys/types.h>
+#include <arch/kernel-stat.h>
 
 #ifndef __MES_MODE_T
 #define __MES_MODE_T
 typedef int mode_t;
 #endif
 
-// *INDENT-OFF*
-#if __i386__ || __arm__
-struct stat
-{
-  unsigned long  st_dev;
-  unsigned long  st_ino;
-  unsigned short st_mode;
-  unsigned short st_nlink;
-  unsigned short st_uid;
-  unsigned short st_gid;
-  unsigned long  st_rdev;
-  long           st_size; /* Linux: unsigned long; glibc: off_t (i.e. signed) */
-  unsigned long  st_blksize;
-  unsigned long  st_blocks;
-  time_t         st_atime; /* Linux: unsigned long; glibc: time_t */
-  unsigned long  st_atime_usec;
-  time_t         st_mtime; /* Linux: unsigned long; glibc: time_t */
-  unsigned long  st_mtime_usec;
-  time_t         st_ctime; /* Linux: unsigned long; glibc: time_t */
-  unsigned long  st_ctime_usec;
-  unsigned long  __foo0;
-  unsigned long  __foo1;
-};
-#elif __x86_64__
-struct stat
-{
-  unsigned long  st_dev;
-  unsigned long  st_ino;
-  unsigned int   st_mode;
-  unsigned int   st_nlink;
-  unsigned int   st_uid;
-  unsigned int   st_gid;
-  unsigned long  st_rdev;
-  long           st_size;
-  unsigned long  st_blksize;
-  unsigned long  st_blocks;
-  time_t         st_atime;
-  unsigned long  st_atime_usec;
-  time_t         st_mtime;
-  unsigned long  st_mtime_usec;
-  time_t         st_ctime;
-  unsigned long  st_ctime_usec;
-  unsigned long  __foo0;
-  unsigned long  __foo1;
-};
-#endif
-// *INDENT-ON*
-
 int chmod (char const *file_name, mode_t mode);
 int fstat (int filedes, struct stat *buf);
 int mkdir (char const *file_name, mode_t mode);
diff --git a/kaem.run b/kaem.run
index 3c78e39a..1d8df90b 100644
--- a/kaem.run
+++ b/kaem.run
@@ -53,6 +53,7 @@ M2-Planet                                       \
     -f lib/mes/fdputc.c                         \
     -f lib/mes/eputc.c                          \
                                                 \
+    -f include/m2/types.h                       \
     -f include/mes/mes.h                        \
     -f include/mes/builtins.h                   \
     -f include/mes/constants.h                  \
@@ -81,6 +82,8 @@ M2-Planet                                       \
     -f lib/mes/fdungetc.c                       \
     -f lib/posix/setenv.c                       \
     -f lib/linux/access.c                       \
+    -f include/linux/m2/kernel-stat.h           \
+    -f include/sys/stat.h                       \
     -f lib/m2/chmod.c                           \
     -f lib/linux/ioctl3.c                       \
     -f lib/m2/isatty.c                          \
diff --git a/lib/linux/_getcwd.c b/lib/linux/_getcwd.c
index 85153cb1..10eb270e 100644
--- a/lib/linux/_getcwd.c
+++ b/lib/linux/_getcwd.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -20,7 +20,7 @@
 
 #include <mes/lib.h>
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 char *
 _getcwd (char *buffer, size_t size)
diff --git a/lib/linux/_open3.c b/lib/linux/_open3.c
index 3072f9bf..cfad689a 100644
--- a/lib/linux/_open3.c
+++ b/lib/linux/_open3.c
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <mes/lib.h>
 #include <fcntl.h>
 
diff --git a/lib/linux/_read.c b/lib/linux/_read.c
index 6c5ff42f..c5a34abc 100644
--- a/lib/linux/_read.c
+++ b/lib/linux/_read.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <mes/lib.h>
 #include <fcntl.h>
 
diff --git a/lib/linux/access.c b/lib/linux/access.c
index 805e8f01..ceb18595 100644
--- a/lib/linux/access.c
+++ b/lib/linux/access.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -20,7 +20,7 @@
 
 #include <mes/lib.h>
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 access (char const *file_name, int how)
diff --git a/lib/linux/brk.c b/lib/linux/brk.c
index 586bd7e1..3517850c 100644
--- a/lib/linux/brk.c
+++ b/lib/linux/brk.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -20,7 +20,7 @@
 
 #include <mes/lib.h>
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 long
 brk (void *addr)
diff --git a/lib/linux/chdir.c b/lib/linux/chdir.c
index ada7feec..aed98378 100644
--- a/lib/linux/chdir.c
+++ b/lib/linux/chdir.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 chdir (char const *file_name)
diff --git a/lib/linux/chmod.c b/lib/linux/chmod.c
index 1feabec5..a6d74a43 100644
--- a/lib/linux/chmod.c
+++ b/lib/linux/chmod.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -20,7 +20,7 @@
 
 #include <mes/lib.h>
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/stat.h>
 
 int
diff --git a/lib/linux/clock_gettime.c b/lib/linux/clock_gettime.c
index 051dba33..63753ef8 100644
--- a/lib/linux/clock_gettime.c
+++ b/lib/linux/clock_gettime.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -20,7 +20,7 @@
 
 #include <mes/lib.h>
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <time.h>
 
 int
diff --git a/lib/linux/close.c b/lib/linux/close.c
index e25e8318..490b4881 100644
--- a/lib/linux/close.c
+++ b/lib/linux/close.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <mes/lib.h>
 
 int
diff --git a/lib/linux/dup.c b/lib/linux/dup.c
index 9237ef97..b954d3de 100644
--- a/lib/linux/dup.c
+++ b/lib/linux/dup.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 dup (int old)
diff --git a/lib/linux/dup2.c b/lib/linux/dup2.c
index ef996273..9a0752e3 100644
--- a/lib/linux/dup2.c
+++ b/lib/linux/dup2.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 dup2 (int old, int new)
diff --git a/lib/linux/execve.c b/lib/linux/execve.c
index 51c8b4ff..7cb02e20 100644
--- a/lib/linux/execve.c
+++ b/lib/linux/execve.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 execve (char const *file_name, char *const argv[], char *const env[])
diff --git a/lib/linux/fcntl.c b/lib/linux/fcntl.c
index e10e7348..85a167ae 100644
--- a/lib/linux/fcntl.c
+++ b/lib/linux/fcntl.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <stdarg.h>
 
 int
diff --git a/lib/linux/fork.c b/lib/linux/fork.c
index 1f5c25fc..d07050bf 100644
--- a/lib/linux/fork.c
+++ b/lib/linux/fork.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 fork ()
diff --git a/lib/linux/fstat.c b/lib/linux/fstat.c
index 19d3f6a9..f4965776 100644
--- a/lib/linux/fstat.c
+++ b/lib/linux/fstat.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/stat.h>
 
 int
diff --git a/lib/linux/fsync.c b/lib/linux/fsync.c
index 0eef6db4..ba75088d 100644
--- a/lib/linux/fsync.c
+++ b/lib/linux/fsync.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 fsync (int filedes)
diff --git a/lib/linux/getdents.c b/lib/linux/getdents.c
index 5ebafa45..03717710 100644
--- a/lib/linux/getdents.c
+++ b/lib/linux/getdents.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/types.h>
 
 int
diff --git a/lib/linux/getegid.c b/lib/linux/getegid.c
index 5ad2f2c6..2fb8098f 100644
--- a/lib/linux/getegid.c
+++ b/lib/linux/getegid.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 gid_t
diff --git a/lib/linux/geteuid.c b/lib/linux/geteuid.c
index 4fcf9fd1..62d2da47 100644
--- a/lib/linux/geteuid.c
+++ b/lib/linux/geteuid.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 uid_t
diff --git a/lib/linux/getgid.c b/lib/linux/getgid.c
index 4402b528..48fd3579 100644
--- a/lib/linux/getgid.c
+++ b/lib/linux/getgid.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 gid_t
diff --git a/lib/linux/getpid.c b/lib/linux/getpid.c
index 9cab47ae..73cb74b6 100644
--- a/lib/linux/getpid.c
+++ b/lib/linux/getpid.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 pid_t
diff --git a/lib/linux/getppid.c b/lib/linux/getppid.c
index 7eea4539..49d472ba 100644
--- a/lib/linux/getppid.c
+++ b/lib/linux/getppid.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 pid_t
diff --git a/lib/linux/getrusage.c b/lib/linux/getrusage.c
index 2a789949..174d4c0b 100644
--- a/lib/linux/getrusage.c
+++ b/lib/linux/getrusage.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/resource.h>
 
 int
diff --git a/lib/linux/gettimeofday.c b/lib/linux/gettimeofday.c
index 495f059f..ed4e336f 100644
--- a/lib/linux/gettimeofday.c
+++ b/lib/linux/gettimeofday.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -20,7 +20,7 @@
 
 #include <mes/lib.h>
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/time.h>
 
 int
diff --git a/lib/linux/getuid.c b/lib/linux/getuid.c
index e6edd257..d5ca3a50 100644
--- a/lib/linux/getuid.c
+++ b/lib/linux/getuid.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 uid_t
diff --git a/lib/linux/ioctl.c b/lib/linux/ioctl.c
index 0e6e14ac..27547c68 100644
--- a/lib/linux/ioctl.c
+++ b/lib/linux/ioctl.c
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <stdarg.h>
 #include <sys/ioctl.h>
 
diff --git a/lib/linux/ioctl3.c b/lib/linux/ioctl3.c
index 3f759d06..7990b8b7 100644
--- a/lib/linux/ioctl3.c
+++ b/lib/linux/ioctl3.c
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <mes/lib.h>
 
 int
diff --git a/lib/linux/kill.c b/lib/linux/kill.c
index 4298a9db..f04424fb 100644
--- a/lib/linux/kill.c
+++ b/lib/linux/kill.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 int
diff --git a/lib/linux/link.c b/lib/linux/link.c
index cf8dec32..e2d66912 100644
--- a/lib/linux/link.c
+++ b/lib/linux/link.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 link (char const *old_name, char const *new_name)
diff --git a/lib/linux/lseek.c b/lib/linux/lseek.c
index f71af59f..c72a75cf 100644
--- a/lib/linux/lseek.c
+++ b/lib/linux/lseek.c
@@ -20,7 +20,7 @@
 
 #include <mes/lib.h>
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <stdio.h>
 #include <sys/types.h>
 
diff --git a/lib/linux/lstat.c b/lib/linux/lstat.c
index 039de0e1..feebc6cb 100644
--- a/lib/linux/lstat.c
+++ b/lib/linux/lstat.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/stat.h>
 
 int
diff --git a/lib/linux/mkdir.c b/lib/linux/mkdir.c
index 53188888..59319329 100644
--- a/lib/linux/mkdir.c
+++ b/lib/linux/mkdir.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/stat.h>
 
 int
diff --git a/lib/linux/mknod.c b/lib/linux/mknod.c
index 8339f7a6..24a9b0c7 100644
--- a/lib/linux/mknod.c
+++ b/lib/linux/mknod.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/stat.h>
 
 int
diff --git a/lib/linux/nanosleep.c b/lib/linux/nanosleep.c
index bc838a4f..a5e2a044 100644
--- a/lib/linux/nanosleep.c
+++ b/lib/linux/nanosleep.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <time.h>
 #include <sys/time.h>
 
diff --git a/lib/linux/pipe.c b/lib/linux/pipe.c
index 0ed4c23e..f6b3689a 100644
--- a/lib/linux/pipe.c
+++ b/lib/linux/pipe.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 int
diff --git a/lib/linux/read.c b/lib/linux/read.c
index efd25744..d91f81b2 100644
--- a/lib/linux/read.c
+++ b/lib/linux/read.c
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <mes/lib.h>
 #include <fcntl.h>
 
diff --git a/lib/linux/readlink.c b/lib/linux/readlink.c
index 9990b50f..96443273 100644
--- a/lib/linux/readlink.c
+++ b/lib/linux/readlink.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/stat.h>
 
 ssize_t
diff --git a/lib/linux/rename.c b/lib/linux/rename.c
index 492c734d..762c3093 100644
--- a/lib/linux/rename.c
+++ b/lib/linux/rename.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 int
diff --git a/lib/linux/rmdir.c b/lib/linux/rmdir.c
index 7c096832..5d4c0f49 100644
--- a/lib/linux/rmdir.c
+++ b/lib/linux/rmdir.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 rmdir (char const *file_name)
diff --git a/lib/linux/setgid.c b/lib/linux/setgid.c
index 5512c622..13399c2e 100644
--- a/lib/linux/setgid.c
+++ b/lib/linux/setgid.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 int
diff --git a/lib/linux/settimer.c b/lib/linux/settimer.c
index a66240f1..7247c8a0 100644
--- a/lib/linux/settimer.c
+++ b/lib/linux/settimer.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/time.h>
 #include <unistd.h>
 
diff --git a/lib/linux/setuid.c b/lib/linux/setuid.c
index 5157dcae..d5e2ae76 100644
--- a/lib/linux/setuid.c
+++ b/lib/linux/setuid.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 int
diff --git a/lib/linux/signal.c b/lib/linux/signal.c
index 11174be9..23cf106d 100644
--- a/lib/linux/signal.c
+++ b/lib/linux/signal.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 #include <signal.h>
 
diff --git a/lib/linux/sigprogmask.c b/lib/linux/sigprogmask.c
index c0326a28..4b0bb8eb 100644
--- a/lib/linux/sigprogmask.c
+++ b/lib/linux/sigprogmask.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <signal.h>
 #include <unistd.h>
 
diff --git a/lib/linux/stat.c b/lib/linux/stat.c
index d8f4465b..df0022aa 100644
--- a/lib/linux/stat.c
+++ b/lib/linux/stat.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/stat.h>
 
 int
diff --git a/lib/linux/symlink.c b/lib/linux/symlink.c
index 53f99fb7..4e4084d2 100644
--- a/lib/linux/symlink.c
+++ b/lib/linux/symlink.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <unistd.h>
 
 int
diff --git a/lib/linux/time.c b/lib/linux/time.c
index f4931970..53c92052 100644
--- a/lib/linux/time.c
+++ b/lib/linux/time.c
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <time.h>
 #include <sys/time.h>
 #include <stdlib.h>
diff --git a/lib/linux/unlink.c b/lib/linux/unlink.c
index 03713e64..9f204b5f 100644
--- a/lib/linux/unlink.c
+++ b/lib/linux/unlink.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -20,7 +20,7 @@
 
 #include <mes/lib.h>
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 unlink (char const *file_name)
diff --git a/lib/linux/waitpid.c b/lib/linux/waitpid.c
index 693e3dfa..bb89c692 100644
--- a/lib/linux/waitpid.c
+++ b/lib/linux/waitpid.c
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/types.h>
 
 pid_t
diff --git a/lib/m2/execve.c b/lib/m2/execve.c
index 7fe7c9ba..1f078c3d 100644
--- a/lib/m2/execve.c
+++ b/lib/m2/execve.c
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+ * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
  *
  * This file is part of GNU Mes.
  *
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 
 int
 execve (char const *file_name, char **argv, char **env)
diff --git a/lib/m2/open.c b/lib/m2/open.c
index 3d3fe4dc..ee5513e7 100644
--- a/lib/m2/open.c
+++ b/lib/m2/open.c
@@ -18,6 +18,8 @@
  * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <linux/syscall.h>
+#include <arch/syscall.h>
 #include <mes/lib.h>
 #include <fcntl.h>
 #include <stdarg.h>
diff --git a/lib/m2/time.c b/lib/m2/time.c
index c589de85..7f43cdad 100644
--- a/lib/m2/time.c
+++ b/lib/m2/time.c
@@ -19,7 +19,7 @@
  */
 
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <time.h>
 
 long
diff --git a/lib/m2/waitpid.c b/lib/m2/waitpid.c
index a3d98d1d..5cd18d98 100644
--- a/lib/m2/waitpid.c
+++ b/lib/m2/waitpid.c
@@ -20,7 +20,7 @@
 
 #include <mes/lib.h>
 #include <linux/syscall.h>
-#include <syscall.h>
+#include <arch/syscall.h>
 #include <sys/types.h>
 
 int
diff --git a/simple.sh b/simple.sh
index ce0ec375..fc5ac371 100755
--- a/simple.sh
+++ b/simple.sh
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # GNU Mes --- Maxwell Equations of Software
-# Copyright © 2019,2020,2022 Jan (janneke) Nieuwenhuizen <[email-masked]>
+# Copyright © 2019,2020,2022,2023 Jan (janneke) Nieuwenhuizen <[email-masked]>
 #
 # This file is part of GNU Mes.
 #
@@ -36,7 +36,9 @@ cat > include/mes/config.h <<EOF
 EOF
 
 ## Build ##
-gcc -g -D HAVE_CONFIG_H=1 -I include            \
+gcc -g -D HAVE_CONFIG_H=1                       \
+    -I include                                  \
+    -I include/$mes_kernel/$mes_cpu             \
     -o out-system-libc/mes                      \
                                                 \
     lib/mes/eputs.c                             \
@@ -163,11 +165,15 @@ cat > include/mes/config.h <<EOF
 #define MES_VERSION "git"
 EOF
 
+mkdir -p include/arch
+cp -f include/$mes_kernel/$mes_cpu/kernel-stat.h include/arch
+cp -f include/$mes_kernel/$mes_cpu/syscall.h include/arch
+
 ## Build ##
 compiler=gcc     # not configurable
 $CC -g -D HAVE_CONFIG_H=1                               \
     -I include -I include/$mes_kernel/$mes_cpu          \
-       -nostdinc -nostdlib                              \
+    -nostdinc -nostdlib                                 \
     -fno-builtin -fno-stack-protector                   \
     -o out-mes/mes                                      \
                                                         \
-- 
2.38.1