summaryrefslogtreecommitdiff
path: root/compat/msvc.h
AgeCommit message (Collapse)AuthorFilesLines
2019-06-25msvc: add pragmas for common warningsLibravatar Philip Oakley1-0/+4
MSVC can be overzealous about some warnings. Disable them. Signed-off-by: Philip Oakley <philipoakley@iee.org> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-06-20msvc: define ftello()Libravatar Jeff Hostetler1-0/+2
It is just called differently in MSVC's headers. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-06-20msvc: define O_ACCMODELibravatar Philip Oakley1-0/+2
This constant is not defined in MSVC's headers. In UCRT's fcntl.h, _O_RDONLY, _O_WRONLY and _O_RDWR are defined as 0, 1 and 2, respectively. Yes, that means that UCRT breaks with the tradition that O_RDWR == O_RDONLY | O_WRONLY. It is a perfectly legal way to define those constants, though, therefore we need to take care of defining O_ACCMODE accordingly. This is particularly important in order to keep our "open() can set errno to EISDIR" emulation working: it tests that (flags & O_ACCMODE) is not identical to O_RDONLY before going on to test specifically whether the file for which open() reported EACCES is, in fact, a directory. Signed-off-by: Philip Oakley <philipoakley@iee.org> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-06-20msvc: include sigset_t definitionLibravatar Philip Oakley1-0/+2
On MSVC (VS2008) sigset_t is not defined. Signed-off-by: Philip Oakley <philipoakley@iee.org> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-20msvc: directly use MS version (_stricmp) of strcasecmpLibravatar Sven Strickroth1-7/+1
This also removes an implicit conversion from size_t (unsigned) to int (signed). _stricmp as well as _strnicmp are both available since VS2012. Signed-off-by: Sven Strickroth <email@cs-ware.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-11MSVC: fix stat definition hellLibravatar Karsten Blees1-15/+0
In msvc.h, there's a couple of stat related functions defined diffently from mingw.h. When we remove these definitions, the only problem we get is "warning C4005: '_stati64' : macro redefinition" for this line in mingw.h: #define _stati64(x,y) mingw_stat(x,y) The reason is that as of MSVCR80.dll (distributed with MSVC 2005), the original _stati64 family of functions was renamed to _stat32i64, and the former function names became macros (pointing to the appropriate function based on the definition of _USE_32BIT_TIME_T). Defining _stati64 works on MinGW because MinGW by default compiles against the MSVCRT.DLL that is part of Windows (i.e. _stati64 is a function rather than a macro). Note: MinGW *can* compile for newer MSVC runtime versions, and MSVC apparently can also compile for the Windows MSVCRT.DLL via the DDK (see http://www.syndicateofideas.com/posts/fighting-the-msvcrt-dll-hell ). Remove the stat definitions from msvc.h, as they are not compiler related. In mingw.h, determine the runtime version in use from the definitions of _stati64 and _USE_32BIT_TIME_T, and define stat() accordingly. This also fixes that stat() in MSVC builds still resolves to mingw_lstat() instead of mingw_stat(). Signed-off-by: Karsten Blees <blees@dcon.de> Acked-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-25msvc: test-svn-fe: Fix linker "unresolved external" errorLibravatar Ramsay Jones1-0/+2
In particular, while linking test-svn-fe.exe, the linker complains that the external symbol _strtoull is unresolved. A call to this function was added in commit ddcc8c5b ("vcs-svn: skeleton of an svn delta parser", 25-12-2010). The NO_STRTOULL build variable attempts to provide support to old systems which can't even declare 'unsigned long long' variables, let alone provide the strtoll() or strtoull() functions. Setting this build variable does not provide an implementation of these functions. Rather, it simply allows the compat implementations of strto{i,u}max() to use strtol() and strtoul() instead. In order to fix the linker error on systems with NO_STRTOULL set, currently MSVC and OSF1, we can substitute a call to strtoumax(). However, we can easily provide support for the strtoull() and strtoll() functions on MSVC, since they are essentially already available as _strtoui64() and _strtoi64(). This allows us to remove NO_STRTOULL for MSVC. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Tested-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-31Compile fix for MSVC: Include <io.h>Libravatar Vincent van Ravesteijn1-0/+1
This include is needed for _commit(..) which is used in mingw.h. Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org> Acked-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-26compat: provide a fallback va_copy definitionLibravatar Jeff King1-1/+0
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>
2010-01-16MSVC: Fix an "incompatible pointer types" compiler warningLibravatar Ramsay Jones1-24/+16
In particular, the following warning is issued while compiling compat/msvc.c: ...mingw.c(223) : warning C4133: 'function' : incompatible \ types - from '_stati64 *' to '_stat64 *' which relates to a call of _fstati64() in the mingw_fstat() function definition. This is caused by various layers of macro magic and attempts to avoid macro redefinition compiler warnings. For example, the call to _fstati64() mentioned above is actually a call to _fstat64(), and expects a pointer to a struct _stat64 rather than the struct _stati64 which is passed to mingw_fstat(). The definition of struct _stati64 given in compat/msvc.h had the same "shape" as the definition of struct _stat64, so the call to _fstat64() does not actually cause any runtime errors, but the structure types are indeed incompatible. In order to avoid the compiler warning, we add declarations for the mingw_lstat() and mingw_fstat() functions and supporting macros to msvc.h, suppressing the corresponding declarations in mingw.h, so that we can use the appropriate structure type (and function) names from the msvc headers. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-18Define strncasecmp and ftruncate for MSVCLibravatar Marius Storm-Olsen1-0/+2
Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-18Make usage of windows.h lean and meanLibravatar Marius Storm-Olsen1-7/+0
Centralize the include of windows.h in git-compat-util.h, turn on WIN32_LEAN_AND_MEAN to avoid including plenty of other header files which is not needed in Git. Also ensure we load winsock2.h first, so we don't load the older winsock definitions at a later stage, since they contain duplicate definitions. When moving windows.h into git-compat-util.h, we need to protect the definition of struct pollfd in mingw.h, since this file is used by both MinGW and MSVC, and the latter defines this struct in winsock2.h. We need to keep the windows.h include in compat/win32.h, since its shared by both MinGW and Cygwin, and we're not touching Cygwin in this commit. The include in git-compat-util.h is protected with an ifdef WIN32, which is not the case when compiling for Cygwin. Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-18Add platform files for porting to MSVCLibravatar Frank Li1-0/+55
Add msvc.c and msvc.h to build git under MSVC. Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>