lbdb: fix compilation on Mavericks

Apply three patches from chrisbarrett/lbdb to fix compilation on Mavericks