summaryrefslogtreecommitdiff
path: root/bits.h
blob: 82eb153d497efc973c557662f043a82ba4d671e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
 *
 * This file is part of nios2sim-ng.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License. See the file "COPYING" in the main directory of this archive
 * for more details.
 */

#ifndef _BITS_H_
#define _BITS_H_

#define BIT_MASK_FILL(n)	(((n) == 64) ? ~0ULL : ((1ULL << (n))-1))
#define BIT_MASK(n)		(1UL << ((n) % 32))
#define BIT_UINT32(n)		((n) / 32)

/**
 * Sets a bit in memory.
 */
static inline void set_bit(unsigned int nr, uint32_t *addr)
{
	uint32_t mask = BIT_MASK(nr);
	uint32_t *p = addr + BIT_UINT32(nr);

	*p |= mask;
}

/**
 * Clears a bit in memory.
 */
static inline void clear_bit(unsigned int nr, uint32_t *addr)
{
	uint32_t mask = BIT_MASK(nr);
	uint32_t *p = addr + BIT_UINT32(nr);

	*p &= ~mask;
}

#endif /* _BITS_H_ */
p-back&id=db6a71dd9a75fb07f6758582299acfe1ab5827dc'>c666faa713221f3177d849f99b16ad3428d7d684 /samples parentd2b024d32d6e6f704633a8a474bd883cf9e25254 (diff)
samples/bpf: fix bpf loader
llvm can emit relocations into sections other than program code (like debug info sections). Ignore them during parsing of elf file Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples')