lbdb: fix compilation on Mountain Lion and Mavericks

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