Commit graph

45 commits

Author SHA1 Message Date
Felix Fietkau
6339204c21 CMakeLists.txt: bump minimum cmake version
Removes warnings and fixes rpath issues on macOS

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-12-18 13:31:23 +01:00
Felix Fietkau
e80dc00ee9 link librt if needed for shm_open
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-11-28 22:10:43 +01:00
Felix Fietkau
d4c3066e7c udebug: add udebug library code
Copied and adapted from udebug.git

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-11-27 18:30:01 +01:00
Petr Štetiar
b0886a37f3 cmake: add a possibility to set library version
Add a new `ABIVERSION` define which allows to control the SOVERSION used
for the built shared library. This is needed for downstream packaging to
properly track breaking ABI changes when updating to newer versions of
the library.

Suggested-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2020-01-20 16:54:10 +01:00
Petr Štetiar
bf680707ac tests: add unit tests covered with Clang sanitizers
Currently we run all tests via Valgrind. This patch adds 2nd batch of
tests which are compiled with Clang AddressSanitizer[1],
LeakSanitizer[2] and UndefinedBehaviorSanitizer[3] in order to catch
more issues during QA on CI.

AddressSanitizer is a fast memory error detector.  The tool can detect
the following types of bugs:

 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free, use-after-return, use-after-scope
 * Double-free, invalid free

LeakSanitizer is a run-time memory leak detector. It can be combined
with AddressSanitizer to get both memory error and leak detection, or
used in a stand-alone mode.

UndefinedBehaviorSanitizer (UBSan) is a fast undefined behavior
detector. UBSan modifies the program at compile-time to catch various
kinds of undefined behavior during program execution, for example:

 * Using misaligned or null pointer
 * Signed integer overflow
 * Conversion to, from, or between floating-point types which would
   overflow the destination

1. http://clang.llvm.org/docs/AddressSanitizer.html
2. http://http://clang.llvm.org/docs/LeakSanitizer.html
3. http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-25 10:31:58 +01:00
Petr Štetiar
f804578847 cmake: add more hardening compiler flags
In order to spot possible issues with direct impact on security during
QA on CI (GCC version 6 and higher).

Ref: https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-25 10:31:58 +01:00
Petr Štetiar
eb216a9524 cmake: use extra compiler warnings only on gcc6+
gcc version 4.8.4 (Ubuntu 14.04) and -Wextra produces following:

 json_script.c:124:3: error: missing initializer for field 'name' of 'struct blobmsg_policy' [-Werror=missing-field-initializers]

Reported-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-01 12:26:41 +01:00
Petr Štetiar
b0a5cd8a28 add cram based unit tests
For improved QA etc. For the start with initial test cases for avl,
base64, jshn and list components. Moved runqueue and blobmsg from
examples to tests.  Converted just a few first test cases from
json-script example into the new cram based unit test, more to come.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-24 13:26:58 +01:00
Petr Štetiar
c955464d7a enable extra compiler checks
Let's enforce additional automatic checks enforced by the compiler in
order to catch possible errors during compilation.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-20 14:34:01 +01:00
Bachtin, Dmitri
2b89f2169b Build static version of libblobmsg_json
Signed-off-by: Dmitri Bachtin <dbachtin@init-ka.de>
2015-09-09 11:02:49 +02:00
Nikolay Dimitrov
4c94515cc8 libubox: cmake: Add BUILD_EXAMPLES option
Add ability to skip building the examples. The default value is ON to follow
the original cmake behavior.

Signed-off-by: Nikolay Dimitrov <picmaster@mail.bg>
2015-06-14 15:25:38 +02:00
Yegor Yefremov
791a361ad1 ubox: CMake: fix json-c detection
Use PKG_SEARCH_MODULE() to detect json-c library,
otherwise the search fails, if both json-c and json
are not present in pkg-config database.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2015-05-10 14:14:45 +02: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
Jo-Philipp Wich
ca6d547205 ulog: introduce new simple logging api
The ulog api is intended to be used by procd, fstools, ubox etc. to provide
a generic logging api for early boot messages and automatic switching between
syslog / kmsg / stdout depending on the way the process is executed.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-02-26 10:43:56 +01:00
Yousong Zhou
8cc3903383 examples: fix build.
- runqueue-example.c: fix include path for in-tree build.
 - blobmsg-example.c: add inttypes.h for using PRIu64.
 - add examples/ subdirectory to main CMakeLists.txt

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-11 17:57:19 +01:00
Yousong Zhou
c5d80836cd lua: do not hardcode /opt/local/include for Apple.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-11 17:57:07 +01:00
Yousong Zhou
cbf80de7f4 libubox: drop legacy json-c support
The cmake logic is wrong (E.G. PKG_CHECK_FOR_MODULES fails unless all
modules are found), and the legacy libjson.so name is also used by the other
libjson (http://sourceforge.net/projects/libjson/) which provides an
incompatible API, so just drop it.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-11 17:56:54 +01:00
John Crispin
dffbc09baf jshn: pretty print indented output with jshn -i -w
Signed-off-by: John Crispin <blogic@openwrt.org>
2014-08-04 20:01:16 +02:00
John Crispin
e130b08d98 build a static version of libubox
Signed-off-by: John Crispin <blogic@openwrt.org>
2014-06-11 01:39:12 +01:00
Felix Fietkau
d4b56b0940 kvlist: add a simply key/value store implementation
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-12 01:42:44 +02:00
John Crispin
e8b26ce48d add md5.c to libubox
Signed-off-by: John Crispin <blogic@openwrt.org>
2013-11-19 20:31:45 +01:00
Felix Fietkau
cb6c1718e7 runqueue: add a simple task queueing/completion tracking implementation
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:10:00 +02:00
Helmut Schaa
ecee1a3bea libubox: Allow to build against libjson-c > 0.9
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
2013-05-07 15:53:36 +02:00
Felix Fietkau
7c11f6e913 safe_list: add a new linked list variant
Use this linked list implementation as a replacement for list.h if you
want to allow deleting arbitrary list entries from within one or more
recursive iterator calling context

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-18 05:47:53 +01:00
Thomas Gstädtner
49e6e062b8 add pkgconfig support for json-c
this includes a fallback for legacy support
2013-03-05 10:44:48 +01:00
Felix Fietkau
38ea521911 add json_script, a minimalistic JSON based script interpreter
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-28 21:50:55 +01:00
Felix Fietkau
9a3519536b blobmsg_json: prefer to link against libjson-c over libjson (the new library name in git versions of json-c)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-10 15:32:45 +01:00
Felix Fietkau
e009fd8c82 build: remove install prefix override
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-23 15:22:29 +01:00
Felix Fietkau
dde64e47ca uloop: use clock_gettime with the monotonic clock instead of using gettimeofday()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-06 03:04:04 +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
Felix Fietkau
9afe120530 add -Wmissing-declarations to cflags 2012-10-22 20:03:53 +02:00
Felix Fietkau
768a69b3ce add ustream, an api for stream buffer management 2012-10-21 23:00:06 +02:00
Felix Fietkau
a81cb397ef add lua binding for uloop (written by John Crispin) 2012-09-27 13:41:02 +02:00
Felix Fietkau
cddd9326dc add vlist (from netifd) 2012-05-26 18:01:18 +02:00
Felix Fietkau
08a4bf2a29 add avl_strcmp 2012-05-26 18:01:18 +02:00
Felix Fietkau
fda6079b30 add jshn 2011-05-23 22:21:27 +02:00
Felix Fietkau
a7c9ae6d6a support building without json support 2011-03-26 23:50:33 +01:00
Felix Fietkau
dc8c37fa8b change minimum cmake version to 2.6 2011-02-12 23:58:09 +01:00
Felix Fietkau
c9e852301b remove hash.[ch] - i don't think we will need it 2011-02-06 17:20:46 +01:00
Felix Fietkau
02074ab521 remove uhtbl - i don't think we will need it 2011-02-06 17:19:35 +01:00
Felix Fietkau
7e9712363b add a json to blobmsg parsing library 2011-02-06 16:14:15 +01:00
Felix Fietkau
36ddbe83b3 add back usock 2011-01-31 21:24:20 +01:00
Felix Fietkau
d1c5aa705a remove unl 2011-01-31 20:58:17 +01:00
Felix Fietkau
3205134afd link against libnl-tiny 2011-01-31 20:36:36 +01:00
Felix Fietkau
efd7c8c4df convert to cmake 2011-01-31 20:23:34 +01:00