This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Complete sys/procfs.h unification
On Tue, 25 Sep 2018, Adhemerval Zanella wrote:
> Another possible way to increase coverage is to add static asserts with
> expected struct size and members offset. It won't check the expected type
> though, and it would require some more arch-specific code to add the
> expected values.
For the record, here is the (unfinished) patch I prepared to test against
<linux/elfcore.h>. I then found the problem that the installed uapi
<linux/elfcore.h> header doesn't actually work, so I couldn't then test if
the logic in this test patch is actually correct and works when the two
headers are in sync with each other. (Obviously once linux/elfcore.h is
fixed the test will need to become appropriately conditional on the
version of kernel headers used.)
(I don't assert that the gen-as-const mechanism is necessarily optimal for
this test - it does mean the data to be compared is unnecessarily
generated at glibc build time rather than just at test time, for example.
I think the gen-as-const machinery, involving as it does a combination of
an awk script and a sed command in Makerules, would be an excellent
candidate for moving to some common Python infrastructure for extracting
the values of compile-time constants from C code which could then be used
both in the glibc build and in test code checking various things about
such constants, if we get consensus on requiring Python for the build.)
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 773aaea0e9..78b3667022 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -208,3 +208,11 @@ tests += tst-align-clone tst-getpid1 \
tst-thread-affinity-sched
tests-internal += tst-setgetname
endif
+
+ifeq ($(subdir),nptl_db)
+gen-as-const-headers += procfs-glibc.sym procfs-linux.sym
+tests-special += $(objpfx)tst-sys-procfs.out
+$(objpfx)tst-sys-procfs.out: $(common-objpfx)procfs-glibc.h \
+ $(common-objpfx)procfs-linux.h
+ diff $^ > $@; $(evaluate-test)
+endif
diff --git a/sysdeps/unix/sysv/linux/procfs-glibc.sym b/sysdeps/unix/sysv/linux/procfs-glibc.sym
new file mode 100644
index 0000000000..bc062e12e1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/procfs-glibc.sym
@@ -0,0 +1,73 @@
+#include <stddef.h>
+#include <sys/procfs.h>
+
+--
+
+#define MEMBER_SIZE(S, F) sizeof ((S) { 0 }.F)
+
+sizeof_elf_siginfo sizeof (struct elf_siginfo)
+sizeof_elf_prstatus sizeof (struct elf_prstatus)
+sizeof_elf_prpsinfo sizeof (struct elf_prpsinfo)
+
+sizeof_elf_siginfo_si_signo MEMBER_SIZE (struct elf_siginfo, si_signo)
+offset_elf_siginfo_si_signo offsetof (struct elf_siginfo, si_signo)
+sizeof_elf_siginfo_si_code MEMBER_SIZE (struct elf_siginfo, si_code)
+offset_elf_siginfo_si_code offsetof (struct elf_siginfo, si_code)
+sizeof_elf_siginfo_si_errno MEMBER_SIZE (struct elf_siginfo, si_errno)
+offset_elf_siginfo_si_errno offsetof (struct elf_siginfo, si_errno)
+
+sizeof_elf_prstatus_pr_info MEMBER_SIZE (struct elf_prstatus, pr_info)
+offset_elf_prstatus_pr_info offsetof (struct elf_prstatus, pr_info)
+sizeof_elf_prstatus_pr_cursig MEMBER_SIZE (struct elf_prstatus, pr_cursig)
+offset_elf_prstatus_pr_cursig offsetof (struct elf_prstatus, pr_cursig)
+sizeof_elf_prstatus_pr_sigpend MEMBER_SIZE (struct elf_prstatus, pr_sigpend)
+offset_elf_prstatus_pr_sigpend offsetof (struct elf_prstatus, pr_sigpend)
+sizeof_elf_prstatus_pr_sighold MEMBER_SIZE (struct elf_prstatus, pr_sighold)
+offset_elf_prstatus_pr_sighold offsetof (struct elf_prstatus, pr_sighold)
+sizeof_elf_prstatus_pr_pid MEMBER_SIZE (struct elf_prstatus, pr_pid)
+offset_elf_prstatus_pr_pid offsetof (struct elf_prstatus, pr_pid)
+sizeof_elf_prstatus_pr_ppid MEMBER_SIZE (struct elf_prstatus, pr_ppid)
+offset_elf_prstatus_pr_ppid offsetof (struct elf_prstatus, pr_ppid)
+sizeof_elf_prstatus_pr_pgrp MEMBER_SIZE (struct elf_prstatus, pr_pgrp)
+offset_elf_prstatus_pr_pgrp offsetof (struct elf_prstatus, pr_pgrp)
+sizeof_elf_prstatus_pr_sid MEMBER_SIZE (struct elf_prstatus, pr_sid)
+offset_elf_prstatus_pr_sid offsetof (struct elf_prstatus, pr_sid)
+sizeof_elf_prstatus_pr_utime MEMBER_SIZE (struct elf_prstatus, pr_utime)
+offset_elf_prstatus_pr_utime offsetof (struct elf_prstatus, pr_utime)
+sizeof_elf_prstatus_pr_stime MEMBER_SIZE (struct elf_prstatus, pr_stime)
+offset_elf_prstatus_pr_stime offsetof (struct elf_prstatus, pr_stime)
+sizeof_elf_prstatus_pr_cutime MEMBER_SIZE (struct elf_prstatus, pr_cutime)
+offset_elf_prstatus_pr_cutime offsetof (struct elf_prstatus, pr_cutime)
+sizeof_elf_prstatus_pr_cstime MEMBER_SIZE (struct elf_prstatus, pr_cstime)
+offset_elf_prstatus_pr_cstime offsetof (struct elf_prstatus, pr_cstime)
+sizeof_elf_prstatus_pr_reg MEMBER_SIZE (struct elf_prstatus, pr_reg)
+offset_elf_prstatus_pr_reg offsetof (struct elf_prstatus, pr_reg)
+sizeof_elf_prstatus_pr_fpvalid MEMBER_SIZE (struct elf_prstatus, pr_fpvalid)
+offset_elf_prstatus_pr_fpvalid offsetof (struct elf_prstatus, pr_fpvalid)
+
+sizeof_elf_prpsinfo_pr_state MEMBER_SIZE (struct elf_prpsinfo, pr_state)
+offset_elf_prpsinfo_pr_state offsetof (struct elf_prpsinfo, pr_state)
+sizeof_elf_prpsinfo_pr_sname MEMBER_SIZE (struct elf_prpsinfo, pr_sname)
+offset_elf_prpsinfo_pr_sname offsetof (struct elf_prpsinfo, pr_sname)
+sizeof_elf_prpsinfo_pr_zomb MEMBER_SIZE (struct elf_prpsinfo, pr_zomb)
+offset_elf_prpsinfo_pr_zomb offsetof (struct elf_prpsinfo, pr_zomb)
+sizeof_elf_prpsinfo_pr_nice MEMBER_SIZE (struct elf_prpsinfo, pr_nice)
+offset_elf_prpsinfo_pr_nice offsetof (struct elf_prpsinfo, pr_nice)
+sizeof_elf_prpsinfo_pr_flag MEMBER_SIZE (struct elf_prpsinfo, pr_flag)
+offset_elf_prpsinfo_pr_flag offsetof (struct elf_prpsinfo, pr_flag)
+sizeof_elf_prpsinfo_pr_uid MEMBER_SIZE (struct elf_prpsinfo, pr_uid)
+offset_elf_prpsinfo_pr_uid offsetof (struct elf_prpsinfo, pr_uid)
+sizeof_elf_prpsinfo_pr_gid MEMBER_SIZE (struct elf_prpsinfo, pr_gid)
+offset_elf_prpsinfo_pr_gid offsetof (struct elf_prpsinfo, pr_gid)
+sizeof_elf_prpsinfo_pr_pid MEMBER_SIZE (struct elf_prpsinfo, pr_pid)
+offset_elf_prpsinfo_pr_pid offsetof (struct elf_prpsinfo, pr_pid)
+sizeof_elf_prpsinfo_pr_ppid MEMBER_SIZE (struct elf_prpsinfo, pr_ppid)
+offset_elf_prpsinfo_pr_ppid offsetof (struct elf_prpsinfo, pr_ppid)
+sizeof_elf_prpsinfo_pr_pgrp MEMBER_SIZE (struct elf_prpsinfo, pr_pgrp)
+offset_elf_prpsinfo_pr_pgrp offsetof (struct elf_prpsinfo, pr_pgrp)
+sizeof_elf_prpsinfo_pr_sid MEMBER_SIZE (struct elf_prpsinfo, pr_sid)
+offset_elf_prpsinfo_pr_sid offsetof (struct elf_prpsinfo, pr_sid)
+sizeof_elf_prpsinfo_pr_fname MEMBER_SIZE (struct elf_prpsinfo, pr_fname)
+offset_elf_prpsinfo_pr_fname offsetof (struct elf_prpsinfo, pr_fname)
+sizeof_elf_prpsinfo_pr_psargs MEMBER_SIZE (struct elf_prpsinfo, pr_psargs)
+offset_elf_prpsinfo_pr_psargs offsetof (struct elf_prpsinfo, pr_psargs)
diff --git a/sysdeps/unix/sysv/linux/procfs-linux.sym b/sysdeps/unix/sysv/linux/procfs-linux.sym
new file mode 100644
index 0000000000..f3ad298421
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/procfs-linux.sym
@@ -0,0 +1,73 @@
+#include <linux/elfcore.h>
+#include <stddef.h>
+
+--
+
+#define MEMBER_SIZE(S, F) sizeof ((S) { 0 }.F)
+
+sizeof_elf_siginfo sizeof (struct elf_siginfo)
+sizeof_elf_prstatus sizeof (struct elf_prstatus)
+sizeof_elf_prpsinfo sizeof (struct elf_prpsinfo)
+
+sizeof_elf_siginfo_si_signo MEMBER_SIZE (struct elf_siginfo, si_signo)
+offset_elf_siginfo_si_signo offsetof (struct elf_siginfo, si_signo)
+sizeof_elf_siginfo_si_code MEMBER_SIZE (struct elf_siginfo, si_code)
+offset_elf_siginfo_si_code offsetof (struct elf_siginfo, si_code)
+sizeof_elf_siginfo_si_errno MEMBER_SIZE (struct elf_siginfo, si_errno)
+offset_elf_siginfo_si_errno offsetof (struct elf_siginfo, si_errno)
+
+sizeof_elf_prstatus_pr_info MEMBER_SIZE (struct elf_prstatus, pr_info)
+offset_elf_prstatus_pr_info offsetof (struct elf_prstatus, pr_info)
+sizeof_elf_prstatus_pr_cursig MEMBER_SIZE (struct elf_prstatus, pr_cursig)
+offset_elf_prstatus_pr_cursig offsetof (struct elf_prstatus, pr_cursig)
+sizeof_elf_prstatus_pr_sigpend MEMBER_SIZE (struct elf_prstatus, pr_sigpend)
+offset_elf_prstatus_pr_sigpend offsetof (struct elf_prstatus, pr_sigpend)
+sizeof_elf_prstatus_pr_sighold MEMBER_SIZE (struct elf_prstatus, pr_sighold)
+offset_elf_prstatus_pr_sighold offsetof (struct elf_prstatus, pr_sighold)
+sizeof_elf_prstatus_pr_pid MEMBER_SIZE (struct elf_prstatus, pr_pid)
+offset_elf_prstatus_pr_pid offsetof (struct elf_prstatus, pr_pid)
+sizeof_elf_prstatus_pr_ppid MEMBER_SIZE (struct elf_prstatus, pr_ppid)
+offset_elf_prstatus_pr_ppid offsetof (struct elf_prstatus, pr_ppid)
+sizeof_elf_prstatus_pr_pgrp MEMBER_SIZE (struct elf_prstatus, pr_pgrp)
+offset_elf_prstatus_pr_pgrp offsetof (struct elf_prstatus, pr_pgrp)
+sizeof_elf_prstatus_pr_sid MEMBER_SIZE (struct elf_prstatus, pr_sid)
+offset_elf_prstatus_pr_sid offsetof (struct elf_prstatus, pr_sid)
+sizeof_elf_prstatus_pr_utime MEMBER_SIZE (struct elf_prstatus, pr_utime)
+offset_elf_prstatus_pr_utime offsetof (struct elf_prstatus, pr_utime)
+sizeof_elf_prstatus_pr_stime MEMBER_SIZE (struct elf_prstatus, pr_stime)
+offset_elf_prstatus_pr_stime offsetof (struct elf_prstatus, pr_stime)
+sizeof_elf_prstatus_pr_cutime MEMBER_SIZE (struct elf_prstatus, pr_cutime)
+offset_elf_prstatus_pr_cutime offsetof (struct elf_prstatus, pr_cutime)
+sizeof_elf_prstatus_pr_cstime MEMBER_SIZE (struct elf_prstatus, pr_cstime)
+offset_elf_prstatus_pr_cstime offsetof (struct elf_prstatus, pr_cstime)
+sizeof_elf_prstatus_pr_reg MEMBER_SIZE (struct elf_prstatus, pr_reg)
+offset_elf_prstatus_pr_reg offsetof (struct elf_prstatus, pr_reg)
+sizeof_elf_prstatus_pr_fpvalid MEMBER_SIZE (struct elf_prstatus, pr_fpvalid)
+offset_elf_prstatus_pr_fpvalid offsetof (struct elf_prstatus, pr_fpvalid)
+
+sizeof_elf_prpsinfo_pr_state MEMBER_SIZE (struct elf_prpsinfo, pr_state)
+offset_elf_prpsinfo_pr_state offsetof (struct elf_prpsinfo, pr_state)
+sizeof_elf_prpsinfo_pr_sname MEMBER_SIZE (struct elf_prpsinfo, pr_sname)
+offset_elf_prpsinfo_pr_sname offsetof (struct elf_prpsinfo, pr_sname)
+sizeof_elf_prpsinfo_pr_zomb MEMBER_SIZE (struct elf_prpsinfo, pr_zomb)
+offset_elf_prpsinfo_pr_zomb offsetof (struct elf_prpsinfo, pr_zomb)
+sizeof_elf_prpsinfo_pr_nice MEMBER_SIZE (struct elf_prpsinfo, pr_nice)
+offset_elf_prpsinfo_pr_nice offsetof (struct elf_prpsinfo, pr_nice)
+sizeof_elf_prpsinfo_pr_flag MEMBER_SIZE (struct elf_prpsinfo, pr_flag)
+offset_elf_prpsinfo_pr_flag offsetof (struct elf_prpsinfo, pr_flag)
+sizeof_elf_prpsinfo_pr_uid MEMBER_SIZE (struct elf_prpsinfo, pr_uid)
+offset_elf_prpsinfo_pr_uid offsetof (struct elf_prpsinfo, pr_uid)
+sizeof_elf_prpsinfo_pr_gid MEMBER_SIZE (struct elf_prpsinfo, pr_gid)
+offset_elf_prpsinfo_pr_gid offsetof (struct elf_prpsinfo, pr_gid)
+sizeof_elf_prpsinfo_pr_pid MEMBER_SIZE (struct elf_prpsinfo, pr_pid)
+offset_elf_prpsinfo_pr_pid offsetof (struct elf_prpsinfo, pr_pid)
+sizeof_elf_prpsinfo_pr_ppid MEMBER_SIZE (struct elf_prpsinfo, pr_ppid)
+offset_elf_prpsinfo_pr_ppid offsetof (struct elf_prpsinfo, pr_ppid)
+sizeof_elf_prpsinfo_pr_pgrp MEMBER_SIZE (struct elf_prpsinfo, pr_pgrp)
+offset_elf_prpsinfo_pr_pgrp offsetof (struct elf_prpsinfo, pr_pgrp)
+sizeof_elf_prpsinfo_pr_sid MEMBER_SIZE (struct elf_prpsinfo, pr_sid)
+offset_elf_prpsinfo_pr_sid offsetof (struct elf_prpsinfo, pr_sid)
+sizeof_elf_prpsinfo_pr_fname MEMBER_SIZE (struct elf_prpsinfo, pr_fname)
+offset_elf_prpsinfo_pr_fname offsetof (struct elf_prpsinfo, pr_fname)
+sizeof_elf_prpsinfo_pr_psargs MEMBER_SIZE (struct elf_prpsinfo, pr_psargs)
+offset_elf_prpsinfo_pr_psargs offsetof (struct elf_prpsinfo, pr_psargs)
--
Joseph S. Myers
joseph@codesourcery.com