From 5bdf6cee379efc28bb83402ccab5ef007b6e7fea Mon Sep 17 00:00:00 2001 From: roman Date: Tue, 6 Jan 2026 09:48:01 +0100 Subject: [PATCH 1/7] ci UPDATE add solaris,freebsd,32bit & BE workflows --- .github/workflows/ci.yml | 128 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96a45331f..ac3a10514 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: options: "-DENABLE_TESTS=ON", packager: "sudo apt-get", # no expect because stdout seems to be redirected - packages: "libcmocka-dev libxxhash-dev shunit2", + packages: "libcmocka-dev libxxhash-dev", snaps: "", build-cmd: "make" } @@ -36,7 +36,7 @@ jobs: cc: "clang", options: "-DENABLE_TESTS=ON", packager: "sudo apt-get", - packages: "libcmocka-dev libxxhash-dev shunit2", + packages: "libcmocka-dev libxxhash-dev", snaps: "", build-cmd: "make" } @@ -47,7 +47,7 @@ jobs: cc: "gcc", options: "", packager: "sudo apt-get", - packages: "libcmocka-dev libxxhash-dev valgrind shunit2", + packages: "libcmocka-dev libxxhash-dev valgrind", snaps: "", build-cmd: "make" } @@ -59,7 +59,7 @@ jobs: options: "", packager: "sudo apt-get", # no valgrind because it does not support DWARF5 yet generated by clang 14 - packages: "libcmocka-dev libxxhash-dev shunit2", + packages: "libcmocka-dev libxxhash-dev", snaps: "", build-cmd: "make" } @@ -70,7 +70,7 @@ jobs: cc: "clang", options: "-DENABLE_TESTS=ON -DPATH_EXPECT=", packager: "brew", - packages: "cmocka xxhash shunit2 tcl-tk", + packages: "cmocka xxhash tcl-tk", snaps: "", build-cmd: "make" } @@ -241,3 +241,121 @@ jobs: - name: Install working-directory: '${{ github.workspace }}/../build' run: cmake --install . --strip + + build-solaris: + name: Release, Solaris, gcc + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + + - name: Build and test + uses: vmactions/solaris-vm@main + with: + release: '11.4-gcc' + usesh: true + + prepare: | + echo "Installing dependencies..." + export PATH=/opt/csw/bin:$PATH + + pkgutil -y -i git cmake libpcre2_dev + + # build cmocka from source + git clone --depth 1 https://github.com/clibs/cmocka.git + cd cmocka + mkdir build-cmocka + cd build-cmocka + cmake -DCMAKE_BUILD_TYPE=Release .. + gmake + gmake install + cd ../.. + + run: | + set -e + echo "Starting build..." + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON .. + gmake + ctest --output-on-failure + + build-freebsd: + name: Release, FreeBSD, clang + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + + - name: Release, FreeBSD, clang + uses: vmactions/freebsd-vm@main + with: + usesh: true + + prepare: | + echo "Installing dependencies..." + pkg update -f + pkg install -y cmake cmocka xxhash bash git pcre2 + + run: | + set -e + echo "Starting build..." + mkdir build + cd build + + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON .. + make + ctest --output-on-failure + + build-linux-32bit: + name: Release, Linux 32-bit, gcc + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + + - name: Build in 32-bit container + run: | + docker run --rm \ + -v ${{ github.workspace }}:${{ github.workspace }} \ + -w ${{ github.workspace }} \ + i386/ubuntu \ + /bin/bash -c " \ + apt-get update -q && \ + apt-get install -y -q git cmake gcc libcmocka-dev libxxhash-dev libpcre2-dev && \ + mkdir build && cd build && \ + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON .. && \ + make && \ + ctest --output-on-failure \ + " + + build-big-endian: + name: Release, Big-endian, s390x + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + + - name: Build and test + # use QEMU user-static emulation to run non-x86 Linux + uses: uraimo/run-on-arch-action@master + with: + arch: s390x + distro: ubuntu22.04 + + # speeds up build by caching Docker images in GitHub Packages + githubToken: ${{ github.token }} + + # map the build directory to the container + dockerRunArgs: | + --volume "${PWD}:/workspace" + + # install dependencies inside the emulated container + install: | + apt-get update -q -y + apt-get install -q -y git cmake gcc libcmocka-dev libxxhash-dev libpcre2-dev + + # run the build + run: | + set -e + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON .. + make + ctest --output-on-failure From 6807e805059fc459529855c426f6cee0e007b5fc Mon Sep 17 00:00:00 2001 From: roman Date: Tue, 6 Jan 2026 13:21:11 +0100 Subject: [PATCH 2/7] compat UPDATE find byteswap correctly --- CMakeLists.txt | 4 ++++ CMakeModules/UseCompat.cmake | 2 ++ compat/compat.h.in | 7 ++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e49fc6c00..9eda06a22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,6 +341,10 @@ endif() # link compat use_compat() +if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + add_compile_definitions(__EXTENSIONS__) +endif() + # create static libyang library if(NOT BUILD_SHARED_LIBS) add_definitions(-DSTATIC) diff --git a/CMakeModules/UseCompat.cmake b/CMakeModules/UseCompat.cmake index 2d6292d66..7ea8aa95c 100644 --- a/CMakeModules/UseCompat.cmake +++ b/CMakeModules/UseCompat.cmake @@ -61,6 +61,8 @@ macro(USE_COMPAT) check_include_file("alloca.h" HAVE_ALLOCA_H) + check_include_file("byteswap.h" HAVE_BYTESWAP_H) + list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200809L) list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D__BSD_VISIBLE=1) diff --git a/compat/compat.h.in b/compat/compat.h.in index 0a62c72a4..3de06357a 100644 --- a/compat/compat.h.in +++ b/compat/compat.h.in @@ -26,11 +26,12 @@ # include #endif -#if defined (__APPLE__) || defined (_WIN32) +#cmakedefine HAVE_BYTESWAP_H +#ifdef HAVE_BYTESWAP_H +# include +#else # define bswap_32 __builtin_bswap32 # define bswap64 __builtin_bswap64 -#else -# include #endif #include From 02b403c6a2cceb82fa4607caab070eec204e567c Mon Sep 17 00:00:00 2001 From: roman Date: Wed, 7 Jan 2026 09:39:58 +0100 Subject: [PATCH 3/7] libyang UPDATE fix uninit vars in release build --- src/parser_json.c | 2 +- tools/lint/linenoise/utf8.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser_json.c b/src/parser_json.c index 5f8a3e043..c87001e88 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -1191,7 +1191,7 @@ lydjson_parse_attribute(struct lyd_json_ctx *lydctx, struct lyd_node *attr_node, { LY_ERR r; const char *opaq_name, *mod_name, *attr_mod = NULL; - size_t opaq_name_len, attr_mod_len; + size_t opaq_name_len, attr_mod_len = 0; if (!attr_node) { /* learn the attribute module name */ diff --git a/tools/lint/linenoise/utf8.c b/tools/lint/linenoise/utf8.c index dba1e4ba6..eebed1a7a 100644 --- a/tools/lint/linenoise/utf8.c +++ b/tools/lint/linenoise/utf8.c @@ -400,7 +400,7 @@ static size_t utf8BytesToCodePoint(const char* buf, size_t len, int* cp) { */ size_t linenoiseUtf8NextCharLen(const char* buf, size_t buf_len, size_t pos, size_t *col_len) { size_t beg = pos; - int cp; + int cp = 0; size_t len = utf8BytesToCodePoint(buf + pos, buf_len - pos, &cp); if (isCombiningChar(cp)) { /* NOTREACHED */ @@ -423,7 +423,7 @@ size_t linenoiseUtf8PrevCharLen(const char* buf, size_t UNUSED(buf_len), size_t while (pos > 0) { size_t len = prevUtf8CharLen(buf, pos); pos -= len; - int cp; + int cp = 0; utf8BytesToCodePoint(buf + pos, len, &cp); if (!isCombiningChar(cp)) { if (col_len != NULL) *col_len = isWideChar(cp) ? 2 : 1; From d7d9dc76e52ab8e047dce644fbb96a96290f3e43 Mon Sep 17 00:00:00 2001 From: roman Date: Wed, 7 Jan 2026 09:40:23 +0100 Subject: [PATCH 4/7] ht BUGFIX 32-bit system compatibility XXH3_64bits_withSeed may not be available on some 32-bit systems, so use XXH32 instead, since the functions return 32bits anyway --- CMakeLists.txt | 4 ++++ CMakeModules/FindXXHash.cmake | 3 +++ src/hash_table.c | 13 ++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9eda06a22..bbbb5235f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -422,6 +422,10 @@ if(XXHASH_FOUND) include_directories(${XXHASH_INCLUDE_DIR}) target_link_libraries(yang ${XXHASH_LIBRARY}) message(STATUS "Hash algorithm: xxhash") + if (HAVE_XXH3_64BITS_WITHSEED) + # for 32-bit system compatibility, this may not be available there, so use XXH32 instead + add_definitions(-DLY_XXH3_64BITS_WITHSEED) + endif() else() message(STATUS "Hash algorithm: internal Jenkin's one-at-a-time") endif() diff --git a/CMakeModules/FindXXHash.cmake b/CMakeModules/FindXXHash.cmake index 3ce77f7df..af98c60f8 100644 --- a/CMakeModules/FindXXHash.cmake +++ b/CMakeModules/FindXXHash.cmake @@ -34,5 +34,8 @@ find_library(XXHASH_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib ) +# for 32-bit system compatibility +check_symbol_exists(XXH3_64bits_withSeed ${XXHASH_INCLUDE_DIR}/xxhash.h HAVE_XXH3_64BITS_WITHSEED) + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(XXHash FOUND_VAR XXHASH_FOUND REQUIRED_VARS XXHASH_INCLUDE_DIR XXHASH_LIBRARY) diff --git a/src/hash_table.c b/src/hash_table.c index 4011a73f5..4dd49e28f 100644 --- a/src/hash_table.c +++ b/src/hash_table.c @@ -35,10 +35,17 @@ lyht_hash_multi(uint32_t hash, const char *key_part, size_t len) { #ifdef LY_XXHASH_SUPPORT if (key_part && len) { +# ifdef LY_XXH3_64BITS_WITHSEED return XXH3_64bits_withSeed(key_part, len, hash); +# else + return XXH32(key_part, len, hash); +# endif } - +# ifdef LY_XXH3_64BITS_WITHSEED return XXH3_64bits_withSeed(NULL, 0, hash); +# else + return XXH32(NULL, 0, hash); +# endif #else uint32_t i; @@ -62,7 +69,11 @@ LIBYANG_API_DEF uint32_t lyht_hash(const char *key, size_t len) { #ifdef LY_XXHASH_SUPPORT +# ifdef LY_XXH3_64BITS_WITHSEED return XXH3_64bits(key, len); +# else + return XXH32(key, len, 0); +# endif #else uint32_t hash; From d5e03d91609432312246a844085656162dda4b88 Mon Sep 17 00:00:00 2001 From: roman Date: Wed, 7 Jan 2026 10:12:50 +0100 Subject: [PATCH 5/7] compat UPDATE check for dirent.d_type --- CMakeModules/UseCompat.cmake | 3 +++ compat/compat.h.in | 1 + src/tree_schema.c | 27 ++++++++++++++++++--------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CMakeModules/UseCompat.cmake b/CMakeModules/UseCompat.cmake index 7ea8aa95c..53bb0236e 100644 --- a/CMakeModules/UseCompat.cmake +++ b/CMakeModules/UseCompat.cmake @@ -18,6 +18,7 @@ include(CheckSymbolExists) include(CheckFunctionExists) include(CheckIncludeFile) include(TestBigEndian) +include(CheckStructHasMember) if(POLICY CMP0075) cmake_policy(SET CMP0075 NEW) endif() @@ -63,6 +64,8 @@ macro(USE_COMPAT) check_include_file("byteswap.h" HAVE_BYTESWAP_H) + check_struct_has_member("struct dirent" d_type "dirent.h" HAVE_DIRENT_D_TYPE) + list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200809L) list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D__BSD_VISIBLE=1) diff --git a/compat/compat.h.in b/compat/compat.h.in index 3de06357a..d516f1c45 100644 --- a/compat/compat.h.in +++ b/compat/compat.h.in @@ -86,6 +86,7 @@ #cmakedefine HAVE_MMAP #cmakedefine HAVE_STRCASECMP #cmakedefine HAVE_SETENV +#cmakedefine HAVE_DIRENT_D_TYPE #ifndef bswap64 #define bswap64(val) \ diff --git a/src/tree_schema.c b/src/tree_schema.c index eb50c79c0..8600077e5 100644 --- a/src/tree_schema.c +++ b/src/tree_schema.c @@ -2349,13 +2349,28 @@ lys_search_localfile_file_type(const struct dirent *file, const char *wd, struct { LY_ERR rc = LY_SUCCESS; char *str = NULL; - ly_bool is_dir = 0, is_reg = 0; + ly_bool is_dir = 0, is_reg = 0, need_stat = 1; struct stat st; *skip = 0; - if ((file->d_type == DT_UNKNOWN) || (file->d_type == DT_LNK)) { - /* FS does not support this field or its a symbolic link, need to call stat */ +#ifdef HAVE_DIRENT_D_TYPE + if (file->d_type == DT_DIR) { + /* dirent - dir */ + is_dir = 1; + need_stat = 0; + } else if (file->d_type == DT_REG) { + /* dirent - file */ + is_reg = 1; + need_stat = 0; + } else if ((file->d_type != DT_UNKNOWN) && (file->d_type != DT_LNK)) { + /* it is a known type, but not dir or regular file, so trust d_type and just skip it */ + need_stat = 0; + } +#endif // HAVE_DIRENT_D_TYPE + + if (need_stat) { + /* need to use stat to determine the file type */ if (asprintf(&str, "%s/%s", wd, file->d_name) == -1) { LOGMEM(NULL); rc = LY_EMEM; @@ -2371,12 +2386,6 @@ lys_search_localfile_file_type(const struct dirent *file, const char *wd, struct /* stat - file */ is_reg = 1; } - } else if (file->d_type == DT_DIR) { - /* dirent - dir */ - is_dir = 1; - } else if (file->d_type == DT_REG) { - /* dirent - file */ - is_reg = 1; } if (is_dir && (dirs->count || !implicit_cwd)) { From e20b817b6703bb3ed8d7146ca7ec57aa19f11bfb Mon Sep 17 00:00:00 2001 From: roman Date: Wed, 7 Jan 2026 13:10:50 +0100 Subject: [PATCH 6/7] yanglint BUGFIX only change tty size if we have it --- tests/yanglint/interactive/all.tcl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/yanglint/interactive/all.tcl b/tests/yanglint/interactive/all.tcl index 4c988deb8..5dcce41bc 100644 --- a/tests/yanglint/interactive/all.tcl +++ b/tests/yanglint/interactive/all.tcl @@ -1,11 +1,17 @@ package require tcltest package require Expect -# Save current terminal size -set stty_output [exec stty size] -scan $stty_output "%d %d" orig_lines orig_columns -# setting some large terminal width -stty columns 720 +# Save current terminal size, but only if we are in an environtment with a tty (i.g. may not be present in a CI) +set has_tty 0 +if {![catch {exec stty size} stty_output]} { + scan $stty_output "%d %d" orig_lines orig_columns + set has_tty 1 +} + +if {$has_tty} { + # setting some large terminal width + stty columns 720 +} # Hook to determine if any of the tests failed. # Sets a global variable exitCode to 1 if any test fails otherwise it is set to 0. @@ -21,7 +27,9 @@ if {[info exists ::env(TESTS_DIR)]} { # run all interactive tests tcltest::runAllTests -# Restore original terminal size -exec stty rows $orig_lines cols $orig_columns +if {$has_tty} { + # Restore original terminal size + exec stty rows $orig_lines cols $orig_columns +} exit $exitCode From 7d57d2cb1505263a19aab29f93a15a67ea5f4bc3 Mon Sep 17 00:00:00 2001 From: roman Date: Wed, 7 Jan 2026 14:30:40 +0100 Subject: [PATCH 7/7] cmake UPDATE clarify solaris compat --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbbb5235f..e1e4b2123 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,6 +342,8 @@ endif() use_compat() if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + # required for some extensions on Solaris (e.g. strndup), see man 7 standards, section "Feature Test Macros" + # https://docs.oracle.com/cd/E88353_01/html/E37853/posix-7.html add_compile_definitions(__EXTENSIONS__) endif()