shithub: dav1d

ref: c3c49fcd05049a0f89f84ed1a8ce3c7267ef8a8f
dir: /src/plan9/plan9.h/

View raw version
#ifndef __plan9_h__
#define __plan9_h__

#define DAV1D_VERSION "no."
#define DAV1D_API_VERSION_MAJOR 9
#define DAV1D_API_VERSION_MINOR 9
#define DAV1D_API_VERSION_PATCH 9

#include <u.h>
#include <libc.h>
#include </sys/include/stdio.h>
#include </sys/include/thread.h>

#define EINVAL -15
#define ENOMEM -16
#define ENOPROTOOPT -17
#define ERANGE -18
#define EAGAIN -19
#define EIO -20

typedef s8int int8_t;
typedef u8int uint8_t;
typedef s16int int16_t;
typedef u16int uint16_t;
typedef s32int int32_t;
typedef u32int uint32_t;
typedef vlong int64_t;
typedef uvlong uint64_t;
typedef uvlong size_t;
typedef vlong ptrdiff_t;
typedef vlong intptr_t;
typedef uintptr uintptr_t;
typedef long atomic_int;
typedef long atomic_uint;

#define __func__ "no."
#define __attribute__(a)

#define UINT_MAX 0xffffffffU
#define INT_MAX 0x7fffffff
#define INT_MIN (-INT_MAX-1)
#define INT16_MIN ((int16_t)0x8000)
#define INT16_MAX 0x7fff
#define INT64_MIN ((int64_t)0x8000000000000000ULL)
#define SHRT_MAX 0x7fff
#define SHRT_MIN (-SHRT_MAX-1)
#define PRIu64 "zu"

#define memory_order_acquire 0
#define memory_order_relaxed 1
#define atomic_init(p,v) do { *(p) = (v); } while(0)
#define atomic_store(p,v) do { *(p) = (v); } while(0)
#define atomic_load(p) *(p)
#define atomic_load_explicit(p,o) *(p)
#define atomic_fetch_add(i, v) (ainc(i)-1) /* let's hope v is always 1 */
#define atomic_fetch_sub(i, v) (adec(i)+1) /* let's hope v is always 1 */

int __builtin_ctz(unsigned int x);
int __builtin_clz(unsigned int x);
int __builtin_clzll(unsigned long long x);

#define _aligned_malloc(sz, align) mallocalign(sz, align, 0, 0)
#define _aligned_free(p) free(p)

#define llabs(a) ((a)<0?-(a):(a))

#endif