Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/compat/msvc-posix.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / compat / msvc-posix.h` 55 lines ยท 1541 bytes Raw Blame History 1 #ifndef COMPAT_MSVC_POSIX_H 2 #define COMPAT_MSVC_POSIX_H 3 4 #include 5 #include 6 #include 7 #include 8 9 #pragma warning(disable: 4018) /* signed/unsigned comparison */ 10 #pragma warning(disable: 4244) /* type conversion, possible loss of data */ 11 #pragma warning(disable: 4090) /* 'function' : different 'const' qualifiers (ALLOC_GROW etc.)*/ 12 13 /* porting function */ 14 #define inline __inline 15 #define __inline__ __inline 16 #define __attribute__(x) 17 #define strcasecmp _stricmp 18 #define strncasecmp _strnicmp 19 #define strtoull _strtoui64 20 #define strtoll _strtoi64 21 22 #undef ERROR 23 24 #define ftello _ftelli64 25 26 typedef int sigset_t; 27 /* open for reading, writing, or both (not in fcntl.h) */ 28 #define O_ACCMODE (_O_RDONLY | _O_WRONLY | _O_RDWR) 29 30 #include "mingw-posix.h" 31 32 /* 33 * MSVC's `_chsize()` takes a 32-bit `long` and silently truncates files 34 * to 2 GiB. `_chsize_s()` accepts a 64-bit length but returns 0 on 35 * success or an errno value on failure, rather than the -1/errno 36 * convention POSIX `ftruncate()` callers expect. Wrap it so callers 37 * that test the return value as `< 0` or against `-1` keep working. 38 * 39 * Note: this declaration must follow `#include "mingw-posix.h"` so 40 * `off_t` resolves to `off64_t` and the parameter type matches the 41 * underlying `_chsize_s()` width. 42 */ 43 static inline int msvc_ftruncate(int fd, off_t length) 44 { 45 int err = _chsize_s(fd, length); 46 47 if (err) { 48 errno = err; 49 return -1; 50 } 51 return 0; 52 } 53 #define ftruncate msvc_ftruncate 54 55 #endif /* COMPAT_MSVC_POSIX_H */