Commit Graph

68 Commits

Author SHA1 Message Date
Edward Thomson
82f15896de threads: introduce git_thread_exit
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 *`.
2016-11-18 07:34:09 -05:00
Arthur Schreiber
ab96ca5572 Make sure we use the C locale for regcomp on macOS. 2016-10-06 13:15:31 +02:00
Patrick Steinhardt
aab266c932 threads: add platform-independent thread initialization function 2016-06-20 20:07:33 +02:00
Patrick Steinhardt
6551004fb1 threads: split up OS-dependent rwlock code 2016-06-20 19:49:40 +02:00
Patrick Steinhardt
139bffa074 threads: split up OS-dependent thread-condition code 2016-06-20 19:49:34 +02:00
Patrick Steinhardt
1c13540510 threads: split up OS-dependent mutex code 2016-06-20 19:34:51 +02:00
Patrick Steinhardt
faebc1c6ec threads: split up OS-dependent thread code 2016-06-20 19:32:59 +02:00
Carlos Martín Nieto
87c181970d Split the page size from the mmap alignment
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.
2016-03-16 21:36:25 +01:00
Edward Thomson
3d6a42d1e1 nsec: support NDK's crazy nanoseconds
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).
2016-02-25 11:40:48 -05:00
Edward Thomson
04c3b35f9c map: use giterr_set internally
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.
2016-02-23 13:08:50 -05:00
Edward Thomson
35439f5997 win32: introduce p_timeval that isn't stupid
Windows defines `timeval` with `long`, which we cannot
sanely cope with.  Instead, use a custom timeval struct.
2016-02-12 10:34:15 -08:00
Edward Thomson
8649dfd8df p_futimes: support using futimens when available 2015-09-30 05:37:20 -04:00
Edward Thomson
69c8bf7e0d posix compat: include sys/stat.h for mingw 2015-06-30 14:31:07 +00:00
Pierre-Olivier Latour
85a5e8ebe1 Fixed Xcode 6.1 build warnings 2015-06-17 09:00:23 -07:00
Edward Thomson
121c3171e5 Introduce p_utimes and p_futimes
Provide functionality to set the time on a filesystem entry,
using utimes or futimes on POSIX type systems or SetFileTime
on Win32.
2015-06-16 15:32:02 -04:00
Carlos Martín Nieto
c4e6ab5f23 crlf: tick the index forward to work around racy-git behaviour
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.
2015-06-16 08:40:45 +02:00
Edward Thomson
edbfc52cdd git_path: introduce 'git_path_diriter'
Introduce a new `git_path_diriter` that can iterate directories
efficiently for each platform.
2015-05-01 12:31:05 -04:00
Stefan Sperling
aad0bd6bc7 Fix segmentation fault observed on OpenBSD/sparc64
A non-readable mapping of a file causes an access violation in
the pack tests. Always use PROT_READ to work around this.
2014-11-03 13:49:04 +01:00
Carlos Martín Nieto
177a29d832 Merge commit 'refs/pull/2366/head' of github.com:libgit2/libgit2 2014-10-27 10:39:45 +01:00
Jacques Germishuys
07d03d3145 Introduce some consistency in definition/declaration ordering 2014-08-05 20:52:00 +02:00
Jacques Germishuys
662f90e6ec Move p_realpath logic to realpath.c 2014-08-05 20:52:00 +02:00
Jacques Germishuys
2f795d8fc5 Cleanup portability/compatibility layer
* 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)
2014-08-05 20:51:59 +02:00
Jacques Germishuys
529c37156d Fix unix/posix.h include guard 2014-07-13 16:23:16 +02:00
Albert Meltzer
62e562f92b Fix compiler warning (git_off_t cast to size_t).
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.
2014-05-19 17:37:29 -07:00
Carlos Martín Nieto
f7310540ae indexer: use mmap for writing
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.
2014-05-17 01:39:43 +02:00
Philip Kelley
c2c8161541 Win32: UTF-8 <-> WCHAR conversion overhaul 2014-04-19 21:50:44 -04:00
Russell Belfer
7697e54176 Test cancel from indexer progress callback
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.
2013-12-11 15:02:20 -08:00
Jasper Lievisse Adriaanse
0d4a5b13af Add missing prototype for p_realpath(). 2013-04-22 00:13:35 +02:00
Carlos Martín Nieto
872ca1d302 Fix compilation on OpenBSD 2013-04-15 20:00:42 +02:00
Russell Belfer
e40f1c2d23 Make tree iterator handle icase equivalence
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.
2013-03-08 16:39:57 -08:00
Carlos Martín Nieto
67fcac567b Fix p_realpath on OpenBSD
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.
2013-01-29 18:46:17 +01:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Russell Belfer
cccacac555 Add POSIX compat lstat() variant for win32
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.
2012-11-14 22:41:51 -08:00
Eduardo Bart
345eef2374 Move inet_pton to posix platform-compatibility layer 2012-11-07 16:15:09 -02:00
Russell Belfer
824d5e4d26 Always use internal fnmatch, not system 2012-10-15 12:54:46 -07:00
Vicent Marti
17f7bde2f7 posix: Always set a default mapping mode 2012-08-26 18:00:10 -07:00
Russell Belfer
85bd174626 Some cleanup suggested during review
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
2012-08-22 16:16:42 -07:00
Russell Belfer
ca1b6e5409 Add template dir and set gid to repo init
This extends git_repository_init_ext further with support for
initializing the repository from an external template directory
and with support for the "create shared" type flags that make a
set GID repository directory.

This also adds tests for much of the new functionality to the
existing `repo/init.c` test suite.

Also, this adds a bunch of new utility functions including a
very general purpose `git_futils_mkdir` (with the ability to
make paths and to chmod the paths post-creation) and a file
tree copying function `git_futils_cp_r`.  Also, this includes
some new path functions that were useful to keep the code
simple.
2012-08-22 16:07:19 -07:00
Ben Straub
bfc6563405 Merge branch 'development' into clone 2012-07-17 08:08:34 -07:00
Ben Straub
1d68fcd04b Checkout: handle symlinks.
Includes unfinished win32 implementation.
2012-07-16 16:22:41 -07:00
Chris Young
96ef3d8462 Make this more generic and mergeable.
Needs AmigaOS.cmake now from CMake package at OS4Depot, or contents below:
--8<--
SET(AMIGA 1)
SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
--8<--
2012-06-13 23:16:14 +01:00
Chris Young
2aeadb9c78 Actually do the mmap... unsurprisingly, this makes the indexer work on SFS
On RAM: the .idx and .pack files become links to a .lock and the original download respectively.
Assume some feature (such as record locking) supported by SFS but not JXFS or RAM: is required.
2012-06-12 19:25:09 +01:00
Chris Young
90490113af Basic mmap/munmap compatiblity 2012-06-10 18:08:15 +01:00
Chris Young
2774ccb851 no fnmatch.h 2012-06-07 20:40:34 +01:00
Chris Young
c3f35902f3 Merge remote-tracking branch 'source/development' into update-test
Merging main libgit2!
Conflicts:
	CMakeLists.txt
	src/unix/map.c
2012-06-07 20:29:22 +01:00
Chris Young
82c23c5870 Assume this is irrelevant for now 2012-06-05 12:06:40 +01:00
Scott J. Goldman
6fb1c0b489 Fix readdir_r() usage for Solaris
On Solaris, struct dirent is defined differently than Linux. The field
containing the path name is of size 0, rather than NAME_MAX. So, we need to
use a properly sized buffer on Solaris to avoid a stack overflow.

Also fix some DIR* leaks on cleanup.
2012-05-12 09:51:32 -07:00
Scott J. Goldman
ec42eafd4a Hook up Windows compat fnmatch() for Solaris
Since Solaris does not support some of the same flags as glibc fnmatch(),
we just use the implementation we have for Windows.

Now that it's no longer a windows-specific thing, I moved it into compat/
instead of win32/
2012-05-10 09:52:49 -07:00
Russell Belfer
e3c4751070 Resolve comments from pull request
This converts the map validation function into a macro, tweaks
the GITERR_OS system error automatic appending, and adds a
tentative new error access API and some quick unit tests for
both the old and new error APIs.
2012-03-13 14:23:24 -07:00
Russell Belfer
e1de726c15 Migrate ODB files to new error handling
This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to
the new style of error handling.  Also got the unix and win32
versions of map.c.  There are some minor changes to other
files but no others were completely converted.

This also contains an update to filebuf so that a zeroed out
filebuf will not think that the fd (== 0) is actually open
(and inadvertently call close() on fd 0 if cleaned up).

Lastly, this was built and tested on win32 and contains a
bunch of fixes for the win32 build which was pretty broken.
2012-03-12 22:55:40 -07:00