[lib] add support for BSDs