From 23d2cd6592a25384bccfa6f4e63c84f291cc0f28 Mon Sep 17 00:00:00 2001 From: skarg Date: Wed, 29 Oct 2008 03:49:43 +0000 Subject: [PATCH] Corrected compilation on linux - added conditional min macros. --- bacnet-stack/demo/mstpcap/main.c | 5 +++++ bacnet-stack/ports/linux/mstpsnap.c | 5 +++++ bacnet-stack/ports/linux/rx_fsm.c | 11 +++++++++-- bacnet-stack/ports/win32/rx_fsm.c | 5 +++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/bacnet-stack/demo/mstpcap/main.c b/bacnet-stack/demo/mstpcap/main.c index c777e449..bacbccd5 100644 --- a/bacnet-stack/demo/mstpcap/main.c +++ b/bacnet-stack/demo/mstpcap/main.c @@ -47,6 +47,11 @@ #include "mstp.h" #include "mstptext.h" +#ifndef max +#define max(a,b) (((a) (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + /* local port data - shared with RS-485 */ static volatile struct mstp_port_struct_t MSTP_Port; /* buffers needed by mstp port struct */ diff --git a/bacnet-stack/ports/linux/mstpsnap.c b/bacnet-stack/ports/linux/mstpsnap.c index e9cfd74b..f64d7452 100644 --- a/bacnet-stack/ports/linux/mstpsnap.c +++ b/bacnet-stack/ports/linux/mstpsnap.c @@ -48,6 +48,11 @@ #include "mstptext.h" #include "bacint.h" +#ifndef max +#define max(a,b) (((a) (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + /* local port data - shared with RS-485 */ static volatile struct mstp_port_struct_t MSTP_Port; /* buffers needed by mstp port struct */ diff --git a/bacnet-stack/ports/linux/rx_fsm.c b/bacnet-stack/ports/linux/rx_fsm.c index ee56bc17..8262defc 100644 --- a/bacnet-stack/ports/linux/rx_fsm.c +++ b/bacnet-stack/ports/linux/rx_fsm.c @@ -54,6 +54,11 @@ #include "mstp.h" #include "mstptext.h" +#ifndef max +#define max(a,b) (((a) (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + /* local port data - shared with RS-485 */ static volatile struct mstp_port_struct_t MSTP_Port; /* buffers needed by mstp port struct */ @@ -185,6 +190,7 @@ static void write_received_packet( uint32_t orig_len; /* actual length of packet */ uint8_t header[8]; /* MS/TP header */ struct timeval tv; + size_t max_data = 0; if (pFile) { gettimeofday(&tv, NULL); @@ -211,8 +217,8 @@ static void write_received_packet( fwrite(header, sizeof(header), 1, pFile); if (mstp_port->DataLength) { fwrite(mstp_port->InputBuffer, max_data, 1, pFile); - fwrite(&(mstp_port->DataCRCActualMSB), 1, 1, pFile); - fwrite(&(mstp_port->DataCRCActualLSB), 1, 1, pFile); + fwrite((char *)&(mstp_port->DataCRCActualMSB), 1, 1, pFile); + fwrite((char *)&(mstp_port->DataCRCActualLSB), 1, 1, pFile); } } else { fprintf(stderr, "rx_fsm: failed to open %s: %s\n", Capture_Filename, @@ -236,6 +242,7 @@ static void print_received_packet( { unsigned i = 0; int timestamp = 0; + size_t max_data = 0; timestamp = timestamp_ms(); fprintf(stderr, "%03d ", timestamp); diff --git a/bacnet-stack/ports/win32/rx_fsm.c b/bacnet-stack/ports/win32/rx_fsm.c index 471981c6..cfef59ca 100644 --- a/bacnet-stack/ports/win32/rx_fsm.c +++ b/bacnet-stack/ports/win32/rx_fsm.c @@ -52,6 +52,11 @@ #include "mstptext.h" #include "crc.h" +#ifndef max +#define max(a,b) (((a) (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + /* file format for libpcap/winpcap */ /* from http://wiki.wireshark.org/Development/LibpcapFileFormat */ typedef struct pcap_hdr_s {