core: Adding workaround for missing <byteswap.h> on FreeBSD

This commit also fixes a couple of compilation issues with gcc 4.2.1

Change-Id: Iacc5a742b666849694b6ee947482e78340f74336