ObjFW
|
#include "objfw-defs.h"
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "platform.h"
Go to the source code of this file.
Macros | |
#define | OFByteSwap16(i) (__builtin_constant_p(i) ? _OFByteSwap16Const(i) : _OFByteSwap16NonConst(i)) |
Byte swaps the specified 16 bit integer. | |
#define | OFByteSwap32(i) (__builtin_constant_p(i) ? _OFByteSwap32Const(i) : _OFByteSwap32NonConst(i)) |
Byte swaps the specified 32 bit integer. | |
#define | OFByteSwap64(i) (__builtin_constant_p(i) ? _OFByteSwap64Const(i) : _OFByteSwap64NonConst(i)) |
Byte swaps the specified 64 bit integer. | |
#define | OFFromBigEndian16(i) (i) |
Converts the specified 16 bit integer from big endian to native endian. | |
#define | OFFromBigEndian32(i) (i) |
Converts the specified 32 bit integer from big endian to native endian. | |
#define | OFFromBigEndian64(i) (i) |
Converts the specified 64 bit integer from big endian to native endian. | |
#define | OFFromLittleEndian16(i) OFByteSwap16(i) |
Converts the specified 16 bit integer from little endian to native endian. | |
#define | OFFromLittleEndian32(i) OFByteSwap32(i) |
Converts the specified 32 bit integer from little endian to native endian. | |
#define | OFFromLittleEndian64(i) OFByteSwap64(i) |
Converts the specified 64 bit integer from little endian to native endian. | |
#define | OFToBigEndian16(i) (i) |
Converts the specified 16 bit integer from native endian to big endian. | |
#define | OFToBigEndian32(i) (i) |
Converts the specified 32 bit integer from native endian to big endian. | |
#define | OFToBigEndian64(i) (i) |
Converts the specified 64 bit integer from native endian to big endian. | |
#define | OFToLittleEndian16(i) OFByteSwap16(i) |
Converts the specified 16 bit integer from native endian to little endian. | |
#define | OFToLittleEndian32(i) OFByteSwap32(i) |
Converts the specified 32 bit integer from native endian to little endian. | |
#define | OFToLittleEndian64(i) OFByteSwap64(i) |
Converts the specified 64 bit integer from native endian to little endian. | |
#define | OFFromBigEndianFloat(f) (f) |
Converts the specified float from big endian to native endian. | |
#define | OFFromBigEndianDouble(d) (d) |
Converts the specified double from big endian to native endian. | |
#define | OFFromLittleEndianFloat(f) OFByteSwapFloat(f) |
Converts the specified float from little endian to native endian. | |
#define | OFFromLittleEndianDouble(d) OFByteSwapDouble(d) |
Converts the specified double from little endian to native endian. | |
#define | OFToBigEndianFloat(f) (f) |
Converts the specified float from native endian to big endian. | |
#define | OFToBigEndianDouble(d) (d) |
Converts the specified double from native endian to big endian. | |
#define | OFToLittleEndianFloat(f) OFByteSwapFloat(f) |
Converts the specified float from native endian to little endian. | |
#define | OFToLittleEndianDouble(d) OFByteSwapDouble(d) |
Converts the specified double from native endian to little endian. | |
#define | OFRotateLeft(value, bits) |
Rotates the specified value left by the specified amount of bits. | |
#define | OFRotateRight(value, bits) |
Rotates the specified value right by the specified amount of bits. | |
#define | OFRoundUpToPowerOf2(pow2, value) (((value) + (pow2) - 1) & ~((pow2) - 1)) |
Rounds up the specified value to the specified power of two. | |
Functions | |
static OF_INLINE uint32_t OF_CONST_FUNC | OFBitConvertFloatToUInt32 (float f) |
Bit-converts the specified float to a uint32_t. | |
static OF_INLINE float OF_CONST_FUNC | OFBitConvertUInt32ToFloat (uint32_t uInt32) |
Bit-converts the specified uint32_t to a float. | |
static OF_INLINE uint64_t OF_CONST_FUNC | OFBitConvertDoubleToUInt64 (double d) |
Bit-converts the specified double to a uint64_t. | |
static OF_INLINE double OF_CONST_FUNC | OFBitConvertUInt64ToDouble (uint64_t uInt64) |
Bit-converts the specified uint64_t to a double. | |
static OF_INLINE float OF_CONST_FUNC | OFByteSwapFloat (float f) |
Byte swaps the specified float. | |
static OF_INLINE double OF_CONST_FUNC | OFByteSwapDouble (double d) |
Byte swaps the specified double. | |
#define OFByteSwap16 | ( | i | ) | (__builtin_constant_p(i) ? _OFByteSwap16Const(i) : _OFByteSwap16NonConst(i)) |
Byte swaps the specified 16 bit integer.
i | The integer to byte swap |
#define OFByteSwap32 | ( | i | ) | (__builtin_constant_p(i) ? _OFByteSwap32Const(i) : _OFByteSwap32NonConst(i)) |
Byte swaps the specified 32 bit integer.
i | The integer to byte swap |
#define OFByteSwap64 | ( | i | ) | (__builtin_constant_p(i) ? _OFByteSwap64Const(i) : _OFByteSwap64NonConst(i)) |
Byte swaps the specified 64 bit integer.
i | The integer to byte swap |
#define OFFromBigEndian16 | ( | i | ) | (i) |
Converts the specified 16 bit integer from big endian to native endian.
i | The 16 bit integer to convert |
#define OFFromBigEndian32 | ( | i | ) | (i) |
Converts the specified 32 bit integer from big endian to native endian.
i | The 32 bit integer to convert |
#define OFFromBigEndian64 | ( | i | ) | (i) |
Converts the specified 64 bit integer from big endian to native endian.
i | The 64 bit integer to convert |
#define OFFromBigEndianDouble | ( | d | ) | (d) |
Converts the specified double from big endian to native endian.
d | The double to convert |
#define OFFromBigEndianFloat | ( | f | ) | (f) |
Converts the specified float from big endian to native endian.
f | The float to convert |
#define OFFromLittleEndian16 | ( | i | ) | OFByteSwap16(i) |
Converts the specified 16 bit integer from little endian to native endian.
i | The 16 bit integer to convert |
#define OFFromLittleEndian32 | ( | i | ) | OFByteSwap32(i) |
Converts the specified 32 bit integer from little endian to native endian.
i | The 32 bit integer to convert |
#define OFFromLittleEndian64 | ( | i | ) | OFByteSwap64(i) |
Converts the specified 64 bit integer from little endian to native endian.
i | The 64 bit integer to convert |
#define OFFromLittleEndianDouble | ( | d | ) | OFByteSwapDouble(d) |
Converts the specified double from little endian to native endian.
d | The double to convert |
#define OFFromLittleEndianFloat | ( | f | ) | OFByteSwapFloat(f) |
Converts the specified float from little endian to native endian.
f | The float to convert |
#define OFRotateLeft | ( | value, | |
bits ) |
Rotates the specified value left by the specified amount of bits.
value | The value to rotate |
bits | The number of bits to rotate left the value by |
#define OFRotateRight | ( | value, | |
bits ) |
Rotates the specified value right by the specified amount of bits.
value | The value to rotate |
bits | The number of bits to rotate right the value by |
#define OFRoundUpToPowerOf2 | ( | pow2, | |
value ) (((value) + (pow2) - 1) & ~((pow2) - 1)) |
Rounds up the specified value to the specified power of two.
pow2 | The power of 2 to round up to |
value | The value to round up to the specified power of two |
#define OFToBigEndian16 | ( | i | ) | (i) |
Converts the specified 16 bit integer from native endian to big endian.
i | The 16 bit integer to convert |
#define OFToBigEndian32 | ( | i | ) | (i) |
Converts the specified 32 bit integer from native endian to big endian.
i | The 32 bit integer to convert |
#define OFToBigEndian64 | ( | i | ) | (i) |
Converts the specified 64 bit integer from native endian to big endian.
i | The 64 bit integer to convert |
#define OFToBigEndianDouble | ( | d | ) | (d) |
Converts the specified double from native endian to big endian.
d | The double to convert |
#define OFToBigEndianFloat | ( | f | ) | (f) |
Converts the specified float from native endian to big endian.
f | The float to convert |
#define OFToLittleEndian16 | ( | i | ) | OFByteSwap16(i) |
Converts the specified 16 bit integer from native endian to little endian.
i | The 16 bit integer to convert |
#define OFToLittleEndian32 | ( | i | ) | OFByteSwap32(i) |
Converts the specified 32 bit integer from native endian to little endian.
i | The 32 bit integer to convert |
#define OFToLittleEndian64 | ( | i | ) | OFByteSwap64(i) |
Converts the specified 64 bit integer from native endian to little endian.
i | The 64 bit integer to convert |
#define OFToLittleEndianDouble | ( | d | ) | OFByteSwapDouble(d) |
Converts the specified double from native endian to little endian.
d | The double to convert |
#define OFToLittleEndianFloat | ( | f | ) | OFByteSwapFloat(f) |
Converts the specified float from native endian to little endian.
f | The float to convert |
|
static |
Bit-converts the specified double to a uint64_t.
d | The double to bit-convert |
|
static |
Bit-converts the specified float to a uint32_t.
f | The float to bit-convert |
|
static |
Bit-converts the specified uint32_t to a float.
uInt32 | The uint32_t to bit-convert |
|
static |
Bit-converts the specified uint64_t to a double.
uInt64 | The uint64_t to bit-convert |
|
static |
Byte swaps the specified double.
d | The double to byte swap |
|
static |
Byte swaps the specified float.
f | The float to byte swap |