What happens when we try to link this into Kyu?
aarch64-linux-gnu-ld.bfd: (.text+0x5180): undefined reference to `m_freem' aarch64-linux-gnu-ld.bfd: (.text+0x51a0): undefined reference to `splnet' aarch64-linux-gnu-ld.bfd: (.text+0x51c8): undefined reference to `splx' aarch64-linux-gnu-ld.bfd: (.text+0x52b8): undefined reference to `in_pcbbind'We get a myriad of warnings. The above are just a small sample. This is not unexpected. The BSD code makes many calls to things that simply don't exist in Kyu. the game now will be figuring out how to supply them and what changes to make to the BSD code to work in the Kyu environment.
I collected the full list (at this time), extracted just the names, then ran that through sort and uniq to get the following list of 60 missing functions. I have regrouped some of the functions in a minor way:
bcopy bzero imin min max htonl htons ntohl ntohs splimp splnet splx inetctlerrmap iptime rtalloc wakeup zeroin_addr in_control in_localaddr in_losing in_pcballoc in_pcbbind in_pcbconnect in_pcbdetach in_pcbdisconnect in_pcblookup in_pcbnotify in_setpeeraddr in_setsockaddr insque _remque remque ip_ctloutput ip_output ip_srcroute ip_stripoptions m_adj m_copydata m_copym m_free m_freem m_get m_gethdr m_pullup m_retryhdr sbappend sbdrop sbflush sbreserve soabort socantrcvmore socantsendmore sohasoutofband soisconnected soisconnecting soisdisconnected soisdisconnecting sonewconn1 soreserve sowakeupSo, for no particular reason, working from the bottom up.
The endian handling routines can be found in the Kyu file "arch/cpu.h" I am tempted though to put these (along with min,max,bcopy) into some kind of "bsd_utils" library. Maybe into kyu_bsd.c, but also generate a kyu_bsd.h file. This would avoid include file dependencies with the Kyu source. I would like to restrict that to kyu_bsd.c only.
I pulled in uipc_mbuf.c and after hacking on it a bit, it compiles cleanly and supplies all the m_* routines.
I added kyu_compat.h and include it in all the source files. For now it just pulls in KYU:arch/cpu.h to get the htonl() family.
The imin, min, max are all defined in libkern/libkern.h which is pulled in by systm.h -- I had this uncommented in one place, but when I reactivated it, all of those missing calls went away.
I added bcopy and bzero to kyu_bsd.c
remque and insque are more interesting. They deserve a whole page of their own, so we conclude this.
Kyu / [email protected]