lib/iec_std_lib.h
author Mario de Sousa <msousa@fe.up.pt>
Mon, 04 Apr 2011 11:19:48 +0100
changeset 269 98fc461e1888
parent 217 f5dfadf5de54
child 254 28bd86c56793
child 280 69a307407f7b
permissions -rwxr-xr-x
Fixing stupid bug (that was disabling code generation).
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
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
    60
#define __64b_sufix LL
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
    61
#endif
57
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
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
    64
// Keep this macro expention step to let sfx change into L or LL
57
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,)
217
f5dfadf5de54 Adding support for declare, init, get and set macros
laurent
parents: 212
diff changeset
    82
#define __STRING_LITERAL(count,value) (STRING){count,value}
57
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;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   164
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
   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;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   177
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
   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);
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   181
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
   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;
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   188
  time_t epoch_seconds;
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
   189
873a5b60a7ea Fixed -I 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_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
   191
  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
   192
  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
   193
  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
   194
  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
   195
  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
   196
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   197
  epoch_seconds = mktime(&broken_down_time); /* determine number of seconds since the epoch, i.e. Jan 1st 1970 */
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
   198
873a5b60a7ea Fixed -I 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
  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
   200
    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
   201
873a5b60a7ea Fixed -I 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_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
   203
  ts.tv_nsec = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   204
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
   205
  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
   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
873a5b60a7ea Fixed -I 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
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
   209
  struct timespec ts;
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   210
  struct tm broken_down_time;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   211
  time_t epoch_seconds;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   212
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
   213
  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
   214
  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
   215
  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
   216
873a5b60a7ea Fixed -I 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_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
   218
  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
   219
  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
   220
  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
   221
  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
   222
  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
   223
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   224
  epoch_seconds = mktime(&broken_down_time); /* determine number of seconds since the epoch, i.e. Jan 1st 1970 */
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
   225
  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
   226
    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
   227
873a5b60a7ea Fixed -I 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
  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
   229
  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
   230
    /* 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
   231
    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
   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
  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
   234
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   235
149
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
/*   EN/ENO PARAMS  */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   238
/********************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   239
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   240
#define EN_ENO_PARAMS BOOL EN, BOOL *ENO
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   241
#define TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   242
  if (!EN) {\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   243
    if (ENO != NULL)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   244
      *ENO = __BOOL_LITERAL(FALSE);\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   245
    return __INIT_##TYPENAME;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   246
  }\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   247
  else if (ENO != NULL)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   248
    *ENO = __BOOL_LITERAL(TRUE);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   249
#define TEST_EN_COND(TYPENAME, COND)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   250
  if (!EN || (COND)) {\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   251
    if (ENO != NULL)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   252
      *ENO = __BOOL_LITERAL(FALSE);\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   253
    return __INIT_##TYPENAME;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   254
  }\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   255
  else if (ENO != NULL)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   256
    *ENO = __BOOL_LITERAL(TRUE);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   257
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
   258
/***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   259
/*   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
   260
/***************/
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   261
#define __TIME_CMP(t1, t2) (t2.tv_sec == t1.tv_sec ? t1.tv_nsec - t2.tv_nsec : t1.tv_sec - t2.tv_sec)
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   262
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   263
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
   264
  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
   265
             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
   266
  __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
   267
  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
   268
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   269
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
   270
  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
   271
             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
   272
  __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
   273
  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
   274
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   275
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
   276
  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
   277
  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
   278
  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
   279
  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
   280
              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
   281
  __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
   282
  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
   283
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   284
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
   285
  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
   286
  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
   287
  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
   288
              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
   289
  __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
   290
  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
   291
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   292
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   293
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
   294
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   295
  return (TIME){IN.tv_sec % 86400, IN.tv_nsec};
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   296
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   297
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
   298
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   299
  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
   300
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   301
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
   302
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   303
  return __TIME_ADD(IN1, IN2);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   304
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   305
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
   306
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   307
  return __TIME_SUB(IN1, IN2);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   308
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   309
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
   310
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   311
  return __TIME_MUL(IN1, IN2);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   312
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   313
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
   314
  TEST_EN(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   315
  return __TIME_DIV(IN1, IN2);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   316
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   317
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
   318
/***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   319
/* 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
   320
/***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   321
#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
   322
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   323
static inline __strlen_t __len(EN_ENO_PARAMS, STRING IN){
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   324
    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
   325
    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
   326
}
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   327
static inline STRING __left(EN_ENO_PARAMS, STRING IN, __strlen_t L){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   328
    STRING res;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   329
    TEST_EN_COND(STRING, L < 0)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   330
    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
   331
    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
   332
    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
   333
    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
   334
    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
   335
}
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   336
static inline STRING __right(EN_ENO_PARAMS, STRING IN, __strlen_t L){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   337
    STRING res;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   338
    TEST_EN_COND(STRING, L < 0)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   339
    res = __INIT_STRING;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   340
    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
   341
    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
   342
    res.len = L;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   343
    return res;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   344
}
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   345
static inline STRING __mid(EN_ENO_PARAMS, STRING IN, __strlen_t L, __strlen_t P){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   346
    STRING res;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   347
    TEST_EN_COND(STRING, L < 0 || P < 0)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   348
    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
   349
    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
   350
	    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
   351
	    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
   352
	    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
   353
        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
   354
    }
873a5b60a7ea Fixed -I 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
    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
   356
}
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   357
static inline STRING __concat(EN_ENO_PARAMS, UINT param_count, ...){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   358
  UINT i;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   359
  STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   360
  va_list ap;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   361
  __strlen_t charcount;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   362
  TEST_EN(STRING)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   363
  charcount = 0;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   364
  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
   365
873a5b60a7ea Fixed -I 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
  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
   367
873a5b60a7ea Fixed -I 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
  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
   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
    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
   371
    __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
   372
    __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
   373
    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
   374
    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
   375
  }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   376
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   377
  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
   378
873a5b60a7ea Fixed -I 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
  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
   380
  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
   381
}
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   382
static inline STRING __insert(EN_ENO_PARAMS, STRING IN1, STRING IN2, __strlen_t P){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   383
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   384
    __strlen_t to_copy;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   385
    TEST_EN_COND(STRING, P < 0)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   386
    res = __INIT_STRING;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   387
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   388
    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
   389
    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
   390
    P = res.len = to_copy;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   391
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
   392
    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
   393
    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
   394
    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
   395
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   396
    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
   397
    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
   398
    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
   399
873a5b60a7ea Fixed -I 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
    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
   401
}
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   402
static inline STRING __delete(EN_ENO_PARAMS, STRING IN, __strlen_t L, __strlen_t P){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   403
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   404
    __strlen_t to_copy;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   405
    TEST_EN_COND(STRING, L < 0 || P < 0)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   406
    res = __INIT_STRING;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   407
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   408
    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
   409
    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
   410
    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
   411
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   412
    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
   413
        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
   414
        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
   415
        res.len += to_copy;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   416
    }
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   417
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   418
    return res;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   419
}
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   420
static inline STRING __replace(EN_ENO_PARAMS, STRING IN1, STRING IN2, __strlen_t L, __strlen_t P){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   421
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   422
    __strlen_t to_copy;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   423
    TEST_EN_COND(STRING, L < 0 || P < 0)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   424
    res = __INIT_STRING;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   425
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   426
    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
   427
    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
   428
    P = res.len = to_copy;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   429
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   430
    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
   431
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   432
    if( to_copy + res.len > STR_MAX_LEN )
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   433
       to_copy = STR_MAX_LEN - res.len;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   434
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
   435
    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
   436
    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
   437
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   438
    P += L;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   439
    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
   440
    {
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   441
        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
   442
        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
   443
        res.len += to_copy;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   444
    }
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   445
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   446
    return res;
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   447
}
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   448
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   449
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   450
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   451
static inline __strlen_t __pfind(STRING* IN1, STRING* IN2){
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   452
    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
   453
    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
   454
    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
   455
    {
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   456
        if(IN1->body[count1 + count2] != IN2->body[count2]){
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   457
            count1 += count2 + 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
   458
            count2 = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   459
        }
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   460
        else {
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   461
            count2++;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   462
        }
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
   463
    }
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   464
    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
   465
}
161
a27957e13d42 STRING max size and length type can now be overloaded (define STR_MAX_LEN and STR_LEN_TYPE before including iec_types.h)
etisserant
parents: 156
diff changeset
   466
static inline __strlen_t __find(EN_ENO_PARAMS, STRING IN1, STRING IN2){
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   467
    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
   468
    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
   469
}
873a5b60a7ea Fixed -I 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
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   471
/***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   472
/* 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
   473
/***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   474
    /***************/
873a5b60a7ea Fixed -I 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
    /*  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
   476
    /***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   477
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
   478
{
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   479
    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
   480
    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
   481
        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
   482
    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
   483
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   484
static inline STRING __bit_to_string(EN_ENO_PARAMS, LWORD IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   485
    STRING res;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   486
    TEST_EN(STRING)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   487
    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, "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
   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 __real_to_string(EN_ENO_PARAMS, LREAL IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   493
    STRING res;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   494
    TEST_EN(STRING)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   495
    res = __INIT_STRING;
114
28cf5bddeb9f cast fir gcc4 fix in lib
etisserant
parents: 107
diff changeset
   496
    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
   497
    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
   498
    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
   499
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   500
static inline STRING __sint_to_string(EN_ENO_PARAMS, LINT IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   501
    STRING res;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   502
    TEST_EN(STRING)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   503
    res = __INIT_STRING;
114
28cf5bddeb9f cast fir gcc4 fix in lib
etisserant
parents: 107
diff changeset
   504
    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
   505
    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
   506
    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
   507
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   508
static inline STRING __uint_to_string(EN_ENO_PARAMS, ULINT IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   509
    STRING res;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   510
    TEST_EN(STRING)
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   511
    res = __INIT_STRING;
114
28cf5bddeb9f cast fir gcc4 fix in lib
etisserant
parents: 107
diff changeset
   512
    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
   513
    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
   514
    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
   515
}
873a5b60a7ea Fixed -I 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
    /***************/
873a5b60a7ea Fixed -I 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
    /* 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
   518
    /***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   519
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
   520
    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
   521
    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
   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
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   524
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
   525
    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
   526
    __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
   527
    unsigned int shift = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   528
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
   529
    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
   530
        /* 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
   531
        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
   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
            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
   534
            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
   535
                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
   536
                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
   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
        }
873a5b60a7ea Fixed -I 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
    }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
   540
        /* 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
   541
        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
   542
        {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   543
            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
   544
            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
   545
                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
   546
                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
   547
            }
873a5b60a7ea Fixed -I 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
        }
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   549
    }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
   550
        /* 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
   551
        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
   552
        {
873a5b60a7ea Fixed -I 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
            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
   554
            if( c >= '0' && c <= '9'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   555
                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
   556
                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
   557
            }else if( c >= 'a' && c <= 'f'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   558
                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
   559
                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
   560
            }else if( c >= 'A' && c <= 'F'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   561
                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
   562
                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
   563
            }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   564
        }
873a5b60a7ea Fixed -I 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
    }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
   566
        /* -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
   567
        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
   568
        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
   569
        {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   570
            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
   571
            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
   572
                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
   573
                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
   574
                shift += 1;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   575
            }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
   576
                res = 0;
163
61f65dd6eeb9 Fixed errors in string_to_int.
etisserant
parents: 161
diff changeset
   577
                fac = IN->body[0] == '-' ? -1 : 1;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   578
                shift = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   579
            }
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
        }
873a5b60a7ea Fixed -I 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
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   582
    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
   583
}
873a5b60a7ea Fixed -I 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
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   585
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
   586
    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
   587
    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
   588
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   589
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
   590
    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
   591
    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
   592
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   593
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
   594
    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
   595
    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
   596
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   597
static inline LREAL __string_to_real(EN_ENO_PARAMS, STRING IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   598
	__strlen_t l;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   599
	TEST_EN(LREAL)
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   600
	l = IN.len;
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
   601
    /* 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
   602
    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
   603
    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
   604
        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
   605
    }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
   606
        return (LREAL)__pstring_to_sint(&IN);
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   607
    }
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
}
873a5b60a7ea Fixed -I 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
    /***************/
873a5b60a7ea Fixed -I 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
    /*   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
   612
    /***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   613
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
   614
    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
   615
    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
   616
}
873a5b60a7ea Fixed -I 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
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   618
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
   619
    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
   620
    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
   621
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   622
static inline TIME __string_to_time(EN_ENO_PARAMS, STRING IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   623
	__strlen_t l;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   624
	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
   625
    /* 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
   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
     *  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
   628
     *                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
   629
     *                                        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
   630
     *                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
   631
     *  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
   632
     *                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
   633
     *                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
   634
     *                                        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
   635
     *
873a5b60a7ea Fixed -I 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
     *  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
   637
     *  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
   638
     *  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
   639
     *  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
   640
     *  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
   641
     *  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
   642
     *  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
   643
     *
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   644
     */
873a5b60a7ea Fixed -I 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
    /* 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
   646
    /* search the dot */
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   647
	l = IN.len;
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
   648
    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
   649
    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
   650
        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
   651
        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
   652
    }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
   653
        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
   654
    }
873a5b60a7ea Fixed -I 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
}
873a5b60a7ea Fixed -I 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
873a5b60a7ea Fixed -I 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
    /***************/
873a5b60a7ea Fixed -I 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
    /*  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
   659
    /***************/
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   660
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
   661
    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
   662
    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
   663
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   664
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
   665
    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
   666
    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
   667
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   668
static inline STRING __time_to_string(EN_ENO_PARAMS, TIME IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   669
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   670
    div_t days;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   671
    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
   672
    /*t#5d14h12m18s3.5ms*/
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   673
    res = __INIT_STRING;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   674
    days = div(IN.tv_sec ,86400);
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
   675
    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
   676
        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
   677
    }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
   678
        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
   679
        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
   680
            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
   681
        }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
   682
            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
   683
            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
   684
                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
   685
            }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
   686
                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
   687
                    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
   688
                }else{
42
b45c7f34dec1 IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents: 41
diff changeset
   689
                    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
   690
                }
873a5b60a7ea Fixed -I 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
            }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   692
        }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   693
    }
873a5b60a7ea Fixed -I 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
    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
   695
    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
   696
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   697
static inline STRING __date_to_string(EN_ENO_PARAMS, DATE IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   698
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   699
    struct tm* broken_down_time;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   700
    time_t seconds;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   701
	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
   702
    /* D#1984-06-25 */
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   703
    res = __INIT_STRING;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   704
    seconds = IN.tv_sec;
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   705
    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
   706
        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
   707
        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
   708
    }
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   709
    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
   710
    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
   711
    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
   712
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   713
static inline STRING __tod_to_string(EN_ENO_PARAMS, TOD IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   714
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   715
    struct tm* broken_down_time;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   716
    time_t seconds;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   717
    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
   718
    /* TOD#15:36:55.36 */
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   719
    res = __INIT_STRING;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   720
    seconds = IN.tv_sec;
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   721
    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
   722
        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
   723
        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
   724
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   725
    if(IN.tv_nsec == 0){
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   726
        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
   727
    }else{
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   728
        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
   729
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   730
    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
   731
    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
   732
}
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   733
static inline STRING __dt_to_string(EN_ENO_PARAMS, DT IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   734
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   735
    struct tm* broken_down_time;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   736
    time_t seconds;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   737
    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
   738
    /* DT#1984-06-25-15:36:55.36 */
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   739
    seconds = IN.tv_sec;
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   740
    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
   741
        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
   742
        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
   743
    }
873a5b60a7ea Fixed -I 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
    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
   745
        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
   746
                 broken_down_time->tm_year,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   747
                 broken_down_time->tm_mon,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   748
                 broken_down_time->tm_mday,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   749
                 broken_down_time->tm_hour,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   750
                 broken_down_time->tm_min,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   751
                 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
   752
    }else{
42
b45c7f34dec1 IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents: 41
diff changeset
   753
        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
   754
                 broken_down_time->tm_year,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   755
                 broken_down_time->tm_mon,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   756
                 broken_down_time->tm_mday,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   757
                 broken_down_time->tm_hour,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   758
                 broken_down_time->tm_min,
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   759
                 (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
   760
    }
873a5b60a7ea Fixed -I 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
    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
   762
    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
   763
}
873a5b60a7ea Fixed -I 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
    /* BCD */
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   765
#define __bcd_digit(fac)
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   766
static inline ULINT __bcd_to_uint(EN_ENO_PARAMS, LWORD IN){
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   767
    ULINT res;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   768
    ULINT i;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   769
    TEST_EN(ULINT)
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   770
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   771
    res = IN & 0xf;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   772
    for(i = 10ULL; i <= 1000000000000000ULL; i *= 10){
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   773
        if(!(IN >>= 4))
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   774
            break;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   775
        res += (IN & 0xf) * i;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   776
    }
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   777
    return res;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   778
}
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   779
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   780
static inline LWORD __uint_to_bcd(EN_ENO_PARAMS, ULINT IN){
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   781
    LWORD res;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   782
    USINT i;
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   783
    TEST_EN(LWORD)
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   784
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   785
    res = IN % 10;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   786
    for(i = 4; i<=60; i += 4){
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   787
        if(!(IN /= 10))
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   788
            break;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   789
        res |= (IN % 10) << i;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   790
    }
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   791
    return res;
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
   792
}
873a5b60a7ea Fixed -I 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
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   794
/* workaround for va-atgs limitation on shorter that int params */
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
   795
#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
   796
#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
   797
#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
   798
#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
   799
#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
   800
#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
   801
#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
   802
#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
   803
#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
   804
#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
   805
#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
   806
#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
   807
#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
   808
#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
   809
#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
   810
#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
   811
#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
   812
#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
   813
#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
   814
#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
   815
#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
   816
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   817
/*******************************************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   818
/*     Arithmetic and bitwise functions    */
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
#define __arith_expand(fname,TYPENAME, OP) \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   821
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
   822
  va_list ap;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   823
  UINT i;\
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   824
  TEST_EN(TYPENAME)\
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   825
  \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   826
  va_start (ap, op1);         /* Initialize the argument list.  */\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   827
  \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   828
  for (i = 0; i < param_count - 1; i++){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   829
    op1 = op1 OP va_arg (ap, VA_ARGS_##TYPENAME);\
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
  \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   832
  va_end (ap);                  /* Clean up.  */\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   833
  return op1;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   834
}
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
#define __arith_static(fname,TYPENAME, OP) \
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   837
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
   838
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   839
  return op1 OP op2;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   840
}
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
/*     ADD    */
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 __add_(TYPENAME) __arith_expand(__add_, TYPENAME, + )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   846
ANY_NUM(__add_)
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
/*     MUL    */
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 __mul_(TYPENAME) __arith_expand(__mul_, TYPENAME, * )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   852
ANY_NUM(__mul_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   853
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   854
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   855
/*     SUB    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   856
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   857
#define __sub_(TYPENAME) __arith_static(__sub_, TYPENAME, - )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   858
ANY_NUM(__sub_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   859
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
/*     DIV    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   862
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   863
#define __div_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   864
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
   865
  TEST_EN_COND(TYPENAME, op2 == 0)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   866
  return op1 / op2;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   867
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   868
ANY_NUM(__div_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   869
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
/*     MOD    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   872
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   873
#define __mod_(TYPENAME) __arith_static(__mod_, TYPENAME, % )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   874
ANY_INT(__mod_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   875
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   876
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   877
/*     AND    */
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
__arith_expand(__and_, BOOL, && )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   880
#define __and_(TYPENAME) __arith_expand(__and_, TYPENAME, & )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   881
ANY_NBIT(__and_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   882
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   883
/*************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   884
/*     OR    */
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
__arith_expand(__or_, BOOL, || )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   887
#define __or_(TYPENAME) __arith_expand(__or_, TYPENAME, |)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   888
ANY_NBIT(__or_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   889
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   890
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   891
/*     XOR    */
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
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
   894
  va_list ap;
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   895
  UINT i;
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   896
  TEST_EN(BOOL)
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   897
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   898
  va_start (ap, op1);         /* Initialize the argument list.  */
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   899
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   900
  for (i = 0; i < param_count - 1; i++){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   901
    BOOL tmp = va_arg (ap, VA_ARGS_BOOL);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   902
    op1 = (op1 && !tmp) || (!op1 && tmp);
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   903
  }
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   904
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   905
  va_end (ap);                  /* Clean up.  */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   906
  return op1;
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   907
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   908
#define __xor_(TYPENAME) __arith_expand(__xor_, TYPENAME, ^)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   909
ANY_NBIT(__xor_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   910
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
/*     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
static inline BOOL __not_BOOL(EN_ENO_PARAMS, BOOL op1){
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   915
  TEST_EN(BOOL)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   916
  return !op1;
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   917
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   918
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   919
#define __not_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   920
static inline TYPENAME __not_##TYPENAME(EN_ENO_PARAMS, TYPENAME op1){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   921
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   922
  return ~op1;\
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
ANY_NBIT(__not_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   925
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
/*     MOVE    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   928
/***************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   929
#define __move_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   930
static inline TYPENAME __move_##TYPENAME(EN_ENO_PARAMS, TYPENAME op1){\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   931
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   932
  return op1;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   933
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   934
ANY(__move_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   935
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
/* Binary ops */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   938
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   939
#define __shift_(fname, TYPENAME, OP)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   940
static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, TYPENAME IN, USINT N) {\
156
6b16b7f8b527 Warning conditions on win32 fixed
greg
parents: 149
diff changeset
   941
  TEST_EN(TYPENAME)\
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   942
  return IN OP N;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   943
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   944
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   945
#define __shl_(TYPENAME) __shift_(__shl_, TYPENAME, << )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   946
/* Call previously defined macro for each ANY_NBIT */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   947
ANY_NBIT(__shl_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   948
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   949
#define __shr_(TYPENAME) __shift_(__shr_, TYPENAME, >> )
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   950
/* Call previously defined macro for each ANY_NBIT */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   951
ANY_NBIT(__shr_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   952
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   953
#define __ror_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   954
static inline TYPENAME __ror_##TYPENAME(EN_ENO_PARAMS, TYPENAME IN, USINT N){\
156
6b16b7f8b527 Warning conditions on win32 fixed
greg
parents: 149
diff changeset
   955
  TEST_EN(TYPENAME)\
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   956
  N %= 8*sizeof(TYPENAME);\
199
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
   957
  return (IN >> N) | (IN << (8*sizeof(TYPENAME)-N));\
149
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
/* Call previously defined macro for each ANY_NBIT */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   960
ANY_NBIT(__ror_)
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
#define __rol_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   963
static inline TYPENAME __rol_##TYPENAME(EN_ENO_PARAMS, TYPENAME IN, USINT N){\
156
6b16b7f8b527 Warning conditions on win32 fixed
greg
parents: 149
diff changeset
   964
  TEST_EN(TYPENAME)\
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   965
  N %= 8*sizeof(TYPENAME);\
199
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
   966
  return (IN << N) | (IN >> (8*sizeof(TYPENAME)-N));\
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   967
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   968
/* Call previously defined macro for each ANY_NBIT */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   969
ANY_NBIT(__rol_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
   970
165
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   971
/*******************************************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   972
/*     Arithmetic and bitwise functions    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   973
/*******************************************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   974
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   975
#define __numeric(fname,TYPENAME, FUNC) \
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   976
static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, TYPENAME op){\
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   977
  TEST_EN(TYPENAME)\
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   978
  return FUNC(op);\
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   979
}
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   980
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   981
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   982
  /*    ABS     */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
   983
  /**************/
187
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   984
#define __abs_signed(TYPENAME) \
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   985
static inline TYPENAME __abs_##TYPENAME(EN_ENO_PARAMS, TYPENAME op){\
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   986
  TEST_EN(TYPENAME)\
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   987
  if (op < 0)\
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   988
    return -op;\
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   989
  return op;\
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   990
}
187
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   991
ANY_REAL(__abs_signed)
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   992
ANY_SINT(__abs_signed)
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   993
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   994
#define __abs_unsigned(TYPENAME) \
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   995
static inline TYPENAME __abs_##TYPENAME(EN_ENO_PARAMS, TYPENAME op){\
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   996
  TEST_EN(TYPENAME)\
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   997
  return op;\
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   998
}
f2cd0b5236f7 Warning when compiling abs functions for unsigned integer fixed
lbessard
parents: 180
diff changeset
   999
ANY_UINT(__abs_unsigned)
165
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1000
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1001
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1002
  /*    SQRT    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1003
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1004
#define __sqrt_(TYPENAME) __numeric(__sqrt_, TYPENAME, sqrt)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1005
ANY_REAL(__sqrt_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1006
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1007
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1008
  /*     LN     */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1009
  /**************/
199
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1010
#define __ln_(TYPENAME) __numeric(__ln_, TYPENAME, log)
165
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1011
ANY_REAL(__ln_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1012
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1013
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1014
  /*     LOG    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1015
  /**************/
199
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1016
#define __log_(TYPENAME) __numeric(__log_, TYPENAME, log10)
165
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1017
ANY_REAL(__log_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1018
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1019
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1020
  /*     EXP    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1021
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1022
#define __exp_(TYPENAME) __numeric(__exp_, TYPENAME, exp)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1023
ANY_REAL(__exp_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1024
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1025
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1026
  /*     SIN    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1027
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1028
#define __sin_(TYPENAME) __numeric(__sin_, TYPENAME, sin)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1029
ANY_REAL(__sin_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1030
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1031
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1032
  /*     COS    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1033
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1034
#define __cos_(TYPENAME) __numeric(__cos_, TYPENAME, cos)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1035
ANY_REAL(__cos_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1036
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1037
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1038
  /*     TAN    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1039
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1040
#define __tan_(TYPENAME) __numeric(__tan_, TYPENAME, tan)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1041
ANY_REAL(__tan_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1042
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1043
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1044
  /*    ASIN    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1045
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1046
#define __asin_(TYPENAME) __numeric(__asin_, TYPENAME, asin)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1047
ANY_REAL(__asin_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1048
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1049
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1050
  /*    ACOS    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1051
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1052
#define __acos_(TYPENAME) __numeric(__acos_, TYPENAME, acos)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1053
ANY_REAL(__acos_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1054
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1055
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1056
  /*    ATAN    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1057
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1058
#define __atan_(TYPENAME) __numeric(__atan_, TYPENAME, atan)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1059
ANY_REAL(__atan_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1060
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1061
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1062
  /*    EXPT    */
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1063
  /**************/
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1064
#define __expt_(TYPENAME)\
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1065
static inline TYPENAME __expt_##TYPENAME(EN_ENO_PARAMS, TYPENAME IN1, REAL IN2){\
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1066
  TEST_EN(TYPENAME)\
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1067
  return pow(IN1, IN2);\
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1068
}ANY_REAL(__expt_)
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1069
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1070
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1071
/* Selection  */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1072
/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1073
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1074
  /**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1075
  /*    SEL     */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1076
  /**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1077
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1078
#define __sel_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1079
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
  1080
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1081
  return G ? op1 : op0;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1082
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1083
ANY(__sel_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1084
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1085
	/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1086
	/*   limit    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1087
	/**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1088
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1089
#define __limit_(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1090
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
  1091
  TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1092
  return IN > MN ? IN < MX ? IN : MX : MN;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1093
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1094
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1095
/* Call previously defined macro for each concerned type */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1096
ANY_NBIT(__limit_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1097
ANY_NUM(__limit_)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1098
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1099
#define __limit_time(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1100
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
  1101
    TEST_EN(TYPENAME)\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1102
    return __TIME_CMP(IN, MN) > 0 ? /* IN>MN ?*/\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1103
           __TIME_CMP(IN, MX) < 0 ? /* IN<MX ?*/\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1104
           IN : MX : MN;\
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1105
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1106
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1107
/* Call previously defined macro for each concerned type */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1108
ANY_DATE(__limit_time)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1109
__limit_time(TIME)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1110
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1111
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
  1112
    TEST_EN(STRING)
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1113
    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
  1114
}
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1115
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1116
    /**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1117
    /*     MAX    */
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1118
    /**************/
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1119
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
  1120
#define __extrem_(fname,TYPENAME, COND) \
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1121
static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, UINT param_count, 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
  1122
  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
  1123
  UINT i;\
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
  1124
  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
  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
  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
  1127
  \
165
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1128
  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
  1129
    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
  1130
    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
  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
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1133
  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
  1134
  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
  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
873a5b60a7ea Fixed -I 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
#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
  1138
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
  1139
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
  1140
873a5b60a7ea Fixed -I 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
__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
  1142
#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
  1143
873a5b60a7ea Fixed -I 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
/* 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
  1145
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
  1146
__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
  1147
873a5b60a7ea Fixed -I 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
    /**************/
873a5b60a7ea Fixed -I 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
    /*     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
  1150
    /**************/
165
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1151
#define __min_num(TYPENAME) __extrem_(__min_, TYPENAME, op1 > 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
  1152
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
  1153
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
  1154
165
83963465b773 Bug on standard function not defined with EN/ENO fixed
lbessard
parents: 163
diff changeset
  1155
__extrem_(__min_, STRING, __STR_CMP(op1,tmp) > 0)
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
  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
#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
  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
/* 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
  1160
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
  1161
__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
  1162
873a5b60a7ea Fixed -I 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
    /*     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
  1165
    /**************/
873a5b60a7ea Fixed -I 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
#define __mux_(TYPENAME) \
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1167
static inline TYPENAME __mux_##TYPENAME(EN_ENO_PARAMS, UINT param_count, UINT K, ...){\
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
  1168
  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
  1169
  UINT i;\
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
  1170
  TYPENAME tmp;\
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
  1171
  TEST_EN_COND(TYPENAME, K >= param_count)\
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
  1172
  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
  1173
  \
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
  1174
  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
  1175
  \
873a5b60a7ea Fixed -I 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
  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
  1177
    if(K == i){\
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
  1178
        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
  1179
        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
  1180
        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
  1181
    }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
  1182
        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
  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
  \
873a5b60a7ea Fixed -I 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
  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
  1187
  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
  1188
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1189
873a5b60a7ea Fixed -I 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(__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
  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
/**************/
873a5b60a7ea Fixed -I 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
/* 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
  1194
/**************/
873a5b60a7ea Fixed -I 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
#define __compare_(fname,TYPENAME, COND) \
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1197
static inline BOOL fname##TYPENAME(EN_ENO_PARAMS, UINT param_count, 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
  1198
  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
  1199
  UINT i;\
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
  1200
  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
  1201
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1202
  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
  1203
  DBG(#fname #TYPENAME "\n")\
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1204
  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
  1205
  \
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
  1206
  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
  1207
    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
  1208
    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
  1209
    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
  1210
        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
  1211
    }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
  1212
        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
  1213
        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
  1214
    }\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1215
  }\
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1216
  \
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1217
  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
  1218
  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
  1219
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1220
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1221
#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
  1222
#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
  1223
#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
  1224
149
05ca171a3d57 Adding support for EN/ENO in standard functions
lbessard
parents: 140
diff changeset
  1225
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
  1226
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1227
    /*     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
  1228
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1229
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1230
#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
  1231
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
  1232
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
  1233
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1234
#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
  1235
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
  1236
__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
  1237
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1238
__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
  1239
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1240
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1241
    /*     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
  1242
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1243
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1244
#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
  1245
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
  1246
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
  1247
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1248
#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
  1249
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
  1250
__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
  1251
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1252
__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
  1253
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1254
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1255
    /*     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
  1256
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1257
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1258
#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
  1259
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
  1260
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
  1261
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1262
#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
  1263
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
  1264
__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
  1265
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1266
__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
  1267
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1268
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1269
    /*     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
  1270
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1271
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1272
#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
  1273
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
  1274
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
  1275
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1276
#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
  1277
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
  1278
__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
  1279
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1280
__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
  1281
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1282
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1283
    /*     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
  1284
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1285
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1286
#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
  1287
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
  1288
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
  1289
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1290
#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
  1291
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
  1292
__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
  1293
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1294
__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
  1295
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1296
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1297
    /*     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
  1298
    /**************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1299
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1300
#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
  1301
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
  1302
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
  1303
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1304
#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
  1305
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
  1306
__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
  1307
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1308
__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
  1309
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
  1310
199
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1311
/* Get string representation of variable referenced by a void pointer
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1312
 * where type is given as its number */
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1313
/*#define __decl_str_case(cat,TYPENAME) \
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1314
    case TYPENAME##_ENUM:\
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1315
        return __##cat##_to_string(*(TYPENAME*)p);
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1316
#define __decl_str_case_bit(TYPENAME) __decl_str_case(bit,TYPENAME)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1317
#define __decl_str_case_real(TYPENAME) __decl_str_case(real,TYPENAME)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1318
#define __decl_str_case_sint(TYPENAME) __decl_str_case(sint,TYPENAME)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1319
#define __decl_str_case_uint(TYPENAME) __decl_str_case(uint,TYPENAME)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1320
static inline STRING __get_type_enum_str(__IEC_types_enum t, void* p){
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1321
 switch(t){
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1322
  __decl_str_case(bool,BOOL)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1323
  ANY_NBIT(__decl_str_case_bit)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1324
  ANY_REAL(__decl_str_case_real)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1325
  ANY_SINT(__decl_str_case_sint)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1326
  ANY_UINT(__decl_str_case_uint)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1327
  __decl_str_case(time,TIME)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1328
  __decl_str_case(date,DATE)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1329
  __decl_str_case(tod,TOD)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1330
  __decl_str_case(dt, DT)
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1331
 }
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1332
}
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1333
*/
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1334
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1335
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1336
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1337
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1338
b075f28ec081 Bug with type conversion EN/ENO not evaluated fixed
laurent
parents: 187
diff changeset
  1339