git/compat/msvc.h
Jeff King ab8632ae36 compat: provide a fallback va_copy definition
va_copy is C99.  We have avoided using va_copy many times in the past,
which has led to a bunch of cut-and-paste.  From everything I found
searching the web, implementations have historically either provided
va_copy or just let your code assume that simple assignment of worked.

So my guess is that this will be sufficient, though we won't really
know for sure until somebody reports a problem.

Signed-off-by: Jeff King <peff@peff.net>
Improved-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-26 01:06:50 -08:00

42 lines
1 KiB
C

#ifndef __MSVC__HEAD
#define __MSVC__HEAD
#include <direct.h>
#include <process.h>
#include <malloc.h>
/* porting function */
#define inline __inline
#define __inline__ __inline
#define __attribute__(x)
#define strncasecmp _strnicmp
#define ftruncate _chsize
static __inline int strcasecmp (const char *s1, const char *s2)
{
int size1 = strlen(s1);
int sisz2 = strlen(s2);
return _strnicmp(s1, s2, sisz2 > size1 ? sisz2 : size1);
}
#undef ERROR
/* Use mingw_lstat() instead of lstat()/stat() and mingw_fstat() instead
* of fstat(). We add the declaration of these functions here, suppressing
* the corresponding declarations in mingw.h, so that we can use the
* appropriate structure type (and function) names from the msvc headers.
*/
#define stat _stat64
int mingw_lstat(const char *file_name, struct stat *buf);
int mingw_fstat(int fd, struct stat *buf);
#define fstat mingw_fstat
#define lstat mingw_lstat
#define _stat64(x,y) mingw_lstat(x,y)
#define ALREADY_DECLARED_STAT_FUNCS
#include "compat/mingw.h"
#undef ALREADY_DECLARED_STAT_FUNCS
#endif