2014-02-19 21:03 GMT+01:00 Peeters Simon <[email protected]>: > 2014-02-19 20:41 GMT+01:00 Kay Sievers <[email protected]>: >> On Wed, Feb 19, 2014 at 8:34 PM, Peeters Simon <[email protected]> >> wrote: >>> This weekend I switched 2 of my devices to kdbus. both running a 32bit >>> system (my atom based netbook and a beaglebone black) >>> >>> while compiling I ran in to trouble on both devices because of missing >>> division and modulo operations for uint64, both related to bloom.size >>> in match.c. >>> >>> So my question is: is it really necessary for bloom.size to be a >>> uint64? I can not imagine any use case for bloom sizes exceeding >>> UINT32_MAX. >>> I am not sure what the proper fix would be, I temporary fixed this by >>> casting bloom.size to uint32 where needed, and this works. >> >> Try changing it to div_u64()? You find that in other places in the >> kdbus code too. >> >> Send a patch please, if it works. > > will do in a minute (have to get my netbook downstairs) > >>> I also noted that in kdbus.h (while compiling kdbus itself) ioctl.h >>> does not get included resulting in missing definitions for _IO() and >>> family. (at least on arm) >> >> Where is it defined on arm? There is an include in kdbus.h. > > the problem is that it is "#ifndef __KERNEL__" and I assume that > __KERNEL__ gets defined when building the module.
both patches attached (sory, didn't bother to try and get git send-email to answer to the right thread)
From f54b345444b1e7002a18d6deb383a9db457a9ce0 Mon Sep 17 00:00:00 2001 From: Simon Peeters <[email protected]> Date: Wed, 19 Feb 2014 21:42:50 +0100 Subject: [PATCH 1/2] match.c use div64_u64 to devide trough bloom.size This fixes the build on 32bit systems which can't devide trough a 64 bit value. --- match.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/match.c b/match.c index 628ed2c..3038521 100644 --- a/match.c +++ b/match.c @@ -403,9 +403,13 @@ int kdbus_match_db_add(struct kdbus_conn *conn, rule->type = item->type; switch (item->type) { - case KDBUS_ITEM_BLOOM_MASK: + case KDBUS_ITEM_BLOOM_MASK: { + u64 generations; + u64 remainder; + + generations = div64_u64_rem(size, conn->bus->bloom.size, &remainder); if (size < conn->bus->bloom.size || - size % conn->bus->bloom.size > 0) { + remainder > 0) { ret = -EDOM; break; } @@ -418,11 +422,10 @@ int kdbus_match_db_add(struct kdbus_conn *conn, } /* we get an array of n generations of bloom masks */ - rule->bloom_mask.generations = - size / conn->bus->bloom.size; + rule->bloom_mask.generations = generations; break; - + } case KDBUS_ITEM_NAME: if (size == 0) { ret = -EINVAL; -- 1.8.5.4
From acd1e61a0f8b670b42d55cac71ff0447231b22f1 Mon Sep 17 00:00:00 2001 From: Simon Peeters <[email protected]> Date: Thu, 20 Feb 2014 03:15:51 +0100 Subject: [PATCH 2/2] kdbus.h: include ioctl.h also when building the module. for some wierd reason intel architectures do not need this, but at least arm does. --- kdbus.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kdbus.h b/kdbus.h index 0aa639c..f747262 100644 --- a/kdbus.h +++ b/kdbus.h @@ -21,6 +21,8 @@ #include <sys/ioctl.h> #include <sys/types.h> #include <linux/types.h> +#else +#include <asm-generic/ioctl.h> #endif #define KDBUS_IOC_MAGIC 0x95 -- 1.8.5.4
_______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
