/* * Pure Data Packet header file. Scalar type definitions. * Copyright (c) by Tom Schouten * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /** @file typedefs.h @brief C type definitions Typedefs for all objects used throughout the kernel. If a c-module only refers indirectly to an object, including this header is enough. */ #ifndef PF_TYPEDEFS_H #define PF_TYPEDEFS_H /* system headers */ #include // used by pf_stream_t typedef signed char s8; ///< signed 8 bit integer typedef signed short s16; ///< signed 16 bit integer typedef signed long s32; ///< signed 32 bit integer typedef signed long long s64; ///< signed 64 bit integer typedef unsigned char u8; ///< unsigned 8 bit integer typedef unsigned short u16; ///< unsigned 16 bit integer typedef unsigned long u32; ///< unsigned 32 bit integer typedef unsigned long long u64; ///< unsigned 64 bit integer // #ifndef __cplusplus // typedef int bool; // #define true 1; // #define false 0; // #endif /* symbol.h */ struct pf_symbol; typedef struct pf_symbol pf_symbol_t; ///< symbol type /* list.h */ struct pf_list; struct pf_atom; union pf_word; typedef int pf_word_type_t; ///< atom type type typedef struct pf_list pf_list_t; ///< list type (container of atoms) typedef struct pf_atom pf_atom_t; ///< atom type typedef union pf_word pf_word_t; ///< union representing all scalar types that can reside in an atom container /* stream.h */ struct pf_stream_base; struct pf_stream_file; struct pf_stream_process; struct pf_stream_string; struct pf_stream_interface; union pf_stream; typedef struct pf_stream_base pf_stream_base_t; ///< base stream type typedef struct pf_stream_file pf_stream_file_t; ///< file stream type typedef struct pf_stream_process pf_stream_process_t; ///< process stream type typedef struct pf_stream_string pf_stream_string_t; ///< string stream type typedef union pf_stream pf_stream_t; ///< stream union typedef struct pf_stream_interface pf_stream_interface_t; /// stream interface type typedef void (*pf_stream_close_t) (pf_stream_t *s); ///< stream close method typedef int (*pf_stream_fd_t) (pf_stream_t *s); ///< file descriptor getter //typedef void (*pf_stream_flush_t) (pf_stream_t *s); ///< stream close method typedef int (*pf_stream_get_char_t) (pf_stream_t *s, int *c); ///< stream read char method. return value is 'read' return value typedef int (*pf_stream_unget_char_t) (pf_stream_t *s, int c); ///< stream write char method typedef void (*pf_stream_puta_t) (pf_stream_t *s, pf_atom_t *a); ///< stream write atom method typedef pf_atom_t * (*pf_stream_geta_t) (pf_stream_t *s); ///< stream read atom method typedef int (*pf_stream_vprintf_t)(pf_stream_t *s, char *fmt, va_list ap); ///< stream print formatted output method typedef int (*pf_stream_io_t)(pf_stream_t *s, void *buf, int bytes); ///< stream raw read/write method typedef int (*pf_stream_remaining_t) (pf_stream_t *buf); ///< stream read char method typedef int (*pf_stream_transfer_t) (pf_stream_t *buf, pf_stream_t *out); ///< stream read char method /* forth.h */ typedef struct pf_list pf_stack_t; ///< stack object struct pf_vm; typedef struct pf_vm pf_vm_t; ///< forth virtual machine typedef int pf_error_t; ///< forth error code typedef void (*pf_forth_primitive_t)(pf_vm_t *vm); ///< forth primitive /* string.h */ struct pf_string; typedef struct pf_string pf_string_t; ///< string header /* packet.h */ struct pf_header; struct pf_class; typedef struct pf_header *pf_packet_t; ///< Packet typedef struct pf_header pf_header_t; ///< Packet header. typedef struct pf_class pf_class_t; ///< Packet class containing resource management methods for a packet type. typedef pf_packet_t (*pf_list_to_packet_t)(pf_list_t *); ///< Packet factory method. Returns invalid packet (-1) on error. typedef void (*pf_method_t)(pf_header_t *); ///< Raw packet method (operating on packet header, not reference) typedef void (*pf_method_packet_t)(pf_header_t *, pf_header_t *); ///< Raw packet method (operating on packet header, not reference) typedef pf_error_t (*pf_method_string_t)(pf_header_t *, pf_string_t *); ///< Stream poster (in case for "write" this needs to return e_unparse if serialize fails). typedef pf_symbol_t* (*pf_method_to_desc_t)(pf_header_t *); /* error.h */ struct pf_error_info; typedef struct pf_error_info pf_error_info_t; ///< forth vm error info struct /* debug.h */ // nothing. uses chars and ints /* dictionary.h */ struct pf_dictionary; typedef struct pf_dictionary pf_dictionary_t; /* hash.h */ struct pf_hash; typedef struct pf_hash pf_hash_t; /* image.h */ struct pf_image; typedef struct pf_image pf_image_t; ///< image hader /* matrix.h */ struct pf_matrix; typedef struct pf_matrix pf_matrix_t; ///< matrix header /* thread.h */ typedef void* (*pf_thread_body_t)(void *); ///< thread body function struct pf_command_queue; typedef struct pf_command_queue pf_command_queue_t; ///< command queue /* plugin.h */ struct pf_void; typedef struct pf_void pf_void_t; /* objects that are not considered global and are not defined here: mem.h plugin.h png.h util.h */ /* generic packet subheader */ //typedef unsigned char t_raw[PF_SUBHEADER_SIZE]; typedef unsigned int t_raw; // GCC stuff #define unlikely(x) __builtin_expect((x),0) #define likely(x) __builtin_expect((x),1) #endif