gwion-util
utilities for the Gwion project
Loading...
Searching...
No Matches
Macros | Typedefs | Functions
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)   (String)
 
#define container_of(ptr, type, member)    ((type *)((char *)(ptr)-offsetof(type, member)))
 
#define ANN   __attribute__((nonnull))
 
#define ANN2(...)   __attribute__((nonnull(__VA_ARGS__)))
 
#define ANEW   __attribute__((malloc))
 
#define NUSED   __attribute__((unused))
 
#define LOOP_OPTIM
 
#define likely(x)   __builtin_expect(!!(x), 1)
 
#define unlikely(x)   __builtin_expect(!!(x), 0)
 
#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)    (String)

Definition at line 13 of file defs.h.

◆ ANEW

#define ANEW   __attribute__((malloc))

Definition at line 22 of file defs.h.

◆ ANN

#define ANN   __attribute__((nonnull))

Definition at line 19 of file defs.h.

◆ ANN2

#define ANN2 ( ...)    __attribute__((nonnull(__VA_ARGS__)))

Definition at line 20 of file defs.h.

◆ CHECK_B

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

Definition at line 41 of file defs.h.

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

◆ CHECK_O

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

Definition at line 45 of file defs.h.

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

◆ container_of

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

Definition at line 16 of file defs.h.

16#define container_of(ptr, type, member) \
17 ((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 50 of file defs.h.

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

◆ DECL_O

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

Definition at line 53 of file defs.h.

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

◆ likely

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

Definition at line 38 of file defs.h.

◆ LOOP_OPTIM

#define LOOP_OPTIM

Definition at line 34 of file defs.h.

◆ NUSED

#define NUSED   __attribute__((unused))

Definition at line 23 of file defs.h.

◆ unlikely

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

Definition at line 39 of file defs.h.

Typedef Documentation

◆ uint

typedef unsigned int uint

Definition at line 63 of file defs.h.

Function Documentation

◆ num_digit()

static m_uint num_digit ( const m_uint i)
inlinestatic

Definition at line 65 of file defs.h.

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

◆ round2szint()

static m_uint round2szint ( const m_uint i)
inlinestatic

Definition at line 69 of file defs.h.

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