l2md: get l2md to compile and run on MacOS

Few tweaks to make the code compile on MacOS. As a prerequisite to get
it running, `brew install libgit2` is needed.

Signed-off-by: Alexei Starovoitov <ast@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
diff --git a/README b/README
index a845a53..5247066 100644
--- a/README
+++ b/README
@@ -27,6 +27,7 @@
 
 Fedora: libgit2-devel
 Ubuntu: libgit2-dev
+MacOS:  brew install libgit2
 
 To build, just type:
 
diff --git a/config.c b/config.c
index 0aadf35..c02854e 100644
--- a/config.c
+++ b/config.c
@@ -71,7 +71,7 @@
 
 	wordexp(dir, &p, 0);
 	dir = p.we_wordv[0];
-	strlcpy(cfg->general.base, dir, sizeof(cfg->general.base));
+	__strlcpy(cfg->general.base, dir, sizeof(cfg->general.base));
 	wordfree(&p);
 }
 
@@ -105,7 +105,7 @@
 
 	wordexp(ctx, &p, 0);
 	ctx = p.we_wordv[0];
-	strlcpy(out, ctx, sizeof(repo->out));
+	__strlcpy(out, ctx, sizeof(repo->out));
 	wordfree(&p);
 }
 
@@ -135,7 +135,7 @@
 			      repo->urls_num);
 	url = url_last(repo);
 	memset(url, 0, sizeof(*url));
-	strlcpy(url->path, git_url, sizeof(url->path));
+	__strlcpy(url->path, git_url, sizeof(url->path));
 }
 
 static void config_new_repo(struct config *cfg, const char *name)
@@ -149,7 +149,7 @@
 	memset(repo, 0, sizeof(*repo));
 	config_set_out(cfg, cfg->general.out, false);
 	config_set_repo_status(cfg, true);
-	strlcpy(repo->name, name, sizeof(repo->name));
+	__strlcpy(repo->name, name, sizeof(repo->name));
 }
 
 static void config_set_defaults(struct config *cfg, const char *homedir)
@@ -174,7 +174,7 @@
 	}
 
 	verbose("Using base dir %s\n", default_data_dir);
-	strlcpy(cfg->general.base, data_dir, sizeof(cfg->general.base));
+	__strlcpy(cfg->general.base, data_dir, sizeof(cfg->general.base));
 
 	config_set_ops(cfg, &ops_maildir);
 	cfg->ops->set_defaults(cfg);
diff --git a/l2md.h b/l2md.h
index 1eabacc..ffdd2d4 100644
--- a/l2md.h
+++ b/l2md.h
@@ -145,7 +145,7 @@
 int timeval_sub(struct timeval *res, struct timeval *x,
 		struct timeval *y);
 
-size_t strlcpy(char *dest, const char *src, size_t size);
+size_t __strlcpy(char *dest, const char *src, size_t size);
 int slprintf(char *dst, size_t size, const char *fmt, ...);
 
 void verbose(const char *format, ...) __check_format_printf(1, 2);
diff --git a/maildir.c b/maildir.c
index 7b7cc41..9283036 100644
--- a/maildir.c
+++ b/maildir.c
@@ -38,7 +38,7 @@
 	char path[PATH_MAX];
 
 	slprintf(path, sizeof(path), "%s/maildir", cfg->general.base);
-	strlcpy(cfg->general.out, path, sizeof(cfg->general.out));
+	__strlcpy(cfg->general.out, path, sizeof(cfg->general.out));
 }
 
 const struct mail_ops ops_maildir = {
diff --git a/repo.c b/repo.c
index 49b0ea4..8cd9f6d 100644
--- a/repo.c
+++ b/repo.c
@@ -274,7 +274,7 @@
 		git_oid_tostr(oid_curr, sizeof(oid_curr), &loid);
 		printf("Processed %u new mail(s) for %s. %s: %s -> %s in %ld.%02lds.\n",
 		       count, repo->name, repo->urls[url].path, oid_last ? oid_curr :
-		       "[none]", oid_done, res.tv_sec, res.tv_usec);
+		       "[none]", oid_done, res.tv_sec, (long)res.tv_usec);
 	}
 
 	git_revwalk_free(walker);
diff --git a/utils.c b/utils.c
index a1a387e..e4c7849 100644
--- a/utils.c
+++ b/utils.c
@@ -94,6 +94,8 @@
 	xmkdir1(path);
 }
 
+typedef off_t loff_t;
+
 int xread_file(const char *file, char *to, size_t len, bool fatal)
 {
 	loff_t ret;
@@ -208,7 +210,7 @@
 	return x->tv_sec < y->tv_sec;
 }
 
-size_t strlcpy(char *dest, const char *src, size_t size)
+size_t __strlcpy(char *dest, const char *src, size_t size)
 {
 	size_t ret = strlen(src);