lib/iec_std_lib.h
changeset 59 37ba6f9e51e2
parent 57 db9cadaab2ea
child 66 501e9d494744
equal deleted inserted replaced
58:273d6d5cec9d 59:37ba6f9e51e2
    42 #else
    42 #else
    43 #define DBG(...)
    43 #define DBG(...)
    44 #define DBG_TYPE(TYPENAME, name)
    44 #define DBG_TYPE(TYPENAME, name)
    45 #endif
    45 #endif
    46 
    46 
    47 /*****************/
    47 /*********************/
    48 /*  Types defs   */
    48 /*  IEC Types defs   */
    49 /*****************/
    49 /*********************/
    50 
    50 
    51 typedef uint8_t  BOOL;
    51 /* Include non windows.h clashing typedefs */
       
    52 #include "iec_types.h"
       
    53 
       
    54 /* Those typdefs clash with windows.h */
       
    55 /* i.e. this file cannot be included aside windows.h */
       
    56 typedef IEC_BOOL  BOOL;
    52 
    57 
    53 #define TRUE 1
    58 #define TRUE 1
    54 #define FALSE 0
    59 #define FALSE 0
    55 
    60 
    56 typedef int8_t    SINT;
    61 typedef IEC_SINT    SINT;
    57 typedef int16_t   INT;
    62 typedef IEC_INT   INT;
    58 typedef int32_t   DINT;
    63 typedef IEC_DINT   DINT;
    59 typedef int64_t   LINT;
    64 typedef IEC_LINT   LINT;
    60 
    65 
    61 typedef uint8_t    USINT;
    66 typedef IEC_USINT    USINT;
    62 typedef uint16_t   UINT;
    67 typedef IEC_UINT   UINT;
    63 typedef uint32_t   UDINT;
    68 typedef IEC_UDINT   UDINT;
    64 typedef uint64_t   ULINT;
    69 typedef IEC_ULINT   ULINT;
    65 
    70 
    66 typedef uint8_t    BYTE;
    71 typedef IEC_BYTE    BYTE;
    67 typedef uint16_t   WORD;
    72 typedef IEC_WORD   WORD;
    68 typedef uint32_t   DWORD;
    73 typedef IEC_DWORD   DWORD;
    69 typedef uint64_t   LWORD;
    74 typedef IEC_LWORD   LWORD;
    70 
    75 
    71 typedef float    REAL;
    76 typedef IEC_REAL    REAL;
    72 typedef double   LREAL;
    77 typedef IEC_LREAL   LREAL;
    73 
    78 
    74 
    79 typedef IEC_TIME TIME;
    75 #if !defined __timespec_defined
    80 typedef IEC_DATE DATE;
    76 # define __timespec_defined     1
    81 typedef IEC_DT DT;
    77 
    82 typedef IEC_TOD TOD;
    78 struct timespec
       
    79   {
       
    80     long int tv_sec;            /* Seconds.  */
       
    81     long int tv_nsec;           /* Nanoseconds.  */
       
    82   };
       
    83 
       
    84 #endif
       
    85 
       
    86 typedef struct timespec TIME;
       
    87 typedef struct timespec DATE;
       
    88 typedef struct timespec DT;
       
    89 typedef struct timespec TOD;
       
    90 
    83 
    91 #define __TIME_CMP(t1, t2) (t2.tv_sec == t1.tv_sec ? t2.tv_nsec - t1.tv_nsec : t1.tv_sec - t2.tv_sec) 
    84 #define __TIME_CMP(t1, t2) (t2.tv_sec == t1.tv_sec ? t2.tv_nsec - t1.tv_nsec : t1.tv_sec - t2.tv_sec) 
    92 extern TIME __CURRENT_TIME;
    85 extern TIME __CURRENT_TIME;
    93 
    86 
    94 #define STR_MAX_LEN 40
    87 typedef IEC_STRING STRING;
    95 typedef int8_t __strlen_t;
       
    96 typedef struct {
       
    97     __strlen_t len;
       
    98     uint8_t body[STR_MAX_LEN];
       
    99 } STRING;
       
   100 
    88 
   101 #define __STR_CMP(str1, str2) memcmp((char*)&str1.body,(char*)&str2.body, str1.len < str2.len ? str1.len : str2.len)
    89 #define __STR_CMP(str1, str2) memcmp((char*)&str1.body,(char*)&str2.body, str1.len < str2.len ? str1.len : str2.len)
   102 
    90 
   103 /* TODO
    91 /* TODO
   104 typedef struct {
    92 typedef struct {