blob: 889afa9f990ff88930b94758cc336ca2ca79da35 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sam Ravnborgf5e706a2008-07-17 21:55:51 -07002/*
3 * bitops.h: Bit string operations on the Sparc.
4 *
5 * Copyright 1995 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright 1996 Eddie C. Dost (ecd@skynet.be)
7 * Copyright 2001 Anton Blanchard (anton@samba.org)
8 */
9
10#ifndef _SPARC_BITOPS_H
11#define _SPARC_BITOPS_H
12
13#include <linux/compiler.h>
14#include <asm/byteorder.h>
15
16#ifdef __KERNEL__
17
18#ifndef _LINUX_BITOPS_H
19#error only <linux/bitops.h> can be included directly
20#endif
21
Sam Ravnborgf05a6862014-05-16 23:25:50 +020022unsigned long ___set_bit(unsigned long *addr, unsigned long mask);
23unsigned long ___clear_bit(unsigned long *addr, unsigned long mask);
24unsigned long ___change_bit(unsigned long *addr, unsigned long mask);
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070025
26/*
27 * Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'
28 * is in the highest of the four bytes and bit '31' is the high bit
29 * within the first byte. Sparc is BIG-Endian. Unless noted otherwise
30 * all bit-ops return 0 if bit was previously clear and != 0 otherwise.
31 */
32static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *addr)
33{
34 unsigned long *ADDR, mask;
35
36 ADDR = ((unsigned long *) addr) + (nr >> 5);
37 mask = 1 << (nr & 31);
38
39 return ___set_bit(ADDR, mask) != 0;
40}
41
42static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
43{
44 unsigned long *ADDR, mask;
45
46 ADDR = ((unsigned long *) addr) + (nr >> 5);
47 mask = 1 << (nr & 31);
48
49 (void) ___set_bit(ADDR, mask);
50}
51
52static inline int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
53{
54 unsigned long *ADDR, mask;
55
56 ADDR = ((unsigned long *) addr) + (nr >> 5);
57 mask = 1 << (nr & 31);
58
59 return ___clear_bit(ADDR, mask) != 0;
60}
61
62static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
63{
64 unsigned long *ADDR, mask;
65
66 ADDR = ((unsigned long *) addr) + (nr >> 5);
67 mask = 1 << (nr & 31);
68
69 (void) ___clear_bit(ADDR, mask);
70}
71
72static inline int test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
73{
74 unsigned long *ADDR, mask;
75
76 ADDR = ((unsigned long *) addr) + (nr >> 5);
77 mask = 1 << (nr & 31);
78
79 return ___change_bit(ADDR, mask) != 0;
80}
81
82static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
83{
84 unsigned long *ADDR, mask;
85
86 ADDR = ((unsigned long *) addr) + (nr >> 5);
87 mask = 1 << (nr & 31);
88
89 (void) ___change_bit(ADDR, mask);
90}
91
92#include <asm-generic/bitops/non-atomic.h>
93
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070094#include <asm-generic/bitops/ffz.h>
95#include <asm-generic/bitops/__ffs.h>
96#include <asm-generic/bitops/sched.h>
97#include <asm-generic/bitops/ffs.h>
98#include <asm-generic/bitops/fls.h>
Rusty Russelle8e8e802008-12-03 16:04:52 -080099#include <asm-generic/bitops/__fls.h>
Sam Ravnborgf5e706a2008-07-17 21:55:51 -0700100#include <asm-generic/bitops/fls64.h>
101#include <asm-generic/bitops/hweight.h>
102#include <asm-generic/bitops/lock.h>
Akinobu Mita861b5ae2011-03-23 16:42:02 -0700103#include <asm-generic/bitops/le.h>
Sam Ravnborgf5e706a2008-07-17 21:55:51 -0700104#include <asm-generic/bitops/ext2-atomic.h>
Sam Ravnborgf5e706a2008-07-17 21:55:51 -0700105
106#endif /* __KERNEL__ */
107
108#endif /* defined(_SPARC_BITOPS_H) */