Path: blob/master/arch/sparc/include/asm/bitops_64.h
17356 views
/*1* bitops.h: Bit string operations on the V9.2*3* Copyright 1996, 1997 David S. Miller ([email protected])4*/56#ifndef _SPARC64_BITOPS_H7#define _SPARC64_BITOPS_H89#ifndef _LINUX_BITOPS_H10#error only <linux/bitops.h> can be included directly11#endif1213#include <linux/compiler.h>14#include <asm/byteorder.h>1516extern int test_and_set_bit(unsigned long nr, volatile unsigned long *addr);17extern int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr);18extern int test_and_change_bit(unsigned long nr, volatile unsigned long *addr);19extern void set_bit(unsigned long nr, volatile unsigned long *addr);20extern void clear_bit(unsigned long nr, volatile unsigned long *addr);21extern void change_bit(unsigned long nr, volatile unsigned long *addr);2223#include <asm-generic/bitops/non-atomic.h>2425#define smp_mb__before_clear_bit() barrier()26#define smp_mb__after_clear_bit() barrier()2728#include <asm-generic/bitops/ffz.h>29#include <asm-generic/bitops/__ffs.h>30#include <asm-generic/bitops/fls.h>31#include <asm-generic/bitops/__fls.h>32#include <asm-generic/bitops/fls64.h>3334#ifdef __KERNEL__3536#include <asm-generic/bitops/sched.h>37#include <asm-generic/bitops/ffs.h>3839/*40* hweightN: returns the hamming weight (i.e. the number41* of bits set) of a N-bit word42*/4344#ifdef ULTRA_HAS_POPULATION_COUNT4546static inline unsigned int __arch_hweight64(unsigned long w)47{48unsigned int res;4950__asm__ ("popc %1,%0" : "=r" (res) : "r" (w));51return res;52}5354static inline unsigned int __arch_hweight32(unsigned int w)55{56unsigned int res;5758__asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffffffff));59return res;60}6162static inline unsigned int __arch_hweight16(unsigned int w)63{64unsigned int res;6566__asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffff));67return res;68}6970static inline unsigned int __arch_hweight8(unsigned int w)71{72unsigned int res;7374__asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xff));75return res;76}7778#else7980#include <asm-generic/bitops/arch_hweight.h>8182#endif83#include <asm-generic/bitops/const_hweight.h>84#include <asm-generic/bitops/lock.h>85#endif /* __KERNEL__ */8687#include <asm-generic/bitops/find.h>8889#ifdef __KERNEL__9091#include <asm-generic/bitops/le.h>9293#define ext2_set_bit_atomic(lock,nr,addr) \94test_and_set_bit((nr) ^ 0x38,(unsigned long *)(addr))95#define ext2_clear_bit_atomic(lock,nr,addr) \96test_and_clear_bit((nr) ^ 0x38,(unsigned long *)(addr))9798#endif /* __KERNEL__ */99100#endif /* defined(_SPARC64_BITOPS_H) */101102103