]>
Commit | Line | Data |
---|---|---|
bb742ede | 1 | /* |
359fc2d2 | 2 | * Copyright (C) the libgit2 contributors. All rights reserved. |
bb742ede VM |
3 | * |
4 | * This file is part of libgit2, distributed under the GNU GPL v2 with | |
5 | * a Linking Exception. For full terms see the included COPYING file. | |
6 | */ | |
529c3715 JG |
7 | #ifndef INCLUDE_posix__unix_h__ |
8 | #define INCLUDE_posix__unix_h__ | |
f79026b4 | 9 | |
6fb1c0b4 | 10 | #include <stdio.h> |
edbfc52c | 11 | #include <dirent.h> |
e40f1c2d | 12 | #include <sys/param.h> |
85a5e8eb | 13 | #include <sys/time.h> |
69c8bf7e | 14 | #include <sys/stat.h> |
6fb1c0b4 | 15 | |
2f795d8f JG |
16 | typedef int GIT_SOCKET; |
17 | #define INVALID_SOCKET -1 | |
18 | ||
2f795d8f JG |
19 | #define p_lseek(f,n,w) lseek(f, n, w) |
20 | #define p_fstat(f,b) fstat(f, b) | |
f79026b4 | 21 | #define p_lstat(p,b) lstat(p,b) |
07d03d31 | 22 | #define p_stat(p,b) stat(p, b) |
2f795d8f | 23 | |
3d6a42d1 ET |
24 | #if defined(GIT_USE_STAT_MTIMESPEC) |
25 | # define st_atime_nsec st_atimespec.tv_nsec | |
26 | # define st_mtime_nsec st_mtimespec.tv_nsec | |
27 | # define st_ctime_nsec st_ctimespec.tv_nsec | |
28 | #elif defined(GIT_USE_STAT_MTIM) | |
29 | # define st_atime_nsec st_atim.tv_nsec | |
30 | # define st_mtime_nsec st_mtim.tv_nsec | |
31 | # define st_ctime_nsec st_ctim.tv_nsec | |
32 | #elif !defined(GIT_USE_STAT_MTIME_NSEC) && defined(GIT_USE_NEC) | |
33 | # error GIT_USE_NSEC defined but unknown struct stat nanosecond type | |
34 | #endif | |
35 | ||
121c3171 | 36 | #define p_utimes(f, t) utimes(f, t) |
121c3171 | 37 | |
f79026b4 | 38 | #define p_readlink(a, b, c) readlink(a, b, c) |
ca1b6e54 | 39 | #define p_symlink(o,n) symlink(o, n) |
f79026b4 VM |
40 | #define p_link(o,n) link(o, n) |
41 | #define p_unlink(p) unlink(p) | |
42 | #define p_mkdir(p,m) mkdir(p, m) | |
43 | #define p_fsync(fd) fsync(fd) | |
662f90e6 | 44 | extern char *p_realpath(const char *, char *); |
67fcac56 | 45 | |
2f795d8f JG |
46 | #define p_recv(s,b,l,f) recv(s,b,l,f) |
47 | #define p_send(s,b,l,f) send(s,b,l,f) | |
48 | #define p_inet_pton(a, b, c) inet_pton(a, b, c) | |
49 | ||
07d03d31 JG |
50 | #define p_strcasecmp(s1, s2) strcasecmp(s1, s2) |
51 | #define p_strncasecmp(s1, s2, c) strncasecmp(s1, s2, c) | |
2fc78e70 | 52 | #define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a) |
84dd3820 | 53 | #define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__) |
f978b748 | 54 | #define p_mkstemp(p) mkstemp(p) |
2f795d8f JG |
55 | #define p_chdir(p) chdir(p) |
56 | #define p_chmod(p,m) chmod(p, m) | |
57 | #define p_rmdir(p) rmdir(p) | |
58 | #define p_access(p,m) access(p,m) | |
59 | #define p_ftruncate(fd, sz) ftruncate(fd, sz) | |
f79026b4 | 60 | |
cccacac5 RB |
61 | /* see win32/posix.h for explanation about why this exists */ |
62 | #define p_lstat_posixly(p,b) lstat(p,b) | |
63 | ||
2f795d8f JG |
64 | #define p_localtime_r(c, r) localtime_r(c, r) |
65 | #define p_gmtime_r(c, r) gmtime_r(c, r) | |
66 | ||
35439f59 ET |
67 | #define p_timeval timeval |
68 | ||
8649dfd8 | 69 | #ifdef HAVE_FUTIMENS |
35439f59 | 70 | GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2]) |
8649dfd8 ET |
71 | { |
72 | struct timespec s[2]; | |
73 | s[0].tv_sec = t[0].tv_sec; | |
74 | s[0].tv_nsec = t[0].tv_usec * 1000; | |
75 | s[1].tv_sec = t[1].tv_sec; | |
76 | s[1].tv_nsec = t[1].tv_usec * 1000; | |
77 | return futimens(f, s); | |
78 | } | |
79 | #else | |
80 | # define p_futimes futimes | |
81 | #endif | |
82 | ||
ab96ca55 AS |
83 | #ifdef HAVE_REGCOMP_L |
84 | #include <xlocale.h> | |
85 | GIT_INLINE(int) p_regcomp(regex_t *preg, const char *pattern, int cflags) | |
86 | { | |
87 | return regcomp_l(preg, pattern, cflags, (locale_t) 0); | |
88 | } | |
89 | #else | |
90 | # define p_regcomp regcomp | |
91 | #endif | |
92 | ||
f79026b4 | 93 | #endif |