Reduct  v4.0.5-1-g4851deb
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_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_LIB_ENTRY   "reduct_module_init"
 The name of the entry symbol for a Reduct module.
 
#define REDUCT_INPUT_ID_NONE   ((reduct_input_id_t) - 1)
 Invalid handle value.
 
#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.
 
typedef reduct_handle_t(* reduct_module_init_fn) (struct reduct *reduct)
 Module initialization function type.
 
typedef uint16_t reduct_input_id_t
 Identifies a reduct_input_t within a Reduct structure.
 

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_UNUSED

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

Definition at line 67 of file defs.h.

◆ REDUCT_PI

#define REDUCT_PI   3.14159265358979323846

PI constant.

Definition at line 72 of file defs.h.

◆ REDUCT_E

#define REDUCT_E   2.7182818284590452354

E constant.

Definition at line 77 of file defs.h.

◆ REDUCT_INF

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

INFINITY constant.

Definition at line 82 of file defs.h.

◆ REDUCT_NAN

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

NAN constant.

Definition at line 92 of file defs.h.

◆ REDUCT_PATH_MAX

#define REDUCT_PATH_MAX   1024

Maximum path length for Reduct.

Definition at line 102 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 113 of file defs.h.

◆ REDUCT_LIB_ENTRY

#define REDUCT_LIB_ENTRY   "reduct_module_init"

The name of the entry symbol for a Reduct module.

Definition at line 139 of file defs.h.

◆ REDUCT_INPUT_ID_NONE

#define REDUCT_INPUT_ID_NONE   ((reduct_input_id_t) - 1)

Invalid handle value.

Definition at line 152 of file defs.h.

◆ REDUCT_ALIGNMENT

#define REDUCT_ALIGNMENT   64

The memory alignment for items.

Definition at line 154 of file defs.h.

◆ REDUCT_ROUND_UP

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

Definition at line 156 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.

Definition at line 126 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 126 of file defs.h.

◆ reduct_module_init_fn

typedef reduct_handle_t(* reduct_module_init_fn) (struct reduct *reduct)

Module initialization function type.

Definition at line 137 of file defs.h.

◆ reduct_input_id_t

typedef uint16_t reduct_input_id_t

Identifies a reduct_input_t within a Reduct structure.

Avoid the need to store a reduct_input_t* within a reduct_item_t saving space.

Definition at line 147 of file defs.h.