Fix leveldb compilation for NetBSD
Backport of core PR12294
This backport has not been tested and does not include the
documentation, as there is no demand for adding support for NetBSD.
The only purpose is to help doing so if want to do it in the future.
Reviewers: #bitcoin_abc, deadalnix, jasonbcox
Reviewed By: #bitcoin_abc, jasonbcox
Differential Revision: https://reviews.bitcoinabc.org/D3816