#ifndef _RC_H #define _RC_H #ifdef __cplusplus #define _rc_restrict __restrict extern "C" { #else #define _rc_restrict restrict #endif #include #ifndef __GNUC__ #define _rc_attr(_) #else #define _rc_attr(v) __attribute__(v) #endif #define _rc_alloc_fn _rc_attr((returns_nonnull, malloc)) #define _rc_gmut_fn _rc_attr((nonnull)) #define _rc_mut_fn _rc_attr((pure, nonnull)) #define _rc_fn _rc_attr((const, nonnull)) #if __bool_true_false_are_defined #define RC_TRUE true #define RC_FALSE false typedef bool rc_bool; #else #define RC_TRUE 1 #define RC_FALSE 0 typedef int rc_bool; #endif typedef struct rc* rc_t; typedef struct rc_weak rc_weak_t; typedef void* _rc_attr((may_alias)) rc_ptr_t; typedef const void* _rc_attr((may_alias)) rc_const_ptr_t; void* _rc_restrict rc_malloc(size_t sz) _rc_attr((malloc, alloc_size(1), returns_nonnull)); void rc_free(rc_ptr_t ptr) _rc_gmut_fn; rc_ptr_t rc_clone(rc_const_ptr_t ptr) _rc_mut_fn _rc_attr((returns_nonnull)); size_t rc_refs(rc_const_ptr_t ptr)_rc_fn; rc_bool rc_is_valid(rc_const_ptr_t ptr) _rc_fn; rc_weak_t* _rc_restrict rc_create_weak(rc_const_ptr_t ptr) _rc_gmut_fn _rc_alloc_fn; void rc_weak_free(rc_weak_t* _rc_restrict ptr) _rc_gmut_fn; #ifdef __cplusplus } #endif #endif /* _RC_H */