Lely core libraries  2.3.4
endian.c File Reference

This file is part of the utilities library; it contains the implementation of the byte order functions. More...

#include "util.h"
#include <lely/util/endian.h>
#include <assert.h>
Include dependency graph for endian.c:

Go to the source code of this file.

Functions

void bcpybe (uint_least8_t *dst, int dstbit, const uint_least8_t *src, int srcbit, size_t n)
 Copies n bits from a source to a destination buffer. More...
 
void bcpyle (uint_least8_t *dst, int dstbit, const uint_least8_t *src, int srcbit, size_t n)
 Copies n bits from a source to a destination buffer. More...
 

Detailed Description

This file is part of the utilities library; it contains the implementation of the byte order functions.

See also
lely/util/endian.h
Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com
M. W. Hessel mhess.nosp@m.el@l.nosp@m.ely.c.nosp@m.om

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 endian.c.

Function Documentation

◆ bcpybe()

void bcpybe ( uint_least8_t *  dst,
int  dstbit,
const uint_least8_t *  src,
int  srcbit,
size_t  n 
)

Copies n bits from a source to a destination buffer.

The buffers MUST NOT overlap. This function assumes a big-endian bit ordering (i.e., bit 0 is the most significant bit). On platforms where CHAR_BIT != 8, only the 8 least significant bits of each byte are copied.

Parameters
dsta pointer to the destination buffer.
dstbitthe destination offset (in bits) with respect to dst.
srca pointer to the source buffer.
srcbitthe source offset (in bits) with respect to src.
nthe number of bits to copy.

Definition at line 39 of file endian.c.

◆ bcpyle()

void bcpyle ( uint_least8_t *  dst,
int  dstbit,
const uint_least8_t *  src,
int  srcbit,
size_t  n 
)

Copies n bits from a source to a destination buffer.

The buffers MUST NOT overlap. This function assumes a little-endian bit ordering (i.e., bit 0 is the least significant bit). On platforms where CHAR_BIT != 8, only the 8 least significant bits of each byte are copied.

Parameters
dsta pointer to the destination buffer.
dstbitthe destination offset (in bits) with respect to dst.
srca pointer to the source buffer.
srcbitthe source offset (in bits) with respect to src.
nthe number of bits to copy.

Definition at line 123 of file endian.c.