Lely core libraries  2.3.4
bits.h File Reference

This header file is part of the utilities library; it contains the bit function definitions. More...

#include <lely/features.h>
#include <stdint.h>
Include dependency graph for bits.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint_least16_t bswap16 (uint_least16_t x)
 Reverses the byte order of the 16-bit unsigned integer x. More...
 
uint_least32_t bswap32 (uint_least32_t x)
 Reverses the byte order of the 32-bit unsigned integer x. More...
 
uint_least64_t bswap64 (uint_least64_t x)
 Reverses the byte order of the 64-bit unsigned integer x. More...
 
int cls8 (uint_least8_t x)
 Counts the number of leading set bits in the unsigned 8-bit integer x.
 
int clz8 (uint_least8_t x)
 Counts the number of leading zero bits in the unsigned 8-bit integer x.
 
int cls16 (uint_least16_t x)
 Counts the number of leading set bits in the unsigned 16-bit integer x.
 
int clz16 (uint_least16_t x)
 Counts the number of leading zero bits in the unsigned 16-bit integer x.
 
int cls32 (uint_least32_t x)
 Counts the number of leading set bits in the unsigned 32-bit integer x.
 
int clz32 (uint_least32_t x)
 Counts the number of leading zero bits in the unsigned 32-bit integer x.
 
int cls64 (uint_least64_t x)
 Counts the number of leading set bits in the unsigned 64-bit integer x.
 
int clz64 (uint_least64_t x)
 Counts the number of leading zero bits in the unsigned 64-bit integer x.
 
int cts8 (uint_least8_t x)
 Counts the number of trailing set bits in the unsigned 8-bit integer x.
 
int ctz8 (uint_least8_t x)
 Counts the number of trailing zero bits in the unsigned 8-bit integer x.
 
int cts16 (uint_least16_t x)
 Counts the number of trailing set bits in the unsigned 16-bit integer x.
 
int ctz16 (uint_least16_t x)
 Counts the number of trailing zero bits in the unsigned 16-bit integer x.
 
int cts32 (uint_least32_t x)
 Counts the number of trailing set bits in the unsigned 32-bit integer x.
 
int ctz32 (uint_least32_t x)
 Counts the number of trailing zero bits in the unsigned 32-bit integer x.
 
int cts64 (uint_least64_t x)
 Counts the number of trailing set bits in the unsigned 64-bit integer x.
 
int ctz64 (uint_least64_t x)
 Counts the number of trailing zero bits in the unsigned 64-bit integer x.
 
int ffs8 (uint_least8_t x)
 Returns the index (starting from one) of the first set bit in the unsigned 8-bit integer x, or 0 if all bits are zero.
 
int ffz8 (uint_least8_t x)
 Returns the index (starting from one) of the first zero bit in the unsigned 8-bit integer x, or 0 if all bits are set.
 
int ffs16 (uint_least16_t x)
 Returns the index (starting from one) of the first set bit in the unsigned 16-bit integer x, or 0 if all bits are zero.
 
int ffz16 (uint_least16_t x)
 Returns the index (starting from one) of the first zero bit in the unsigned 16-bit integer x, or 0 if all bits are set.
 
int ffs32 (uint_least32_t x)
 Returns the index (starting from one) of the first set bit in the unsigned 32-bit integer x, or 0 if all bits are zero.
 
int ffz32 (uint_least32_t x)
 Returns the index (starting from one) of the first zero bit in the unsigned 32-bit integer x, or 0 if all bits are set.
 
int ffs64 (uint_least64_t x)
 Returns the index (starting from one) of the first set bit in the unsigned 64-bit integer x, or 0 if all bits are zero.
 
int ffz64 (uint_least64_t x)
 Returns the index (starting from one) of the first zero bit in the unsigned 64-bit integer x, or 0 if all bits are set.
 
int parity8 (uint_least8_t x)
 Returns the parity of the unsigned 8-bit integer x.
 
int parity16 (uint_least16_t x)
 Returns the parity of the unsigned 16-bit integer x.
 
int parity32 (uint_least32_t x)
 Returns the parity of the unsigned 32-bit integer x.
 
int parity64 (uint_least64_t x)
 Returns the parity of the unsigned 64-bit integer x.
 
int popcount8 (uint_least8_t x)
 Returns the population count (the number of set bits) in the unsigned 8-bit integer x.
 
int popcount16 (uint_least16_t x)
 Returns the population count (the number of set bits) in the unsigned 16-bit integer x.
 
int popcount32 (uint_least32_t x)
 Returns the population count (the number of set bits) in the unsigned 32-bit integer x.
 
int popcount64 (uint_least64_t x)
 Returns the population count (the number of set bits) in the unsigned 64-bit integer x.
 
uint_least8_t rol8 (uint_least8_t x, unsigned int n)
 Rotates the 8-bit unsigned integer x left by n bits.
 
uint_least8_t ror8 (uint_least8_t x, unsigned int n)
 Rotates the 8-bit unsigned integer x right by n bits.
 
uint_least16_t rol16 (uint_least16_t x, unsigned int n)
 Rotates the 16-bit unsigned integer x left by n bits.
 
uint_least16_t ror16 (uint_least16_t x, unsigned int n)
 Rotates the 16-bit unsigned integer x right by n bits.
 
uint_least32_t rol32 (uint_least32_t x, unsigned int n)
 Rotates the 32-bit unsigned integer x left by n bits.
 
uint_least32_t ror32 (uint_least32_t x, unsigned int n)
 Rotates the 32-bit unsigned integer x right by n bits.
 
uint_least64_t rol64 (uint_least64_t x, unsigned int n)
 Rotates the 64-bit unsigned integer x left by n bits.
 
uint_least64_t ror64 (uint_least64_t x, unsigned int n)
 Rotates the 64-bit unsigned integer x right by n bits.
 

Detailed Description

This header file is part of the utilities library; it contains the bit function definitions.

Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file bits.h.

Function Documentation

◆ bswap16()

uint_least16_t bswap16 ( uint_least16_t  x)
inline

Reverses the byte order of the 16-bit unsigned integer x.

This function assumes 8-bit bytes.

Definition at line 283 of file bits.h.

◆ bswap32()

uint_least32_t bswap32 ( uint_least32_t  x)
inline

Reverses the byte order of the 32-bit unsigned integer x.

This function assumes 8-bit bytes.

Definition at line 295 of file bits.h.

◆ bswap64()

uint_least64_t bswap64 ( uint_least64_t  x)
inline

Reverses the byte order of the 64-bit unsigned integer x.

This function assumes 8-bit bytes.

Definition at line 308 of file bits.h.