Files
git/compat/msvc.h
Jeff Hostetler b9a0f8e268 msvc: fix isatty()
The hack that works in MINGW does not work with MSVC's CRT. Add MSVC
versions of isatty() and swap_osfhnd().

The MINGW versions attempt to replace the underlying OS HANDLE in an
existing file descriptor (fd) by writing to some undocumented fields in
the "ioinfo" structures inside the CRT. These structures changed size
and shape with the new UCRT in VS2015. The new MSVC versions of these
routines work without touching private fields. In theory, we should be
able to replace the ming versions with
this one.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2016-10-24 09:06:01 -07:00

42 lines
805 B
C

#ifndef __MSVC__HEAD
#define __MSVC__HEAD
#include <direct.h>
#include <process.h>
#include <malloc.h>
#include <io.h>
/* porting function */
#define inline __inline
#define __inline__ __inline
#define __attribute__(x)
#define strncasecmp _strnicmp
#define ftruncate _chsize
#define strtoull _strtoui64
#define strtoll _strtoi64
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
#ifdef _MSC_VER
#define ftello _ftelli64
#define isatty msc_isatty
int msc_isatty(int);
typedef int sigset_t;
/* open for reading, writing, or both (not in fcntl.h) */
#define O_ACCMODE (_O_RDONLY | _O_WRONLY | _O_RDWR)
#endif
#include "compat/mingw.h"
#endif