lib/C/iec_std_lib.h
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 06 May 2016 10:48:37 +0300
changeset 1005 e27c2af708ad
parent 905 31224f8cac32
child 1021 21a97cdb317d
permissions -rwxr-xr-x
fix C compilation warning from gcc about /* inside of comment section.


./beremiz/iec_std_lib.h:240:1: error: "/*" within comment [-Werror=comment]
/*
^
compilation terminated due to -Wfatal-errors.
cc1: all warnings being treated as errors
107
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     1
/*
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
     2
 * copyright 2008 Edouard TISSERANT
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
     3
 * copyright 2011 Mario de Sousa (msousa@fe.up.pt)
107
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     4
 *
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     5
 * Offered to the public under the terms of the GNU Lesser General Public
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     6
 * License as published by the Free Software Foundation; either version 2
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     7
 * of the License, or (at your option) any later version.
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     8
 *
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
     9
 * This program is distributed in the hope that it will be useful, but
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    10
 * WITHOUT ANY WARRANTY; without even the implied warranty of
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    12
 * General Public License for more details.
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    13
 *
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    14
 * This code is made available on the understanding that it will not be
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    15
 * used in safety-critical situations without a full and competent review.
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    16
 */
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    17
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
    18
/****
107
ff5c92df0c78 Fixed headers of generated code
etisserant
parents: 66
diff changeset
    19
 * 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
    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
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    22
/* NOTE: This file is full of (what may seem at first) very strange macros.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    23
 *       If you want to know what all these strange macros are doing,
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    24
 *       just parse this file through a C preprocessor (e.g. cpp), 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    25
 *       and analyse the output!
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    26
 *       $gcc -E iec_std_lib.h 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    27
 */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    28
739
Mario de Sousa <msousa@fe.up.pt>
parents: 700
diff changeset
    29
#ifndef _IEC_STD_LIB_H
Mario de Sousa <msousa@fe.up.pt>
parents: 700
diff changeset
    30
#define _IEC_STD_LIB_H
Mario de Sousa <msousa@fe.up.pt>
parents: 700
diff changeset
    31
Mario de Sousa <msousa@fe.up.pt>
parents: 700
diff changeset
    32
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
    33
#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
    34
#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
    35
#include <math.h>
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    36
#include <stdint.h>
707
e666763ac743 Fix undefined function toupper in iec_std_lib
Laurent Bessard
parents: 706
diff changeset
    37
#include <ctype.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
    38
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    39
#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
    40
#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
    41
#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
    42
#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
    43
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    44
#ifdef DEBUG_IEC
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    45
#define DBG(...) printf(__VA_ARGS__);
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    46
#define DBG_TYPE(TYPENAME, name) __print_##TYPENAME(name);
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    47
#else
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    48
#define DBG(...)
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    49
#define DBG_TYPE(TYPENAME, name)
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    50
#endif
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
    51
137
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
    52
/*
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
    53
 * Include type defs.
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
    54
 */
9ceda59abd27 Re-organized types headers, to ease debug code generation
etisserant
parents: 129
diff changeset
    55
#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
    56
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    57
extern TIME __CURRENT_TIME;
140
8c0366d41e84 Added __DEBUG global var to eventually change PLC code execution
etisserant
parents: 137
diff changeset
    58
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
    59
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
    60
/* 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
    61
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
    62
    __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
    63
    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
    64
} 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
    65
*/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    66
/*
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    67
# if __WORDSIZE == 64
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    68
#define __32b_sufix
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    69
#define __64b_sufix L
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    70
#else
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    71
#define __32b_sufix L
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
    72
#define __64b_sufix LL
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
    73
#endif
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    74
*/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    75
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    76
# if __WORDSIZE == 64
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    77
#define __32b_sufix
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    78
#define __64b_sufix L
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    79
#else
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    80
#define __32b_sufix L
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    81
/* changed this from LL to L temporarily. It was causing a bug when compiling resulting code with gcc.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    82
 * I have other things to worry about at the moment.. 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    83
 */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    84
#define __64b_sufix L   
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    85
#endif
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
    86
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    87
582
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
    88
#define __lit(type,value,...) (type)value##__VA_ARGS__
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
    89
// Keep this macro expention step to let sfx(__VA_ARGS__) change into L or LL
638
049748e9410a Fix bug with NE function for STRING variables
Laurent Bessard
parents: 625
diff changeset
    90
#define __literal(type,value,...) __lit(type,value,__VA_ARGS__)
582
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
    91
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
    92
#define __BOOL_LITERAL(value) __literal(BOOL,value)
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
    93
#define __SINT_LITERAL(value) __literal(SINT,value)
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
    94
#define __INT_LITERAL(value) __literal(INT,value)
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    95
#define __DINT_LITERAL(value) __literal(DINT,value,__32b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    96
#define __LINT_LITERAL(value) __literal(LINT,value,__64b_sufix)
582
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
    97
#define __USINT_LITERAL(value) __literal(USINT,value)
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
    98
#define __UINT_LITERAL(value) __literal(UINT,value)
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
    99
#define __UDINT_LITERAL(value) __literal(UDINT,value,__32b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   100
#define __ULINT_LITERAL(value) __literal(ULINT,value,__64b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   101
#define __REAL_LITERAL(value) __literal(REAL,value,__32b_sufix)
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   102
#define __LREAL_LITERAL(value) __literal(LREAL,value,__64b_sufix)
582
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
   103
#define __TIME_LITERAL(value) __literal(TIME,value)
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
   104
#define __DATE_LITERAL(value) __literal(DATE,value)
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
   105
#define __TOD_LITERAL(value) __literal(TOD,value)
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
   106
#define __DT_LITERAL(value) __literal(DT,value)
625
c0bda77b37a0 Merge with c2546c6e0cfa5ad55b288895f17f1b9f2a228f3b
Laurent Bessard
parents: 593
diff changeset
   107
#define __STRING_LITERAL(count,value) (STRING){count,value}
582
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
   108
#define __BYTE_LITERAL(value) __literal(BYTE,value)
8495119e7271 Fix structure initialize.
Manuele conti <conti.ma@alice.it>
parents: 539
diff changeset
   109
#define __WORD_LITERAL(value) __literal(WORD,value)
57
db9cadaab2ea Now generated SoftPLC compiles with mingw32 and run windows.
etisserant
parents: 55
diff changeset
   110
#define __DWORD_LITERAL(value) __literal(DWORD,value,__32b_sufix)
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   111
#define __LWORD_LITERAL(value) __literal(LWORD,value,__64b_sufix)
55
8b7a21820737 Started support for long long (LL suffix) 64 bit literals on 32 bit platforms (unfinished)
etisserant
parents: 48
diff changeset
   112
8b7a21820737 Started support for long long (LL suffix) 64 bit literals on 32 bit platforms (unfinished)
etisserant
parents: 48
diff changeset
   113
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
   114
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
   115
    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
   116
873a5b60a7ea Fixed -I 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
    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
   118
    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
   119
    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
   120
    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
   121
873a5b60a7ea Fixed -I 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
    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
   123
    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
   124
    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
   125
    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
   126
873a5b60a7ea Fixed -I 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
    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
   128
    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
   129
    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
   130
    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
   131
873a5b60a7ea Fixed -I 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
    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
   133
    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
   134
873a5b60a7ea Fixed -I 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
    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
   136
    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
   137
    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
   138
    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
   139
} __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
   140
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   141
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   142
/**********************************************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   143
/**********************************************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   144
/*****                                                            *****/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   145
/*****      Some helper functions...                              *****/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   146
/*****                     ...used later:                         *****/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   147
/*****    - when declaring the IEC 61131-3 standard functions     *****/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   148
/*****    - in the C source code itself in SFC and ST expressions *****/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   149
/*****                                                            *****/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   150
/**********************************************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   151
/**********************************************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   152
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   153
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   154
/****************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   155
/* Notify IEC runtime error */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   156
/****************************/
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
   157
873a5b60a7ea Fixed -I 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
/* function that generates an IEC runtime error */
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   159
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
   160
  /* 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
   161
  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
   162
  /*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
   163
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   164
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   165
/*******************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   166
/* Time normalization function */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   167
/*******************************/
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
   168
254
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   169
static inline void __normalize_timespec (IEC_TIMESPEC *ts) {
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
   170
  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
   171
    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
   172
    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
   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
  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
   175
    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
   176
    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
   177
  }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   178
}
873a5b60a7ea Fixed -I 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
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   180
/**********************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   181
/* Time conversion to/from timespec functions */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   182
/**********************************************/
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   183
/* NOTE: The following function was turned into a macro, so it could be used to initialize the initial value of TIME variables.
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   184
 *       Since each macro parameter is evaluated several times, the macro may result in multiple function invocations if an expression
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   185
 *       containing a function invocation is passed as a parameter. However, currently matiec only uses this conversion macro with 
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   186
 *       constant literals, so it is safe to change it into a macro.
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   187
 */
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   188
/* NOTE: I (Mario - msousa@fe.up.pt) believe that the following function contains a bug when handling negative times.
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   189
 *       The equivalent macro has this bug fixed.
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   190
 *       e.g.;
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   191
 *          T#3.8s
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   192
 *       using the function, will result in a timespec of 3.8s !!!: 
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   193
 *          tv_sec  =  4               <-----  1 *  3.8           is rounded up when converting a double to an int!
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   194
 *          tv_nsec = -200 000 000     <-----  1 * (3.8 - 4)*1e9
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   195
 * 
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   196
 *         -T#3.8s
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   197
 *       using the function, will result in a timespec of -11.8s !!!: 
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   198
 *          tv_sec  = -4                 <-----  -1 *  3.8 is rounded down when converting a double to an int!
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   199
 *          tv_nsec = -7 800 000 000     <-----  -1 * (3.8 - -4)*1e9
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   200
 */
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   201
/* NOTE: Due to the fact that the C compiler may round a tv_sec number away from zero, 
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   202
 *       the following macro may result in a timespec that is not normalized, i.e. with a tv_sec > 0, and a tv_nsec < 0 !!!!
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   203
 *       This is due to the rounding that C compiler applies when converting a (long double) to a (long int).
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   204
 *       To produce normalized timespec's we need to use floor(), but we cannot call any library functions since we want this macro to be 
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   205
 *       useable as a variable initializer.
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   206
 *       VAR x : TIME = T#3.5h; END_VAR --->  IEC_TIME x = __time_to_timespec(1, 0, 0, 0, 3.5, 0);
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   207
 */
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   208
/*
254
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   209
static inline IEC_TIMESPEC __time_to_timespec(int sign, double mseconds, double seconds, double minutes, double hours, double days) {
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   210
  IEC_TIMESPEC ts;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   211
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   212
  // sign is 1 for positive values, -1 for negative 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
   213
  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
   214
  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
   215
  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
   216
  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
   217
873a5b60a7ea Fixed -I 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
  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
   219
}
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   220
*/
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   221
/* NOTE: Unfortunately older versions of ANSI C (e.g. C99) do not allow explicit identification of elements in initializers
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   222
 *         e.g.  {tv_sec = 1, tv_nsec = 300}
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   223
 *       They are therefore commented out. This however means that any change to the definition of IEC_TIMESPEC may require this
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   224
 *       macro to be updated too!
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   225
 */
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   226
#define __time_to_timespec(sign,mseconds,seconds,minutes,hours,days) \
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   227
          ((IEC_TIMESPEC){\
903
f712705bef65 Fix stupid mistake in previous commit (use 'long double' instead of 'ld' in istandard library macro)
mjsousa
parents: 900
diff changeset
   228
              /*tv_sec  =*/ ((long int)   (((sign>=0)?1:-1)*((((long double)days*24 + (long double)hours)*60 + (long double)minutes)*60 + (long double)seconds + (long double)mseconds/1e3))), \
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   229
              /*tv_nsec =*/ ((long int)(( \
903
f712705bef65 Fix stupid mistake in previous commit (use 'long double' instead of 'ld' in istandard library macro)
mjsousa
parents: 900
diff changeset
   230
                            ((long double)(((sign>=0)?1:-1)*((((long double)days*24 + (long double)hours)*60 + (long double)minutes)*60 + (long double)seconds + (long double)mseconds/1e3))) - \
f712705bef65 Fix stupid mistake in previous commit (use 'long double' instead of 'ld' in istandard library macro)
mjsousa
parents: 900
diff changeset
   231
                            ((long int)   (((sign>=0)?1:-1)*((((long double)days*24 + (long double)hours)*60 + (long double)minutes)*60 + (long double)seconds + (long double)mseconds/1e3)))   \
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   232
                            )*1e9))\
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   233
        })
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   234
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   235
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   236
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   237
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   238
/* NOTE: The following function was turned into a macro, so it could be used to initialize the initial value of TOD (TIME_OF_DAY) variables */
1005
e27c2af708ad fix C compilation warning from gcc about /* inside of comment section.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 905
diff changeset
   239
/* NOTE: many (but not all) of the same comments made regarding __time_to_timespec() are also valid here, so go and read those comments too!*/
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   240
/*
254
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   241
static inline IEC_TIMESPEC __tod_to_timespec(double seconds, double minutes, double hours) {
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   242
  IEC_TIMESPEC ts;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   243
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
   244
  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
   245
  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
   246
  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
   247
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
   248
  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
   249
}
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   250
*/
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   251
#define __tod_to_timespec(seconds,minutes,hours) \
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   252
          ((IEC_TIMESPEC){\
903
f712705bef65 Fix stupid mistake in previous commit (use 'long double' instead of 'ld' in istandard library macro)
mjsousa
parents: 900
diff changeset
   253
              /*tv_sec  =*/ ((long int)   ((((long double)hours)*60 + (long double)minutes)*60 + (long double)seconds)), \
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   254
              /*tv_nsec =*/ ((long int)(( \
903
f712705bef65 Fix stupid mistake in previous commit (use 'long double' instead of 'ld' in istandard library macro)
mjsousa
parents: 900
diff changeset
   255
                            ((long double)((((long double)hours)*60 + (long double)minutes)*60 + (long double)seconds)) - \
f712705bef65 Fix stupid mistake in previous commit (use 'long double' instead of 'ld' in istandard library macro)
mjsousa
parents: 900
diff changeset
   256
                            ((long int)   ((((long double)hours)*60 + (long double)minutes)*60 + (long double)seconds))   \
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   257
                            )*1e9))\
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   258
        })
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   259
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
   260
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   261
#define EPOCH_YEAR 1970
714
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   262
#define SECONDS_PER_MINUTE 60
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   263
#define SECONDS_PER_HOUR (60 * SECONDS_PER_MINUTE)
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   264
#define SECONDS_PER_DAY (24 * SECONDS_PER_HOUR)
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   265
#define __isleap(year) \
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   266
  ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   267
static const unsigned short int __mon_yday[2][13] =
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   268
{
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   269
  /* Normal years.  */
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   270
  { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   271
  /* Leap years.  */
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   272
  { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   273
};
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   274
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   275
typedef struct {
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   276
	int tm_sec;			/* Seconds.	[0-60] (1 leap second) */
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   277
	int tm_min;			/* Minutes.	[0-59] */
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   278
	int tm_hour;			/* Hours.	[0-23] */
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   279
	int tm_day;			/* Day.		[1-31] */
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   280
	int tm_mon;			/* Month.	[0-11] */
900
1e749c7b70f8 Fix time conversion function in std library, and change into macro (so it may be used in variable initialisations)
mjsousa
parents: 818
diff changeset
   281
	int tm_year;			/* Year	*/
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   282
} tm;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   283
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   284
static inline tm convert_seconds_to_date_and_time(long int seconds) {
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   285
  tm dt;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   286
  long int days, rem;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   287
  days = seconds / SECONDS_PER_DAY;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   288
  rem = seconds % SECONDS_PER_DAY;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   289
  if (rem < 0) {
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   290
	  rem += SECONDS_PER_DAY;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   291
	  days--;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   292
  }
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   293
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   294
  // time of day
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   295
  dt.tm_hour = rem / SECONDS_PER_HOUR;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   296
  rem %= SECONDS_PER_HOUR;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   297
  dt.tm_min = rem / 60;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   298
  dt.tm_sec = rem % 60;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   299
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   300
  // date
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   301
  dt.tm_year = EPOCH_YEAR;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   302
  while (days >= (rem = __isleap(dt.tm_year) ? 366 : 365)) {
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   303
	  dt.tm_year++;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   304
	  days -= rem;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   305
  }
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   306
  while (days < 0) {
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   307
	  dt.tm_year--;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   308
	  days += __isleap(dt.tm_year) ? 366 : 365;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   309
  }
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   310
  dt.tm_mon = 1;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   311
  while (days > __mon_yday[__isleap(dt.tm_year)][dt.tm_mon]) {
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   312
	  dt.tm_mon += 1;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   313
  }
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   314
  dt.tm_day = days - __mon_yday[__isleap(dt.tm_year)][dt.tm_mon - 1] + 1;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   315
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   316
  return dt;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   317
}
709
bca119630cf6 Fixed timegm usage incompatible with mingw, reverted to mktime in case mingw is detected
Edouard Tisserant
parents: 707
diff changeset
   318
254
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   319
static inline IEC_TIMESPEC __date_to_timespec(int day, int month, int year) {
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   320
  IEC_TIMESPEC ts;
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   321
  int a4, b4, a100, b100, a400, b400;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   322
  int yday;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   323
  int intervening_leap_days;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   324
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   325
  if (month < 1 || month > 12)
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   326
	 __iec_error();
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   327
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   328
  yday = __mon_yday[__isleap(year)][month - 1] + day;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   329
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   330
  if (yday > __mon_yday[__isleap(year)][month])
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   331
	  __iec_error();
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   332
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   333
  a4 = (year >> 2) - ! (year & 3);
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   334
  b4 = (EPOCH_YEAR >> 2) - ! (EPOCH_YEAR & 3);
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   335
  a100 = a4 / 25 - (a4 % 25 < 0);
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   336
  b100 = b4 / 25 - (b4 % 25 < 0);
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   337
  a400 = a100 >> 2;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   338
  b400 = b100 >> 2;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   339
  intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
705
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   340
  
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   341
  ts.tv_sec = ((year - EPOCH_YEAR) * 365 + intervening_leap_days + yday - 1) * 24 * 60 * 60;
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
   342
  ts.tv_nsec = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   343
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   344
  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
   345
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   346
705
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   347
static inline IEC_TIMESPEC __dt_to_timespec(double seconds, double minutes, double hours, int day, int month, int year) {
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   348
  IEC_TIMESPEC ts_date = __date_to_timespec(day, month, year);
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   349
  IEC_TIMESPEC ts = __tod_to_timespec(seconds, minutes, hours);
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   350
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   351
  ts.tv_sec += ts_date.tv_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
   352
873a5b60a7ea Fixed -I 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
  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
   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
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   356
/*******************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   357
/* Time operations */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   358
/*******************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   359
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   360
#define __time_cmp(t1, t2) (t2.tv_sec == t1.tv_sec ? t1.tv_nsec - t2.tv_nsec : t1.tv_sec - t2.tv_sec)
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   361
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   362
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
   363
  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
   364
             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
   365
  __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
   366
  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
   367
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   368
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
   369
  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
   370
             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
   371
  __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
   372
  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
   373
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   374
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
   375
  LREAL s_f = IN1.tv_sec * IN2;
639
f0ef73eceb57 Fix some warning about loss of precision data in iec_std_lib.h file.
Edouard Tisserant
parents: 638
diff changeset
   376
  time_t s = (time_t)s_f;
700
b0ef6711f2a8 Fix some warning about loss of precision data in iec_std_lib.h file.
Manuele Conti <conti.ma@alice.it>
parents: 696
diff changeset
   377
  div_t ns = div((int)((LREAL)IN1.tv_nsec * IN2), 1000000000);
639
f0ef73eceb57 Fix some warning about loss of precision data in iec_std_lib.h file.
Edouard Tisserant
parents: 638
diff changeset
   378
  TIME res = {(long)s + ns.quot,
f0ef73eceb57 Fix some warning about loss of precision data in iec_std_lib.h file.
Edouard Tisserant
parents: 638
diff changeset
   379
		      (long)ns.rem + (s_f - s) * 1000000000 };
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
   380
  __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
   381
  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
   382
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   383
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
   384
  LREAL s_f = IN1.tv_sec / IN2;
639
f0ef73eceb57 Fix some warning about loss of precision data in iec_std_lib.h file.
Edouard Tisserant
parents: 638
diff changeset
   385
  time_t s = (time_t)s_f;
f0ef73eceb57 Fix some warning about loss of precision data in iec_std_lib.h file.
Edouard Tisserant
parents: 638
diff changeset
   386
  TIME res = {(long)s,
f0ef73eceb57 Fix some warning about loss of precision data in iec_std_lib.h file.
Edouard Tisserant
parents: 638
diff changeset
   387
              (long)(IN1.tv_nsec / IN2 + (s_f - s) * 1000000000) };
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
   388
  __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
   389
  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
   390
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   391
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   392
873a5b60a7ea Fixed -I 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
/***************/
873a5b60a7ea Fixed -I 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
/* 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
   395
/***************/
314
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   396
    /*****************/
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   397
    /*  REAL_TO_INT  */
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   398
    /*****************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   399
static inline LINT __real_round(LREAL IN) {
314
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   400
	return fmod(IN, 1) == 0 ? ((LINT)IN / 2) * 2 : (LINT)IN;
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   401
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   402
static inline LINT __preal_to_sint(LREAL IN) {
314
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   403
   return IN >= 0 ? __real_round(IN + 0.5) : __real_round(IN - 0.5);
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   404
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   405
static inline LINT __preal_to_uint(LREAL IN) {
314
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   406
   return IN >= 0 ? __real_round(IN + 0.5) : 0;
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   407
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   408
static inline LINT __real_to_sint(LREAL IN)  {return (LINT)__preal_to_sint(IN);}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   409
static inline LWORD __real_to_bit(LREAL IN)  {return (LWORD)__preal_to_uint(IN);}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   410
static inline ULINT __real_to_uint(LREAL IN) {return (ULINT)__preal_to_uint(IN);}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   411
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
   412
    /***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   413
    /*  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
   414
    /***************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   415
static inline STRING __bool_to_string(BOOL IN) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   416
    if(IN) return (STRING){4, "TRUE"};
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   417
    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
   418
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   419
static inline STRING __bit_to_string(LWORD IN) {
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   420
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   421
    res = __INIT_STRING;
389
94b67e38188a silenced warning on X86_64 build by casying numerical operand of snprintf
Edouard Tisserant
parents: 384
diff changeset
   422
    res.len = snprintf((char*)res.body, STR_MAX_LEN, "16#%llx",(long long unsigned int)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
   423
    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
   424
    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
   425
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   426
static inline STRING __real_to_string(LREAL IN) {
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   427
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   428
    res = __INIT_STRING;
114
28cf5bddeb9f cast fir gcc4 fix in lib
etisserant
parents: 107
diff changeset
   429
    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
   430
    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
   431
    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
   432
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   433
static inline STRING __sint_to_string(LINT IN) {
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   434
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   435
    res = __INIT_STRING;
389
94b67e38188a silenced warning on X86_64 build by casying numerical operand of snprintf
Edouard Tisserant
parents: 384
diff changeset
   436
    res.len = snprintf((char*)res.body, STR_MAX_LEN, "%lld", (long long int)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
   437
    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
   438
    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
   439
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   440
static inline STRING __uint_to_string(ULINT IN) {
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   441
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   442
    res = __INIT_STRING;
389
94b67e38188a silenced warning on X86_64 build by casying numerical operand of snprintf
Edouard Tisserant
parents: 384
diff changeset
   443
    res.len = snprintf((char*)res.body, STR_MAX_LEN, "%llu", (long long unsigned int)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
   444
    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
   445
    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
   446
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   447
    /***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   448
    /* 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
   449
    /***************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   450
static inline BOOL __string_to_bool(STRING IN) {
705
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   451
    int i;
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   452
    if (IN.len == 1) return !memcmp(&IN.body,"1", IN.len);
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   453
    for (i = 0; i < IN.len; i++) IN.body[i] = toupper(IN.body[i]);
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   454
    return IN.len == 4 ? !memcmp(&IN.body,"TRUE", IN.len) : 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
   455
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   456
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   457
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
   458
    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
   459
    __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
   460
    unsigned int shift = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   461
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
   462
    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
   463
        /* 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
   464
        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
   465
        {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   466
            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
   467
            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
   468
                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
   469
                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
   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
    }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
   473
        /* 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
   474
        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
   475
        {
873a5b60a7ea Fixed -I 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
            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
   477
            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
   478
                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
   479
                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
   480
            }
873a5b60a7ea Fixed -I 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
        }
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   482
    }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
   483
        /* 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
   484
        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
   485
        {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   486
            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
   487
            if( c >= '0' && c <= '9'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   488
                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
   489
                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
   490
            }else if( c >= 'a' && c <= 'f'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   491
                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
   492
                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
   493
            }else if( c >= 'A' && c <= 'F'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   494
                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
   495
                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
   496
            }
873a5b60a7ea Fixed -I 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
        }
873a5b60a7ea Fixed -I 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
    }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
   499
        /* -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
   500
        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
   501
        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
   502
        {
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   503
            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
   504
            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
   505
                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
   506
                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
   507
                shift += 1;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   508
            }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
   509
                res = 0;
163
61f65dd6eeb9 Fixed errors in string_to_int.
etisserant
parents: 161
diff changeset
   510
                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
   511
                shift = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   512
            }
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
        }
873a5b60a7ea Fixed -I 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
    }
873a5b60a7ea Fixed -I 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
    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
   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
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   518
static inline LINT  __string_to_sint(STRING IN) {return (LINT)__pstring_to_sint(&IN);}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   519
static inline LWORD __string_to_bit (STRING IN) {return (LWORD)__pstring_to_sint(&IN);}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   520
static inline ULINT __string_to_uint(STRING IN) {return (ULINT)__pstring_to_sint(&IN);}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   521
static inline LREAL __string_to_real(STRING IN) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   522
    __strlen_t l;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   523
    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
   524
    /* 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
   525
    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
   526
    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
   527
        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
   528
    }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
   529
        return (LREAL)__pstring_to_sint(&IN);
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   530
    }
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
   531
}
873a5b60a7ea Fixed -I 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
    /***************/
873a5b60a7ea Fixed -I 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
    /*   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
   535
    /***************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   536
static inline TIME    __int_to_time(LINT IN)  {return (TIME){IN, 0};}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   537
static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   538
static inline TIME __string_to_time(STRING IN){
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   539
    __strlen_t 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
   540
    /* 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
   541
     *
873a5b60a7ea Fixed -I 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
     *  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
   543
     *                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
   544
     *                                        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
   545
     *                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
   546
     *  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
   547
     *                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
   548
     *                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
   549
     *                                        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
   550
     *
873a5b60a7ea Fixed -I 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
     *  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
   552
     *  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
   553
     *  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
   554
     *  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
   555
     *  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
   556
     *  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
   557
     *  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
   558
     *
873a5b60a7ea Fixed -I 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
     */
873a5b60a7ea Fixed -I 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
    /* 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
   561
    /* search the dot */
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   562
    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
   563
    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
   564
    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
   565
        LREAL IN_val = atof((const char *)&IN.body);
639
f0ef73eceb57 Fix some warning about loss of precision data in iec_std_lib.h file.
Edouard Tisserant
parents: 638
diff changeset
   566
        return  (TIME){(long)IN_val, (long)(IN_val - (LINT)IN_val)*1000000000};
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
   567
    }else{
639
f0ef73eceb57 Fix some warning about loss of precision data in iec_std_lib.h file.
Edouard Tisserant
parents: 638
diff changeset
   568
        return  (TIME){(long)__pstring_to_sint(&IN), 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
   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
}
873a5b60a7ea Fixed -I 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
873a5b60a7ea Fixed -I 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
    /***************/
873a5b60a7ea Fixed -I 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
    /*  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
   574
    /***************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   575
static inline LREAL __time_to_real(TIME 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
   576
    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
   577
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   578
static inline LINT __time_to_int(TIME IN) {return IN.tv_sec;}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   579
static inline STRING __time_to_string(TIME IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   580
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   581
    div_t days;
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
   582
    /*t#5d14h12m18s3.5ms*/
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   583
    res = __INIT_STRING;
714
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   584
    days = div(IN.tv_sec, SECONDS_PER_DAY);
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
   585
    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
   586
        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
   587
    }else{
714
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   588
        div_t hours = div(days.rem, SECONDS_PER_HOUR);
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
   589
        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
   590
            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
   591
        }else{
714
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   592
            div_t minuts = div(hours.rem, SECONDS_PER_MINUTE);
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
   593
            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
   594
                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
   595
            }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
   596
                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
   597
                    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
   598
                }else{
42
b45c7f34dec1 IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents: 41
diff changeset
   599
                    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
   600
                }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   601
            }
873a5b60a7ea Fixed -I 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
        }
873a5b60a7ea Fixed -I 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
    }
873a5b60a7ea Fixed -I 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
    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
   605
    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
   606
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   607
static inline STRING __date_to_string(DATE IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   608
    STRING res;
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   609
    tm broken_down_time;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   610
    /* D#1984-06-25 */
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   611
    broken_down_time = convert_seconds_to_date_and_time(IN.tv_sec);
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   612
    res = __INIT_STRING;
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   613
    res.len = snprintf((char*)&res.body, STR_MAX_LEN, "D#%d-%2.2d-%2.2d",
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   614
             broken_down_time.tm_year,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   615
             broken_down_time.tm_mon,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   616
             broken_down_time.tm_day);
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
   617
    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
   618
    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
   619
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   620
static inline STRING __tod_to_string(TOD IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   621
    STRING res;
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   622
    tm broken_down_time;
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   623
    time_t 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
   624
    /* TOD#15:36:55.36 */
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   625
    seconds = IN.tv_sec;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   626
    if (seconds >= SECONDS_PER_DAY){
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   627
		__iec_error();
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   628
		return (STRING){9,"TOD#ERROR"};
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   629
	}
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   630
    broken_down_time = convert_seconds_to_date_and_time(seconds);
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   631
    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
   632
    if(IN.tv_nsec == 0){
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   633
        res.len = snprintf((char*)&res.body, STR_MAX_LEN, "TOD#%2.2d:%2.2d:%2.2d",
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   634
                 broken_down_time.tm_hour,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   635
                 broken_down_time.tm_min,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   636
                 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
   637
    }else{
803
36ac3a58be39 Fixed bug in string format when translating TIME and DATETIME to STRING
Laurent Bessard
parents: 799
diff changeset
   638
        res.len = snprintf((char*)&res.body, STR_MAX_LEN, "TOD#%2.2d:%2.2d:%09.6f",
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   639
                 broken_down_time.tm_hour,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   640
                 broken_down_time.tm_min,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   641
                 (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
   642
    }
873a5b60a7ea Fixed -I 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
    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
   644
    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
   645
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   646
static inline STRING __dt_to_string(DT IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   647
    STRING res;
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   648
    tm broken_down_time;
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   649
    /* DT#1984-06-25-15:36:55.36 */
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   650
    broken_down_time = convert_seconds_to_date_and_time(IN.tv_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
   651
    if(IN.tv_nsec == 0){
705
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   652
        res.len = snprintf((char*)&res.body, STR_MAX_LEN, "DT#%d-%2.2d-%2.2d-%2.2d:%2.2d:%2.2d",
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   653
                 broken_down_time.tm_year,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   654
                 broken_down_time.tm_mon,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   655
                 broken_down_time.tm_day,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   656
                 broken_down_time.tm_hour,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   657
                 broken_down_time.tm_min,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   658
                 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
   659
    }else{
803
36ac3a58be39 Fixed bug in string format when translating TIME and DATETIME to STRING
Laurent Bessard
parents: 799
diff changeset
   660
        res.len = snprintf((char*)&res.body, STR_MAX_LEN, "DT#%d-%2.2d-%2.2d-%2.2d:%2.2d:%09.6f",
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   661
                 broken_down_time.tm_year,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   662
                 broken_down_time.tm_mon,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   663
                 broken_down_time.tm_day,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   664
                 broken_down_time.tm_hour,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   665
                 broken_down_time.tm_min,
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   666
                 (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
   667
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   668
    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
   669
    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
   670
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   671
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   672
    /**********************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   673
    /*  [ANY_DATE | TIME] _TO_ [ANY_DATE | TIME]  */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   674
    /**********************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   675
714
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   676
static inline TOD __date_and_time_to_time_of_day(DT IN) {
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   677
	return (TOD){
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   678
		IN.tv_sec % SECONDS_PER_DAY + (IN.tv_sec < 0 ? SECONDS_PER_DAY : 0),
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   679
		IN.tv_nsec};
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   680
}
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   681
static inline DATE __date_and_time_to_date(DT IN){
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   682
	return (DATE){
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   683
		IN.tv_sec - IN.tv_sec % SECONDS_PER_DAY - (IN.tv_sec < 0 ? SECONDS_PER_DAY : 0),
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   684
		0};
91fe96900800 Fixed bug in DATE_AND_TIME_TO_TIME_OF_DAY and DATE_AND_TIME_TO_DATE when date and time is before 1970-01-01-00:00:00
Laurent Bessard
parents: 712
diff changeset
   685
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   686
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   687
    /*****************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   688
    /*  FROM/TO BCD  */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   689
    /*****************/
715
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   690
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   691
static inline BOOL __test_bcd(LWORD IN) {
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   692
	while (IN) {
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   693
		if ((IN & 0xf) > 9) return 1;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   694
		IN >>= 4;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   695
	}
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   696
	return 0;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   697
}
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   698
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   699
static inline ULINT __bcd_to_uint(LWORD IN){
715
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   700
    ULINT res = IN & 0xf;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   701
    ULINT factor = 10ULL;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   702
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   703
    while (IN >>= 4) {
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   704
        res += (IN & 0xf) * factor;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   705
        factor *= 10;
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   706
    }
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   707
    return res;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   708
}
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   709
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   710
static inline LWORD __uint_to_bcd(ULINT IN){
715
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   711
    LWORD res = IN % 10;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   712
    USINT shift = 4;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   713
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   714
    while (IN /= 10) {
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   715
        res |= (IN % 10) << shift;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   716
        shift += 4;
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   717
    }
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   718
    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
   719
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   720
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   721
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   722
    /************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   723
    /*  MOVE_*  */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   724
    /************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   725
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   726
/* some helpful __move_[ANY] functions, used in the *_TO_** and MOVE  standard functions */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   727
/* e.g. __move_BOOL, __move_BYTE, __move_REAL, __move_TIME, ... */
393
f09a5ffe1edc Fixing SUB standard function defined in standard library
laurent
parents: 389
diff changeset
   728
#define __move_(TYPENAME)\
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   729
static inline TYPENAME __move_##TYPENAME(TYPENAME op1) {return op1;}
393
f09a5ffe1edc Fixing SUB standard function defined in standard library
laurent
parents: 389
diff changeset
   730
__ANY(__move_)
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   731
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   732
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   733
905
31224f8cac32 Move standard FBs to a pre-converted C file, insted of converting them every time along with the IEC source.
mjsousa
parents: 904
diff changeset
   734
31224f8cac32 Move standard FBs to a pre-converted C file, insted of converting them every time along with the IEC source.
mjsousa
parents: 904
diff changeset
   735
31224f8cac32 Move standard FBs to a pre-converted C file, insted of converting them every time along with the IEC source.
mjsousa
parents: 904
diff changeset
   736
31224f8cac32 Move standard FBs to a pre-converted C file, insted of converting them every time along with the IEC source.
mjsousa
parents: 904
diff changeset
   737
31224f8cac32 Move standard FBs to a pre-converted C file, insted of converting them every time along with the IEC source.
mjsousa
parents: 904
diff changeset
   738
31224f8cac32 Move standard FBs to a pre-converted C file, insted of converting them every time along with the IEC source.
mjsousa
parents: 904
diff changeset
   739
#include "iec_std_functions.h"
31224f8cac32 Move standard FBs to a pre-converted C file, insted of converting them every time along with the IEC source.
mjsousa
parents: 904
diff changeset
   740
#include "iec_std_FB.h"
739
Mario de Sousa <msousa@fe.up.pt>
parents: 700
diff changeset
   741
Mario de Sousa <msousa@fe.up.pt>
parents: 700
diff changeset
   742
#endif /* _IEC_STD_LIB_H */