Portability fixes,  with these changes I am able to build liblightgrep on FreeBSD.