Adapted to compile in DragonFly BSD

Please take in account it is untested in Linux/MAC/Windows