Commit 9ecf860d48b39241a2dce61dd33455816064d56b

Ben Straub 2012-06-06T13:24:25

Rename posix wrappers with 'p_' prefix.

diff --git a/src/date.c b/src/date.c
index 5529dc2..658b09e 100644
--- a/src/date.c
+++ b/src/date.c
@@ -271,7 +271,7 @@ static int match_multi_number(unsigned long num, char c, const char *date, char 
 	case '.':
 		now = time(NULL);
 		refuse_future = NULL;
-		if (gmtime_r(&now, &now_tm))
+		if (p_gmtime_r(&now, &now_tm))
 			refuse_future = &now_tm;
 
 		if (num > 70) {
@@ -334,7 +334,7 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
 	 */
 	if (num >= 100000000 && nodate(tm)) {
 		time_t time = num;
-		if (gmtime_r(&time, tm)) {
+		if (p_gmtime_r(&time, tm)) {
 			*tm_gmt = 1;
 			return end - date;
 		}
@@ -561,7 +561,7 @@ static git_time_t update_tm(struct tm *tm, struct tm *now, unsigned long sec)
 	}
 
 	n = mktime(tm) - sec;
-	localtime_r(&n, tm);
+	p_localtime_r(&n, tm);
 	return n;
 }
 
@@ -639,7 +639,7 @@ static void date_never(struct tm *tm, struct tm *now, int *num)
 	time_t n = 0;
    GIT_UNUSED(now);
    GIT_UNUSED(num);
-	localtime_r(&n, tm);
+	p_localtime_r(&n, tm);
 }
 
 static const struct special {
@@ -832,7 +832,7 @@ static git_time_t approxidate_str(const char *date,
 	time_t time_sec;
 
 	time_sec = tv->tv_sec;
-	localtime_r(&time_sec, &tm);
+	p_localtime_r(&time_sec, &tm);
 	now = tm;
 
 	tm.tm_year = -1;
@@ -870,7 +870,7 @@ int git__date_parse(git_time_t *out, const char *date)
 		return 0;
 	}
 
-	gettimeofday(&tv, NULL);
+	p_gettimeofday(&tv, NULL);
 	*out = approxidate_str(date, &tv, &error_ret);
    return error_ret;
 }
diff --git a/src/posix.h b/src/posix.h
index d020d94..3f52f9b 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -59,9 +59,17 @@ extern int p_rename(const char *from, const char *to);
 typedef int GIT_SOCKET;
 #define INVALID_SOCKET -1
 
+#define p_localtime_r localtime_r
+#define p_gmtime_r gmtime_r
+#define p_gettimeofday gettimeofday
+
 #else
 
 typedef SOCKET GIT_SOCKET;
+extern struct tm * p_localtime_r (const time_t *timer, struct tm *result);
+extern struct tm * p_gmtime_r (const time_t *timer, struct tm *result);
+extern int p_gettimeofday(struct timeval *tv, struct timezone *tz);
+
 
 #endif
 
diff --git a/src/signature.c b/src/signature.c
index 6b28a3e..332bdf6 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -119,8 +119,8 @@ int git_signature_now(git_signature **sig_out, const char *name, const char *ema
 
 	time(&now);
 
-	utc_tm = gmtime_r(&now, &_utc);
-	local_tm = localtime_r(&now, &_local);
+	utc_tm = p_gmtime_r(&now, &_utc);
+	local_tm = p_localtime_r(&now, &_local);
 
 	offset = mktime(local_tm) - mktime(utc_tm);
 	offset /= 60;
diff --git a/src/win32/posix.h b/src/win32/posix.h
index c38caa8..baa4a3b 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -52,8 +52,4 @@ extern int p_rename(const char *from, const char *to);
 extern int p_recv(GIT_SOCKET socket, void *buffer, size_t length, int flags);
 extern int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags);
 
-extern struct tm * localtime_r (const time_t *timer, struct tm *result);
-extern struct tm * gmtime_r (const time_t *timer, struct tm *result);
-extern int gettimeofday(struct timeval *tv, struct timezone *tz);
-
 #endif
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 092bafe..f0441df 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -476,7 +476,7 @@ int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags)
  * On Win32, `gmtime_r` doesn't exist but `gmtime` is threadsafe, so we can use that
  */
 struct tm * 
-localtime_r (const time_t *timer, struct tm *result) 
+p_localtime_r (const time_t *timer, struct tm *result) 
 { 
    struct tm *local_result; 
    local_result = localtime (timer); 
@@ -488,7 +488,7 @@ localtime_r (const time_t *timer, struct tm *result)
    return result; 
 } 
 struct tm * 
-gmtime_r (const time_t *timer, struct tm *result) 
+p_gmtime_r (const time_t *timer, struct tm *result) 
 { 
    struct tm *local_result; 
    local_result = gmtime (timer); 
@@ -512,7 +512,7 @@ struct timezone
    int  tz_dsttime;     /* type of dst correction */
 };
  
-int gettimeofday(struct timeval *tv, struct timezone *tz)
+int p_gettimeofday(struct timeval *tv, struct timezone *tz)
 {
    FILETIME ft;
    unsigned __int64 tmpres = 0;