lib/C/iec_std_lib.h
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 28 Jun 2016 16:35:47 +0300
changeset 1021 21a97cdb317d
parent 1005 e27c2af708ad
parent 1011 76175defb87b
child 1033 dcf358607302
permissions -rwxr-xr-x
Merged mjsousa/matiec into default
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
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   165
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   166
/*******************/
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   167
/* Math Operations */
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   168
/*******************/
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   169
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   170
static inline double __expt(double in1, double in2) {
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   171
  return pow(in1, in2);
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   172
}
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   173
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   174
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   175
/*******************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   176
/* Time normalization function */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   177
/*******************************/
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   178
254
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   179
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
   180
  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
   181
    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
   182
    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
   183
  }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   184
  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
   185
    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
   186
    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
   187
  }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   188
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   189
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   190
/**********************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   191
/* 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
   192
/**********************************************/
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
   193
/* 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
   194
 *       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
   195
 *       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
   196
 *       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
   197
 */
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
/* 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
   199
 *       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
   200
 *       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
   201
 *          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
   202
 *       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
   203
 *          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
   204
 *          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
   205
 * 
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
 *         -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
   207
 *       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
   208
 *          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
   209
 *          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
   210
 */
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
   211
/* 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
   212
 *       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
   213
 *       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
   214
 *       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
   215
 *       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
   216
 *       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
   217
 */
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
   218
/*
254
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   219
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
   220
  IEC_TIMESPEC ts;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   221
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
   222
  // 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
   223
  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
   224
  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
   225
  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
   226
  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
   227
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   228
  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
   229
}
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
   230
*/
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
   231
/* 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
   232
 *         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
   233
 *       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
   234
 *       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
   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
#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
   237
          ((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
   238
              /*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
   239
              /*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
   240
                            ((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
   241
                            ((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
   242
                            )*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
   243
        })
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
   244
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
   245
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
   246
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
   247
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
   248
/* 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
   249
/* 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
   250
/*
254
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   251
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
   252
  IEC_TIMESPEC ts;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   253
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
   254
  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
   255
  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
   256
  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
   257
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   258
  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
   259
}
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
   260
*/
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
   261
#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
   262
          ((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
   263
              /*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
   264
              /*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
   265
                            ((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
   266
                            ((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
   267
                            )*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
   268
        })
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
   269
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   270
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   271
#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
   272
#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
   273
#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
   274
#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
   275
#define __isleap(year) \
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   276
  ((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
   277
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
   278
{
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   279
  /* Normal years.  */
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   280
  { 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
   281
  /* Leap years.  */
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   282
  { 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
   283
};
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   284
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   285
typedef struct {
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   286
	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
   287
	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
   288
	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
   289
	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
   290
	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
   291
	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
   292
} tm;
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
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
   295
  tm dt;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   296
  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
   297
  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
   298
  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
   299
  if (rem < 0) {
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   300
	  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
   301
	  days--;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   302
  }
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   303
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   304
  // time of day
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   305
  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
   306
  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
   307
  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
   308
  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
   309
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   310
  // date
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   311
  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
   312
  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
   313
	  dt.tm_year++;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   314
	  days -= rem;
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
  while (days < 0) {
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   317
	  dt.tm_year--;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   318
	  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
   319
  }
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   320
  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
   321
  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
   322
	  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
   323
  }
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   324
  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
   325
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   326
  return dt;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   327
}
709
bca119630cf6 Fixed timegm usage incompatible with mingw, reverted to mktime in case mingw is detected
Edouard Tisserant
parents: 707
diff changeset
   328
254
28bd86c56793 Initial TIME support in debugger
Edouard Tisserant
parents: 217
diff changeset
   329
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
   330
  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
   331
  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
   332
  int yday;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   333
  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
   334
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   335
  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
   336
	 __iec_error();
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   337
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   338
  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
   339
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   340
  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
   341
	  __iec_error();
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   342
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   343
  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
   344
  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
   345
  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
   346
  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
   347
  a400 = a100 >> 2;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   348
  b400 = b100 >> 2;
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   349
  intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
705
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   350
  
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   351
  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
   352
  ts.tv_nsec = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   353
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   354
  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
   355
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   356
705
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   357
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
   358
  IEC_TIMESPEC ts_date = __date_to_timespec(day, month, year);
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   359
  IEC_TIMESPEC ts = __tod_to_timespec(seconds, minutes, hours);
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   360
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   361
  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
   362
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   363
  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
   364
}
873a5b60a7ea Fixed -I 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
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   366
/*******************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   367
/* Time operations */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   368
/*******************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   369
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   370
#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
   371
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   372
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
   373
  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
   374
             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
   375
  __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
   376
  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
   377
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   378
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
   379
  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
   380
             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
   381
  __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
   382
  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
   383
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   384
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
   385
  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
   386
  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
   387
  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
   388
  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
   389
		      (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
   390
  __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
   391
  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
   392
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   393
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
   394
  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
   395
  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
   396
  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
   397
              (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
   398
  __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
   399
  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
   400
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   401
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   402
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   403
/***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   404
/* 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
   405
/***************/
314
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   406
    /*****************/
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   407
    /*  REAL_TO_INT  */
41d4ac0b4821 Fixing REAL_TO_INT conversion (behaved like a trunc and not like a round)
laurent
parents: 313
diff changeset
   408
    /*****************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   409
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
   410
	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
   411
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   412
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
   413
   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
   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 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
   416
   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
   417
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   418
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
   419
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
   420
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
   421
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
   422
    /***************/
873a5b60a7ea Fixed -I 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
    /*  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
   424
    /***************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   425
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
   426
    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
   427
    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
   428
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   429
static inline STRING __bit_to_string(LWORD IN) {
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   430
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   431
    res = __INIT_STRING;
389
94b67e38188a silenced warning on X86_64 build by casying numerical operand of snprintf
Edouard Tisserant
parents: 384
diff changeset
   432
    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
   433
    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
   434
    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
   435
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   436
static inline STRING __real_to_string(LREAL IN) {
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   437
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   438
    res = __INIT_STRING;
114
28cf5bddeb9f cast fir gcc4 fix in lib
etisserant
parents: 107
diff changeset
   439
    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
   440
    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
   441
    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
   442
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   443
static inline STRING __sint_to_string(LINT IN) {
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   444
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   445
    res = __INIT_STRING;
389
94b67e38188a silenced warning on X86_64 build by casying numerical operand of snprintf
Edouard Tisserant
parents: 384
diff changeset
   446
    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
   447
    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
   448
    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
   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 STRING __uint_to_string(ULINT IN) {
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   451
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   452
    res = __INIT_STRING;
389
94b67e38188a silenced warning on X86_64 build by casying numerical operand of snprintf
Edouard Tisserant
parents: 384
diff changeset
   453
    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
   454
    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
   455
    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
   456
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   457
    /***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   458
    /* 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
   459
    /***************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   460
static inline BOOL __string_to_bool(STRING IN) {
705
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   461
    int i;
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   462
    if (IN.len == 1) return !memcmp(&IN.body,"1", IN.len);
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   463
    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
   464
    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
   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
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   467
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
   468
    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
   469
    __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
   470
    unsigned int shift = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   471
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
   472
    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
   473
        /* 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
   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 <= '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
   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 += 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
   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
        }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   482
    }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
   483
        /* 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
   484
        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
   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 <= '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
   488
                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
   489
                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
   490
            }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   491
        }
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   492
    }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
   493
        /* 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
   494
        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
   495
        {
873a5b60a7ea Fixed -I 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
            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
   497
            if( c >= '0' && c <= '9'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   498
                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
   499
                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
   500
            }else if( c >= 'a' && c <= 'f'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   501
                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
   502
                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
   503
            }else if( c >= 'A' && c <= 'F'){
43
37dd4e2fd2ec Test IEC_LIB and fix bugs (EQ, GT et all)
etisserant
parents: 42
diff changeset
   504
                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
   505
                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
   506
            }
873a5b60a7ea Fixed -I 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
        }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   508
    }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
   509
        /* -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
   510
        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
   511
        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
   512
        {
873a5b60a7ea Fixed -I 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
            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
   514
            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
   515
                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
   516
                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
   517
                shift += 1;
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
   518
            }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
   519
                res = 0;
163
61f65dd6eeb9 Fixed errors in string_to_int.
etisserant
parents: 161
diff changeset
   520
                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
   521
                shift = 0;
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   522
            }
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
   523
        }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   524
    }
873a5b60a7ea Fixed -I 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
    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
   526
}
873a5b60a7ea Fixed -I 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
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   528
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
   529
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
   530
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
   531
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
   532
    __strlen_t l;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   533
    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
   534
    /* 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
   535
    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
   536
    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
   537
        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
   538
    }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
   539
        return (LREAL)__pstring_to_sint(&IN);
180
64334c5a00b1 Bug on "abs" not working with float fixed
greg
parents: 165
diff changeset
   540
    }
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   541
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   542
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   543
    /***************/
873a5b60a7ea Fixed -I 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
    /*   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
   545
    /***************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   546
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
   547
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
   548
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
   549
    __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
   550
    /* 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
   551
     *
873a5b60a7ea Fixed -I 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
     *  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
   553
     *                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
   554
     *                                        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
   555
     *                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
   556
     *  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
   557
     *                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
   558
     *                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
   559
     *                                        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
   560
     *
873a5b60a7ea Fixed -I 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
     *  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
   562
     *  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
   563
     *  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
   564
     *  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
   565
     *  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
   566
     *  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
   567
     *  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
   568
     *
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   569
     */
873a5b60a7ea Fixed -I 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
    /* 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
   571
    /* 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
   572
    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
   573
    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
   574
    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
   575
        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
   576
        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
   577
    }else{
639
f0ef73eceb57 Fix some warning about loss of precision data in iec_std_lib.h file.
Edouard Tisserant
parents: 638
diff changeset
   578
        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
   579
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   580
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   581
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   582
    /***************/
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   583
    /*  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
   584
    /***************/
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   585
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
   586
    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
   587
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   588
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
   589
static inline STRING __time_to_string(TIME IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   590
    STRING res;
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   591
    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
   592
    /*t#5d14h12m18s3.5ms*/
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   593
    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
   594
    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
   595
    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
   596
        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
   597
    }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
   598
        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
   599
        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
   600
            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
   601
        }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
   602
            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
   603
            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
   604
                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
   605
            }else{
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   606
                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
   607
                    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
   608
                }else{
42
b45c7f34dec1 IEC std lib test enhanced string ops, from string and to string conv.
etisserant
parents: 41
diff changeset
   609
                    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
   610
                }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   611
            }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   612
        }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   613
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   614
    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
   615
    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
   616
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   617
static inline STRING __date_to_string(DATE IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   618
    STRING res;
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   619
    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
   620
    /* 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
   621
    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
   622
    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
   623
    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
   624
             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
   625
             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
   626
             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
   627
    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
   628
    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
   629
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   630
static inline STRING __tod_to_string(TOD IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   631
    STRING res;
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   632
    tm broken_down_time;
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   633
    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
   634
    /* 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
   635
    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
   636
    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
   637
		__iec_error();
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   638
		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
   639
	}
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 = convert_seconds_to_date_and_time(seconds);
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   641
    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
   642
    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
   643
        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
   644
                 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
   645
                 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
   646
                 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
   647
    }else{
803
36ac3a58be39 Fixed bug in string format when translating TIME and DATETIME to STRING
Laurent Bessard
parents: 799
diff changeset
   648
        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
   649
                 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
   650
                 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
   651
                 (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
   652
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   653
    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
   654
    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
   655
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   656
static inline STRING __dt_to_string(DT IN){
200
fde2d08ebaee Applying patch from Iztok for old gcc versions
laurent
parents: 199
diff changeset
   657
    STRING res;
711
8a1ba3db05b2 Replacing libc time functions for date <-> timespec translation by platform and localtime independant implementation
Laurent Bessard
parents: 709
diff changeset
   658
    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
   659
    /* 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
   660
    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
   661
    if(IN.tv_nsec == 0){
705
f2323f79252e Fix DATE conversions standard functions
Laurent Bessard
parents: 704
diff changeset
   662
        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
   663
                 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
   664
                 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
   665
                 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
   666
                 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
   667
                 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
   668
                 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
   669
    }else{
803
36ac3a58be39 Fixed bug in string format when translating TIME and DATETIME to STRING
Laurent Bessard
parents: 799
diff changeset
   670
        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
   671
                 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
   672
                 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
   673
                 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
   674
                 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
   675
                 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
   676
                 (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
   677
    }
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   678
    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
   679
    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
   680
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   681
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   682
    /**********************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   683
    /*  [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
   684
    /**********************************************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   685
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
   686
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
   687
	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
   688
		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
   689
		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
   690
}
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
   691
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
   692
	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
   693
		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
   694
		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
   695
}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   696
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   697
    /*****************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   698
    /*  FROM/TO BCD  */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   699
    /*****************/
715
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   700
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   701
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
   702
	while (IN) {
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   703
		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
   704
		IN >>= 4;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   705
	}
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   706
	return 0;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   707
}
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   708
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   709
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
   710
    ULINT res = IN & 0xf;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   711
    ULINT factor = 10ULL;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   712
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   713
    while (IN >>= 4) {
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   714
        res += (IN & 0xf) * factor;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   715
        factor *= 10;
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   716
    }
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   717
    return res;
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   718
}
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   719
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   720
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
   721
    LWORD res = IN % 10;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   722
    USINT shift = 4;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   723
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   724
    while (IN /= 10) {
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   725
        res |= (IN % 10) << shift;
134f110060db Added support for testing BCD value validity in BCD_TO_UINT function
Laurent Bessard
parents: 714
diff changeset
   726
        shift += 4;
212
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   727
    }
8c9ec7d37d3a Fix some warnings on compilation
greg
parents: 200
diff changeset
   728
    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
   729
}
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents:
diff changeset
   730
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
    /*  MOVE_*  */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   734
    /************/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   735
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   736
/* 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
   737
/* 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
   738
#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
   739
static inline TYPENAME __move_##TYPENAME(TYPENAME op1) {return op1;}
393
f09a5ffe1edc Fixing SUB standard function defined in standard library
laurent
parents: 389
diff changeset
   740
__ANY(__move_)
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   741
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   742
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 314
diff changeset
   743
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
   744
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
   745
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
   746
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
   747
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
   748
#include "iec_std_functions.h"
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   749
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   750
#ifdef  DISABLE_EN_ENO_PARAMETERS
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   751
  #include "iec_std_FB_no_ENENO.h"
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   752
#else
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   753
  #include "iec_std_FB.h"
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 905
diff changeset
   754
#endif
739
Mario de Sousa <msousa@fe.up.pt>
parents: 700
diff changeset
   755
Mario de Sousa <msousa@fe.up.pt>
parents: 700
diff changeset
   756
#endif /* _IEC_STD_LIB_H */