Helixis 1.0
Task Programming API
includes/hlx/channels.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2009-2011, helixis.org
00003 ** All rights reserved.
00004 **
00005 ** Redistribution and use in source and binary forms, with or without modification, are permitted provided
00006 ** that the following conditions are met:
00007 **
00008 ** Redistributions of source code must retain the above copyright notice, this list of conditions and the
00009 ** following disclaimer.
00010 **
00011 ** Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
00012 ** the following disclaimer in the documentation and/or other materials provided with the distribution.
00013 **
00014 ** Neither the name of the helixis.org nor the names of its contributors may be used to endorse or promote
00015 ** products derived from this software without specific prior written permission.
00016 **
00017 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
00018 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00019 ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00020 ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00021 ** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00022 ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00023 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00024 ** POSSIBILITY OF SUCH DAMAGE.
00025 */
00026 
00027 #ifndef __HLX_CHANNELS_H__
00028 # define __HLX_CHANNELS_H__
00029 
00030 #ifdef __cplusplus
00031 extern "C"      {
00032 #endif
00033 
00034 /*
00035 ** TYPES
00036 */
00037 
00038 /* CHANNEL ERRORS */
00039 typedef enum
00040 {
00041         CHAN_ERROR_SUCCESS = 0,
00042         CHAN_ERROR_INTERNAL_ERROR = 1,
00043         CHAN_ERROR_MEMORY_EXHAUSTED = 2,
00044         CHAN_ERROR_ALREADY_EXISTS = 3,
00045         CHAN_ERROR_UNDEFINED = 4,
00046         CHAN_ERROR_NOT_EXISTS = 5
00047 }               hlx_channel_errors;
00048 
00049 /*
00050 ** MACROS
00051 */
00052 
00053 # define HLX_CHAN_WRITE(chan, value, type) HLX_TASK_YIELD_UNTIL(__hlx_chan_write_##type(chan, (type)value) > 0);
00054 # define HLX_CHAN_READ(chan, var_ptr, type) HLX_TASK_YIELD_UNTIL(__hlx_chan_read_##type(chan, (type *)var_ptr) > 0);
00055 
00056 # define HLX_CHAN_WRITE_PTR(chan, value) HLX_TASK_YIELD_UNTIL(__hlx_chan_write_ptr(chan, (void *)value) > 0);
00057 # define HLX_CHAN_READ_PTR(chan, var_ptr) HLX_TASK_YIELD_UNTIL(__hlx_chan_read_ptr(chan, (void **)var_ptr) > 0);
00058 
00059 /*
00060 ** FUNCTIONS
00061 */
00062 
00069 hlx_channel_errors      hlx_chan_create(unsigned long id);
00070 
00071 /*
00072 ** /!\ THESE FUNCTIONS MUST NEVER BE USED DIRECTLY, USE MACROS INSTEAD /!\
00073 */
00074 
00075 int             __hlx_chan_write_int(unsigned long id, int value);
00076 int             __hlx_chan_read_int(unsigned long id, int* value);
00077 int             __hlx_chan_write_char(unsigned long id, char value);
00078 int             __hlx_chan_read_char(unsigned long id, char* value);
00079 int             __hlx_chan_write_short(unsigned long id, short value);
00080 int             __hlx_chan_read_short(unsigned long id, short* value);
00081 int             __hlx_chan_write_float(unsigned long id, float value);
00082 int             __hlx_chan_read_float(unsigned long id, float* value);
00083 int             __hlx_chan_write_ptr(unsigned long id, void* value);
00084 int             __hlx_chan_read_ptr(unsigned long id, void** value);
00085 
00086 #ifdef __cplusplus
00087 }
00088 #endif
00089 
00090 #endif /* !__HLX_CHANNELS_H__ */
00091 
00092 /*
00093 ** END OF FILE
00094 */
00095 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines