#!/bin/sh # Copyright 2016 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. # Create runtime_sysinfo.go from gen-sysinfo.go and errno.i. OUT=tmp-runtime_sysinfo.go set -e echo 'package runtime' > ${OUT} # Get all the consts and types, skipping ones which could not be # represented in Go and ones which we need to rewrite. We also skip # function declarations, as we don't need them here. All the symbols # will all have a leading underscore. grep -v '^// ' gen-sysinfo.go | \ grep -v '^func' | \ grep -v '^type _timeval ' | \ grep -v '^type _timespec_t ' | \ grep -v '^type _timespec ' | \ grep -v '^type _epoll_' | \ grep -v 'in6_addr' | \ grep -v 'sockaddr_in6' | \ sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1timeval\2/g' \ -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1timespec\2/g' \ -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1timespec\2/g' \ >> ${OUT} # The time structures need special handling: we need to name the # types, so that we can cast integers to the right types when # assigning to the structures. timeval=`grep '^type _timeval ' gen-sysinfo.go` timeval_sec=`echo $timeval | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'` timeval_usec=`echo $timeval | sed -n -e 's/^.*tv_usec \([^ ]*\);.*$/\1/p'` echo "type timeval_sec_t $timeval_sec" >> ${OUT} echo "type timeval_usec_t $timeval_usec" >> ${OUT} echo $timeval | \ sed -e 's/type _timeval /type timeval /' \ -e 's/tv_sec *[a-zA-Z0-9_]*/tv_sec timeval_sec_t/' \ -e 's/tv_usec *[a-zA-Z0-9_]*/tv_usec timeval_usec_t/' >> ${OUT} timespec=`grep '^type _timespec ' gen-sysinfo.go || true` if test "$timespec" = ""; then # IRIX 6.5 has __timespec instead. timespec=`grep '^type ___timespec ' gen-sysinfo.go || true` fi timespec_sec=`echo $timespec | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'` timespec_nsec=`echo $timespec | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'` echo "type timespec_sec_t $timespec_sec" >> ${OUT} echo "type timespec_nsec_t $timespec_nsec" >> ${OUT} echo $timespec | \ sed -e 's/^type ___timespec /type timespec /' \ -e 's/^type _timespec /type timespec /' \ -e 's/tv_sec *[a-zA-Z0-9_]*/tv_sec timespec_sec_t/' \ -e 's/tv_nsec *[a-zA-Z0-9_]*/tv_nsec timespec_nsec_t/' >> ${OUT} echo >> ${OUT} echo "func (ts *timespec) set_sec(x int64) {" >> ${OUT} echo " ts.tv_sec = timespec_sec_t(x)" >> ${OUT} echo "}" >> ${OUT} echo >> ${OUT} echo "func (ts *timespec) set_nsec(x int32) {" >> ${OUT} echo " ts.tv_nsec = timespec_nsec_t(x)" >> ${OUT} echo "}" >> ${OUT} # The semt structure, for Solaris. grep '^type _sem_t ' gen-sysinfo.go | \ sed -e 's/_sem_t/semt/' >> ${OUT} # Solaris 2 needs _u?pad128_t, but its default definition in terms of long # double is commented by -fdump-go-spec. if grep "^// type _pad128_t" gen-sysinfo.go > /dev/null 2>&1; then echo "type _pad128_t struct { _l [4]int32; }" >> ${OUT} fi if grep "^// type _upad128_t" gen-sysinfo.go > /dev/null 2>&1; then echo "type _upad128_t struct { _l [4]uint32; }" >> ${OUT} fi # 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 Solaris 12 _flow_arp_desc_t struct. grep '^type _flow_arp_desc_t ' gen-sysinfo.go | \ sed -e 's/_in6_addr_t/[16]byte/g' \ >> ${OUT} # The Solaris 12 _flow_l3_desc_t struct. grep '^type _flow_l3_desc_t ' gen-sysinfo.go | \ sed -e 's/_in6_addr_t/[16]byte/g' \ >> ${OUT} # The Solaris 12 _mac_ipaddr_t struct. grep '^type _mac_ipaddr_t ' gen-sysinfo.go | \ sed -e 's/_in6_addr_t/[16]byte/g' \ >> ${OUT} # The Solaris 12 _mactun_info_t struct. grep '^type _mactun_info_t ' gen-sysinfo.go | \ sed -e 's/_in6_addr_t/[16]byte/g' \ >> ${OUT}