lib/iec_std_lib.h
author lbessard
Mon, 01 Dec 2008 14:13:47 +0100
changeset 154 9114afe1f64b
parent 149 05ca171a3d57
child 156 6b16b7f8b527
permissions -rw-r--r--
Bug with standard functions nb_params count on Windows fixed
107
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     1
/*
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     2
 * (c) 2008 Edouard TISSERANT
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     3
 *
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     4
 * Offered to the public under the terms of the GNU Lesser General Public
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     5
 * License as published by the Free Software Foundation; either version 2
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     6
 * of the License, or (at your option) any later version.
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     7
 *
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     8
 * This program is distributed in the hope that it will be useful, but
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    11
 * General Public License for more details.
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    12
 *
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    13
 * This code is made available on the understanding that it will not be
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    14
 * used in safety-critical situations without a full and competent review.
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    15
 */
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    16
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    17
/****
107
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    18
 * IEC 61131-3 standard function library
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    19
 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    20
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    21
#include <limits.h>
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    22
#include <float.h>
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    23
#include <math.h>
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    24
#include <time.h>
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    25
#include <stdint.h>
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    26
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    27
#include <stdio.h>
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    28
#include <stdlib.h>
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    29
#include <string.h>
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    30
#include <stdarg.h>
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    31
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    32
#ifdef DEBUG_IEC
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    33
#define DBG(...) printf(__VA_ARGS__);
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    34
#define DBG_TYPE(TYPENAME, name) __print_##TYPENAME(name);
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    35
#else
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    36
#define DBG(...)
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    37
#define DBG_TYPE(TYPENAME, name)
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    38
#endif
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    39
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
    40
/*
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
    41
 * Include type defs.
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
    42
 */
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
    43
#include "iec_types_all.h"
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    44
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    45
extern TIME __CURRENT_TIME;
140
8c0366d41e84 Added __DEBUG global var to eventually change PLC code execution
etisserant
parents: 137
diff changeset
    46
extern BOOL __DEBUG;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    47
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    48
/* TODO
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    49
typedef struct {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    50
    __strlen_t len;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    51
    u_int16_t body[STR_MAX_LEN];
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    52
} WSTRING;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    53
*/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    54
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    55
# if __WORDSIZE == 64
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    56
#define __32b_sufix
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    57
#define __64b_sufix L
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    58
#else
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    59
#define __32b_sufix L
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    60
#define __64b_sufix LL 
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    61
#endif 
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    62
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    63
#define __lit(type,value,sfx) (type)value##sfx
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    64
// Keep this macro expention step to let sfx change into L or LL 
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    65
#define __literal(type,value,sfx) __lit(type,value,sfx)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    66
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    67
#define __BOOL_LITERAL(value) __literal(BOOL,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    68
#define __SINT_LITERAL(value) __literal(SINT,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    69
#define __INT_LITERAL(value) __literal(INT,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    70
#define __DINT_LITERAL(value) __literal(DINT,value,__32b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    71
#define __LINT_LITERAL(value) __literal(LINT,value,__64b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    72
#define __USINT_LITERAL(value) __literal(USINT,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    73
#define __UINT_LITERAL(value) __literal(UINT,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    74
#define __UDINT_LITERAL(value) __literal(UDINT,value,__32b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    75
#define __ULINT_LITERAL(value) __literal(ULINT,value,__64b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    76
#define __REAL_LITERAL(value) __literal(REAL,value,__32b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    77
#define __LREAL_LITERAL(value) __literal(LREAL,value,__64b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    78
#define __TIME_LITERAL(value) __literal(TIME,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    79
#define __DATE_LITERAL(value) __literal(DATE,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    80
#define __TOD_LITERAL(value) __literal(TOD,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    81
#define __DT_LITERAL(value) __literal(DT,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    82
#define __STRING_LITERAL(value) __literal(STRING,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    83
#define __BYTE_LITERAL(value) __literal(BYTE,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    84
#define __WORD_LITERAL(value) __literal(WORD,value,)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    85
#define __DWORD_LITERAL(value) __literal(DWORD,value,__32b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    86
#define __LWORD_LITERAL(value) __literal(LWORD,value,__32b_sufix)
55
8b7a21820737 Started support for long long (LL suffix) 64 bit literals on 32 bit platforms (unfinished)
etisserant
parents: 48
diff changeset
    87
8b7a21820737 Started support for long long (LL suffix) 64 bit literals on 32 bit platforms (unfinished)
etisserant
parents: 48
diff changeset
    88
8b7a21820737 Started support for long long (LL suffix) 64 bit literals on 32 bit platforms (unfinished)
etisserant
parents: 48
diff changeset
    89
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    90
#define __INIT_REAL 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    91
#define __INIT_LREAL 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    92
#define __INIT_SINT 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    93
#define __INIT_INT 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    94
#define __INIT_DINT 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    95
#define __INIT_LINT 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    96
#define __INIT_USINT 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    97
#define __INIT_UINT 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    98
#define __INIT_UDINT 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    99
#define __INIT_ULINT 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   100
#define __INIT_TIME (TIME){0,0}
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   101
#define __INIT_BOOL 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   102
#define __INIT_BYTE 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   103
#define __INIT_WORD 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   104
#define __INIT_DWORD 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   105
#define __INIT_LWORD 0
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   106
#define __INIT_STRING (STRING){0,""}
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   107
//#define __INIT_WSTRING
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   108
#define __INIT_DATE (DATE){0,0}
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   109
#define __INIT_TOD (TOD){0,0}
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   110
#define __INIT_DT (DT){0,0}
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   111
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   112
typedef union __IL_DEFVAR_T {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   113
    BOOL    BOOLvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   114
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   115
    SINT    SINTvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   116
    INT     INTvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   117
    DINT    DINTvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   118
    LINT    LINTvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   119
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   120
    USINT   USINTvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   121
    UINT    UINTvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   122
    UDINT   UDINTvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   123
    ULINT   ULINTvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   124
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   125
    BYTE    BYTEvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   126
    WORD    WORDvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   127
    DWORD   DWORDvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   128
    LWORD   LWORDvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   129
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   130
    REAL    REALvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   131
    LREAL   LREALvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   132
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   133
    TIME    TIMEvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   134
    TOD TODvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   135
    DT  DTvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   136
    DATE    DATEvar;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   137
} __IL_DEFVAR_T;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   138
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   139
/*****************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   140
/* Misc internal */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   141
/*****************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   142
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   143
/* function that generates an IEC runtime error */
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   144
static inline void IEC_error(void) {
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   145
  /* TODO... */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   146
  fprintf(stderr, "IEC 61131-3 runtime error.\n");
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   147
  /*exit(1);*/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   148
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   149
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   150
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   151
static inline void __normalize_timespec (struct timespec *ts) {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   152
  if( ts->tv_nsec < -1000000000 || (( ts->tv_sec > 0 ) && ( ts->tv_nsec < 0 ))){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   153
    ts->tv_sec--;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   154
    ts->tv_nsec += 1000000000;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   155
  }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   156
  if( ts->tv_nsec > 1000000000 || (( ts->tv_sec < 0 ) && ( ts->tv_nsec > 0 ))){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   157
    ts->tv_sec++;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   158
    ts->tv_nsec -= 1000000000;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   159
  }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   160
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   161
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   162
static inline struct timespec __time_to_timespec(int sign, double mseconds, double seconds, double minutes, double hours, double days) {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   163
  struct timespec ts;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   164
  
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   165
  /* sign is 1 for positive values, -1 for negative time... */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   166
  long double total_sec = ((days*24 + hours)*60 + minutes)*60 + seconds + mseconds/1e3;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   167
  if (sign >= 0) sign = 1; else sign = -1;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   168
  ts.tv_sec = sign * (long int)total_sec;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   169
  ts.tv_nsec = sign * (long int)((total_sec - ts.tv_sec)*1e9);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   170
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   171
  return ts;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   172
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   173
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   174
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   175
static inline struct timespec __tod_to_timespec(double seconds, double minutes, double hours) {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   176
  struct timespec ts;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   177
  
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   178
  long double total_sec = (hours*60 + minutes)*60 + seconds;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   179
  ts.tv_sec = (long int)total_sec;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   180
  ts.tv_nsec = (long int)((total_sec - ts.tv_sec)*1e9);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   181
  
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   182
  return ts;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   183
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   184
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   185
static inline struct timespec __date_to_timespec(int day, int month, int year) {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   186
  struct timespec ts;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   187
  struct tm broken_down_time;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   188
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   189
  broken_down_time.tm_sec = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   190
  broken_down_time.tm_min = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   191
  broken_down_time.tm_hour = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   192
  broken_down_time.tm_mday = day;  /* day of month, from 1 to 31 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   193
  broken_down_time.tm_mon = month - 1;   /* month since January, in the range 0 to 11 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   194
  broken_down_time.tm_year = year - 1900;  /* number of years since 1900 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   195
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   196
  time_t epoch_seconds = mktime(&broken_down_time); /* determine number of seconds since the epoch, i.e. Jan 1st 1970 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   197
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   198
  if ((time_t)(-1) == epoch_seconds)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   199
    IEC_error();
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   200
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   201
  ts.tv_sec = epoch_seconds;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   202
  ts.tv_nsec = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   203
  
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   204
  return ts;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   205
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   206
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   207
static inline struct timespec __dt_to_timespec(double seconds,  double minutes, double hours, int day, int month, int year) {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   208
  struct timespec ts;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   209
  
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   210
  long double total_sec = (hours*60 + minutes)*60 + seconds;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   211
  ts.tv_sec = (long int)total_sec;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   212
  ts.tv_nsec = (long int)((total_sec - ts.tv_sec)*1e9);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   213
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   214
  struct tm broken_down_time;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   215
  broken_down_time.tm_sec = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   216
  broken_down_time.tm_min = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   217
  broken_down_time.tm_hour = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   218
  broken_down_time.tm_mday = day;  /* day of month, from 1 to 31 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   219
  broken_down_time.tm_mon = month - 1;   /* month since January, in the range 0 to 11 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   220
  broken_down_time.tm_year = year - 1900;  /* number of years since 1900 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   221
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   222
  time_t epoch_seconds = mktime(&broken_down_time); /* determine number of seconds since the epoch, i.e. Jan 1st 1970 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   223
  if ((time_t)(-1) == epoch_seconds)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   224
    IEC_error();
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   225
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   226
  ts.tv_sec += epoch_seconds;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   227
  if (ts.tv_sec < epoch_seconds)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   228
    /* since the TOD is always positive, if the above happens then we had an overflow */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   229
    IEC_error();
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   230
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   231
  return ts;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   232
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   233
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   234
/********************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   235
/*   EN/ENO PARAMS  */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   236
/********************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   237
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   238
#define EN_ENO_PARAMS BOOL EN, BOOL *ENO
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   239
#define TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   240
  if (!EN) {\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   241
    if (ENO != NULL)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   242
      *ENO = __BOOL_LITERAL(FALSE);\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   243
    return __INIT_##TYPENAME;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   244
  }\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   245
  else if (ENO != NULL)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   246
    *ENO = __BOOL_LITERAL(TRUE);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   247
#define TEST_EN_COND(TYPENAME, COND)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   248
  if (!EN || (COND)) {\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   249
    if (ENO != NULL)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   250
      *ENO = __BOOL_LITERAL(FALSE);\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   251
    return __INIT_##TYPENAME;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   252
  }\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   253
  else if (ENO != NULL)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   254
    *ENO = __BOOL_LITERAL(TRUE);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   255
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   256
/***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   257
/*   Time ops  */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   258
/***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   259
#define __TIME_CMP(t1, t2) (t2.tv_sec == t1.tv_sec ? t1.tv_nsec - t2.tv_nsec : t1.tv_sec - t2.tv_sec) 
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   260
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   261
static inline TIME __TIME_ADD(TIME IN1, TIME IN2){
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   262
  TIME res ={IN1.tv_sec + IN2.tv_sec,
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   263
             IN1.tv_nsec + IN2.tv_nsec };
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   264
  __normalize_timespec(&res);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   265
  return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   266
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   267
static inline TIME __TIME_SUB(TIME IN1, TIME IN2){
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   268
  TIME res ={IN1.tv_sec - IN2.tv_sec,
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   269
             IN1.tv_nsec - IN2.tv_nsec };
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   270
  __normalize_timespec(&res);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   271
  return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   272
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   273
static inline TIME __TIME_MUL(TIME IN1, LREAL IN2){
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   274
  LREAL s_f = IN1.tv_sec * IN2;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   275
  time_t s = s_f;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   276
  div_t ns = div((LREAL)IN1.tv_nsec * IN2, 1000000000);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   277
  TIME res = {s + ns.quot,
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   278
              ns.rem + (s_f - s) * 1000000000 };
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   279
  __normalize_timespec(&res);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   280
  return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   281
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   282
static inline TIME __TIME_DIV(TIME IN1, LREAL IN2){
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   283
  LREAL s_f = IN1.tv_sec / IN2;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   284
  time_t s = s_f;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   285
  TIME res = {s,
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   286
              IN1.tv_nsec / IN2 + (s_f - s) * 1000000000 };
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   287
  __normalize_timespec(&res);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   288
  return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   289
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   290
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   291
static inline TIME __date_and_time_to_time_of_day(EN_ENO_PARAMS, TIME IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   292
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   293
  return (TIME){IN.tv_sec % 86400, IN.tv_nsec};
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   294
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   295
static inline TIME __date_and_time_to_date(EN_ENO_PARAMS, TIME IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   296
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   297
  return (TIME){IN.tv_sec - (IN.tv_sec % (24*60*60)), 0};
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   298
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   299
static inline TIME __time_add(EN_ENO_PARAMS, TIME IN1, TIME IN2){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   300
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   301
  return __TIME_ADD(IN1, IN2);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   302
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   303
static inline TIME __time_sub(EN_ENO_PARAMS, TIME IN1, TIME IN2){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   304
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   305
  return __TIME_SUB(IN1, IN2);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   306
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   307
static inline TIME __time_mul(EN_ENO_PARAMS, TIME IN1, LREAL IN2){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   308
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   309
  return __TIME_MUL(IN1, IN2);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   310
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   311
static inline TIME __time_div(EN_ENO_PARAMS, TIME IN1, LREAL IN2){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   312
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   313
  return __TIME_DIV(IN1, IN2);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   314
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   315
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   316
/***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   317
/* String ops  */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   318
/***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   319
#define __STR_CMP(str1, str2) memcmp((char*)&str1.body,(char*)&str2.body, str1.len < str2.len ? str1.len : str2.len)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   320
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   321
static inline UINT __len(EN_ENO_PARAMS, STRING IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   322
    TEST_EN(UINT)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   323
    return IN.len;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   324
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   325
static inline STRING __left(EN_ENO_PARAMS, STRING IN, SINT L){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   326
    TEST_EN_COND(STRING, L < 0)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   327
    STRING res = __INIT_STRING;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   328
    L = L < IN.len ? L : IN.len;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   329
    memcpy(&res.body, &IN.body, L);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   330
    res.len = L;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   331
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   332
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   333
static inline STRING __right(EN_ENO_PARAMS, STRING IN, SINT L){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   334
    TEST_EN_COND(STRING, L < 0)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   335
    STRING res = __INIT_STRING;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   336
    L = L < IN.len ? L : IN.len;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   337
    memcpy(&res.body, &IN.body[IN.len - L], L);
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   338
    res.len = L;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   339
    return res;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   340
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   341
static inline STRING __mid(EN_ENO_PARAMS, STRING IN, SINT L, SINT P){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   342
    TEST_EN_COND(STRING, L < 0 || P < 0)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   343
    STRING res = __INIT_STRING;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   344
    if(P <= IN.len){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   345
	    P -= 1; /* now can be used as [index]*/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   346
	    L = L + P <= IN.len ? L : IN.len - P;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   347
	    memcpy(&res.body, &IN.body[P] , L);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   348
        res.len = L;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   349
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   350
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   351
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   352
static inline STRING __concat(EN_ENO_PARAMS, SINT param_count, ...){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   353
  TEST_EN(STRING)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   354
  va_list ap;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   355
  UINT i;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   356
  __strlen_t charcount = 0;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   357
  STRING res = __INIT_STRING;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   358
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   359
  va_start (ap, param_count);         /* Initialize the argument list.  */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   360
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   361
  for (i = 0; i < param_count && charcount < STR_MAX_LEN; i++)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   362
  {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   363
    STRING tmp = va_arg(ap, STRING);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   364
    __strlen_t charrem = STR_MAX_LEN - charcount;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   365
    __strlen_t to_write = tmp.len > charrem ? charrem : tmp.len;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   366
    memcpy(&res.body[charcount], &tmp.body , to_write);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   367
    charcount += to_write;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   368
  }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   369
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   370
  res.len = charcount;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   371
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   372
  va_end (ap);                  /* Clean up.  */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   373
  return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   374
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   375
static inline STRING __insert(EN_ENO_PARAMS, STRING IN1, STRING IN2, SINT P){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   376
    TEST_EN_COND(STRING, P < 0)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   377
    STRING res = __INIT_STRING;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   378
    __strlen_t to_copy;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   379
    
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   380
    to_copy = P > IN1.len ? IN1.len : P - 1;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   381
    memcpy(&res.body, &IN1.body , to_copy);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   382
    P = res.len = to_copy;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   383
    
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   384
    to_copy = IN2.len + res.len > STR_MAX_LEN ? STR_MAX_LEN - res.len : IN2.len;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   385
    memcpy(&res.body[res.len], &IN2.body , to_copy);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   386
    res.len += to_copy;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   387
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   388
    to_copy = IN1.len - P < STR_MAX_LEN - res.len ? IN1.len - P : STR_MAX_LEN - res.len ;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   389
    memcpy(&res.body[res.len], &IN1.body[P] , to_copy);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   390
    res.len += to_copy;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   391
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   392
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   393
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   394
static inline STRING __delete(EN_ENO_PARAMS, STRING IN, SINT L, SINT P){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   395
    TEST_EN_COND(STRING, L < 0 || P < 0)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   396
    STRING res = __INIT_STRING;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   397
    __strlen_t to_copy;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   398
    
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   399
    to_copy = P > IN.len ? IN.len : P-1;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   400
    memcpy(&res.body, &IN.body , to_copy);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   401
    P = res.len = to_copy;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   402
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   403
    if( IN.len > P + L ){
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   404
        to_copy = IN.len - P - L;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   405
        memcpy(&res.body[res.len], &IN.body[P + L], to_copy);
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   406
        res.len += to_copy;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   407
    }
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   408
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   409
    return res;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   410
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   411
static inline STRING __replace(EN_ENO_PARAMS, STRING IN1, STRING IN2, SINT L, SINT P){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   412
    TEST_EN_COND(STRING, L < 0 || P < 0)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   413
    STRING res = __INIT_STRING;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   414
    __strlen_t to_copy;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   415
    
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   416
    to_copy = P > IN1.len ? IN1.len : P-1;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   417
    memcpy(&res.body, &IN1.body , to_copy);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   418
    P = res.len = to_copy;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   419
    
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   420
    to_copy = IN2.len < L ? IN2.len : L;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   421
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   422
    if( to_copy + res.len > STR_MAX_LEN ) 
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   423
       to_copy = STR_MAX_LEN - res.len;   
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   424
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   425
    memcpy(&res.body[res.len], &IN2.body , to_copy);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   426
    res.len += to_copy;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   427
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   428
    P += L;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   429
    if( res.len <  STR_MAX_LEN && P < IN1.len)
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   430
    {
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   431
        to_copy = IN1.len - P;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   432
        memcpy(&res.body[res.len], &IN1.body[P] , to_copy);
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   433
        res.len += to_copy;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   434
    }
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   435
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   436
    return res;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   437
}
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   438
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   439
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   440
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   441
static inline UINT __pfind(STRING* IN1, STRING* IN2){
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   442
    UINT count1 = 0; /* offset of first matching char in IN1 */
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   443
    UINT count2 = 0; /* count of matching char */
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   444
    while(count1 + count2 < IN1->len && count2 < IN2->len)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   445
    {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   446
        if(IN1->body[count1 + count2] != IN2->body[count2++]){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   447
            count1 += count2;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   448
            count2 = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   449
        }        
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   450
    }
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   451
    return count2 == IN2->len -1 ? 0 : count1 + 1;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   452
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   453
static inline UINT __find(EN_ENO_PARAMS, STRING IN1, STRING IN2){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   454
    TEST_EN(UINT)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   455
    return __pfind(&IN1, &IN2);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   456
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   457
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   458
/***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   459
/* Convertions */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   460
/***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   461
    /***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   462
    /*  TO_STRING  */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   463
    /***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   464
static inline STRING __bool_to_string(EN_ENO_PARAMS, BOOL IN)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   465
{
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   466
    TEST_EN(STRING)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   467
    if(IN)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   468
        return (STRING){4, "TRUE"};
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   469
    return (STRING){5,"FALSE"};
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   470
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   471
static inline STRING __bit_to_string(EN_ENO_PARAMS, LWORD IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   472
    TEST_EN(STRING)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   473
    STRING res = __INIT_STRING;
114
28cf5bddeb9f cast fir gcc4 fix in lib
etisserant
parents: 107
diff changeset
   474
    res.len = snprintf((char*)res.body, STR_MAX_LEN, "16#%llx", IN);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   475
    if(res.len > STR_MAX_LEN) res.len = STR_MAX_LEN;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   476
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   477
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   478
static inline STRING __real_to_string(EN_ENO_PARAMS, LREAL IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   479
    TEST_EN(STRING)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   480
    STRING res = __INIT_STRING;
114
28cf5bddeb9f cast fir gcc4 fix in lib
etisserant
parents: 107
diff changeset
   481
    res.len = snprintf((char*)res.body, STR_MAX_LEN, "%.10g", IN);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   482
    if(res.len > STR_MAX_LEN) res.len = STR_MAX_LEN;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   483
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   484
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   485
static inline STRING __sint_to_string(EN_ENO_PARAMS, LINT IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   486
    TEST_EN(STRING)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   487
    STRING res = __INIT_STRING;
114
28cf5bddeb9f cast fir gcc4 fix in lib
etisserant
parents: 107
diff changeset
   488
    res.len = snprintf((char*)res.body, STR_MAX_LEN, "%lld", IN);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   489
    if(res.len > STR_MAX_LEN) res.len = STR_MAX_LEN;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   490
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   491
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   492
static inline STRING __uint_to_string(EN_ENO_PARAMS, ULINT IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   493
    TEST_EN(STRING)
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   494
    STRING res = __INIT_STRING;
114
28cf5bddeb9f cast fir gcc4 fix in lib
etisserant
parents: 107
diff changeset
   495
    res.len = snprintf((char*)res.body, STR_MAX_LEN, "%llu", IN);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   496
    if(res.len > STR_MAX_LEN) res.len = STR_MAX_LEN;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   497
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   498
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   499
    /***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   500
    /* FROM_STRING */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   501
    /***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   502
static inline BOOL __string_to_bool(EN_ENO_PARAMS, STRING IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   503
    TEST_EN(BOOL)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   504
    return IN.len == 5 ? !memcmp(&IN.body,"TRUE", IN.len) : 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   505
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   506
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   507
static inline LINT __pstring_to_sint(STRING* IN){
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   508
    LINT res = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   509
    char tmp[STR_MAX_LEN];
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   510
    char tmp2[STR_MAX_LEN];
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   511
    __strlen_t l;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   512
    unsigned int shift = 0;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   513
    
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   514
    if(IN->body[0]=='2' && IN->body[1]=='#'){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   515
        /* 2#0101_1010_1011_1111 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   516
        for(l = IN->len - 1; l >= 2 && shift < 64; l--)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   517
        {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   518
            char c = IN->body[l];
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   519
            if( c >= '0' && c <= '1'){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   520
                res |= ( c - '0') << shift;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   521
                shift += 1;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   522
            }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   523
        }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   524
    }else if(IN->body[0]=='8' && IN->body[1]=='#'){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   525
        /* 8#1234_5665_4321 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   526
        for(l = IN->len - 1; l >= 2 && shift < 64; l--)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   527
        {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   528
            char c = IN->body[l];
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   529
            if( c >= '0' && c <= '7'){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   530
                res |= ( c - '0') << shift;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   531
                shift += 3;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   532
            }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   533
        }
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   534
    }else if(IN->body[0]=='1' && IN->body[1]=='6' && IN->body[2]=='#'){
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   535
        /* 16#1234_5678_9abc_DEFG */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   536
        for(l = IN->len - 1; l >= 3 && shift < 64; l--)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   537
        {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   538
            char c = IN->body[l];
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   539
            if( c >= '0' && c <= '9'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   540
                res |= (LWORD)( c - '0') << shift;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   541
                shift += 4;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   542
            }else if( c >= 'a' && c <= 'f'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   543
                res |= (LWORD)( c - 'a' + 10 ) << shift;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   544
                shift += 4;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   545
            }else if( c >= 'A' && c <= 'F'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   546
                res |= (LWORD)( c - 'A' + 10 ) << shift;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   547
                shift += 4;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   548
            }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   549
        }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   550
    }else{
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   551
        /* -123456789 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   552
        LINT fac = IN->body[0] == '-' ? -1 : 1;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   553
        for(l = IN->len - 1; l >= 0 && shift < 20; l--)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   554
        {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   555
            char c = IN->body[l];
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   556
            if( c >= '0' && c <= '9'){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   557
                res += ( c - '0') * fac;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   558
                fac *= 10;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   559
                shift += 1;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   560
            }else if( c >= '.' ){ /* reset value */
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   561
                res = 0;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   562
                fac = 1;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   563
                shift = 0;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   564
            }            
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   565
        }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   566
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   567
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   568
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   569
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   570
static inline LINT __string_to_sint(EN_ENO_PARAMS, STRING IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   571
    TEST_EN(LINT)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   572
    return (LWORD)__pstring_to_sint(&IN);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   573
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   574
static inline LWORD __string_to_bit(EN_ENO_PARAMS, STRING IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   575
    TEST_EN(LWORD)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   576
    return (LWORD)__pstring_to_sint(&IN);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   577
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   578
static inline ULINT __string_to_uint(EN_ENO_PARAMS, STRING IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   579
    TEST_EN(ULINT)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   580
    return (ULINT)__pstring_to_sint(&IN);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   581
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   582
static inline LREAL __string_to_real(EN_ENO_PARAMS, STRING IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   583
    TEST_EN(LREAL)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   584
    /* search the dot */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   585
    __strlen_t l = IN.len;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   586
    while(--l > 0 && IN.body[l] != '.');
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   587
    if(l != 0){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   588
        return atof((const char *)&IN.body);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   589
    }else{
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   590
        return (LREAL)__pstring_to_sint(&IN);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   591
    }    
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   592
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   593
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   594
    /***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   595
    /*   TO_TIME   */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   596
    /***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   597
static inline TIME __int_to_time(EN_ENO_PARAMS, LINT IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   598
    TEST_EN(TIME)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   599
    return (TIME){IN, 0};
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   600
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   601
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   602
static inline TIME __real_to_time(EN_ENO_PARAMS, LREAL IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   603
    TEST_EN(TIME)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   604
    return (TIME){IN, (IN - (LINT)IN) * 1000000000};
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   605
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   606
static inline TIME __string_to_time(EN_ENO_PARAMS, STRING IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   607
    TEST_EN(TIME)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   608
    /* TODO :
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   609
     *
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   610
     *  Duration literals without underlines: T#14ms    T#-14ms   T#14.7s   T#14.7m
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   611
     *                short prefix            T#14.7h    t#14.7d   t#25h15m
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   612
     *                                        t#5d14h12m18s3.5ms
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   613
     *                long prefix             TIME#14ms    TIME#-14ms   time#14.7s
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   614
     *  Duration literals with underlines:
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   615
     *                short prefix            t#25h_15m t#5d_14h_12m_18s_3.5ms
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   616
     *                long prefix             TIME#25h_15m
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   617
     *                                        time#5d_14h_12m_18s_3.5ms
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   618
     *
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   619
     *  Long prefix notation                 Short prefix notation
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   620
     *  DATE#1984-06-25                      D#1984-06-25
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   621
     *  date#1984-06-25                      d#1984-06-25
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   622
     *  TIME_OF_DAY#15:36:55.36              TOD#15:36:55.36
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   623
     *  time_of_day#15:36:55.36              tod#15:36:55.36
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   624
     *  DATE_AND_TIME#1984-06-25-15:36:55.36 DT#1984-06-25-15:36:55.36
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   625
     *  date_and_time#1984-06-25-15:36:55.36 dt#1984-06-25-15:36:55.36
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   626
     *
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   627
     */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   628
    /* Quick hack : only transform seconds */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   629
    /* search the dot */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   630
    __strlen_t l = IN.len;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   631
    while(--l > 0 && IN.body[l] != '.');
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   632
    if(l != 0){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   633
        LREAL IN_val = atof((const char *)&IN.body);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   634
        return  (TIME){IN_val, (IN_val - (LINT)IN_val)*1000000000};
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   635
    }else{
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   636
        return  (TIME){__pstring_to_sint(&IN), 0};
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   637
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   638
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   639
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   640
    /***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   641
    /*  FROM_TIME  */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   642
    /***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   643
static inline LREAL __time_to_real(EN_ENO_PARAMS, TIME IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   644
    TEST_EN(LREAL)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   645
    return (LREAL)IN.tv_sec + ((LREAL)IN.tv_nsec/1000000000);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   646
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   647
static inline LINT __time_to_int(EN_ENO_PARAMS, TIME IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   648
    TEST_EN(LINT)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   649
    return IN.tv_sec;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   650
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   651
static inline STRING __time_to_string(EN_ENO_PARAMS, TIME IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   652
    TEST_EN(STRING)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   653
    /*t#5d14h12m18s3.5ms*/
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   654
    STRING res = __INIT_STRING;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   655
    div_t days = div(IN.tv_sec ,86400);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   656
    if(!days.rem && IN.tv_nsec == 0){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   657
        res.len = snprintf((char*)&res.body, STR_MAX_LEN, "T#%dd", days.quot);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   658
    }else{
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   659
        div_t hours = div(days.rem, 3600);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   660
        if(!hours.rem && IN.tv_nsec == 0){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   661
            res.len = snprintf((char*)&res.body, STR_MAX_LEN, "T#%dd%dh", days.quot, hours.quot);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   662
        }else{
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   663
            div_t minuts = div(hours.rem, 60);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   664
            if(!minuts.rem && IN.tv_nsec == 0){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   665
                res.len = snprintf((char*)&res.body, STR_MAX_LEN, "T#%dd%dh%dm", days.quot, hours.quot, minuts.quot);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   666
            }else{
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   667
                if(IN.tv_nsec == 0){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   668
                    res.len = snprintf((char*)&res.body, STR_MAX_LEN, "T#%dd%dh%dm%ds", days.quot, hours.quot, minuts.quot, minuts.rem);
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   669
                }else{
42
b45c7f34dec1 IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents: 41
diff changeset
   670
                    res.len = snprintf((char*)&res.body, STR_MAX_LEN, "T#%dd%dh%dm%ds%gms", days.quot, hours.quot, minuts.quot, minuts.rem, (LREAL)IN.tv_nsec / 1000000);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   671
                }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   672
            }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   673
        }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   674
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   675
    if(res.len > STR_MAX_LEN) res.len = STR_MAX_LEN;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   676
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   677
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   678
static inline STRING __date_to_string(EN_ENO_PARAMS, DATE IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   679
    TEST_EN(STRING)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   680
    /* D#1984-06-25 */
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   681
    STRING res = __INIT_STRING;
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   682
    struct tm* broken_down_time;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   683
    time_t seconds = IN.tv_sec;
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   684
    if (NULL == (broken_down_time = localtime(&seconds))){ /* get the UTC (GMT) broken down time */
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   685
        IEC_error();
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   686
        return (STRING){7,"D#ERROR"};
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   687
    }
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   688
    res.len = snprintf((char*)&res.body, STR_MAX_LEN, "D#%d-%2.2d-%2.2d", broken_down_time->tm_year + 1900, broken_down_time->tm_mon + 1, broken_down_time->tm_mday);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   689
    if(res.len > STR_MAX_LEN) res.len = STR_MAX_LEN;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   690
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   691
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   692
static inline STRING __tod_to_string(EN_ENO_PARAMS, TOD IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   693
    TEST_EN(STRING)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   694
    /* TOD#15:36:55.36 */
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   695
    STRING res = __INIT_STRING;
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   696
    struct tm* broken_down_time;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   697
    time_t seconds = IN.tv_sec;
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   698
    if (NULL == (broken_down_time = localtime(&seconds))){ /* get the UTC (GMT) broken down time */
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   699
        IEC_error();
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   700
        return (STRING){9,"TOD#ERROR"};
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   701
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   702
    if(IN.tv_nsec == 0){
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   703
        res.len = snprintf((char*)&res.body, STR_MAX_LEN, "TOD#%2.2d:%2.2d:%d", broken_down_time->tm_hour, broken_down_time->tm_min, broken_down_time->tm_sec);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   704
    }else{
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   705
        res.len = snprintf((char*)&res.body, STR_MAX_LEN, "TOD#%2.2d:%2.2d:%g", broken_down_time->tm_hour, broken_down_time->tm_min, (LREAL)broken_down_time->tm_sec + (LREAL)IN.tv_nsec / 1e9);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   706
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   707
    if(res.len > STR_MAX_LEN) res.len = STR_MAX_LEN;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   708
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   709
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   710
static inline STRING __dt_to_string(EN_ENO_PARAMS, DT IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   711
    TEST_EN(STRING)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   712
    /* DT#1984-06-25-15:36:55.36 */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   713
    STRING res;
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   714
    struct tm* broken_down_time;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   715
    time_t seconds = IN.tv_sec;
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   716
    if (NULL == (broken_down_time = localtime(&seconds))){ /* get the UTC (GMT) broken down time */
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   717
        IEC_error();
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   718
        return (STRING){8,"DT#ERROR"};
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   719
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   720
    if(IN.tv_nsec == 0){
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   721
        res.len = snprintf((char*)&res.body, STR_MAX_LEN, "DT#%d-%2.2d-%2.2d-%2.2d:%2.2d:%d",
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   722
                 broken_down_time->tm_year,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   723
                 broken_down_time->tm_mon,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   724
                 broken_down_time->tm_mday,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   725
                 broken_down_time->tm_hour,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   726
                 broken_down_time->tm_min,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   727
                 broken_down_time->tm_sec);
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   728
    }else{
42
b45c7f34dec1 IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents: 41
diff changeset
   729
        res.len = snprintf((char*)&res.body, STR_MAX_LEN, "DT#%d-%2.2d-%2.2d-%2.2d:%2.2d:%g",
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   730
                 broken_down_time->tm_year,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   731
                 broken_down_time->tm_mon,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   732
                 broken_down_time->tm_mday,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   733
                 broken_down_time->tm_hour,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   734
                 broken_down_time->tm_min,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   735
                 (LREAL)broken_down_time->tm_sec + ((LREAL)IN.tv_nsec / 1e9));
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   736
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   737
    if(res.len > STR_MAX_LEN) res.len = STR_MAX_LEN;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   738
    return res;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   739
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   740
    /* BCD */
48
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   741
#define __bcd_digit(fac) 
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   742
static inline ULINT __bcd_to_uint(EN_ENO_PARAMS, LWORD IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   743
    TEST_EN(ULINT)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   744
    return IN & 0xf +
48
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   745
           !(IN >>= 4) ? 0 : IN & 0xf * 10ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   746
           !(IN >>= 4) ? 0 : IN & 0xf * 100ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   747
           !(IN >>= 4) ? 0 : IN & 0xf * 1000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   748
           !(IN >>= 4) ? 0 : IN & 0xf * 10000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   749
           !(IN >>= 4) ? 0 : IN & 0xf * 100000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   750
           !(IN >>= 4) ? 0 : IN & 0xf * 1000000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   751
           !(IN >>= 4) ? 0 : IN & 0xf * 10000000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   752
           !(IN >>= 4) ? 0 : IN & 0xf * 100000000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   753
           !(IN >>= 4) ? 0 : IN & 0xf * 1000000000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   754
           !(IN >>= 4) ? 0 : IN & 0xf * 10000000000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   755
           !(IN >>= 4) ? 0 : IN & 0xf * 100000000000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   756
           !(IN >>= 4) ? 0 : IN & 0xf * 1000000000000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   757
           !(IN >>= 4) ? 0 : IN & 0xf * 10000000000000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   758
           !(IN >>= 4) ? 0 : IN & 0xf * 100000000000000ULL + 
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   759
           !(IN >>= 4) ? 0 : IN & 0xf * 1000000000000000ULL;
3d24cc85bb3c Fixed some problems win 32 bits GCC and Long Long literals
etisserant
parents: 43
diff changeset
   760
           
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   761
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   762
static inline LWORD __uint_to_bcd(EN_ENO_PARAMS, ULINT IN){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   763
    TEST_EN(LWORD)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   764
    return (IN - (IN /= 10))|
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   765
           (IN - (IN /= 10)) << 4 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   766
           (IN - (IN /= 10)) << 8 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   767
           (IN - (IN /= 10)) << 12 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   768
           (IN - (IN /= 10)) << 16 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   769
           (IN - (IN /= 10)) << 20 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   770
           (IN - (IN /= 10)) << 24 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   771
           (IN - (IN /= 10)) << 28 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   772
           (IN - (IN /= 10)) << 32 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   773
           (IN - (IN /= 10)) << 36 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   774
           (IN - (IN /= 10)) << 40 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   775
           (IN - (IN /= 10)) << 44 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   776
           (IN - (IN /= 10)) << 48 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   777
           (IN - (IN /= 10)) << 52 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   778
           (IN - (IN /= 10)) << 56 |
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   779
           (IN - (IN /= 10)) << 60;
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   780
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   781
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   782
/* workaround for va-atgs limitation on shorter that int params */    
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   783
#define VA_ARGS_REAL LREAL
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   784
#define VA_ARGS_LREAL LREAL
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   785
#define VA_ARGS_SINT DINT
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   786
#define VA_ARGS_INT DINT
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   787
#define VA_ARGS_DINT DINT
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   788
#define VA_ARGS_LINT LINT
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   789
#define VA_ARGS_USINT UDINT
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   790
#define VA_ARGS_UINT UDINT
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   791
#define VA_ARGS_UDINT UDINT
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   792
#define VA_ARGS_ULINT ULINT
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   793
#define VA_ARGS_TIME TIME
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   794
#define VA_ARGS_BOOL DWORD
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   795
#define VA_ARGS_BYTE DWORD
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   796
#define VA_ARGS_WORD DWORD
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   797
#define VA_ARGS_DWORD DWORD
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   798
#define VA_ARGS_LWORD LWORD
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   799
#define VA_ARGS_STRING STRING
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   800
#define VA_ARGS_WSTRING WSTRING
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   801
#define VA_ARGS_DATE DATE
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   802
#define VA_ARGS_TOD TOD
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   803
#define VA_ARGS_DT DT
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   804
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   805
/*******************************************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   806
/*     Arithmetic and bitwise functions    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   807
/*******************************************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   808
#define __arith_expand(fname,TYPENAME, OP) \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   809
static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, UINT param_count, TYPENAME op1, ...){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   810
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   811
  va_list ap;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   812
  UINT i;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   813
  \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   814
  va_start (ap, op1);         /* Initialize the argument list.  */\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   815
  \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   816
  for (i = 0; i < param_count - 1; i++){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   817
    op1 = op1 OP va_arg (ap, VA_ARGS_##TYPENAME);\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   818
  }\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   819
  \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   820
  va_end (ap);                  /* Clean up.  */\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   821
  return op1;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   822
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   823
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   824
#define __arith_static(fname,TYPENAME, OP) \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   825
static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   826
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   827
  return op1 OP op2;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   828
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   829
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   830
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   831
/*     ADD    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   832
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   833
#define __add_(TYPENAME) __arith_expand(__add_, TYPENAME, + )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   834
ANY_NUM(__add_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   835
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   836
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   837
/*     MUL    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   838
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   839
#define __mul_(TYPENAME) __arith_expand(__mul_, TYPENAME, * )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   840
ANY_NUM(__mul_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   841
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   842
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   843
/*     SUB    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   844
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   845
#define __sub_(TYPENAME) __arith_static(__sub_, TYPENAME, - )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   846
ANY_NUM(__sub_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   847
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   848
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   849
/*     DIV    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   850
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   851
#define __div_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   852
static inline TYPENAME __div_##TYPENAME(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   853
  TEST_EN_COND(TYPENAME, op2 == 0)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   854
  return op1 / op2;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   855
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   856
ANY_NUM(__div_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   857
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   858
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   859
/*     MOD    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   860
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   861
#define __mod_(TYPENAME) __arith_static(__mod_, TYPENAME, % )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   862
ANY_INT(__mod_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   863
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   864
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   865
/*     AND    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   866
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   867
__arith_expand(__and_, BOOL, && )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   868
#define __and_(TYPENAME) __arith_expand(__and_, TYPENAME, & )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   869
ANY_NBIT(__and_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   870
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   871
/*************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   872
/*     OR    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   873
/*************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   874
__arith_expand(__or_, BOOL, || )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   875
#define __or_(TYPENAME) __arith_expand(__or_, TYPENAME, |)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   876
ANY_NBIT(__or_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   877
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   878
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   879
/*     XOR    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   880
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   881
static inline BOOL __xor_BOOL(EN_ENO_PARAMS, UINT param_count, BOOL op1, ...){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   882
  TEST_EN(BOOL)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   883
  va_list ap;
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   884
  UINT i;
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   885
  
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   886
  va_start (ap, op1);         /* Initialize the argument list.  */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   887
  
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   888
  for (i = 0; i < param_count - 1; i++){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   889
    BOOL tmp = va_arg (ap, VA_ARGS_BOOL);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   890
    op1 = (op1 && !tmp) || (!op1 && tmp);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   891
  }
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   892
  
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   893
  va_end (ap);                  /* Clean up.  */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   894
  return op1;
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   895
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   896
#define __xor_(TYPENAME) __arith_expand(__xor_, TYPENAME, ^)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   897
ANY_NBIT(__xor_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   898
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   899
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   900
/*     NOT    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   901
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   902
static inline BOOL __not_BOOL(EN_ENO_PARAMS, BOOL op1){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   903
  TEST_EN(BOOL)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   904
  return !op1;
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   905
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   906
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   907
#define __not_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   908
static inline TYPENAME __not_##TYPENAME(EN_ENO_PARAMS, TYPENAME op1){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   909
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   910
  return ~op1;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   911
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   912
ANY_NBIT(__not_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   913
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   914
/***************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   915
/*     MOVE    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   916
/***************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   917
#define __move_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   918
static inline TYPENAME __move_##TYPENAME(EN_ENO_PARAMS, TYPENAME op1){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   919
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   920
  return op1;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   921
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   922
ANY(__move_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   923
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   924
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   925
/* Binary ops */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   926
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   927
#define __shift_(fname, TYPENAME, OP)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   928
static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, TYPENAME IN, USINT N) {\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   929
  TEST_EN_COND(TYPENAME, N < 0)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   930
  return IN OP N;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   931
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   932
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   933
#define __shl_(TYPENAME) __shift_(__shl_, TYPENAME, << )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   934
/* Call previously defined macro for each ANY_NBIT */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   935
ANY_NBIT(__shl_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   936
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   937
#define __shr_(TYPENAME) __shift_(__shr_, TYPENAME, >> )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   938
/* Call previously defined macro for each ANY_NBIT */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   939
ANY_NBIT(__shr_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   940
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   941
#define __ror_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   942
static inline TYPENAME __ror_##TYPENAME(EN_ENO_PARAMS, TYPENAME IN, USINT N){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   943
  TEST_EN_COND(TYPENAME, N < 0)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   944
  N %= 8*sizeof(TYPENAME);\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   945
  return (IN >> N) | (IN << 8*sizeof(TYPENAME)-N);\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   946
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   947
/* Call previously defined macro for each ANY_NBIT */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   948
ANY_NBIT(__ror_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   949
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   950
#define __rol_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   951
static inline TYPENAME __rol_##TYPENAME(EN_ENO_PARAMS, TYPENAME IN, USINT N){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   952
  TEST_EN_COND(TYPENAME, N < 0)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   953
  N %= 8*sizeof(TYPENAME);\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   954
  return (IN << N) | (IN >> 8*sizeof(TYPENAME)-N);\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   955
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   956
/* Call previously defined macro for each ANY_NBIT */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   957
ANY_NBIT(__rol_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   958
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   959
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   960
/* Selection  */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   961
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   962
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   963
  /**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   964
  /*    SEL     */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   965
  /**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   966
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   967
#define __sel_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   968
static inline TYPENAME __sel_##TYPENAME(EN_ENO_PARAMS, BOOL G, TYPENAME op0, TYPENAME op1){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   969
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   970
  return G ? op1 : op0;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   971
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   972
ANY(__sel_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   973
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   974
	/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   975
	/*   limit    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   976
	/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   977
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   978
#define __limit_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   979
static inline TYPENAME __limit_##TYPENAME(EN_ENO_PARAMS, TYPENAME MN, TYPENAME IN, TYPENAME MX){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   980
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   981
  return IN > MN ? IN < MX ? IN : MX : MN;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   982
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   983
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   984
/* Call previously defined macro for each concerned type */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   985
ANY_NBIT(__limit_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   986
ANY_NUM(__limit_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   987
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   988
#define __limit_time(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   989
static inline TYPENAME __limit_##TYPENAME(EN_ENO_PARAMS, TYPENAME MN, TYPENAME IN, TYPENAME MX){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   990
    TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   991
    return __TIME_CMP(IN, MN) > 0 ? /* IN>MN ?*/\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   992
           __TIME_CMP(IN, MX) < 0 ? /* IN<MX ?*/\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   993
           IN : MX : MN;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   994
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   995
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   996
/* Call previously defined macro for each concerned type */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   997
ANY_DATE(__limit_time)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   998
__limit_time(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   999
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1000
static inline STRING __limit_STRING(EN_ENO_PARAMS, STRING MN, STRING IN, STRING MX){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1001
    TEST_EN(STRING)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1002
    return __STR_CMP(IN, MN) > 0 ? __STR_CMP(IN, MX) < 0 ? IN : MX : MN;
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1003
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1004
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1005
    /**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1006
    /*     MAX    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1007
    /**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1008
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1009
#define __extrem_(fname,TYPENAME, COND) \
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1010
static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, UINT param_count, TYPENAME op1, ...){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1011
  TEST_EN(TYPENAME)\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1012
  va_list ap;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1013
  UINT i;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1014
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1015
  va_start (ap, op1);         /* Initialize the argument list.  */\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1016
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1017
  for (i = 0; i < param_count; i++){\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1018
    TYPENAME tmp = va_arg (ap, VA_ARGS_##TYPENAME);\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1019
    op1 = COND ? tmp : op1;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1020
  }\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1021
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1022
  va_end (ap);                  /* Clean up.  */\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1023
  return op1;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1024
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1025
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1026
#define __max_num(TYPENAME) __extrem_(__max_,TYPENAME, op1 < tmp)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1027
ANY_NBIT(__max_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1028
ANY_NUM(__max_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1029
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1030
__extrem_(__max_, STRING, __STR_CMP(op1,tmp) < 0)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1031
#define __max_time(TYPENAME) __extrem_(__max_, TYPENAME, __TIME_CMP(op1, tmp) < 0)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1032
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1033
/* Call previously defined macro for each concerned type */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1034
ANY_DATE(__max_time)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1035
__max_time(TIME)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1036
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1037
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1038
    /*     MIN    */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1039
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1040
#define __min_num(TYPENAME) __extrem_(__min, TYPENAME, op1 > tmp)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1041
ANY_NBIT(__min_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1042
ANY_NUM(__min_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1043
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1044
__extrem_(__min, STRING, __STR_CMP(op1,tmp) > 0)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1045
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1046
#define __min_time(TYPENAME) __extrem_(__min_, TYPENAME, __TIME_CMP(op1, tmp) > 0)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1047
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1048
/* Call previously defined macro for each concerned type */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1049
ANY_DATE(__min_time)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1050
__min_time(TIME)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1051
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1052
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1053
    /*     MUX    */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1054
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1055
#define __mux_(TYPENAME) \
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1056
static inline TYPENAME __mux_##TYPENAME(EN_ENO_PARAMS, UINT param_count, UINT K, ...){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1057
  TEST_EN_COND(TYPENAME, K < 0 || K >= param_count)\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1058
  va_list ap;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1059
  UINT i;\
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
  1060
  TYPENAME tmp = __INIT_##TYPENAME;\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1061
  \
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
  1062
  va_start (ap, K);         /* Initialize the argument list.  */\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1063
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1064
  for (i = 0; i < param_count; i++){\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1065
    if(K == i){\
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
  1066
        tmp = va_arg (ap, VA_ARGS_##TYPENAME);\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1067
        va_end (ap);                  /* Clean up.  */\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1068
        return tmp;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1069
    }else{\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1070
        va_arg (ap, VA_ARGS_##TYPENAME);\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1071
    }\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1072
  }\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1073
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1074
  va_end (ap);                  /* Clean up.  */\
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
  1075
  return tmp;\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1076
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1077
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1078
ANY(__mux_)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1079
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1080
/**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1081
/* Comparison */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1082
/**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1083
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1084
#define __compare_(fname,TYPENAME, COND) \
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1085
static inline BOOL fname##TYPENAME(EN_ENO_PARAMS, UINT param_count, TYPENAME op1, ...){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1086
  TEST_EN(BOOL)\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1087
  va_list ap;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1088
  UINT i;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1089
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1090
  va_start (ap, op1);         /* Initialize the argument list.  */\
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1091
  DBG(#fname #TYPENAME "\n")\
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1092
  DBG_TYPE(TYPENAME, op1)\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1093
  \
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1094
  for (i = 0; i < param_count - 1; i++){\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1095
    TYPENAME tmp = va_arg (ap, VA_ARGS_##TYPENAME);\
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1096
    DBG_TYPE(TYPENAME, tmp)\
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1097
    if(COND){\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1098
        op1 = tmp;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1099
    }else{\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1100
        va_end (ap);                  /* Clean up.  */\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1101
        return 0;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1102
    }\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1103
  }\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1104
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1105
  va_end (ap);                  /* Clean up.  */\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1106
  return 1;\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1107
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1108
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1109
#define __compare_num(fname, TYPENAME, TEST) __compare_(fname, TYPENAME, op1 TEST tmp )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1110
#define __compare_time(fname, TYPENAME, TEST) __compare_(fname, TYPENAME, __TIME_CMP(op1, tmp) TEST 0)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1111
#define __compare_string(fname, TEST) __compare_(fname, STRING, __STR_CMP(op1, tmp) TEST 0 )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1112
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1113
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1114
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1115
    /*     GT     */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1116
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1117
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1118
#define __gt_num(TYPENAME) __compare_num(__gt_, TYPENAME, > )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1119
ANY_NBIT(__gt_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1120
ANY_NUM(__gt_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1121
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1122
#define __gt_time(TYPENAME) __compare_time(__gt_, TYPENAME, > )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1123
ANY_DATE(__gt_time)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1124
__gt_time(TIME)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1125
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1126
__compare_string(__gt_, > )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1127
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1128
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1129
    /*     GE     */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1130
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1131
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1132
#define __ge_num(TYPENAME) __compare_num(__ge_, TYPENAME, >= )
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1133
ANY_BIT(__ge_num)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1134
ANY_NUM(__ge_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1135
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1136
#define __ge_time(TYPENAME) __compare_time(__ge_, TYPENAME, >= )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1137
ANY_DATE(__ge_time)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1138
__ge_time(TIME)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1139
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1140
__compare_string(__ge_, >=)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1141
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1142
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1143
    /*     EQ     */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1144
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1145
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1146
#define __eq_num(TYPENAME) __compare_num(__eq_, TYPENAME, == )
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1147
ANY_BIT(__eq_num)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1148
ANY_NUM(__eq_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1149
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1150
#define __eq_time(TYPENAME) __compare_time(__eq_, TYPENAME, == )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1151
ANY_DATE(__eq_time)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1152
__eq_time(TIME)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1153
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1154
__compare_string(__eq_, == )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1155
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1156
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1157
    /*     LT     */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1158
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1159
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1160
#define __lt_num(TYPENAME) __compare_num(__lt_, TYPENAME, < )
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1161
ANY_BIT(__lt_num)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1162
ANY_NUM(__lt_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1163
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1164
#define __lt_time(TYPENAME) __compare_time(__lt_, TYPENAME, < )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1165
ANY_DATE(__lt_time)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1166
__lt_time(TIME)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1167
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1168
__compare_string(__lt_, < )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1169
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1170
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1171
    /*     LE     */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1172
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1173
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1174
#define __le_num(TYPENAME) __compare_num(__le_, TYPENAME, <= )
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1175
ANY_BIT(__le_num)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1176
ANY_NUM(__le_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1177
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1178
#define __le_time(TYPENAME) __compare_time(__le_, TYPENAME, <= )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1179
ANY_DATE(__le_time)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1180
__le_time(TIME)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1181
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1182
__compare_string(__le_, <= )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1183
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1184
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1185
    /*     NE     */
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1186
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1187
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1188
#define __ne_num(TYPENAME) __compare_num(__ne_, TYPENAME, != )
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1189
ANY_BIT(__ne_num)
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1190
ANY_NUM(__ne_num)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1191
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1192
#define __ne_time(TYPENAME) __compare_time(__ne_, TYPENAME, != )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1193
ANY_DATE(__ne_time)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1194
__ne_time(TIME)
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1195
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1196
__compare_string(__ne_, != )
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1197
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1198
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1199
///* Get string representation of variable referenced by a void pointer
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1200
// * where type is given as its number */
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1201
//#define __decl_str_case(cat,TYPENAME) \
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1202
//    case TYPENAME##_ENUM:\
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1203
//        return __##cat##_to_string(*(TYPENAME*)p);
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1204
//#define __decl_str_case_bit(TYPENAME) __decl_str_case(bit,TYPENAME)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1205
//#define __decl_str_case_real(TYPENAME) __decl_str_case(real,TYPENAME)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1206
//#define __decl_str_case_sint(TYPENAME) __decl_str_case(sint,TYPENAME)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1207
//#define __decl_str_case_uint(TYPENAME) __decl_str_case(uint,TYPENAME)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1208
//static inline STRING __get_type_enum_str(__IEC_types_enum t, void* p){
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1209
// switch(t){
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1210
//  __decl_str_case(bool,BOOL)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1211
//  ANY_NBIT(__decl_str_case_bit)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1212
//  ANY_REAL(__decl_str_case_real)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1213
//  ANY_SINT(__decl_str_case_sint)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1214
//  ANY_UINT(__decl_str_case_uint)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1215
//  __decl_str_case(time,TIME)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1216
//  __decl_str_case(date,DATE)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1217
//  __decl_str_case(tod,TOD)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1218
//  __decl_str_case(dt, DT)
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1219
// }
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1220
//}
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1221
//
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1222
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1223
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1224
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1225
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1226
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
  1227