Re: [PATCH] perf arm64: Simplify mksyscalltbl

From: Arnd Bergmann
Date: Tue Jan 05 2021 - 05:48:39 EST


On Mon, Dec 28, 2020 at 3:44 AM Hans-Peter Nilsson <hp@xxxxxxxx> wrote:
>
> This patch isn't intended to have any effect on the compiled
> code. It just removes one level of indirection: calling the
> *host* compiler to build and then run a program that just
> printf:s the numerical entries of the syscall-table. In other
> words, the generated syscalls.c changes from:
> [46] = "ftruncate",
> to:
> [__NR3264_ftruncate] = "ftruncate",

If you include the file, why not just use the macros directly, like

#define __SYSCALL(nr, sym) [nr] = #sym ;
static const char *syscalltbl_arm64[] = {
#include <uapi/asm-generic/unistd.h>
};
#undef __SYSCALL

The leaves an extra "sys_" in front of every name, but if you
care, that could be left out afterwards.

> At the time of this patch, powerpc (the origin, see comments),
> and also e.g. x86 has moved on, from filtering "gcc -dM -E"
> output to reading separate specific text-file, a table of
> syscall numbers. IMHO should arm64 consider adopting this.

Right, we had patches to convert include/uapi/asm-generic/unistd.h
to the syscall.tbl format some time ago, but they were never
merged as there were a few remaining bugs. I had planned to
pick up that work but have not gotten around to it yet.

If anyone is interested in doing this, I can dig out the last version
of the patches.

Arnd