]> git.proxmox.com Git - libgit2.git/blobdiff - src/unix/posix.h
New upstream version 1.3.0+dfsg.1
[libgit2.git] / src / unix / posix.h
index 52985fd8a868fd9452a7af8638099d4201482b4f..7b3325e78176dd385690fde2acad469d1e00cf05 100644 (file)
@@ -4,8 +4,12 @@
  * This file is part of libgit2, distributed under the GNU GPL v2 with
  * a Linking Exception. For full terms see the included COPYING file.
  */
-#ifndef INCLUDE_posix__unix_h__
-#define INCLUDE_posix__unix_h__
+#ifndef INCLUDE_unix_posix_h__
+#define INCLUDE_unix_posix_h__
+
+#ifndef LIBGIT2_NO_FEATURES_H
+# include "git2/sys/features.h"
+#endif
 
 #include <stdio.h>
 #include <dirent.h>
@@ -29,7 +33,7 @@ typedef int GIT_SOCKET;
 # define st_atime_nsec st_atim.tv_nsec
 # define st_mtime_nsec st_mtim.tv_nsec
 # define st_ctime_nsec st_ctim.tv_nsec
-#elif !defined(GIT_USE_STAT_MTIME_NSEC) && defined(GIT_USE_NEC)
+#elif !defined(GIT_USE_STAT_MTIME_NSEC) && defined(GIT_USE_NSEC)
 # error GIT_USE_NSEC defined but unknown struct stat nanosecond type
 #endif
 
@@ -55,14 +59,26 @@ GIT_INLINE(int) p_fsync(int fd)
 #define p_strcasecmp(s1, s2) strcasecmp(s1, s2)
 #define p_strncasecmp(s1, s2, c) strncasecmp(s1, s2, c)
 #define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
-#define p_snprintf(b, c, ...) snprintf(b, c, __VA_ARGS__)
+#define p_snprintf snprintf
 #define p_mkstemp(p) mkstemp(p)
 #define p_chdir(p) chdir(p)
-#define p_chmod(p,m) chmod(p, m)
 #define p_rmdir(p) rmdir(p)
 #define p_access(p,m) access(p,m)
 #define p_ftruncate(fd, sz) ftruncate(fd, sz)
 
+/*
+ * Pre-Android 5 did not implement a virtual filesystem atop FAT
+ * partitions for Unix permissions, which causes chmod to fail. However,
+ * Unix permissions have no effect on Android anyway as file permissions
+ * are not actually managed this way, so treating it as a no-op across
+ * all Android is safe.
+ */
+#ifdef __ANDROID__
+# define p_chmod(p,m) 0
+#else
+# define p_chmod(p,m) chmod(p, m)
+#endif
+
 /* see win32/posix.h for explanation about why this exists */
 #define p_lstat_posixly(p,b) lstat(p,b)
 
@@ -71,7 +87,7 @@ GIT_INLINE(int) p_fsync(int fd)
 
 #define p_timeval timeval
 
-#ifdef HAVE_FUTIMENS
+#ifdef GIT_USE_FUTIMENS
 GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2])
 {
        struct timespec s[2];
@@ -85,14 +101,7 @@ GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2])
 # define p_futimes futimes
 #endif
 
-#ifdef HAVE_REGCOMP_L
-#include <xlocale.h>
-GIT_INLINE(int) p_regcomp(regex_t *preg, const char *pattern, int cflags)
-{
-       return regcomp_l(preg, pattern, cflags, (locale_t) 0);
-}
-#else
-# define p_regcomp regcomp
-#endif
+#define p_pread(f, d, s, o) pread(f, d, s, o)
+#define p_pwrite(f, d, s, o) pwrite(f, d, s, o)
 
 #endif