Fix build issues on Mac OS platform.
Fix build issues on BSD