aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils/utils.h
Commit message (Collapse)AuthorAgeFilesLines
* utils: Check if the parameter passed to countof() is actually an array typeMartin Willi2014-08-251-1/+2
| | | | This should avoid errors such as the one fixed with 118b2879.
* utils: Add some initial build time assertion macrosMartin Willi2014-08-251-0/+14
| | | | | These are useful to assert constants during build time. We evaluate the expression to 0 when valid, so we can safely use the evaluated value.
* utils: Undefine mem{cpy,move,set} if set before defining themMartin Willi2014-07-071-0/+9
| | | | | Some platforms, such as OS X, use macros for these functions. Undefine them to avoid compiler warnings.
* utils: Helper macros to define overloaded macros based on number of argumentsTobias Brunner2014-06-301-0/+26
|
* utils: Add wrappers for memcpy(3), memmove(3) and memset(3)Tobias Brunner2014-06-241-1/+33
| | | | | | | | These wrappers guarantee that calls to these functions are noops if the number of bytes is 0, as calling them with NULL pointers is undefined according to the C standard, even if the number of bytes is 0 (most implementations probably ignore the pointers anyway in this case, but lets make sure).
* utils: Add a wait_sigint() function to wait for SIGINT or equivalentMartin Willi2014-06-041-0/+5
|
* utils: Provide a path_absolute() function to check path for non-relativenessMartin Willi2014-06-041-0/+8
| | | | The usually used trivial '/' check won't work on Windows platforms.
* utils: Define a platform directory separator character used in pathsMartin Willi2014-06-041-0/+9
|
* windows: Provide a sched_yield() implementationMartin Willi2014-06-041-0/+1
|
* windows: Add utils_init/deinit functions to initialize Winsock2Martin Willi2014-06-041-0/+10
|
* windows: Add a common Windows header for platform specific wrappersMartin Willi2014-06-031-2/+11
| | | | | Include some more basic system headers in utils.h, so we can use that common header on the different platforms.
* enum: Don't directly include enum.hMartin Willi2014-05-161-3/+3
| | | | | To allow enum.h to depend on utils.h definitions, avoid its direct inclusion. Instead include utils.h, which includes enum.h as well.
* utils: Provide a CALLBACK macro, similar to METHOD, but for void* callbacksMartin Willi2014-05-071-0/+13
| | | | | | Using the same mechanism as the METHOD macro, the CALLBACK macro defines a hybrid function signature. It strictly uses a weak void* for the first function parameter, in contrast to the dynamic METHOD object "this" type.
* utils: Enable __atomic* built-ins based on the GCC versionTobias Brunner2014-05-041-0/+7
| | | | | | | | | | | This solves a problem with GNAT when compiling charon-tkm as __atomic* built-ins are only provided in GCC 4.7 and newer. Currently GNAT 4.6 and GCC 4.7.2 is shipped with Debian wheezy (stable), as used in the testing environment. So while the configure script correctly detected the __atomic* built-ins, and defined HAVE_GCC_ATOMIC_OPERATIONS, this define turned out to be incorrect when charon-tkm was later built with GNAT.
* utils: Use GCC's __atomic built-ins if availableTobias Brunner2014-04-241-1/+20
| | | | | | | | 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-2/+11
| | | | | | | | | | 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-0/+14
| | | | 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-1/+27
|
* utils: Move thread-safe strerror replacement to a separate fileTobias Brunner2014-02-241-17/+1
| | | | | For some utils _GNU_SOURCE might be needed but that conflicts with the signature of strerror_r(3).
* Fixed some typosTobias Brunner2014-02-181-3/+3
|
* utils: Add strreplace functionTobias Brunner2014-01-231-1/+15
|
* utils: Include stdio.h for fmemopen() replacementTobias Brunner2013-10-291-0/+1
| | | | | This might now be required because Vstr is not necessarily required anymore, which means stdio.h might not be pulled in by prinf_hook.h.
* utils: Fix check for fmemopen() fallback implementationMartin Willi2013-10-241-1/+2
|
* utils: Provide a fmemopen(3) fallback using BSD funopen()Martin Willi2013-10-241-0/+15
|
* utils: Add utility function to calculate padding lengthTobias Brunner2013-10-171-12/+16
|
* utils: Add case-insensitive version of strpfx()Tobias Brunner2013-08-241-0/+8
|
* utils: add round_up/down() helper functionsMartin Willi2013-07-291-0/+23
|
* utils: Add helper function to check a string for a given prefixTobias Brunner2013-07-081-0/+8
|
* utils: Convert string helper macros to static inline functionsTobias Brunner2013-07-081-6/+15
|
* utils: Remove volatile qualifier from refcount_t typedefTobias Brunner2013-06-191-2/+1
| | | | | It's not really required anymore (if it ever was) and may cause compiler warnings when using the non atomic versions of ref_get/ref_put.
* utils: ref_get() returns the new value of the reference counterMartin Willi2013-06-111-2/+3
| | | | This allows us to use ref_get() for getting unique values.
* Removed unused clalloc() functionTobias Brunner2013-06-111-5/+0
|
* timeval_add_ms() fixedTobias Brunner2013-06-111-1/+1
| | | | 1000000us are exactly 1s so.
* Allow memwipe() to be called with NULL argumentTobias Brunner2013-05-271-0/+4
|
* Add a utility function to resolve TTY color escape codes dynamicallyMartin Willi2013-03-041-0/+40
|
* Add a global return_success() method implementationMartin Willi2013-02-141-0/+5
|
* Moved utils.[ch] to utils folderTobias Brunner2012-10-241-0/+699