summaryrefslogtreecommitdiff
path: root/compat/mingw.h
AgeCommit message (Collapse)Author
2012-04-23Merge branch 'rj/mingw-isguid'Junio C Hamano
By Ramsay Jones * rj/mingw-isguid: compat/mingw.h: Set S_ISUID to prevent a fast-import test failure
2012-04-18compat/mingw.h: Set S_ISUID to prevent a fast-import test failureRamsay Jones
The current t9300-fast-import.sh test number 62 ("L: nested tree copy does not corrupt deltas") was introduced in commit 9a0edb79 ("fast-import: add a test for tree delta base corruption", 15-08-2011). A fix for the demonstrated problem was introduced by commit 8fb3ad76 ("fast-import: prevent producing bad delta", 15-08-2011). However, this fix didn't work on MinGW and so this test has always failed on MinGW. Part of the solution in commit 8fb3ad76 was to add an NO_DELTA preprocessor constant which was defined as follows: +/* + * We abuse the setuid bit on directories to mean "do not delta". + */ +#define NO_DELTA S_ISUID + Unfortunately, the S_ISUID constant on MinGW is defined as zero. In order to fix the problem, we simply alter the definition of S_ISUID in the mingw header file to a more appropriate value. Also, we take the opportunity to similarly define S_ISGID and S_ISVTX. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-05compat/mingw.[ch]: Change return type of exec functions to intRamsay Jones
The POSIX standard specifies a return type of int for all six exec functions. In addition, all exec functions return -1 on error, and simply do not return on success. However, the current emulation of the exec functions on mingw are declared with a void return type. This would cause a problem should any code attempt to call the exec function in a non-void context. In particular, if an exec function were used in a conditional it would fail to compile. In order to improve the fidelity of the emulation, we change the return type of the mingw_execv[p] functions to int and return -1 on error. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-09Merge branch 'maint-1.7.7' into maintJunio C Hamano
* maint-1.7.7: am: don't persist keepcr flag mingw: give waitpid the correct signature git symbolic-ref: documentation fix
2011-12-09mingw: give waitpid the correct signatureErik Faye-Lund
POSIX says that last parameter to waitpid should be 'int', so let's make it so. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-11-15Revert "upload-archive: use start_command instead of fork"Junio C Hamano
This reverts commit c09cd77ea2fe3580b33918a99fe138d239ac2aaf, expecting a better version to be rerolled soon.
2011-10-31upload-archive: use start_command instead of forkErik Faye-Lund
The POSIX-function fork is not supported on Windows. Use our start_command API instead. As this is the last call-site that depends on the fork-stub in compat/mingw.h, remove that as well. Add an undocumented flag to git-archive that tells it that the action originated from a remote, so features can be disabled. Thanks to Jeff King for work on this part. Remove the NOT_MINGW-prereq for t5000, as git-archive --remote now works. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-16mingw: ensure sockets are initialized before calling gethostnamePat Thoyts
If the Windows sockets subsystem has not been initialized yet then an attempt to get the hostname returns an error and prints a warning to the console. This solves this issue for msysGit as seen with 'git fetch'. Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-30Merge branch 'ef/maint-win-verify-path'Junio C Hamano
* ef/maint-win-verify-path: verify_dotfile(): do not assume '/' is the path seperator verify_path(): simplify check at the directory boundary verify_path: consider dos drive prefix real_path: do not assume '/' is the path seperator A Windows path starting with a backslash is absolute
2011-05-27real_path: do not assume '/' is the path seperatorTheo Niessink
real_path currently assumes it's input had '/' as path seperator. This assumption does not hold true for the code-path from prefix_path (on Windows), where real_path can be called before normalize_path_copy. Fix real_path so it doesn't make this assumption. Create a helper function to reverse-search for the last path-seperator in a string. Signed-off-by: Theo Niessink <theo@taletn.com> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-23Merge branch 'js/mingw-shutdown'Junio C Hamano
* js/mingw-shutdown: Windows: add a wrapper for the shutdown() system call
2011-05-18Windows: add a wrapper for the shutdown() system callJohannes Sixt
Even though Windows's socket functions look like their POSIX counter parts, they do not operate on file descriptors, but on "socket objects". To bring the functions in line with POSIX, we have proxy functions that wrap and unwrap the socket objects in file descriptors using open_osfhandle and get_osfhandle. But shutdown() was not proxied, yet. Fix this. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-15Merge branch 'sp/maint-fd-limit'Junio C Hamano
* sp/maint-fd-limit: sha1_file.c: Don't retain open fds on small packs mingw: add minimum getrlimit() compatibility stub Limit file descriptors used by packs
2011-03-02mingw: add minimum getrlimit() compatibility stubErik Faye-Lund
We don't have getrlimit on Windows :( Limit of 2048 taken from MSDN: http://msdn.microsoft.com/en-us/library/6e3b887c(v=vs.71).aspx Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2011-02-28Merge branch 'hv/mingw-fs-funnies'Junio C Hamano
* hv/mingw-fs-funnies: mingw_rmdir: set errno=ENOTEMPTY when appropriate mingw: add fallback for rmdir in case directory is in use mingw: make failures to unlink or move raise a question mingw: work around irregular failures of unlink on windows mingw: move unlink wrapper to mingw.c
2011-02-07mingw: add fallback for rmdir in case directory is in useHeiko Voigt
The same logic as for unlink and rename also applies to rmdir. For example in case you have a shell open in a git controlled folder. This will easily fail. So lets be nice for such cases as well. Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-07mingw: move unlink wrapper to mingw.cHeiko Voigt
The next patch implements a workaround in case unlink fails on Windows. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-12-16Merge branch 'rj/msvc-fix'Junio C Hamano
* rj/msvc-fix: msvc: Fix macro redefinition warnings msvc: Fix build by adding missing INTMAX_MAX define msvc: git-daemon.exe: Fix linker "unresolved externals" error msvc: Fix compilation errors in compat/win32/sys/poll.c
2010-12-13Merge branch 'ef/win32-dirent'Junio C Hamano
* ef/win32-dirent: win32: use our own dirent.h msvc: opendir: handle paths ending with a slash win32: dirent: handle errors msvc: opendir: do not start the search msvc: opendir: allocate enough memory msvc: opendir: fix malloc-failure Conflicts: Makefile
2010-12-10msvc: Fix macro redefinition warningsRamsay Jones
Commit 4091bfc (MinGW: Add missing file mode bit defines, 28-12-2009) causes the msvc build to issue many additional (currently 1008) macro redefinition warnings. The warnings relate to the S_IRUSR, S_IWUSR, S_IXUSR and S_IRWXU macros. In order to fix the warnings, we simply remove the offending macro definitions which, for both msvc and MinGW, are not required. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Acked-by: Sebastian Schuberth <sschuberth@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-12-08Merge branch 'il/remote-fd-ext'Junio C Hamano
* il/remote-fd-ext: remote-fd/ext: finishing touches after code review git-remote-ext git-remote-fd Add bidirectional_transfer_loop() Conflicts: compat/mingw.h
2010-11-24win32: use our own dirent.hErik Faye-Lund
The mingw-runtime implemenation of opendir, readdir and closedir sets errno to 0 on success, something that POSIX explicitly forbids. 3ba7a06 ("A loose object is not corrupt if it cannot be read due to EMFILE") introduce a dependency on this behaviour, leading to a broken "git clone" on Windows. compat/mingw.c contains an implementation of readdir, and compat/msvc.c contains implementations of opendir and closedir. Move these to compat/win32/dirent.[ch], and change to our own DIR structure at the same time. This provides a generic Win32-implementation of opendir, readdir and closedir which works on both MinGW and MSVC and does not reset errno, and as a result git clone is working again on Windows. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-04mingw: use poll-emulation from gnulibErik Faye-Lund
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-04mingw: add kill emulationErik Faye-Lund
This is a quite limited kill-emulation; it can only handle SIGTERM on positive pids. However, it's enough for git-daemon. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-04mingw: support waitpid with pid > 0 and WNOHANGErik Faye-Lund
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-04mingw: use real pidErik Faye-Lund
The Windows port have so far been using process handles in place of PID. However, this is not work consistent with what getpid returns. PIDs are system-global identifiers, but process handles are local to a process. Using PIDs instead of process handles allows, for instance, a user to kill a hung process with the Task Manager, something that would have been impossible with process handles. Change the code to use the real PID, and use OpenProcess to get a process-handle. Store the PID and the process handle in a linked list protected by a critical section, so we can safely close the process handle later. Linked list code written by Pat Thoyts. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-04mingw: add network-wrappers for daemonMike Pape
git-daemon requires some socket-functionality that is not yet supported in the Windows-port. This patch adds said functionality, and makes sure WSAStartup gets called by socket(), since it is the first network-call in git-daemon. Signed-off-by: Mike Pape <dotzenlabs@gmail.com> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-13Add bidirectional_transfer_loop()Ilari Liusvaara
This helper function copies bidirectional stream of data between stdin/stdout and specified file descriptors. Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-03Add MinGW-specific execv() override.Eric Sunshine
As of 2dbc887e, shell.c employs execv(), so provide a MinGW-specific mingw_execv() override, complementing existing mingw_execvp() and cousins. As a bonus, this also resolves a compilation warning due to an execv() prototype mismatch between Linux and MinGW. Linux expects the second argument to be (char *const *), whereas MinGW expects (const char *const *). Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2010-10-03Fix Windows-specific macro redefinition warning.Eric Sunshine
shell.c defines macro HELP_COMMAND which collides with a like-named macro from winuser.h. Avoid collision by sanitizing preprocessor namespace after including Windows headers. Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2010-10-01MinGW: fix stat() and lstat() implementations for handling symlinksPat Thoyts
In msysGit the stat() function has been implemented using mingw_lstat which sets the st_mode member to S_IFLNK when a symbolic links is found. This causes the is_executable function to return when git attempts to build a list of available commands in the help code and we end up missing most git commands. (msysGit issue #445) This patch modifies the implementation so that lstat() will return the link flag but if we are called as stat() we read the size of the target and set the mode to that of a regular file. Includes squashed fix st_mode for symlink dirs Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2010-10-01MinGW: Add missing file mode bit definesSebastian Schuberth
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2010-10-01MinGW: Use pid_t more consequently, introduce uid_t for greater compatibilitySebastian Schuberth
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2010-06-21Merge branch 'js/async-thread'Junio C Hamano
* js/async-thread: fast-import: die_nicely() back to vsnprintf (reverts part of ebaa79f) Enable threaded async procedures whenever pthreads is available Dying in an async procedure should only exit the thread, not the process. Reimplement async procedures using pthreads Windows: more pthreads functions Fix signature of fcntl() compatibility dummy Make report() from usage.c public as vreportf() and use it. Modernize t5530-upload-pack-error. Conflicts: http-backend.c
2010-05-20mingw: use _commit to implement fsyncErik Faye-Lund
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-05-20Fix checkout of large files to network shares on Windows XPRené Scharfe
Bigger writes to network drives on Windows XP fail. Cap them at 31MB to allow them to succeed. Callers need to be prepared for write() calls that do less work than requested anyway. On local drives, write() calls are translated to WriteFile() calls with a cap of 64KB on Windows XP and 256KB on Vista. Thus a cap of 31MB won't affect the number of WriteFile() calls which do the actual work. There's still room for some other version of Windows to use a chunk size of 1MB without increasing the number of system calls. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-11Merge branch 'jl/maint-submodule-gitfile-awareness'Junio C Hamano
* jl/maint-submodule-gitfile-awareness: Windows: start_command: Support non-NULL dir in struct child_process
2010-04-11Windows: start_command: Support non-NULL dir in struct child_processJohannes Sixt
A caller of start_command can set the member 'dir' to a directory to request that the child process starts with that directory as CWD. The first user of this feature was added recently in eee49b6 (Teach diff --submodule and status to handle .git files in submodules). On Windows, we have been lazy and had not implemented support for this feature, yet. This fixes the shortcoming. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-07Fix signature of fcntl() compatibility dummyJohannes Sixt
Obviously, this function was never called with two arguments in Windows code sections, but this will be the case in a subsequent patch. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-25Windows: redirect f[re]open("/dev/null") to f[re]open("nul")Johannes Sixt
On Windows, the equivalent of "/dev/null" is "nul". This implements compatibility wrappers around fopen() and freopen() that check for this particular file name. The new tests exercise code paths where this is relevant. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-17MSVC: Windows-native implementation for subset of Pthreads APIAndrzej K. Haczewski
This patch implements native to Windows subset of pthreads API used by Git. It allows to remove Pthreads for Win32 dependency for MSVC, msysgit and Cygwin. [J6t: If the MinGW build was built as part of the msysgit build environment, then threading was already enabled because the pthreads-win32 package is available in msysgit. With this patch, we can now enable threaded code unconditionally.] Signed-off-by: Andrzej K. Haczewski <ahaczewski@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-17MSVC: Fix an "incompatible pointer types" compiler warningRamsay Jones
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>
2010-01-17Windows: avoid the "dup dance" when spawning a child processJohannes Sixt
When stdin, stdout, or stderr must be redirected for a child process that on Windows is spawned using one of the spawn() functions of Microsoft's C runtime, then there is no choice other than to 1. make a backup copy of fd 0,1,2 with dup 2. dup2 the redirection source fd into 0,1,2 3. spawn 4. dup2 the backup back into 0,1,2 5. close the backup copy and the redirection source We used this idiom as well -- but we are not using the spawn() functions anymore! Instead, we have our own implementation. We had hardcoded that stdin, stdout, and stderr of the child process were inherited from the parent's fds 0, 1, and 2. But we can actually specify any fd. With this patch, the fds to inherit are passed from start_command()'s WIN32 section to our spawn implementation. This way, we can avoid the backup copies of the fds. The backup copies were a bug waiting to surface: The OS handles underlying the dup()ed fds were inherited by the child process (but were not associated with a file descriptor in the child). Consequently, the file or pipe represented by the OS handle remained open even after the backup copy was closed in the parent process until the child exited. Since our implementation of pipe() creates non-inheritable OS handles, we still dup() file descriptors in start_command() because dup() happens to create inheritable duplicates. (A nice side effect is that the fd cleanup in start_command is the same for Windows and Unix and remains unchanged.) Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-24Enable support for IPv6 on MinGWMartin Storsjö
The IPv6 support functions are loaded dynamically, to maintain backwards compatibility with versions of Windows prior to XP, and fallback wrappers are provided, implemented in terms of gethostbyname and gethostbyaddr. Signed-off-by: Martin Storsjo <martin@martin.st> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-21Merge branch 'rj/cygwin-msvc'Junio C Hamano
* rj/cygwin-msvc: MSVC: Add support for building with NO_MMAP Makefile: keep MSVC and Cygwin configuration separate
2009-11-09MSVC: Add support for building with NO_MMAPRamsay Jones
When the NO_MMAP build variable is set, the msvc linker complains: error LNK2001: unresolved external symbol _getpagesize The msvc libraries do not define the getpagesize() function, so we move the mingw_getpagesize() implementation from the conditionally built win32mmap.c file to mingw.c. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-20mingw: wrap SSL_set_(w|r)fd to call _get_osfhandleErik Faye-Lund
SSL_set_fd (and friends) expects a OS file handle on Windows, not a file descriptor as on UNIX(-ish). This patch makes the Windows version of SSL_set_fd behave like the UNIX versions, by calling _get_osfhandle on it's input. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-19Make usage of windows.h lean and meanMarius Storm-Olsen
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-19Set _O_BINARY as default fmode for both MinGW and MSVCMarius Storm-Olsen
MinGW set the _CRT_fmode to set both the default fmode and _O_BINARY on stdin/stdout/stderr. Rather use the main() define in mingw.h to set this for both MinGW and MSVC. This will ensure that a MinGW and MSVC build will handle input and output identically. 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-11start_command: do not clobber cmd->env on Windows code pathJohannes Sixt
Previously, it would not be possible to call start_command twice for the same struct child_process that has env set. The fix is achieved by moving the loop that modifies the environment block into a helper function. This also allows us to make two other helper functions static. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>