X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=libgo%2Fmksysinfo.sh;h=a977f56937b24d8584b0ba2065610b6b8e608f1a;hb=2e58ed3087522ab051c23e0c45fb008a6fbef787;hp=a1713df9b572e75f41024b5223915c0bdfcffaae;hpb=f038dae646bac2b31be98ab592c0e5206d2d96f5;p=gcc.git diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index a1713df9b57..a977f56937b 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -163,6 +163,9 @@ cat > sysinfo.c < #endif +#if defined(HAVE_SCHED_H) +#include +#endif /* Constants that may only be defined as expressions on some systems, expressions too complex for -fdump-go-spec to handle. These are @@ -171,12 +174,33 @@ enum { #ifdef TIOCGWINSZ TIOCGWINSZ_val = TIOCGWINSZ, #endif +#ifdef TIOCSWINSZ + TIOCSWINSZ_val = TIOCSWINSZ, +#endif #ifdef TIOCNOTTY TIOCNOTTY_val = TIOCNOTTY, #endif #ifdef TIOCSCTTY TIOCSCTTY_val = TIOCSCTTY, #endif +#ifdef TIOCGPTN + TIOCGPTN_val = TIOCGPTN, +#endif +#ifdef TIOCSPTLCK + TIOCSPTLCK_val = TIOCSPTLCK, +#endif +#ifdef TIOCGDEV + TIOCGDEV_val = TIOCGDEV, +#endif +#ifdef TIOCSIG + TIOCSIG_val = TIOCSIG, +#endif +#ifdef TCGETS + TCGETS_val = TCGETS, +#endif +#ifdef TCSETS + TCSETS_val = TCSETS, +#endif }; EOF @@ -220,6 +244,11 @@ if ! grep '^const O_CLOEXEC' ${OUT} >/dev/null 2>&1; then echo "const O_CLOEXEC = 0" >> ${OUT} fi +# The os package requires F_DUPFD_CLOEXEC to be defined. +if ! grep '^const F_DUPFD_CLOEXEC' ${OUT} >/dev/null 2>&1; then + echo "const F_DUPFD_CLOEXEC = 0" >> ${OUT} +fi + # These flags can be lost on i386 GNU/Linux when using # -D_FILE_OFFSET_BITS=64, because we see "#define F_SETLK F_SETLK64" # before we see the definition of F_SETLK64. @@ -230,6 +259,16 @@ for flag in F_GETLK F_SETLK F_SETLKW; do fi done +# The Flock_t struct for fcntl. +grep '^type _flock ' gen-sysinfo.go | \ + sed -e 's/type _flock/type Flock_t/' \ + -e 's/l_type/Type/' \ + -e 's/l_whence/Whence/' \ + -e 's/l_start/Start/' \ + -e 's/l_len/Len/' \ + -e 's/l_pid/Pid/' \ + >> ${OUT} + # The signal numbers. grep '^const _SIG[^_]' gen-sysinfo.go | \ grep -v '^const _SIGEV_' | \ @@ -400,12 +439,50 @@ if ! grep '^const _PTRACE_TRACEME' ${OUT} > /dev/null 2>&1; then echo "const _PTRACE_TRACEME = 0" >> ${OUT} fi +# A helper function that prints a structure from gen-sysinfo.go with the first +# letter of the field names in upper case. $1 is the name of structure. If $2 +# is not empty, the structure or type is renamed to $2. +upcase_fields () { + name="$1" + def=`grep "^type $name" gen-sysinfo.go` + fields=`echo $def | sed -e 's/^[^{]*{\(.*\)}$/\1/'` + prefix=`echo $def | sed -e 's/{.*//'` + if test "$2" != ""; then + prefix=`echo $prefix | sed -e "s/$1/$2/"` + fi + if test "$fields" != ""; then + nfields= + while test -n "$fields"; do + field=`echo $fields | sed -e 's/^\([^;]*\);.*$/\1/'` + fields=`echo $fields | sed -e 's/^[^;]*; *\(.*\)$/\1/'` + # capitalize the next character. + f=`echo $field | sed -e 's/^\(.\).*$/\1/'` + r=`echo $field | sed -e 's/^.\(.*\)$/\1/'` + f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` + field="$f$r" + nfields="$nfields $field;" + done + echo "${prefix} {$nfields }" + fi +} + # The registers returned by PTRACE_GETREGS. This is probably # GNU/Linux specific; it should do no harm if there is no # _user_regs_struct. regs=`grep '^type _user_regs_struct struct' gen-sysinfo.go || true` +if test "$regs" == ""; then + # s390 + regs=`grep '^type __user_regs_struct struct' gen-sysinfo.go || true` + if test "$regs" != ""; then + # Substructures of __user_regs_struct on s390 + upcase_fields "__user_psw_struct" "PtracePsw" >> ${OUT} || true + upcase_fields "__user_fpregs_struct" "PtraceFpregs" >> ${OUT} || true + upcase_fields "__user_per_struct" "PtracePer" >> ${OUT} || true + fi +fi if test "$regs" != ""; then - regs=`echo $regs | sed -e 's/type _user_regs_struct struct //' -e 's/[{}]//g'` + regs=`echo $regs | + sed -e 's/type __*user_regs_struct struct //' -e 's/[{}]//g'` regs=`echo $regs | sed -e s'/^ *//'` nregs= while test -n "$regs"; do @@ -416,6 +493,10 @@ if test "$regs" != ""; then r=`echo $field | sed -e 's/^.\(.*\)$/\1/'` f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` field="$f$r" + field=`echo "$field" | sed \ + -e 's/__user_psw_struct/PtracePsw/' \ + -e 's/__user_fpregs_struct/PtraceFpregs/' \ + -e 's/__user_per_struct/PtracePer/'` nregs="$nregs $field;" done echo "type PtraceRegs struct {$nregs }" >> ${OUT} @@ -577,7 +658,7 @@ grep '^const _DT_' gen-sysinfo.go | rusage=`grep '^type _rusage struct' gen-sysinfo.go` if test "$rusage" != ""; then # Remove anonymous unions from GNU/Linux . - rusage=`echo $rusage | sed -e 's/Godump_[0-9]* struct {\([^}]*\)};/\1/g'` + rusage=`echo $rusage | sed -e 's/Godump_[0-9][0-9]* struct {\([^}]*\)};/\1/g'` rusage=`echo $rusage | sed -e 's/type _rusage struct //' -e 's/[{}]//g'` rusage=`echo $rusage | sed -e 's/^ *//'` nrusage= @@ -665,12 +746,7 @@ grep '^const _SCM_' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(SCM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} # The ucred struct. -grep '^type _ucred ' gen-sysinfo.go | \ - sed -e 's/_ucred/Ucred/' \ - -e 's/pid/Pid/' \ - -e 's/uid/Uid/' \ - -e 's/gid/Gid/' \ - >> ${OUT} +upcase_fields "_ucred" "Ucred" >> ${OUT} || true # The ip_mreq struct. grep '^type _ip_mreq ' gen-sysinfo.go | \ @@ -760,6 +836,11 @@ if ! grep '^const TIOCGWINSZ' ${OUT} >/dev/null 2>&1; then echo 'const TIOCGWINSZ = _TIOCGWINSZ_val' >> ${OUT} fi fi +if ! grep '^const TIOCSWINSZ' ${OUT} >/dev/null 2>&1; then + if grep '^const _TIOCSWINSZ_val' ${OUT} >/dev/null 2>&1; then + echo 'const TIOCSWINSZ = _TIOCSWINSZ_val' >> ${OUT} + fi +fi if ! grep '^const TIOCNOTTY' ${OUT} >/dev/null 2>&1; then if grep '^const _TIOCNOTTY_val' ${OUT} >/dev/null 2>&1; then echo 'const TIOCNOTTY = _TIOCNOTTY_val' >> ${OUT} @@ -770,10 +851,40 @@ if ! grep '^const TIOCSCTTY' ${OUT} >/dev/null 2>&1; then echo 'const TIOCSCTTY = _TIOCSCTTY_val' >> ${OUT} fi fi +if ! grep '^const TIOCGPTN' ${OUT} >/dev/null 2>&1; then + if grep '^const _TIOCGPTN_val' ${OUT} >/dev/null 2>&1; then + echo 'const TIOCGPTN = _TIOCGPTN_val' >> ${OUT} + fi +fi +if ! grep '^const TIOCSPTLCK' ${OUT} >/dev/null 2>&1; then + if grep '^const _TIOCSPTLCK_val' ${OUT} >/dev/null 2>&1; then + echo 'const TIOCSPTLCK = _TIOCSPTLCK_val' >> ${OUT} + fi +fi +if ! grep '^const TIOCGDEV' ${OUT} >/dev/null 2>&1; then + if grep '^const _TIOCGDEV_val' ${OUT} >/dev/null 2>&1; then + echo 'const TIOCGDEV = _TIOCGDEV_val' >> ${OUT} + fi +fi +if ! grep '^const TIOCSIG' ${OUT} >/dev/null 2>&1; then + if grep '^const _TIOCSIG_val' ${OUT} >/dev/null 2>&1; then + echo 'const TIOCSIG = _TIOCSIG_val' >> ${OUT} + fi +fi # The ioctl flags for terminal control -grep '^const _TC[GS]ET' gen-sysinfo.go | \ +grep '^const _TC[GS]ET' gen-sysinfo.go | grep -v _val | \ sed -e 's/^\(const \)_\(TC[GS]ET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} +if ! grep '^const TCGETS' ${OUT} >/dev/null 2>&1; then + if grep '^const _TCGETS_val' ${OUT} >/dev/null 2>&1; then + echo 'const TCGETS = _TCGETS_val' >> ${OUT} + fi +fi +if ! grep '^const TCSETS' ${OUT} >/dev/null 2>&1; then + if grep '^const _TCSETS_val' ${OUT} >/dev/null 2>&1; then + echo 'const TCSETS = _TCSETS_val' >> ${OUT} + fi +fi # ioctl constants. Might fall back to 0 if TIOCNXCL is missing, too, but # needs handling in syscalls.exec.go. @@ -1125,10 +1236,9 @@ grep '^type _inotify_event ' gen-sysinfo.go | \ -e 's/\[0\]byte/[0]int8/' \ >> ${OUT} -# The Solaris 11 Update 1 _zone_net_addr_t struct. -grep '^type _zone_net_addr_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr/[16]byte/' \ - >> ${OUT} +# The GNU/Linux CLONE flags. +grep '^const _CLONE_' gen-sysinfo.go | \ + sed -e 's/^\(const \)_\(CLONE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} # Struct sizes. set cmsghdr Cmsghdr ip_mreq IPMreq ip_mreqn IPMreqn ipv6_mreq IPv6Mreq \