diff options
author | Edward Thomson <ethomson@microsoft.com> | 2013-11-02 01:03:01 +0400 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2013-11-02 01:27:07 +0400 |
commit | c2408a698ad395c8bd84297de839080d131c6d6d (patch) | |
tree | ebf4edc55b76df48267257c9d20681ae7e6b246f /src/common.h | |
parent | 567649f2ada60e5c3009cc985af238b452b14a81 (diff) |
preserve windows error numbers as well
Diffstat (limited to 'src/common.h')
-rw-r--r-- | src/common.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h index 02d9ce9b6..159d31b2e 100644 --- a/src/common.h +++ b/src/common.h @@ -74,6 +74,30 @@ void giterr_set(int error_class, const char *string, ...); int giterr_set_regex(const regex_t *regex, int error_code); /** + * Gets the system error code for this thread. + */ +GIT_INLINE(int) giterr_system_last(void) +{ +#ifdef GIT_WIN32 + return GetLastError(); +#else + return errno; +#endif +} + +/** + * Sets the system error code for this thread. + */ +GIT_INLINE(void) giterr_system_set(int code) +{ +#ifdef GIT_WIN32 + SetLastError(code); +#else + errno = code; +#endif +} + +/** * Check a versioned structure for validity */ GIT_INLINE(int) giterr__check_version(const void *structure, unsigned int expected_max, const char *name) |