mailing list of musl libc
 help / color / mirror / code / Atom feed
* Deduplicating __NR_* and SYS_* syscall defines
@ 2016-05-10  0:26 Bobby Bingham
  2016-05-10  7:34 ` Alexander Monakov
  2016-05-11 21:53 ` Rich Felker
  0 siblings, 2 replies; 9+ messages in thread
From: Bobby Bingham @ 2016-05-10  0:26 UTC (permalink / raw)
  To: musl

During the powerpc64 review, Rich mentioned wanting to replace the
arch/*/bits/syscall.h files with .in files that would be preprocessed with
something like:

    sed -e p -e s/__NR_/SYS_/ < $< > $@

This would eliminate a lot of intra-file duplication here.

I took a look, and this won't quite work as-is, because the following
lines in the arm version would end up outputting duplicate definitions:

    #define __ARM_NR_breakpoint	0x0f0001
    #define __ARM_NR_cacheflush	0x0f0002
    #define __ARM_NR_usr26		0x0f0003
    #define __ARM_NR_usr32		0x0f0004
    #define __ARM_NR_set_tls	0x0f0005

Same thing for this line in x32:

    #define __X32_SYSCALL_BIT        0x40000000

I'm thinking something like the following awk script would work:

    {
        print
    }

    $1 ~ /^#(define|undef)$/ && $2 ~ /^__NR_/ {
        sub(/__NR_/, "SYS_", $2)
        print
    }

The handling for #undef is for the x32 file.  It looks like only the
`#undef __NR_getdents' in that file is actually necessary, and even that
could be avoided by just omitting the earlier line:

    #define __NR_getdents (__X32_SYSCALL_BIT + 78)

So maybe we can get rid of the #undefs there, and simplify the awk script
accordingly.

Thoughts on this approach?  If this sounds ok, I'll submit a patch.

--
Bobby


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-05-13 16:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10  0:26 Deduplicating __NR_* and SYS_* syscall defines Bobby Bingham
2016-05-10  7:34 ` Alexander Monakov
2016-05-10  8:47   ` Alexander Monakov
2016-05-11 21:53 ` Rich Felker
2016-05-12  0:22   ` Bobby Bingham
2016-05-12  0:57     ` Rich Felker
2016-05-12  3:56       ` Bobby Bingham
2016-05-13 10:15       ` Szabolcs Nagy
2016-05-13 16:02         ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).