--- a/lib/iec_std_lib.h Mon Apr 04 15:59:35 2011 +0100
+++ b/lib/iec_std_lib.h Mon Apr 04 19:18:22 2011 +0200
@@ -148,7 +148,7 @@
}
-static inline void __normalize_timespec (struct timespec *ts) {
+static inline void __normalize_timespec (IEC_TIMESPEC *ts) {
if( ts->tv_nsec < -1000000000 || (( ts->tv_sec > 0 ) && ( ts->tv_nsec < 0 ))){
ts->tv_sec--;
ts->tv_nsec += 1000000000;
@@ -159,8 +159,8 @@
}
}
-static inline struct timespec __time_to_timespec(int sign, double mseconds, double seconds, double minutes, double hours, double days) {
- struct timespec ts;
+static inline IEC_TIMESPEC __time_to_timespec(int sign, double mseconds, double seconds, double minutes, double hours, double days) {
+ IEC_TIMESPEC ts;
/* sign is 1 for positive values, -1 for negative time... */
long double total_sec = ((days*24 + hours)*60 + minutes)*60 + seconds + mseconds/1e3;
@@ -172,8 +172,8 @@
}
-static inline struct timespec __tod_to_timespec(double seconds, double minutes, double hours) {
- struct timespec ts;
+static inline IEC_TIMESPEC __tod_to_timespec(double seconds, double minutes, double hours) {
+ IEC_TIMESPEC ts;
long double total_sec = (hours*60 + minutes)*60 + seconds;
ts.tv_sec = (long int)total_sec;
@@ -182,8 +182,8 @@
return ts;
}
-static inline struct timespec __date_to_timespec(int day, int month, int year) {
- struct timespec ts;
+static inline IEC_TIMESPEC __date_to_timespec(int day, int month, int year) {
+ IEC_TIMESPEC ts;
struct tm broken_down_time;
time_t epoch_seconds;
@@ -205,8 +205,8 @@
return ts;
}
-static inline struct timespec __dt_to_timespec(double seconds, double minutes, double hours, int day, int month, int year) {
- struct timespec ts;
+static inline IEC_TIMESPEC __dt_to_timespec(double seconds, double minutes, double hours, int day, int month, int year) {
+ IEC_TIMESPEC ts;
struct tm broken_down_time;
time_t epoch_seconds;
@@ -791,7 +791,7 @@
return res;
}
-/* workaround for va-atgs limitation on shorter that int params */
+/* workaround for va-args limitation on shorter than int params */
#define VA_ARGS_REAL LREAL
#define VA_ARGS_LREAL LREAL
#define VA_ARGS_SINT DINT
--- a/lib/iec_types.h Mon Apr 04 15:59:35 2011 +0100
+++ b/lib/iec_types.h Mon Apr 04 19:18:22 2011 +0200
@@ -3,7 +3,6 @@
#include <limits.h>
#include <float.h>
-#include <time.h>
#include <stdint.h>
/*********************/
@@ -30,22 +29,15 @@
typedef float IEC_REAL;
typedef double IEC_LREAL;
-
-#if !defined __timespec_defined && !defined __time_t_defined
-# define __timespec_defined 1
-
-struct timespec
- {
+typedef struct {
long int tv_sec; /* Seconds. */
long int tv_nsec; /* Nanoseconds. */
- };
+}__attribute__((packed)) IEC_TIMESPEC;
-#endif
-
-typedef struct timespec IEC_TIME;
-typedef struct timespec IEC_DATE;
-typedef struct timespec IEC_DT;
-typedef struct timespec IEC_TOD;
+typedef IEC_TIMESPEC IEC_TIME;
+typedef IEC_TIMESPEC IEC_DATE;
+typedef IEC_TIMESPEC IEC_DT;
+typedef IEC_TIMESPEC IEC_TOD;
#ifndef STR_MAX_LEN
#define STR_MAX_LEN 126
@@ -59,6 +51,6 @@
typedef struct {
__strlen_t len;
uint8_t body[STR_MAX_LEN];
-} IEC_STRING;
+} __attribute__((packed)) IEC_STRING;
#endif /*IEC_TYPES_H*/
--- a/lib/ieclib.txt Mon Apr 04 15:59:35 2011 +0100
+++ b/lib/ieclib.txt Mon Apr 04 19:18:22 2011 +0200
@@ -35,7 +35,7 @@
*)
(* The standard functions *)
-{#include "standard_functions.txt" }
+(*{#include "standard_functions.txt" }*)
(* The standard function blocks *)
{#include "edge_detection.txt" }
--- a/stage1_2/iec.y Mon Apr 04 15:59:35 2011 +0100
+++ b/stage1_2/iec.y Mon Apr 04 19:18:22 2011 +0200
@@ -7971,6 +7971,11 @@
FILE *in_file = NULL, *lib_file = NULL;
char *libfilename = NULL;
+ for(int i = 0; standard_function_names[i] != NULL; i++)
+ if (library_element_symtable.find_value(standard_function_names[i]) ==
+ library_element_symtable.end_value())
+ library_element_symtable.insert(standard_function_names[i], standard_function_name_token);
+
if((in_file = fopen(filename, "r")) == NULL) {
char *errmsg = strdup2("Error opening main file ", filename);
perror(errmsg);
@@ -8023,11 +8028,6 @@
/* if by any chance the library is not complete, we
* now add the missing reserved keywords to the list!!!
*/
- for(int i = 0; standard_function_names[i] != NULL; i++)
- if (library_element_symtable.find_value(standard_function_names[i]) ==
- library_element_symtable.end_value())
- library_element_symtable.insert(standard_function_names[i], standard_function_name_token);
-
for(int i = 0; standard_function_block_names[i] != NULL; i++)
if (library_element_symtable.find_value(standard_function_block_names[i]) ==
library_element_symtable.end_value())
--- a/stage3/visit_expression_type.cc Mon Apr 04 15:59:35 2011 +0100
+++ b/stage3/visit_expression_type.cc Mon Apr 04 19:18:22 2011 +0200
@@ -57,7 +57,7 @@
(symbol1))
#define STAGE3_ERROR(symbol1, symbol2, msg) { \
- fprintf(stderr, "semantic error between (%d:%d) and (%d:%d): %s\n", \
+ fprintf(stderr, "plc.st:%d-%d..%d-%d: error : %s\n", \
FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column, \
LAST_(symbol1,symbol2) ->last_line, LAST_(symbol1,symbol2) ->last_column, \
msg); \
--- a/stage4/generate_c/generate_c.cc Mon Apr 04 15:59:35 2011 +0100
+++ b/stage4/generate_c/generate_c.cc Mon Apr 04 19:18:22 2011 +0200
@@ -1083,7 +1083,9 @@
s4o.print("(void) {\n");
s4o.indent_right();
s4o.print(s4o.indent_spaces);
- s4o.print("BOOL retain = 0;\n");
+ s4o.print("BOOL retain;\n");
+ s4o.print(s4o.indent_spaces);
+ s4o.print("retain = 0;\n");
/* (B.3) Global variables initializations... */
s4o.print(s4o.indent_spaces);
@@ -1371,7 +1373,9 @@
s4o.print("(void) {\n");
s4o.indent_right();
s4o.print(s4o.indent_spaces);
- s4o.print("BOOL retain = 0;\n");
+ s4o.print("BOOL retain;\n");
+ s4o.print(s4o.indent_spaces);
+ s4o.print("retain = 0;\n");
/* (B.2) Global variables initialisations... */
if (current_global_vars != NULL) {