gwion-util
utilities for the Gwion project
Loading...
Searching...
No Matches
defs.h File Reference

base definitions More...

#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include "gwcommon.h"

Go to the source code of this file.

Macros

#define _(String)
 
#define container_of(ptr, type, member)
 
#define ANN   __attribute__((nonnull))
 
#define ANN2(...)
 
#define ANEW   __attribute__((malloc))
 
#define NUSED   __attribute__((unused))
 
#define LOOP_OPTIM
 
#define likely(x)
 
#define unlikely(x)
 
#define CHECK_B(f)
 
#define CHECK_O(f)
 
#define DECL_B(decl, f, exp)
 
#define DECL_O(decl, f, exp)
 

Typedefs

typedef unsigned int uint
 

Functions

static m_uint num_digit (const m_uint i)
 
static m_uint round2szint (const m_uint i)
 

Detailed Description

base definitions

Definition in file defs.h.

Macro Definition Documentation

◆ _

#define _ ( String)
Value:
(String)

Definition at line 12 of file defs.h.

◆ ANEW

#define ANEW   __attribute__((malloc))

Definition at line 21 of file defs.h.

◆ ANN

#define ANN   __attribute__((nonnull))

Definition at line 18 of file defs.h.

◆ ANN2

#define ANN2 ( ...)
Value:
__attribute__((nonnull(__VA_ARGS__)))
__attribute__((hot, pure))
Definition hash.c:20

Definition at line 19 of file defs.h.

◆ CHECK_B

#define CHECK_B ( f)
Value:
do { \
if (!f) return false; \
} while (0)

Definition at line 40 of file defs.h.

40#define CHECK_B(f) \
41 do { \
42 if (!f) return false; \
43 } while (0)

◆ CHECK_O

#define CHECK_O ( f)
Value:
do { \
if (!f) return NULL; \
} while (0)

Definition at line 44 of file defs.h.

44#define CHECK_O(f) \
45 do { \
46 if (!f) return NULL; \
47 } while (0)

◆ container_of

#define container_of ( ptr,
type,
member )
Value:
((type *)((char *)(ptr)-offsetof(type, member)))

Definition at line 15 of file defs.h.

15#define container_of(ptr, type, member) \
16 ((type *)((char *)(ptr)-offsetof(type, member)))

◆ DECL_B

#define DECL_B ( decl,
f,
exp )
Value:
decl f exp; \
if (!f) return false

Definition at line 49 of file defs.h.

49#define DECL_B(decl, f, exp) \
50 decl f exp; \
51 if (!f) return false

◆ DECL_O

#define DECL_O ( decl,
f,
exp )
Value:
decl f exp; \
if (!f) return NULL

Definition at line 52 of file defs.h.

52#define DECL_O(decl, f, exp) \
53 decl f exp; \
54 if (!f) return NULL

◆ likely

#define likely ( x)
Value:
__builtin_expect(!!(x), 1)

Definition at line 37 of file defs.h.

◆ LOOP_OPTIM

#define LOOP_OPTIM

Definition at line 33 of file defs.h.

◆ NUSED

#define NUSED   __attribute__((unused))

Definition at line 22 of file defs.h.

◆ unlikely

#define unlikely ( x)
Value:
__builtin_expect(!!(x), 0)

Definition at line 38 of file defs.h.

Typedef Documentation

◆ uint

typedef unsigned int uint

Definition at line 62 of file defs.h.

Function Documentation

◆ num_digit()

static m_uint num_digit ( const m_uint i)
inlinestatic

Definition at line 64 of file defs.h.

64 {
65 return i ? (m_uint)floor(log10((float)i) + 1) : 1;
66}
uintptr_t m_uint
Definition gwcommon.h:12

◆ round2szint()

static m_uint round2szint ( const m_uint i)
inlinestatic

Definition at line 68 of file defs.h.

68 {
69 return ((i + (SZ_INT - 1)) & ~(SZ_INT - 1));
70}
#define SZ_INT
Definition gwcommon.h:19