github.com/tidwall/go@v0.0.0-20170415222209-6694a6888b7d/src/cmd/compile/internal/gc/bitset.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package gc
     6  
     7  type bitset8 uint8
     8  
     9  func (f *bitset8) set(mask uint8, b bool) {
    10  	if b {
    11  		*(*uint8)(f) |= mask
    12  	} else {
    13  		*(*uint8)(f) &^= mask
    14  	}
    15  }
    16  
    17  type bitset16 uint16
    18  
    19  func (f *bitset16) set(mask uint16, b bool) {
    20  	if b {
    21  		*(*uint16)(f) |= mask
    22  	} else {
    23  		*(*uint16)(f) &^= mask
    24  	}
    25  }
    26  
    27  type bitset32 uint32
    28  
    29  func (f *bitset32) set(mask uint32, b bool) {
    30  	if b {
    31  		*(*uint32)(f) |= mask
    32  	} else {
    33  		*(*uint32)(f) &^= mask
    34  	}
    35  }