aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* Use standard unsigned integer typesAndreas Steffen2016-03-241-1/+1
|
* sigwaitinfo() may fail with EINTR if interrupted by an unblocked signal not ↵Tobias Brunner2015-11-231-1/+4
| | | | | | in the set Fixes #1213.
* utils: Use the more low-level __NR_ prefix to refer to the syscall numberTobias Brunner2015-11-171-1/+1
| | | | The __NR_ constants are also defined in the Android headers.
* utils: Provide a fallback for sigwaitinfo() if neededTobias Brunner2015-11-131-1/+21
| | | | | Apparently, not available on Mac OS X 10.10 Yosemite. We don't provide this on Windows.
* Replace usages of sigwait(3) with sigwaitinfo(2)Tobias Brunner2015-10-291-2/+1
| | | | | | | This is basically the same call, but it has the advantage of being supported by FreeBSD's valgrind, which sigwait() is not. References #1106.
* utils: Check for dirfd(3)Tobias Brunner2015-08-171-0/+9
| | | | | Not all POSIX compatible systems might provide it yet. If not, we close the lowest FD to close and hope it gets reused by opendir().
* utils: Directly use syscall() to close open FDs in closefrom()Tobias Brunner2015-08-171-5/+53
| | | | | | | This avoids any allocations, since calling malloc() after fork() is potentially unsafe. Fixes #990.
* utils: Don't use directory enumerator to close open FDs in closefrom()Tobias Brunner2015-08-171-24/+36
| | | | | | | | | | Calling malloc() after fork() is potentially unsafe, so we should avoid it if possible. opendir() will still require an allocation but that's less than the variant using the enumerator wrapper, thus, decreasing the conflict potential. This way we can also avoid closing the FD for the enumerated directory itself. References #990.
* utils: Clean up includesMartin Willi2015-04-161-9/+4
|
* align: Move min/max/padding/alignment functions to separate filesMartin Willi2015-04-161-45/+0
|
* time: Move time related functions to separate filesMartin Willi2015-04-161-122/+0
|
* status: Move status_t type and functions to separate filesMartin Willi2015-04-161-31/+0
|
* path: Move path related utility functions to separate filesMartin Willi2015-04-161-146/+0
|
* tty: Move tty related functions to separate filesMartin Willi2015-04-161-67/+0
|
* memory: Move memory manipulation related functions to separate filesMartin Willi2015-04-161-219/+0
|
* string: Move string related utility functions to separate filesMartin Willi2015-04-161-74/+0
|
* atomics: Move atomics/recounting support to separate filesMartin Willi2015-04-161-85/+2
|
* utils: Add malloc/free wrappers returning aligned dataMartin Willi2015-04-151-0/+44
| | | | | | | | | | | | | While we could use posix_memalign(3), that is not fully portable. Further, it might be difficult on some platforms to properly catch it in leak-detective, which results in invalid free()s when releasing such memory. We instead use a simple wrapper, which allocates larger data, and saves the padding size in the allocated header. This requires that memory is released using a dedicated function. To reduce the risk of invalid free() when working on corrupted data, we fill up all the padding with the padding length, and verify it during free_align().
* utils: Add a constant time memeq() variant for cryptographic purposesMartin Willi2015-04-141-0/+19
|
* windows: Use WINAPI call convention for Windows API callbacksMartin Willi2014-06-061-1/+1
| | | | | For x86_64 it does not actually matter, but for i686 builds the call convention is different with WINAPI.
* utils: Add a wait_sigint() function to wait for SIGINT or equivalentMartin Willi2014-06-041-0/+83
|
* utils: Provide a path_absolute() function to check path for non-relativenessMartin Willi2014-06-041-0/+27
| | | | The usually used trivial '/' check won't work on Windows platforms.
* utils: Return plain drive letter as base/pathname for drive letters on WindowsMartin Willi2014-06-041-0/+9
|
* utils: Support Windows path separators in path_basename/dirnameMartin Willi2014-06-041-9/+9
|
* windows: Provide a time_monotonic() based on GetTickCount64()Martin Willi2014-06-041-0/+21
|
* utils: Don't directly depend on pthreadMartin Willi2014-06-041-40/+53
|
* strerror: Don't directly depend on pthreadMartin Willi2014-06-041-0/+2
|
* windows: Add utils_init/deinit functions to initialize Winsock2Martin Willi2014-06-041-0/+20
|
* utils: Printf() defined time output should gmtime/localtime_r() failMartin Willi2014-06-041-10/+13
|
* printf-hook-builtin: Support Windows console colors using TTY escape codesMartin Willi2014-06-041-1/+4
|
* windows: Use _getmaxstdio as replacement for syscall(_SC_OPEN_MAX)Martin Willi2014-06-031-0/+4
|
* windows: replace mkdir() with Windows _mkdir() variantMartin Willi2014-06-031-0/+4
|
* utils: Use GCC's __atomic built-ins if availableTobias Brunner2014-04-241-2/+2
| | | | | | | | These are available since GCC 4.7 and will eventually replace the __sync operations. They support the memory model defined by C++11. For instance, by using __ATOMIC_RELAXED for some operations on the reference counters we can avoid memory barriers, which are required by __sync operations (whose memory model essentially is __ATOMIC_SEQ_CST).
* utils: Add ref_cur() to retrieve the current value of a reference counterTobias Brunner2014-04-241-1/+13
| | | | | | | | | | On many architectures it is safe to read the value directly (those using cache coherency protocols, and with atomic loads for 32-bit values) but it is not if that's not the case or if we ever decide to make refcount_t 64-bit (load not atomic on x86). So make sure the operation is actually atomic and that users do not have to care about the size of refcount_t.
* utils: Add memrchr(3) replacement for platforms that don't support itTobias Brunner2014-02-261-1/+23
| | | | For instance, on Mac OS X memrchr(3) is not provided by the C library.
* utils: Add thread-safe variants of dirname(3) and basename(3)Tobias Brunner2014-02-241-3/+61
|
* utils: Move thread-safe strerror replacement to a separate fileTobias Brunner2014-02-241-78/+0
| | | | | For some utils _GNU_SOURCE might be needed but that conflicts with the signature of strerror_r(3).
* utils: Add strreplace functionTobias Brunner2014-01-231-1/+53
|
* utils: Fix %T printf hook on big-endian systemsTobias Brunner2014-01-061-1/+1
| | | | | | | | The cast to a bool* cut of the actual value on big-endian systems if bool was shorter than int because the bool argument to printf gets promoted to an int. Fixes #479.
* utils: Fix check for fmemopen() fallback implementationMartin Willi2013-10-241-1/+1
|
* utils: Provide a fmemopen(3) fallback using BSD funopen()Martin Willi2013-10-241-0/+46
|
* utils: ref_get() returns the new value of the reference counterMartin Willi2013-06-111-2/+6
| | | | This allows us to use ref_get() for getting unique values.
* Allow memstr() to be called with NULL argumentsTobias Brunner2013-06-111-1/+6
|
* Removed unused clalloc() functionTobias Brunner2013-06-111-13/+0
|
* Add a utility function to resolve TTY color escape codes dynamicallyMartin Willi2013-03-041-0/+63
|
* Add a global return_success() method implementationMartin Willi2013-02-141-0/+8
|
* time is a time_t pointerAndreas Steffen2013-02-041-1/+1
|
* Moved utils.[ch] to utils folderTobias Brunner2012-10-241-0/+570