Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

__shiftin(3) [netbsd man page]

BITS(3) 						   BSD Library Functions Manual 						   BITS(3)

__BIT, __BITS, __SHIFTIN, __SHIFTOUT, __SHIFTOUT_MASK -- macros for preparing bitmasks and operating on bit fields SYNOPSIS
#include <sys/param.h> #include <sys/cdefs.h> uintmax_t __BIT(n); uintmax_t __BITS(m, n); __SHIFTIN(v, mask); __SHIFTOUT(v, mask); __SHIFTOUT_MASK(mask); DESCRIPTION
These macros prepare bitmasks, extract bitfields from words, and insert bitfields into words. A ``bitfield'' is a span of consecutive bits defined by a bitmask, where 1s select the bits in the bitfield. Use __BIT() and __BITS() to define bitmasks: __BIT(n) Return a bitmask with bit n set, where the least significant bit is bit 0. __BITS(m, n) Return a bitmask with bits m through n, inclusive, set. It does not matter whether m > n or m <= n. The least significant bit is bit 0. __SHIFTIN(), __SHIFTOUT(), and __SHIFTOUT_MASK() help read and write bitfields from words: __SHIFTIN(v, mask) Left-shift bits v into the bitfield defined by mask, and return them. No side-effects. __SHIFTOUT(v, mask) Extract and return the bitfield selected by mask from v, right-shifting the bits so that the rightmost selected bit is at bit 0. No side-effects. __SHIFTOUT_MASK(mask) Right-shift the bits in mask so that the rightmost non-zero bit is at bit 0. This is useful for finding the greatest unsigned value that a bitfield can hold. No side-effects. Note that __SHIFTOUT_MASK(m) = __SHIFTOUT(m, m). EXAMPLES
The following example demonstrates basic usage of the bits macros: uint32_t bits, mask, val; bits = __BITS(2, 3); /* 00001100 */ mask = __BIT(2) | __BIT(3); /* 00001100 */ val = __SHIFTIN(0x03, mask); /* 00001100 */ val = __SHIFTOUT(0xf, mask); /* 00000011 */ SEE ALSO
bitops(3), cdefs(3) HISTORY
The bits macros first appeared in atw(4), with different names and implementation. In their current form these macros appeared in NetBSD 4.0. AUTHORS
The bits macros were written by David Young <>. Matt Thomas <> suggested important improvements to the implementation, and contributed the macro names SHIFTIN() and SHIFTOUT(). BUGS
__BIT() and __BITS() can only express 32-bit bitmasks. BSD
October 17, 2012 BSD

Check Out this Related Man Page


glStencilMaskSeparate - control the front and/or back writing of individual bits in the stencil planes C SPECIFICATION
void glStencilMaskSeparate(GLenum face, GLuint mask); PARAMETERS
face Specifies whether the front and/or back stencil writemask is updated. Three symbolic constants are valid: GL_FRONT, GL_BACK, and GL_FRONT_AND_BACK. mask Specifies a bit mask to enable and disable writing of individual bits in the stencil planes. Initially, the mask is all 1's. DESCRIPTION
glStencilMaskSeparate controls the writing of individual bits in the stencil planes. The least significant n bits of mask, where n is the number of bits in the stencil buffer, specify a mask. Where a 1 appears in the mask, it's possible to write to the corresponding bit in the stencil buffer. Where a 0 appears, the corresponding bit is write-protected. Initially, all bits are enabled for writing. There can be two separate mask writemasks; one affects back-facing polygons, and the other affects front-facing polygons as well as other non-polygon primitives. glStencilMask() sets both front and back stencil writemasks to the same values, as if glStencilMaskSeparate() were called with face set to GL_FRONT_AND_BACK. ERRORS
GL_INVALID_ENUM is generated if face is not one of the accepted tokens. ASSOCIATED GETS
glColorMask(), glDepthMask(), glStencilFunc(), glStencilFuncSeparate(), glStencilMask(), glStencilOp(), glStencilOpSeparate() COPYRIGHT
Copyright (C) 2006 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. OpenGL 3.3 03/08/2011 GLSTENCILMASKSEPARAT(3G)
Man Page