On Fre, 2012-09-14 at 16:25 +0200, Jan Engelhardt wrote:
> On Friday 2012-09-14 15:46, Jim Rees wrote:
> >Jan Engelhardt wrote:
> > >A pure K&R-C version would use a string:
> > >#define base10len(i)
> > "\0x1\0x3\0x5\0x8\0x0A\0x0D\0x0F\0x11\0x14"[sizeof(i)]
> > >(if I converted them properly i
On Friday 2012-09-14 15:46, Jim Rees wrote:
>Jan Engelhardt wrote:
>
> >A pure K&R-C version would use a string:
> >#define base10len(i) "\0x1\0x3\0x5\0x8\0x0A\0x0D\0x0F\0x11\0x14"[sizeof(i)]
> >(if I converted them properly into hexadecimal)
> The syntax is \x01\x03\x05...
>
>K&R doesn't have
Jan Engelhardt wrote:
Your way does not function as originally desired.
* base10len(i) no longer expands to a compile-time constant
* you will definitely have a variable base10len_vals in your
objects, so you waste a read operation whenever it is used.
No, I meant my original w
Bernd Petrovitsch wrote:
[]
> Pure K&R:
We can (and should) make it "const" too.
No "const" in K&R either. But I think we can assume the kernel will be
compiled with something a bit more advance.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body
Jan Engelhardt wrote:
>A pure K&R-C version would use a string:
>#define base10len(i) "\0x1\0x3\0x5\0x8\0x0A\0x0D\0x0F\0x11\0x14"[sizeof(i)]
>(if I converted them properly into hexadecimal)
The syntax is \x01\x03\x05...
K&R doesn't have the \x escape, only \0 (octal).
--
To unsubscribe fr
On Friday 2012-09-14 14:30, Jim Rees wrote in an odd quote style
(the > are mine):
>Bernd Petrovitsch wrote:
>
> A pure K&R-C version would use a string:
> snip
> #define base10len(i) "\0x1\0x3\0x5\0x8\0x0A\0x0D\0x0F\0x11\0x14"[sizeof(i)]
> snip
> (if I converted them p
On Fre, 2012-09-14 at 08:30 -0400, Jim Rees wrote:
> Bernd Petrovitsch wrote:
[...]
> A pure K&R-C version would use a string:
> snip
> #define base10len(i) "\0x1\0x3\0x5\0x8\0x0A\0x0D\0x0F\0x11\0x14"[sizeof(i)]
> snip
> (if I converted them properly into hexadecim
On Fri, Sep 14, 2012 at 08:30:14AM -0400, Jim Rees wrote:
> But I still like my way better.
Yeah. It looks less mysterious once you realize it's just a
straightforward application of the usual coincidence
2^10 = 1024 ~ 1000 = 10^3
How about this? Also with some more defines because I l
On Friday 2012-09-14 11:17, Bernd Petrovitsch wrote:
>Shouldn't that have been
> snip
>#define base10len(i) ((const int[]){1,3,5,8,10,13,15,17,20}[sizeof(i)])
> snip
Yeah.
>A pure K&R-C version would use a string:
>#define base10len(i) "\0x1\0x3\0x5\0x8\0x0A\0x0D\0x0F\0x11\0x1
Bernd Petrovitsch wrote:
On Mon, 2012-09-10 at 08:19 +0200, Jan Engelhardt wrote:
> On Tuesday 2012-08-21 23:29, J. Bruce Fields wrote:
[...]
> >+/*
> >+ * length of the decimal representation of an unsigned integer. Just an
> >+ * approximation, but it's right for types of size 1 to
On Mon, 2012-09-10 at 08:19 +0200, Jan Engelhardt wrote:
> On Tuesday 2012-08-21 23:29, J. Bruce Fields wrote:
[...]
> >+/*
> >+ * length of the decimal representation of an unsigned integer. Just an
> >+ * approximation, but it's right for types of size 1 to 36 bytes:
> >+ */
> >+#define base10le
On Tuesday 2012-08-21 23:29, J. Bruce Fields wrote:
>I've seen a couple examples recently where we've gotten this wrong.
>Maybe something like this would help? Is there some better way?
>(Approximation due to Jim Rees).
>
>+/*
>+ * length of the decimal representation of an unsigned integer. Jus
Al Viro wrote:
On Tue, Aug 21, 2012 at 05:22:27PM -0400, Jim Rees wrote:
> J. Bruce Fields wrote:
>
> From: "J. Bruce Fields"
>
> I've seen a couple examples recently where we've gotten this wrong.
> Maybe something like this would help? Is there some better way?
>
On Tue, Aug 21, 2012 at 11:06:13PM +0100, Al Viro wrote:
> On Tue, Aug 21, 2012 at 05:22:27PM -0400, Jim Rees wrote:
> > J. Bruce Fields wrote:
> >
> > From: "J. Bruce Fields"
> >
> > I've seen a couple examples recently where we've gotten this wrong.
> > Maybe something like this would
On Tue, Aug 21, 2012 at 05:22:27PM -0400, Jim Rees wrote:
> J. Bruce Fields wrote:
>
> From: "J. Bruce Fields"
>
> I've seen a couple examples recently where we've gotten this wrong.
> Maybe something like this would help? Is there some better way?
>
> (Approximation due to Jim Ree
J. Bruce Fields wrote:
From: "J. Bruce Fields"
I've seen a couple examples recently where we've gotten this wrong.
Maybe something like this would help? Is there some better way?
(Approximation due to Jim Rees).
Please add Suggested-by: Jim Rees . I'm thinking of
patenting the al
From: "J. Bruce Fields"
I've seen a couple examples recently where we've gotten this wrong.
Maybe something like this would help? Is there some better way?
(Approximation due to Jim Rees).
Signed-off-by: J. Bruce Fields
---
include/linux/string.h |6 ++
net/sunrpc/cache.c |2
17 matches
Mail list logo