Reduct  v4.2.1-1-g0b59ae3
A functional and immutable language.
Loading...
Searching...
No Matches
defs.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <dlfcn.h>
#include <unistd.h>
Include dependency graph for defs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  reduct_handle_t
 Handle type. More...
 

Macros

#define REDUCT_API
 
#define REDUCT_LIB_OPEN(_path)   dlopen(_path, RTLD_NOW | RTLD_GLOBAL)
 
#define REDUCT_LIB_CLOSE(_lib)   dlclose(_lib)
 
#define REDUCT_LIB_SYM(_lib, _name)   dlsym(_lib, _name)
 
#define REDUCT_LIB_ERROR()   dlerror()
 
#define REDUCT_LIKELY(_x)   (_x)
 
#define REDUCT_UNLIKELY(_x)   (_x)
 
#define REDUCT_NORETURN
 
#define REDUCT_ALWAYS_INLINE
 
#define REDUCT_MIN(_a, _b)   ((_a) < (_b) ? (_a) : (_b))
 
#define REDUCT_MAX(_a, _b)   ((_a) > (_b) ? (_a) : (_b))
 
#define REDUCT_CLAMP(_v, _min, _max)   (REDUCT_MAX(_min, REDUCT_MIN(_v, _max)))
 
#define REDUCT_LERP(_a, _b, _t)   ((_a) + ((_b) - (_a)) * (_t))
 
#define REDUCT_UNUSED(_x)   ((void)(_x))
 
#define REDUCT_PI   3.14159265358979323846
 PI constant.
 
#define REDUCT_E   2.7182818284590452354
 E constant.
 
#define REDUCT_INF
 INFINITY constant.
 
#define REDUCT_NAN
 NAN constant.
 
#define REDUCT_PATH_MAX   1024
 Maximum path length for Reduct.
 
#define REDUCT_CONTAINER_OF(_ptr, _type, _member)   ((_type*)((char*)(_ptr) - offsetof(_type, _member)))
 Container of macro.
 
#define REDUCT_ALIGNMENT   64
 The memory alignment for items.
 
#define REDUCT_ROUND_UP(_val, _align)   (((_val) + (_align) - 1) & ~((_align) - 1))
 

Typedefs

typedef void * reduct_lib_t
 
typedef reduct_handle_t(* reduct_native_fn) (struct reduct *reduct, size_t argc, reduct_handle_t *argv)
 Native function pointer type.
 
typedef struct reduct_rvsdg_origin *(* reduct_native_intrinsic_fn) (struct reduct_builder *builder, struct reduct_list *expr)
 Intrinsic handler function type.
 

Macro Definition Documentation

◆ REDUCT_API

#define REDUCT_API

Definition at line 24 of file defs.h.

◆ REDUCT_LIB_OPEN

#define REDUCT_LIB_OPEN (   _path)    dlopen(_path, RTLD_NOW | RTLD_GLOBAL)

Definition at line 39 of file defs.h.

◆ REDUCT_LIB_CLOSE

#define REDUCT_LIB_CLOSE (   _lib)    dlclose(_lib)

Definition at line 40 of file defs.h.

◆ REDUCT_LIB_SYM

#define REDUCT_LIB_SYM (   _lib,
  _name 
)    dlsym(_lib, _name)

Definition at line 41 of file defs.h.

◆ REDUCT_LIB_ERROR

#define REDUCT_LIB_ERROR ( )    dlerror()

Definition at line 42 of file defs.h.

◆ REDUCT_LIKELY

#define REDUCT_LIKELY (   _x)    (_x)

Definition at line 58 of file defs.h.

◆ REDUCT_UNLIKELY

#define REDUCT_UNLIKELY (   _x)    (_x)

Definition at line 59 of file defs.h.

◆ REDUCT_NORETURN

#define REDUCT_NORETURN

Definition at line 60 of file defs.h.

◆ REDUCT_ALWAYS_INLINE

#define REDUCT_ALWAYS_INLINE

Definition at line 61 of file defs.h.

◆ REDUCT_MIN

#define REDUCT_MIN (   _a,
  _b 
)    ((_a) < (_b) ? (_a) : (_b))

Definition at line 64 of file defs.h.

◆ REDUCT_MAX

#define REDUCT_MAX (   _a,
  _b 
)    ((_a) > (_b) ? (_a) : (_b))

Definition at line 65 of file defs.h.

◆ REDUCT_CLAMP

#define REDUCT_CLAMP (   _v,
  _min,
  _max 
)    (REDUCT_MAX(_min, REDUCT_MIN(_v, _max)))

Definition at line 66 of file defs.h.

◆ REDUCT_LERP

#define REDUCT_LERP (   _a,
  _b,
  _t 
)    ((_a) + ((_b) - (_a)) * (_t))

Definition at line 67 of file defs.h.

◆ REDUCT_UNUSED

#define REDUCT_UNUSED (   _x)    ((void)(_x))

Definition at line 69 of file defs.h.

◆ REDUCT_PI

#define REDUCT_PI   3.14159265358979323846

PI constant.

Definition at line 74 of file defs.h.

◆ REDUCT_E

#define REDUCT_E   2.7182818284590452354

E constant.

Definition at line 79 of file defs.h.

◆ REDUCT_INF

#define REDUCT_INF
Value:
(((union { \
uint64_t u; \
double f; \
}){0x7FF0000000000000ULL}) \
.f)

INFINITY constant.

Definition at line 84 of file defs.h.

◆ REDUCT_NAN

#define REDUCT_NAN
Value:
(((union { \
uint64_t u; \
double f; \
}){0x7FF8000000000000ULL}) \
.f)

NAN constant.

Definition at line 94 of file defs.h.

◆ REDUCT_PATH_MAX

#define REDUCT_PATH_MAX   1024

Maximum path length for Reduct.

Definition at line 104 of file defs.h.

◆ REDUCT_CONTAINER_OF

#define REDUCT_CONTAINER_OF (   _ptr,
  _type,
  _member 
)    ((_type*)((char*)(_ptr) - offsetof(_type, _member)))

Container of macro.

Used to get the pointer to a structure from a pointer to one of its members.

Parameters
_ptrThe pointer to the member.
_typeThe type of the structure.
_memberThe name of the member.

Definition at line 115 of file defs.h.

◆ REDUCT_ALIGNMENT

#define REDUCT_ALIGNMENT   64

The memory alignment for items.

Definition at line 139 of file defs.h.

◆ REDUCT_ROUND_UP

#define REDUCT_ROUND_UP (   _val,
  _align 
)    (((_val) + (_align) - 1) & ~((_align) - 1))

Definition at line 141 of file defs.h.

Typedef Documentation

◆ reduct_lib_t

typedef void* reduct_lib_t

Definition at line 38 of file defs.h.

◆ reduct_native_fn

typedef reduct_handle_t(* reduct_native_fn) (struct reduct *reduct, size_t argc, reduct_handle_t *argv)

Native function pointer type.

Warning
argv points into the evaluator's register array and is only valid for the duration of the call. Copy handles out before calling back into Reduct, as re-entrant calls may realloc the array.

Definition at line 131 of file defs.h.

◆ reduct_native_intrinsic_fn

typedef struct reduct_rvsdg_origin *( * reduct_native_intrinsic_fn) (struct reduct_builder *builder, struct reduct_list *expr)

Intrinsic handler function type.

Definition at line 131 of file defs.h.