83 lines
1.7 KiB
C
83 lines
1.7 KiB
C
#ifndef _HIP_H_
|
|
#define _HIP_H_
|
|
|
|
#include <ucontext.h>
|
|
|
|
typedef unsigned char hip_uint8_t;
|
|
typedef unsigned short hip_uint16_t;
|
|
typedef unsigned int hip_uint32_t;
|
|
typedef unsigned long long hip_uint64_t;
|
|
|
|
typedef signed char hip_int8_t;
|
|
typedef signed short hip_int16_t;
|
|
typedef signed int hip_int32_t;
|
|
typedef signed long long hip_int64_t;
|
|
|
|
|
|
typedef hip_uint64_t hip_nsecdur_t;
|
|
|
|
#if defined(__ILP32__) || defined(_WIN32)
|
|
# define MKCTX_NARGS 1
|
|
typedef hip_uint32_t hip_oow_t;
|
|
typedef hip_int32_t hip_ooi_t;
|
|
#else
|
|
# define MKCTX_NARGS 2
|
|
typedef hip_uint64_t hip_oow_t;
|
|
typedef hip_int64_t hip_ooi_t;
|
|
#endif
|
|
|
|
#define HIP_NULL ((void*)0)
|
|
#define HIP_INVALID_FD (-1)
|
|
|
|
typedef struct hip_t hip_t;
|
|
typedef struct hip_uctx_t hip_uctx_t;
|
|
typedef struct hip_uctx_link_t hip_uctx_link_t;
|
|
typedef void (*hip_ufun_t) (hip_uctx_t* uc, void* ctx);
|
|
|
|
enum hip_io_flag_t
|
|
{
|
|
HIP_IO_READ = (1 << 0),
|
|
HIP_IO_WRITE = (1 << 1)
|
|
};
|
|
typedef enum hip_io_flag_t hip_io_flag_t;
|
|
|
|
struct hip_uctx_link_t
|
|
{
|
|
hip_uctx_link_t* next;
|
|
hip_uctx_link_t* prev;
|
|
};
|
|
|
|
#define HIP_OFFSETOF(type, field) ((hip_oow_t)&(((type*)0)->field))
|
|
#define HIP_CONTAINEROF(ptr, type, field) ((type*)((hip_uint8_t*)ptr - HIP_OFFSETOF(type, field)))
|
|
|
|
enum hip_flag_t
|
|
{
|
|
HIP_FLAG_LAZY = (1 << 0)
|
|
};
|
|
typedef enum hip_flag_t hip_flag_t;
|
|
|
|
enum hip_rtn_flag_t
|
|
{
|
|
HIP_RTN_FLAG_AUTO_DESTROY = (1 << 0)
|
|
};
|
|
typedef enum hip_rtn_flag_t hip_rtn_flag_t;
|
|
|
|
#if defined(__cplusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
hip_t* hip_open(int flags);
|
|
void hip_close(hip_t* hip);
|
|
|
|
hip_uctx_t* hip_newrtn(hip_t* hip, int flags, hip_ufun_t uf, void* ctx);
|
|
|
|
|
|
hip_uctx_t* hip_uctx_open(hip_t* hip, hip_oow_t stack_size, int flags, hip_ufun_t uf, void* ctx);
|
|
void hip_uctx_close(hip_uctx_t* uctx);
|
|
|
|
#if defined(__cplusplus)
|
|
}
|
|
#endif
|
|
|
|
#endif
|