Cherry-pick two upstream commits to fix oversights making the build fail on 32 bit platforms. Approved by: portmgr (build fix blanket)