#include <string.h>
#include <unistd.h>
#include <limits.h>
+#include <stdint.h>
+#include <inttypes.h>
typedef struct {
const char *name;
return 0;
}
+static int hlp_u64_max(void)
+{
+ printf("%" PRIu64 "\n", UINT64_MAX);
+ return 0;
+}
+
static int hlp_ulong_max32(void)
{
#if __WORDSIZE == 64
{ "LONG_MAX", hlp_long_max },
{ "ULONG_MAX", hlp_ulong_max },
{ "ULONG_MAX32",hlp_ulong_max32 },
+ { "UINT64_MAX", hlp_u64_max },
{ "byte-order", hlp_endianness },
{ NULL, NULL }
};
# list of indexes = 0..(sizeof Array - 1)
IPCS_IDX=$(seq 0 $(( ${#IPCS_PROCFILES[*]} - 1 )))
+UINT64_MAX=$($TS_HELPER_SYSINFO UINT64_MAX)
+
# checker
function ipcs_limits_check {
for i in $IPCS_IDX; do
a=$(eval ${IPCS_KERNEL_CMD[$i]})
b=$(eval ${IPCS_CMD[$i]})
+ # follow the way how ipcs handles u64 overflow
+ max_kbytes=$(bc <<< "$UINT64_MAX - ($UINT64_MAX % ($PAGE_SIZE / 1024))")
+
#echo
- #echo "KERNEL-CMD: ${IPCS_KERNEL_CMD[$i]}"
- #echo "KERNEL-RAW: $(cat ${IPCS_PROCFILES[$i]})"
- #echo "IPCS-CMD: ${IPCS_CMD[$i]}"
+ #echo "kernel kbytes: $a"
+ #echo "lsipc kbytes: $b"
+ #echo "max kbytes: $max_kbytes"
#echo
- # overflow is handled differently because we don't have large
- # int math, see https://github.com/karelzak/util-linux/issues/51
- if [ $(bc <<<"$a >= 2^64/1024") -eq 1 ]; then
- a=$(bc <<<"(2^64 - $PAGE_SIZE)/1024")
+ if [ $(bc <<<"$a > $max_kbytes") -eq 1 ]; then
+ a=$max_kbytes
fi
if [ x"$a" == x"$b" ]; then