X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-compat-util.h;h=aff627a85a812bb782e68cd27d06eb42d7dac537;hb=c6ec7efdd4c63f5c53184651cb05748e7bc71075;hp=9f941e42b16d927f738b4911b41344dd2f3ed0da;hpb=814035c12a07927ea03350184a14f869cdce7276;p=git.git diff --git a/git-compat-util.h b/git-compat-util.h index 9f941e42b..aff627a85 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -57,16 +57,20 @@ # endif #elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX) && !defined(sgi) #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ -#ifndef __sun__ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ #endif -#endif #define _ALL_SOURCE 1 #define _GNU_SOURCE 1 #define _BSD_SOURCE 1 #define _NETBSD_SOURCE 1 #define _SGI_SOURCE 1 +#ifdef WIN32 /* Both MinGW and MSVC */ +#define WIN32_LEAN_AND_MEAN /* stops windows.h including winsock.h */ +#include +#include +#endif + #include #include #include @@ -92,6 +96,7 @@ #include #include #include +#include #ifndef NO_SYS_SELECT_H #include #endif @@ -115,6 +120,9 @@ /* pull in Windows compatibility stuff */ #include "compat/mingw.h" #endif /* __MINGW32__ */ +#ifdef _MSC_VER +#include "compat/msvc.h" +#endif #ifndef NO_LIBGEN_H #include @@ -169,24 +177,29 @@ extern char *gitbasename(char *); #ifdef __GNUC__ #define NORETURN __attribute__((__noreturn__)) +#define NORETURN_PTR __attribute__((__noreturn__)) #else #define NORETURN +#define NORETURN_PTR #ifndef __attribute__ #define __attribute__(x) #endif #endif +#include "compat/bswap.h" + /* General helper functions */ -extern void usage(const char *err) NORETURN; -extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); -extern void die_errno(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); +extern NORETURN void usage(const char *err); +extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2))); +extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2))); +extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); extern int error(const char *err, ...) __attribute__((format (printf, 1, 2))); extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); -extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN); +extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params)); extern int prefixcmp(const char *str, const char *prefix); -extern time_t tm_to_time_t(const struct tm *tm); +extern int suffixcmp(const char *str, const char *suffix); static inline const char *skip_prefix(const char *str, const char *prefix) {