Windows support

Builds cleanly with msys+mingw x64, though I needed to patch the mtest progs to do it.

I'm trying to get the liblmdb change upstreamed: http://www.openldap.org/its/index.cgi/Incoming?id=7879