Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41398
b: refs/heads/master
c: 4ffd8b3
h: refs/heads/master
v: v3
  • Loading branch information
Ralf Baechle committed Nov 30, 2006
1 parent 9534280 commit 2d98bac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e303e088f25dc7d8bafc0d1942314214a3a57b44
refs/heads/master: 4ffd8b3838f22c34b21a25b7612795ca45d14db6
63 changes: 21 additions & 42 deletions trunk/include/asm-mips/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
#define _ASM_BITOPS_H

#include <linux/compiler.h>
#include <linux/irqflags.h>
#include <linux/types.h>
#include <asm/bug.h>
#include <asm/byteorder.h> /* sigh ... */
#include <asm/cpu-features.h>
#include <asm/sgidefs.h>
#include <asm/war.h>

#if (_MIPS_SZLONG == 32)
#define SZLONG_LOG 5
Expand All @@ -29,32 +32,12 @@
#define cpu_to_lelongp(x) cpu_to_le64p((__u64 *) (x))
#endif

#ifdef __KERNEL__

#include <linux/irqflags.h>
#include <asm/sgidefs.h>
#include <asm/war.h>

/*
* clear_bit() doesn't provide any barrier for the compiler.
*/
#define smp_mb__before_clear_bit() smp_mb()
#define smp_mb__after_clear_bit() smp_mb()

/*
* Only disable interrupt for kernel mode stuff to keep usermode stuff
* that dares to use kernel include files alive.
*/

#define __bi_flags unsigned long flags
#define __bi_local_irq_save(x) local_irq_save(x)
#define __bi_local_irq_restore(x) local_irq_restore(x)
#else
#define __bi_flags
#define __bi_local_irq_save(x)
#define __bi_local_irq_restore(x)
#endif /* __KERNEL__ */

/*
* set_bit - Atomically set a bit in memory
* @nr: the bit to set
Expand Down Expand Up @@ -93,13 +76,13 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
} else {
volatile unsigned long *a = addr;
unsigned long mask;
__bi_flags;
unsigned long flags;

a += nr >> SZLONG_LOG;
mask = 1UL << (nr & SZLONG_MASK);
__bi_local_irq_save(flags);
local_irq_save(flags);
*a |= mask;
__bi_local_irq_restore(flags);
local_irq_restore(flags);
}
}

Expand Down Expand Up @@ -141,13 +124,13 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
} else {
volatile unsigned long *a = addr;
unsigned long mask;
__bi_flags;
unsigned long flags;

a += nr >> SZLONG_LOG;
mask = 1UL << (nr & SZLONG_MASK);
__bi_local_irq_save(flags);
local_irq_save(flags);
*a &= ~mask;
__bi_local_irq_restore(flags);
local_irq_restore(flags);
}
}

Expand Down Expand Up @@ -191,13 +174,13 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
} else {
volatile unsigned long *a = addr;
unsigned long mask;
__bi_flags;
unsigned long flags;

a += nr >> SZLONG_LOG;
mask = 1UL << (nr & SZLONG_MASK);
__bi_local_irq_save(flags);
local_irq_save(flags);
*a ^= mask;
__bi_local_irq_restore(flags);
local_irq_restore(flags);
}
}

Expand Down Expand Up @@ -258,14 +241,14 @@ static inline int test_and_set_bit(unsigned long nr,
volatile unsigned long *a = addr;
unsigned long mask;
int retval;
__bi_flags;
unsigned long flags;

a += nr >> SZLONG_LOG;
mask = 1UL << (nr & SZLONG_MASK);
__bi_local_irq_save(flags);
local_irq_save(flags);
retval = (mask & *a) != 0;
*a |= mask;
__bi_local_irq_restore(flags);
local_irq_restore(flags);

return retval;
}
Expand Down Expand Up @@ -330,14 +313,14 @@ static inline int test_and_clear_bit(unsigned long nr,
volatile unsigned long *a = addr;
unsigned long mask;
int retval;
__bi_flags;
unsigned long flags;

a += nr >> SZLONG_LOG;
mask = 1UL << (nr & SZLONG_MASK);
__bi_local_irq_save(flags);
local_irq_save(flags);
retval = (mask & *a) != 0;
*a &= ~mask;
__bi_local_irq_restore(flags);
local_irq_restore(flags);

return retval;
}
Expand Down Expand Up @@ -399,23 +382,19 @@ static inline int test_and_change_bit(unsigned long nr,
} else {
volatile unsigned long *a = addr;
unsigned long mask, retval;
__bi_flags;
unsigned long flags;

a += nr >> SZLONG_LOG;
mask = 1UL << (nr & SZLONG_MASK);
__bi_local_irq_save(flags);
local_irq_save(flags);
retval = (mask & *a) != 0;
*a ^= mask;
__bi_local_irq_restore(flags);
local_irq_restore(flags);

return retval;
}
}

#undef __bi_flags
#undef __bi_local_irq_save
#undef __bi_local_irq_restore

#include <asm-generic/bitops/non-atomic.h>

/*
Expand Down

0 comments on commit 2d98bac

Please sign in to comment.