summaryrefslogtreecommitdiff
path: root/src/win32
Commit message (Collapse)AuthorAgeFilesLines
...
* mmap: remove unnecessary assertionEdward Thomson2019-11-251-2/+0
| | | | 64 bit types are always 64 bit.
* win32: fix symlinks to relative file targetsPatrick Steinhardt2019-07-201-3/+22
| | | | | | | | | | | | | | | When creating a symlink in Windows, one needs to tell Windows whether the symlink should be a file or directory symlink. To determine which flag to pass, we call `GetFileAttributesW` on the target file to see whether it is a directory and then pass the flag accordingly. The problem though is if create a symlink with a relative target path, then we will check that relative path while not necessarily being inside of the working directory where the symlink is to be created. Thus, getting its attributes will either fail or return attributes of the wrong target. Fix this by resolving the target path relative to the directory in which the symlink is to be created.
* win32: correctly unlink symlinks to directoriesPatrick Steinhardt2019-07-201-0/+16
| | | | | | | | | | | | | | | | | | When deleting a symlink on Windows, then the way to delete it depends on whether it is a directory symlink or a file symlink. In the first case, we need to use `DeleteFile`, in the second `RemoveDirectory`. Right now, `p_unlink` will only ever try to use `DeleteFile`, though, and thus fail to remove directory symlinks. This mismatches how unlink(3P) is expected to behave, though, as it shall remove any symlink disregarding whether it is a file or directory symlink. In order to correctly unlink a symlink, we thus need to check what kind of file this is. If we were to first query file attributes of every file upon calling `p_unlink`, then this would penalize the common case though. Instead, we can try to first delete the file with `DeleteFile` and only if the error returned is `ERROR_ACCESS_DENIED` will we query file attributes and determine whether it is a directory symlink to use `RemoveDirectory` instead.
* fileops: rename to "futils.h" to match function signaturesPatrick Steinhardt2019-07-201-1/+1
| | | | | | | | | Our file utils functions all have a "futils" prefix, e.g. `git_futils_touch`. One would thus naturally guess that their definitions and implementation would live in files "futils.h" and "futils.c", respectively, but in fact they live in "fileops.h". Rename the files to match expectations.
* w32_stack: convert buffer length param to `size_t`Patrick Steinhardt2019-07-052-4/+4
| | | | | | | | In both `git_win32__stack_format` and `git_win32__stack`, we handle buffer lengths via an integer variable. As we only ever pass buffer sizes to it, this should be a `size_t` though to avoid loss of precision. As we also use it to compare with other `size_t` variables, this also silences signed/unsigned comparison warnings.
* w32_stack: treat a len as an size_tEdward Thomson2019-06-252-3/+3
|
* win32: cast GetProcAddress to void * before castingEdward Thomson2019-06-241-5/+5
| | | | | | | GetProcAddress is prototyped to return a `FARPROC`, which is meant to be a generic function pointer. It's literally `int (FAR WINAPI * FARPROC)()` which gcc complains if you attempt to cast to a `void (*)(GIT_SRWLOCK *)`. Cast to a `void *` before casting to avoid warnings about the arguments.
* win32: don't re-define RtlCaptureStackBackTraceEdward Thomson2019-06-241-5/+0
| | | | | RtlCaptureStackBackTrace is well-defined in Windows, no need to redefine it.
* win32: stop inlining file_attribute_to_statEdward Thomson2019-06-242-31/+36
| | | | | | Move `git_win32__file_attribute_to_stat` to a regular function instead of an inlined function. This helps avoid header ordering issues and declarations.
* win32: safely cast path sizes for win apiEdward Thomson2019-06-241-2/+12
|
* w32: safely cast to int during charset conversionEdward Thomson2019-06-241-3/+7
|
* posix: remove `p_fallocate` abstractionPatrick Steinhardt2019-06-141-52/+0
| | | | | | | | | | | | | | | By now, we have repeatedly failed to provide a nice cross-platform implementation of `p_fallocate`. Recent tries to do that escalated quite fast to a set of different CMake checks, implementations, fallbacks, etc., which started to look real awkward to maintain. In fact, `p_fallocate` had only been introduced in commit 4e3949b73 (tests: test that largefiles can be read through the tree API, 2019-01-30) to support a test with large files, but given the maintenance costs it just seems not to be worht it. As we have removed the sole user of `p_fallocate` in the previous commit, let's drop it altogether.
* Merge pull request #4935 from libgit2/ethomson/pcreEdward Thomson2019-05-214-34/+39
|\ | | | | Use PCRE for our fallback regex engine when regcomp_l is unavailable
| * win32: move type definitions for improved inclusionEdward Thomson2019-05-192-29/+39
| | | | | | | | | | Move some win32 type definitions to a standalone file so that they can be included before other header files try to use the definitions.
| * regexec: use pcre as our fallback/builtin regexEdward Thomson2019-05-191-2/+0
| | | | | | | | | | | | | | Use PCRE 8.42 as the builtin regex implementation, using its POSIX compatibility layer. PCRE uses ASCII by default and the users locale will not influence its behavior, so its `regcomp` implementation is similar to `regcomp_l` with a C locale.
| * regexec: prefix all regexec function calls with p_Edward Thomson2019-05-191-3/+0
| | | | | | | | | | | | | | Prefix all the calls to the the regexec family of functions with `p_`. This allows us to swap out all the regular expression functions with our own implementation. Move the declarations to `posix_regex.h` for simpler inclusion.
* | define SYMBOLIC_LINK_FLAG_DIRECTORY if not definedJacques Germishuys2019-05-201-0/+4
|/
* Moved dwFlags declaration to beginning of scopeDaniel Cohen Gindi2019-05-061-1/+2
|
* Support symlinks for directories in win32Daniel Cohen Gindi2019-05-051-2/+6
|
* Merge pull request #4874 from tiennou/test/4615Edward Thomson2019-04-041-0/+52
|\ | | | | Test that largefiles can be read through the tree API
| * p_fallocate: add Windows emulationEdward Thomson2019-02-221-2/+48
| | | | | | | | | | Emulate `p_fallocate` on Windows by seeking beyond the end of the file and setting the size to the current seek position.
| * tests: test that largefiles can be read through the tree APIEtienne Samson2019-01-301-0/+6
| |
* | allocators: extract crtdbg allocator into its own filePatrick Steinhardt2019-02-212-95/+0
|/ | | | | | | | | | | | | | | The Windows-specific crtdbg allocator is currently mixed into the crtdbg stacktracing compilation unit, making it harder to find than necessary. Extract it and move it into the new "allocators/" subdirectory to improve discoverability. This change means that the crtdbg compilation unit is now compiled unconditionally, whereas it has previously only been compiled on Windows platforms. Thus we now have additional guards around the code so that it will only be compiled if GIT_MSVC_CRTDBG is defined. This also allows us to move over the fallback-implementation of `git_win32_crtdbg_init_allocator` into the same compilation unit.
* windows: add SSIZE_MAXEdward Thomson2019-01-251-0/+6
| | | | | | Windows doesn't include ssize_t or its _MAX value by default. We are already declaring ssize_t as SSIZE_T, which is __int64_t on Win64 and long otherwise. Include its _MAX value as a correspondence to its type.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-229-25/+25
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* Fix a bunch of warningslhchavez2019-01-051-1/+0
| | | | | | | | | | | This change fixes a bunch of warnings that were discovered by compiling with `clang -target=i386-pc-linux-gnu`. It turned out that the intrinsics were not necessarily being used in all platforms! Especially in GCC, since it does not support __has_builtin. Some more warnings were gleaned from the Windows build, but I stopped when I saw that some third-party dependencies (e.g. zlib) have warnings of their own, so we might never be able to enable -Werror there.
* Merge pull request #4713 from libgit2/ethomson/win_symlinksEdward Thomson2018-11-151-36/+18
|\ | | | | Support symlinks on Windows when core.symlinks=true
| * win32: add symbolic link supportEdward Thomson2018-10-201-5/+17
| | | | | | | | | | | | | | | | | | Enable `p_symlink` to actually create symbolic links, not just create a fake link (a text file containing the link target). This now means that `core.symlinks=true` works on Windows platforms where symbolic links are enabled (likely due to running in Developer Mode).
| * win32: use GetFinalPathNameByHandle directlyEdward Thomson2018-10-201-31/+1
| | | | | | | | | | | | Now that we've updated to WIN32_WINNT version of Vista or better, we don't need to dynamically load GetFinalPathNameByHandle and can simply invoke it directly.
* | win32: refactor `git_win32_path_remove_namespace`ethomson/unc_pathsEdward Thomson2018-10-191-25/+36
| | | | | | | | | | | | | | | | | | | | | | Update `git_win32_path_remove_namespace` to disambiguate the prefix being removed versus the prefix being added. Now we remove the "namespace", and (may) add a "prefix" in its place. Eg, we remove the `\\?\` namespace. We remove the `\\?\UNC\` namespace, and replace it with the `\\` prefix. This aids readability somewhat. Additionally, use pointer arithmetic instead of offsets, which seems to also help readability.
* | win32: rename `git_win32__canonicalize_path`Edward Thomson2018-10-195-108/+111
| | | | | | | | | | | | | | | | | | | | | | The internal API `git_win32__canonicalize_path` is far, far too easily confused with the internal API `git_win32_path_canonicalize`. The former removes the namespace prefix from a path (eg, given `\\?\C:\Temp\foo`, it returns `C:\Temp\foo`, and given `\\?\UNC\server\share`, it returns `\\server\share`). As such, rename it to `git_win32_path_remove_namespace`. `git_win32_path_canonicalize` remains unchanged.
* | Fix issue with path canonicalization for Win32 pathsGabriel DeBacker2018-09-301-2/+14
|/
* treewide: remove use of C++ style commentsPatrick Steinhardt2018-07-131-1/+1
| | | | | | | | | C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
* Merge pull request #4436 from pks-t/pks/packfile-stream-freeEdward Thomson2018-06-111-2/+2
|\ | | | | pack: rename `git_packfile_stream_free`
| * Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-2/+2
| |
* | alloc: make memory allocators use function pointersPatrick Steinhardt2018-06-072-22/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, our memory allocators are being redirected to the correct implementation at compile time by simply using macros. In order to make them swappable at runtime, this commit reshuffles that by instead making use of a global "git_allocator" structure, whose pointers are set up to reference the allocator functions. Like this, it becomes easy to swap out allocators by simply setting these function pointers. In order to initialize a "git_allocator", our provided allocators "stdalloc" and "crtdbg" both provide an init function. This is being called to initialize a passed in allocator struct and set up its members correctly. No support is yet included to enable users of libgit2 to switch out the memory allocator at a global level.
* | win32: crtdbg: provide independent `free` functionPatrick Steinhardt2018-06-072-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | Currently, the `git__free` function is being defined in a single place, only, disregarding whether we use our standard allocators or the crtdbg allocators. This makes it a bit harder to convert our code base to use pluggable allocators, and furthermore makes the border between our two allocators a bit more blurry. Implement a separate `git__crtdbg__free` function for the crtdbg allocator in order to completely separate both allocator implementations.
* | win32: crtdbg: internalize implementation of allocatorsPatrick Steinhardt2018-06-072-74/+82
|/ | | | | | | | | | | The crtdbg allocators are currently being implemented as inline functions as part of the "w32_crtdbg_stacktrace.h" header. As we are moving towards pluggable allocators with the help of function pointers, though, we cannot make use of inlining anymore. Instead, we can only have a single implementation of these allocating functions. Move all implementations of the crtdbg allocators into "w32_crtdbg_stacktrace.c".
* consistent header guardsethomson/header_guardsEdward Thomson2018-02-0115-34/+34
| | | | use consistent names for the #include / #define header guard pattern.
* path: expose `git_path_is_dirsep`Patrick Steinhardt2017-10-091-3/+1
| | | | | | | This function has previously been implemented in Windows-specific path handling code as `path__is_dirsep`. As we will need this functionality in other parts, extract the logic into "path.h" alongside with a non-Windows implementation.
* path: expose `git_path_is_absolute`Patrick Steinhardt2017-10-091-7/+4
| | | | | | | This function has previously been implemented in Windows-specific path handling code as `path__is_absolute`. As we will need this functionality in other parts, extract the logic into "path.h" alongside with a non-Windows implementation.
* Merge pull request #4288 from pks-t/pks/include-fixupsEdward Thomson2017-08-1522-11/+119
|\ | | | | Include fixups
| * Make sure to always include "common.h" firstPatrick Steinhardt2017-07-0322-11/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
| * win32: fix circular include deps with w32_crtdbgPatrick Steinhardt2017-06-301-0/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The current order of declarations and includes between "common.h" and "w32_crtdbg_stacktrace.h" is rather complicated. Both header files make use of things defined in the other one and are thus circularly dependent on each other. This makes it currently impossible to compile the "w32_crtdbg_stacktrace.c" file when including "common.h" inside of "w32_crtdbg_stacktrace.h". We can disentangle the mess by moving declaration of the inline crtdbg functions into the "w32_crtdbg_stacktrace.h" file and adding additional includes inside of it, such that all required functions are available to it. This allows us to break the dependency cycle.
* | win32: provide fast-path for retrying filesystem operationsethomson/win32_remediateEdward Thomson2017-07-261-11/+9
| | | | | | | | | | | | | | | | | | | | When using the `do_with_retries` macro for retrying filesystem operations in the posix emulation layer, allow the remediation function to return `GIT_RETRY`, meaning that the error was believed to be remediated, and the operation should be retried immediately, without a sleep. This is a slightly more general solution to the problem fixed in #4312.
* | fixed win32 p_unlink retry sleep issueCarson Howard2017-07-261-1/+6
|/ | | Fixed an issue where the retry logic on p_unlink sleeps before it tries setting a file to write mode causing unnecessary slowdown.
* win32: `remediation` not `cleanup`ethomson/win32_posixEdward Thomson2017-04-171-2/+2
| | | | | | The `remediation` function is run in the retry loop in order to attempt to fix any problems that the prior run encountered. There is nothing "cleaned up". Clarify the name.
* win32: enable `p_utimes` for readonly filesEdward Thomson2017-04-051-88/+131
| | | | | Instead of failing to set the timestamp of a read-only file (like any object file), set it writable temporarily to update the timestamp.
* win32: make posix emulation retries configurableEdward Thomson2017-04-032-1/+3
| | | | | | | POSIX emulation retries should be configurable so that tests can disable them. In particular, maniacally threading tests may end up trying to open locked files and need retries, which will slow continuous integration tests significantly.
* win32: do not inherit file descriptorsEdward Thomson2017-04-031-1/+8
|