Portability fixes

These are needed for ec2-new to build on NetBSD.