Commit 811d134978795a5acd171710999071a94beb4305
1 parent
d613a640
OpenBSD support by Anibal Limón
Showing
3 changed files
with
17 additions
and
3 deletions
NEWS
| @@ -15,6 +15,7 @@ libmodbus 2.1.1 (2010-XX-XX) | @@ -15,6 +15,7 @@ libmodbus 2.1.1 (2010-XX-XX) | ||
| 15 | Reported by aladdinwu. | 15 | Reported by aladdinwu. |
| 16 | - Parity setting is now a single char ('N', 'E' or 'O') | 16 | - Parity setting is now a single char ('N', 'E' or 'O') |
| 17 | - Report slave ID server side | 17 | - Report slave ID server side |
| 18 | +- OpenBSD support by Anibal Limón. | ||
| 18 | 19 | ||
| 19 | libmodbus 2.1.0 (2010-03-24) | 20 | libmodbus 2.1.0 (2010-03-24) |
| 20 | ============================ | 21 | ============================ |
src/modbus.c
| @@ -45,11 +45,16 @@ | @@ -45,11 +45,16 @@ | ||
| 45 | #include <limits.h> | 45 | #include <limits.h> |
| 46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
| 47 | 47 | ||
| 48 | +/* Add this for macros that defined unix flavor */ | ||
| 49 | +#if (defined(__unix__) || defined(unix)) && !defined(USG) | ||
| 50 | +#include <sys/param.h> | ||
| 51 | +#endif | ||
| 52 | + | ||
| 48 | /* TCP */ | 53 | /* TCP */ |
| 49 | #include <sys/types.h> | 54 | #include <sys/types.h> |
| 50 | #include <sys/socket.h> | 55 | #include <sys/socket.h> |
| 51 | #include <sys/ioctl.h> | 56 | #include <sys/ioctl.h> |
| 52 | -#if defined(__FreeBSD__ ) && __FreeBSD__ < 5 | 57 | +#if (defined OpenBSD) || (defined(__FreeBSD__ ) && __FreeBSD__ < 5) |
| 53 | #include <netinet/in_systm.h> | 58 | #include <netinet/in_systm.h> |
| 54 | #endif | 59 | #endif |
| 55 | #include <netinet/in.h> | 60 | #include <netinet/in.h> |
| @@ -1527,8 +1532,11 @@ modbus_t* modbus_new_rtu(const char *device, | @@ -1527,8 +1532,11 @@ modbus_t* modbus_new_rtu(const char *device, | ||
| 1527 | 1532 | ||
| 1528 | ctx->com = (modbus_rtu_t *) malloc(sizeof(modbus_rtu_t)); | 1533 | ctx->com = (modbus_rtu_t *) malloc(sizeof(modbus_rtu_t)); |
| 1529 | ctx_rtu = (modbus_rtu_t *)ctx->com; | 1534 | ctx_rtu = (modbus_rtu_t *)ctx->com; |
| 1530 | - | 1535 | +#if defined(OpenBSD) |
| 1536 | + strlcpy(ctx_rtu->device, device, sizeof(ctx_rtu->device)); | ||
| 1537 | +#else | ||
| 1531 | strcpy(ctx_rtu->device, device); | 1538 | strcpy(ctx_rtu->device, device); |
| 1539 | +#endif | ||
| 1532 | ctx_rtu->baud = baud; | 1540 | ctx_rtu->baud = baud; |
| 1533 | if (parity == 'N' || parity == 'E' || parity == 'O') { | 1541 | if (parity == 'N' || parity == 'E' || parity == 'O') { |
| 1534 | ctx_rtu->parity = parity; | 1542 | ctx_rtu->parity = parity; |
src/modbus.h.in
| @@ -18,6 +18,11 @@ | @@ -18,6 +18,11 @@ | ||
| 18 | #ifndef _MODBUS_H_ | 18 | #ifndef _MODBUS_H_ |
| 19 | #define _MODBUS_H_ | 19 | #define _MODBUS_H_ |
| 20 | 20 | ||
| 21 | +/* Add this for macros that defined unix flavor */ | ||
| 22 | +#if (defined(__unix__) || defined(unix)) && !defined(USG) | ||
| 23 | +#include <sys/param.h> | ||
| 24 | +#endif | ||
| 25 | + | ||
| 21 | #ifdef HAVE_INTTYPES_H | 26 | #ifdef HAVE_INTTYPES_H |
| 22 | #include <inttypes.h> | 27 | #include <inttypes.h> |
| 23 | #endif | 28 | #endif |
| @@ -25,7 +30,7 @@ | @@ -25,7 +30,7 @@ | ||
| 25 | #include <stdint.h> | 30 | #include <stdint.h> |
| 26 | #endif | 31 | #endif |
| 27 | #include <termios.h> | 32 | #include <termios.h> |
| 28 | -#if defined(__FreeBSD__ ) && __FreeBSD__ < 5 | 33 | +#if defined(OpenBSD) || (defined(__FreeBSD__ ) && __FreeBSD__ < 5) |
| 29 | #include <netinet/in_systm.h> | 34 | #include <netinet/in_systm.h> |
| 30 | #endif | 35 | #endif |
| 31 | #include <netinet/in.h> | 36 | #include <netinet/in.h> |