Thread (10 messages) flat view 10 messages, 4 authors, 2021-07-08

RE: [PATCH net-next v6 2/5] bitops: add non-atomic bitops for pointers

From: David Laight <hidden>
Date: 2021-07-02 14:47:52
Also in: bpf

From: Kumar Kartikeya Dwivedi
Sent: 02 July 2021 12:18

cpumap needs to set, clear, and test the lowest bit in skb pointer in
various places. To make these checks less noisy, add pointer friendly
bitop macros that also do some typechecking to sanitize the argument.
Would this work?
#define BIT_OP(val, op) ((typeof (val))((unsigned long)(val) op))

Should let you do:
	ptr = BIT_OP(ptr, | 1);
	ptr = BIT_OP(ptr, & ~1);
	if (BIT_OPT(ptr, & 1))
		...

See https://godbolt.org/z/E57aGK4js

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help