root/include/asm-sparc/bitops.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. set_bit
  2. clear_bit
  3. test_bit

   1 #ifndef _SPARC_BITOPS_H
   2 #define _SPARC_BITOPS_H
   3 
   4 /*
   5  * Copyright 1994, David S. Miller (davem@caip.rutgers.edu).
   6  */
   7 
   8 
   9 /* Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'
  10  * is in the highest of the four bytes and bit '31' is the high bit
  11  * within the first byte. Sparc is BIG-Endian. Unless noted otherwise
  12  * all bit-ops return 0 is bit previously clear and != 0 otherwise.
  13  */
  14 
  15 extern __inline__ unsigned int set_bit(unsigned int nr, void *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  16 {
  17 
  18   __asm__ __volatile__(
  19                        "or %g0, %g0, %o2\n\t"
  20                        "or %g0, %g0, %o3\n\t"
  21                        "or %g0, %o0, %o4\n\t"
  22                        "srl %o4, 0x5, %o4\n\t"
  23                        "add %o1, %o4, %o1\n\t"
  24                        "or %g0, 0x1, %o5"
  25                        "or %g0, 0x1f, %o6"
  26                        "and %o6, %o5, %o6"
  27                        "sll %o5, %o6, %o2"
  28                        "ld [%o1], %o5\n\t"
  29                        "and %o5, %o2, %o0"
  30                        "or %o5, %o2, %o5"
  31                        "st %o5, [%o1]");
  32 
  33   return nr; /* confuse gcc :-) */
  34 
  35 }
  36 
  37 extern __inline__ unsigned int clear_bit(unsigned int nr, void *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  38 {
  39   __asm__ __volatile__(
  40                        "or %g0, %g0, %o2\n\t"
  41                        "or %g0, %g0, %o3\n\t"
  42                        "or %g0, %o0, %o4\n\t"
  43                        "srl %o4, 0x5, %o4\n\t"
  44                        "add %o1, %o4, %o1\n\t"
  45                        "or %g0, 0x1, %o5"
  46                        "or %g0, 0x1f, %o6"
  47                        "and %o6, %o5, %o6"
  48                        "sll %o5, %o6, %o2"
  49                        "ld [%o1], %o5\n\t"
  50                        "and %o5, %o2, %o0\n\t"
  51                        "xnor %g0, %o2, %o2\n\t"
  52                        "and %o5, %o2, %o5\n\t"
  53                        "st %o5, [%o1]\n\t");
  54 
  55   return nr; /* confuse gcc ;-) */
  56 
  57 }
  58 
  59 extern __inline__ unsigned int test_bit(int nr, int *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61   __asm__ __volatile__(
  62                        "or %g0, %o0, %o3\n\t"
  63                        "srl %o3, 0x5, %o3\n\t"
  64                        "add %o1, %o3, %o1\n\t"
  65                        "and %o0, 0x1f, %o0\n\t"
  66                        "or %g0, 0x1, %o2\n\t"
  67                        "sll %o2, %o0, %o0"
  68                        "ld [%o1], %o2\n\t"
  69                        "and %o0, %o2, %o0\n\t");
  70 
  71   return nr; /* confuse gcc :> */
  72 
  73 }
  74 
  75 #endif /* defined(_SPARC_BITOPS_H) */

/* [previous][next][first][last][top][bottom][index][help] */