Source: libmaus2 Severity: normal X-Debbugs-Cc: wuruil...@loongson.cn Dear Maintainer,
Some architectures in glibc do not define the sysconf.c file, and using the generic posix sysconf.c file to call the _SC_LEVEL1_DCACHE_LINESIZE variable returns 0 by default, which leads to failure of the test in loongarch, ia64, s390x and other architectures, the detailed error link is as follows: https://buildd.debian.org/status/fetch.php?pkg=libmaus2&arch=loong64&ver=2.0.813%2Bds-1%2Bb1&stamp=1710143471&raw=0 This patch reference lscpu code to read the data in coherency_line_size file directly can fix the above error, and it passes the test on x86 and loongarch. wuruilong -- System Information: Debian Release: trixie/sid APT prefers unreleased APT policy: (500, 'unreleased'), (500, 'unstable') Architecture: loong64 (loongarch64) Kernel: Linux 5.10.0-60.96.0.126.oe2203.loongarch64 (SMP w/32 CPU threads) Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: unable to detect
Description: <short summary of the patch> TODO: Put a short summary on the line above and replace this paragraph with a longer explanation of this change. Complete the meta-information with other relevant fields (see below for details). To make it easier, the information below has been extracted from the changelog. Adjust it or drop it. . libmaus2 (2.0.813+ds-1) unstable; urgency=medium . * New upstream version * Standards-Version: 4.6.2 (routine-update) * Set upstream metadata fields: Bug-Database. * d/copyright: bump copyright year. Author: Étienne Mollier <emoll...@debian.org> --- The information above should follow the Patch Tagging Guidelines, please checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>) Bug: <upstream-bugtracker-url> Bug-Debian: https://bugs.debian.org/<bugnumber> Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> Forwarded: (no|not-needed|<patch-forwarded-url>) Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>) Reviewed-By: <name and email of someone who approved/reviewed the patch> Last-Update: 2024-04-07 --- libmaus2-2.0.813+ds.orig/src/libmaus2/arch/CacheLineSize.cpp +++ libmaus2-2.0.813+ds/src/libmaus2/arch/CacheLineSize.cpp @@ -17,6 +17,7 @@ */ #include <libmaus2/arch/CacheLineSize.hpp> #include <stdexcept> +#include <stdio.h> #include <libmaus2/LibMausConfig.hpp> @@ -39,10 +40,18 @@ std::atomic<unsigned int> libmaus2::arch /** * @return size of a (level 1) cache line in bytes **/ -#if defined(LIBMAUS2_HAVE_SYSCONF) && defined(_SC_LEVEL1_DCACHE_LINESIZE) +#if defined(__linux__) static uint64_t getCacheLineSizeLocal() { - return sysconf(_SC_LEVEL1_DCACHE_LINESIZE); + FILE *fp = NULL; + fp = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r"); + uint64_t i = 0; + if(fp){ + fscanf(fp, "%d", &i); + fclose(fp); + } + return i; } #elif defined(_WIN32) static uint64_t getCacheLineSizeLocal()