00001 #pragma once
00002 #ifndef _SEXP_TYPES_H
00003 #define _SEXP_TYPES_H
00004
00005 #include <stddef.h>
00006 #include <stdint.h>
00007 #include <stdbool.h>
00008 #include "public/sexp-types.h"
00009 #include "_sexp-datatype.h"
00010
00011
00012 #if !defined(NDEBUG) || defined(VALIDATE_SEXP)
00013 # define SEXP_MAGIC0 0xf3f3
00014 # define SEXP_MAGIC0_INV 0xffff
00015 # define SEXP_MAGIC1 0x6767
00016 # define SEXP_MAGIC1_INV 0x0000
00017 #endif
00018
00019 struct SEXP {
00020 #if !defined(NDEBUG) || defined(VALIDATE_SEXP)
00021 volatile uint16_t __magic0;
00022 #endif
00023
00024 SEXP_datatype_t *s_type;
00025 uintptr_t s_valp;
00026 uint8_t s_flgs;
00027
00028 #if !defined(NDEBUG) || defined(VALIDATE_SEXP)
00029 volatile uint16_t __magic1;
00030 #endif
00031 };
00032
00033 #define SEXP_FLAG_SREF 0x01
00034 #define SEXP_FLAG_INVAL 0x02
00035 #define SEXP_FLAG_UNFIN 0x04
00036
00037 static inline void SEXP_flag_set (SEXP_t *s_exp, uint8_t flag)
00038 {
00039 s_exp->s_flgs |= flag;
00040 }
00041
00042 static inline void SEXP_flag_unset (SEXP_t *s_exp, uint8_t flag)
00043 {
00044 s_exp->s_flgs &= ~flag;
00045 }
00046
00047 static inline bool SEXP_flag_isset (SEXP_t *s_exp, uint8_t flag)
00048 {
00049 return ((s_exp->s_flgs & flag) == flag);
00050 }
00051
00052 #endif