Felix Fietkau
0fe13749d0
utils: add helper functions useful for allocating a ring buffer
...
This creates a mapping with twice the size of the allocated memory. The
second half of that mapping points at the same memory as the first half.
This is useful for ring buffers, because any read starting in the first
half can overflow into the second half as long as the read size is
smaller than the size of the memory area.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-12-28 22:44:30 +01:00
Felix Fietkau
a8e70c6d36
add a base64 implementation (based on FreeBSD code)
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-05-08 14:34:29 +02:00
Yousong Zhou
ad9aa180d3
utils: use clock_get_time() for clock_gettime() on Apple.
...
It turns out that mach_absolute_time() is not monotonic at all. While
at it, convert the CLOCK_REALTIME implementation to using
clock_get_time() as well.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2015-01-21 20:11:30 +01:00
Felix Fietkau
9203927e58
utils: add a bitfield size macro
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-30 13:27:03 +02:00
Felix Fietkau
4f44401ae8
utils: add __constructor and __hidden defines
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-18 14:04:06 +01:00
Felix Fietkau
a2453456f2
utils.h: fix name collisions in __u_bswap16 with using "val" both inside the macro and as argument
...
Reported-by: Markus Stenberg <markus.stenberg@iki.fi>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-24 11:33:23 +02:00
Felix Fietkau
e5032709b2
utils: add bitfield inline ops
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-10 13:37:14 +02:00
Felix Fietkau
bd47d85d38
utils: make le16 endian conversion functions work with arguments that have side effects
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-14 23:39:57 +01:00
Felix Fietkau
fcd5ba8fbd
utils.h: make 16-bit little endian conversion robust against pointer subtraction arguments
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-14 22:02:56 +01:00
Felix Fietkau
d01922625d
utils: add little-endian swap helpers
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-13 12:35:19 +01:00
Felix Fietkau
e5a40544ec
utils: prefer using gccs builtin swapping functions which support constant folding
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-11 22:08:07 +01:00
Felix Fietkau
5ad190fccf
utils: move endian swap helpers and __packed definition to utils.h
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-11 21:46:41 +01:00
Felix Fietkau
aa4f3bde06
uloop: add a clock_gettime() implementation for mac os x
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-06 02:42:58 +01:00
Felix Fietkau
7157c3a4df
utils: add BUILD_BUG_ON (similar to the one in the linux kernel)
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-01 16:10:44 +01:00
Felix Fietkau
59000546c0
utils: make it unnecessary to specify the last NULL argument for calloc_a
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-31 15:40:12 +01:00
Felix Fietkau
9c8ab5d64c
utils: move ARRAY_SIZE from uloop to utils.h
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-31 15:24:27 +01:00
Felix Fietkau
d03a6a27c7
add utils.c, containing a calloc-like function to allocate multiple chunks with different sizes in one block and return pointers
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-31 15:24:26 +01:00