summaryrefslogtreecommitdiff
path: root/src/unix
Commit message (Collapse)AuthorAgeFilesLines
* Fix typo on GIT_USE_NECSven Strickroth2020-02-201-1/+1
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* internal: use off64_t instead of git_off_tethomson/off_tEdward Thomson2019-11-251-1/+1
| | | | Prefer `off64_t` internally.
* unix: posix: avoid use of variadic macro `p_snprintf`Patrick Steinhardt2019-08-011-1/+1
| | | | | | | | The macro `p_snprintf` is implemented as a variadic macro that calls `snprintf` directly with `__VA_ARGS__`. In C89, variadic macros are not allowed, but as the arguments of `p_snprintf` and `snprintf` are matching 1:1, we can fix this by simply removing the parameter list from `p_snprintf`.
* regexec: prefix all regexec function calls with p_Edward Thomson2019-05-191-10/+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.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-2/+2
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* consistent header guardsethomson/header_guardsEdward Thomson2018-02-012-3/+3
| | | | use consistent names for the #include / #define header guard pattern.
* features.h: allow building without CMake-generated feature headerPatrick Steinhardt2017-09-121-1/+4
| | | | | | | | | | | | | | | | | | | | | In commit a390a8464 (cmake: move defines into "features.h" header, 2017-07-01), we have introduced a new "features.h" header. This file is being generated by the CMake build system based on how the libgit2 build has been configured, replacing the preexisting method of simply setting the defines inside of the CMake build system. This was done to help splitting up the build instructions into multiple separate subdirectories. An overlooked shortcoming of this approach is that some projects making use of libgit2 build the library with custom build systems, without making use of CMake. For those users, the introduction of the "features.h" file makes their life harder as they would have to also generate this file. Fix this issue by guarding all inclusions of the generated header file by the `LIBGIT2_NO_FEATURES_H` define. Like this, other build systems can skip the feature header and simply define all used features by specifying `-D` flags for the compiler again.
* cmake: move regcomp and futimens checks to "features.h"Patrick Steinhardt2017-08-161-2/+2
| | | | | | | | | | | | | In our CMakeLists.txt, we have to check multiple functions in order to determine if we have to use our own or whether we can use the platform-provided one. For two of these functions, namely `regcomp_l()` and `futimens`, the defined macro is actually used inside of the header file "src/unix/posix.h". As such, these macros are not only required by the library, but also by our test suite, which is makes use of internal headers. To prepare for the CMakeLists.txt split, move these two defines inside of the "features.h" header.
* cmake: move defines into "features.h" headerPatrick Steinhardt2017-08-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a future commit, we will split out the build instructions for our library directory and move them into a subdirectory. One of the benefits is fixing scoping issues, where e.g. defines do not leak to build targets where they do not belong to. But unfortunately, this does also pose the problem of how to propagate some defines which are required by both the library and the test suite. One way would be to create another variable keeping track of all added defines and declare it inside of the parent scope. While this is the most obvious and simplest way of going ahead, it is kind of unfortunate. The main reason to not use this is that these defines become implicit dependencies between the build targets. By simply observing a define inside of the CMakeLists.txt file, one cannot reason whether this define is only required by the current target or whether it is required by different targets, as well. Another approach would be to use an internal header file keeping track of all defines shared between targets. While configuring the library, we will set various variables and let CMake configure the file, adding or removing defines based on what has been configured. Like this, one can easily keep track of the current environment by simply inspecting the header file. Furthermore, these dependencies are becoming clear inside the CMakeLists.txt, as instead of simply adding a define, we now call e.g. `SET(GIT_THREADSAFE 1)`. Having this header file though requires us to make sure it is always included before any "#ifdef"-preprocessor checks are executed. As we have already refactored code to always include the "common.h" header file before any statement inside of a file, this becomes easy: just make sure "common.h" includes the new "features.h" header file first.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-032-2/+8
| | | | | | | | | | | | | | | | | | | | | | 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.
* odb_loose: fsync testsEdward Thomson2017-02-281-1/+6
| | | | | | | Introduce a simple counter that `p_fsync` implements. This is useful for ensuring that `p_fsync` is called when we expect it to be, for example when we have enabled an odb backend to perform `fsync`s when writing objects.
* p_snprintf: no need for arguments to a formatEdward Thomson2017-02-171-1/+1
| | | | | | | | | | | | | | | | | | | `snprintf` requires a _format_ but does not require _arguments_ to the format. eg: `snprintf(buf, 42, "hi")` is perfectly legal. Expand the macro to match. Without this, `p_sprintf(buf, 42, "hi")` errors with: ``` error: expected expression p_snprintf(msg, 42, "hi"); ^ src/unix/posix.h:53:34: note: expanded from macro 'p_snprintf' ^ /usr/include/secure/_stdio.h:57:73: note: expanded from macro 'snprintf' __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__) ```
* giterr_set: consistent error messagesEdward Thomson2016-12-291-1/+1
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* threads: introduce `git_thread_exit`Edward Thomson2016-11-181-0/+2
| | | | | | | | | | Introduce `git_thread_exit`, which will allow threads to terminate at an arbitrary time, returning a `void *`. On Windows, this means that we need to store the current `git_thread` in TLS, so that we can set its `return` value when terminating. We cannot simply use `ExitThread`, since Win32 returns `DWORD`s from threads; we return `void *`.
* Make sure we use the `C` locale for `regcomp` on macOS.Arthur Schreiber2016-10-061-0/+10
|
* threads: add platform-independent thread initialization functionPatrick Steinhardt2016-06-201-0/+1
|
* threads: split up OS-dependent rwlock codePatrick Steinhardt2016-06-201-0/+18
|
* threads: split up OS-dependent thread-condition codePatrick Steinhardt2016-06-201-0/+8
|
* threads: split up OS-dependent mutex codePatrick Steinhardt2016-06-201-0/+7
|
* threads: split up OS-dependent thread codePatrick Steinhardt2016-06-201-0/+20
|
* Split the page size from the mmap alignmentcmn/pool-limitCarlos Martín Nieto2016-03-161-0/+5
| | | | | | | | While often similar, these are not the same on Windows. We want to use the page size on Windows for the pools, but for mmap we need to use the allocation granularity as the alignment. On the other platforms these values remain the same.
* nsec: support NDK's crazy nanosecondsEdward Thomson2016-02-251-0/+12
| | | | | | | | Android NDK does not have a `struct timespec` in its `struct stat` for nanosecond support, instead it has a single nanosecond member inside the struct stat itself. We will use that and use a macro to expand to the `st_mtim` / `st_mtimespec` definition on other systems (much like the existing `st_mtime` backcompat definition).
* map: use `giterr_set` internallyEdward Thomson2016-02-231-1/+1
| | | | | | Use the `giterr_set` function, which actually supports `GITERR_OS`. The `giterr_set_str` function is exposed for external users and will not append the operating system's error message.
* win32: introduce p_timeval that isn't stupidEdward Thomson2016-02-121-1/+3
| | | | | Windows defines `timeval` with `long`, which we cannot sanely cope with. Instead, use a custom timeval struct.
* p_futimes: support using futimens when availableEdward Thomson2015-09-301-1/+14
|
* posix compat: include sys/stat.h for mingwEdward Thomson2015-06-301-0/+1
|
* Fixed Xcode 6.1 build warningsPierre-Olivier Latour2015-06-171-0/+1
|
* Introduce p_utimes and p_futimesEdward Thomson2015-06-161-1/+3
| | | | | | Provide functionality to set the time on a filesystem entry, using utimes or futimes on POSIX type systems or SetFileTime on Win32.
* crlf: tick the index forward to work around racy-git behaviourCarlos Martín Nieto2015-06-161-0/+1
| | | | | | | | | | | | In order to avoid racy-git, we zero out the file size for entries with the same timestamp as the index (or during the initial checkout). This is the case in a couple of crlf tests, as the code is fast enough to do everything in the same second. As we know that we do not perform the modification just after writing out the index, which is what this is designed to work around, tick the mtime of the index file such that it doesn't agree with the files anymore, and we do not zero out these entries.
* git_path: introduce 'git_path_diriter'Edward Thomson2015-05-011-0/+1
| | | | | Introduce a new `git_path_diriter` that can iterate directories efficiently for each platform.
* Fix segmentation fault observed on OpenBSD/sparc64cmn/mmap-readableStefan Sperling2014-11-031-4/+2
| | | | | A non-readable mapping of a file causes an access violation in the pack tests. Always use PROT_READ to work around this.
* Merge commit 'refs/pull/2366/head' of github.com:libgit2/libgit2Carlos Martín Nieto2014-10-271-2/+8
|\
| * Fix compiler warning (git_off_t cast to size_t).Albert Meltzer2014-05-191-2/+8
| | | | | | | | | | | | Use size_t for page size, instead of long. Check result of sysconf. Use size_t for page offset so no cast to size_t (second arg to p_mmap). Use mod instead div/mult pair, so no cast to size_t is necessary.
* | Introduce some consistency in definition/declaration orderingJacques Germishuys2014-08-051-4/+3
| |
* | Move p_realpath logic to realpath.cJacques Germishuys2014-08-052-14/+9
| |
* | Cleanup portability/compatibility layerJacques Germishuys2014-08-051-1/+22
| | | | | | | | | | | | | | * Removes mingw-compat.h * Cleans up separation of compiler/platform idiosyncrasies * Unifies mingw/msvc stat structures and functions * (Tries to) hide more compiler specific implementation details (even in our internal API)
* | Fix unix/posix.h include guardJacques Germishuys2014-07-131-2/+2
|/
* indexer: use mmap for writingCarlos Martín Nieto2014-05-171-0/+6
| | | | | | Some OSs cannot keep their ideas about file content straight when mixing standard IO with file mapping. As we use mmap for reading from the packfile, let's make writing to the pack file use mmap.
* Win32: UTF-8 <-> WCHAR conversion overhaulPhilip Kelley2014-04-191-1/+0
|
* Test cancel from indexer progress callbackRussell Belfer2013-12-111-1/+1
| | | | | | | | | | | | | | | This adds tests that try canceling an indexer operation from within the progress callback. After writing the tests, I wanted to run this under valgrind and had a number of errors in that situation because mmap wasn't working. I added a CMake option to force emulation of mmap and consolidated the Amiga-specific code into that new place (so we don't actually need separate Amiga code now, just have to turn on -DNO_MMAP). Additionally, I made the indexer code propagate error codes more reliably than it used to.
* Add missing prototype for p_realpath().Jasper Lievisse Adriaanse2013-04-221-0/+2
|
* Fix compilation on OpenBSDCarlos Martín Nieto2013-04-151-1/+1
|
* Make tree iterator handle icase equivalenceRussell Belfer2013-03-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | There is a serious bug in the previous tree iterator implementation. If case insensitivity resulted in member elements being equivalent to one another, and those member elements were trees, then the children of the colliding elements would be processed in sequence instead of in a single flattened list. This meant that the tree iterator was not truly acting like a case-insensitive list. This completely reworks the tree iterator to manage lists with case insensitive equivalence classes and advance through the items in a unified manner in a single sorted frame. It is possible that at a future date we might want to update this to separate the case insensitive and case sensitive tree iterators so that the case sensitive one could be a minimal amount of code and the insensitive one would always know what it needed to do without checking flags. But there would be so much shared code between the two, that I'm not sure it that's a win. For now, this gets what we need. More tests are needed, though.
* Fix p_realpath on OpenBSDCarlos Martín Nieto2013-01-292-1/+36
| | | | | | OpenBSD's realpath(3) doesn't require the last part of the path to exist. Override p_realpath in this OS to bring it in line with the library's assumptions.
* update copyrightsEdward Thomson2013-01-082-2/+2
|
* Add POSIX compat lstat() variant for win32Russell Belfer2012-11-141-0/+3
| | | | | | | | | | The existing p_lstat implementation on win32 is not quite POSIX compliant when setting errno to ENOTDIR. This adds an option to make is be compliant so that code (such as checkout) that cares to have separate behavior for ENOTDIR can use it portably. This also contains a couple of other minor cleanups in the posix_w32.c implementations to avoid unnecessary work.
* Move inet_pton to posix platform-compatibility layerEduardo Bart2012-11-071-0/+1
|
* Always use internal fnmatch, not systemRussell Belfer2012-10-151-7/+0
|
* posix: Always set a default mapping modeVicent Marti2012-08-261-0/+2
|
* Some cleanup suggested during reviewRussell Belfer2012-08-221-1/+0
| | | | | | | | | | This cleans up a number of items suggested during code review with @vmg, including: * renaming "outside repo" config API to `git_config_open_default` * killing the `git_config_open_global` API * removing the `git_` prefix from the static functions in fileops * removing some unnecessary functionality from the "cp" command