Commit 7ef3fa5f00ae99f2299d16fb621d3b1ceff926af
1 parent
cb4d3ea6
Minor coding conventions on defines
Showing
1 changed file
with
15 additions
and
12 deletions
src/modbus-data.c
| @@ -5,18 +5,20 @@ | @@ -5,18 +5,20 @@ | ||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
| 8 | + | ||
| 8 | #ifndef _MSC_VER | 9 | #ifndef _MSC_VER |
| 9 | -#include <stdint.h> | 10 | +# include <stdint.h> |
| 10 | #else | 11 | #else |
| 11 | -#include "stdint.h" | 12 | +# include "stdint.h" |
| 12 | #endif | 13 | #endif |
| 14 | + | ||
| 13 | #include <string.h> | 15 | #include <string.h> |
| 14 | #include <assert.h> | 16 | #include <assert.h> |
| 15 | 17 | ||
| 16 | #if defined(_WIN32) | 18 | #if defined(_WIN32) |
| 17 | -# include <winsock2.h> | 19 | +# include <winsock2.h> |
| 18 | #else | 20 | #else |
| 19 | -# include <arpa/inet.h> | 21 | +# include <arpa/inet.h> |
| 20 | #endif | 22 | #endif |
| 21 | 23 | ||
| 22 | #include <config.h> | 24 | #include <config.h> |
| @@ -28,10 +30,10 @@ | @@ -28,10 +30,10 @@ | ||
| 28 | #endif | 30 | #endif |
| 29 | 31 | ||
| 30 | #if defined(__APPLE__) | 32 | #if defined(__APPLE__) |
| 31 | - #include <libkern/OSByteOrder.h> | ||
| 32 | - #define bswap_16 OSSwapInt16 | ||
| 33 | - #define bswap_32 OSSwapInt32 | ||
| 34 | - #define bswap_64 OSSwapInt64 | 33 | +# include <libkern/OSByteOrder.h> |
| 34 | +# define bswap_16 OSSwapInt16 | ||
| 35 | +# define bswap_32 OSSwapInt32 | ||
| 36 | +# define bswap_64 OSSwapInt64 | ||
| 35 | #endif | 37 | #endif |
| 36 | 38 | ||
| 37 | #if defined(__GNUC__) | 39 | #if defined(__GNUC__) |
| @@ -42,14 +44,15 @@ | @@ -42,14 +44,15 @@ | ||
| 42 | # define bswap_32 __builtin_bswap32 | 44 | # define bswap_32 __builtin_bswap32 |
| 43 | # endif | 45 | # endif |
| 44 | #endif | 46 | #endif |
| 47 | + | ||
| 45 | #if defined(_MSC_VER) && (_MSC_VER >= 1400) | 48 | #if defined(_MSC_VER) && (_MSC_VER >= 1400) |
| 46 | -# define bswap_32 _byteswap_ulong | ||
| 47 | -# define bswap_16 _byteswap_ushort | 49 | +# define bswap_32 _byteswap_ulong |
| 50 | +# define bswap_16 _byteswap_ushort | ||
| 48 | #endif | 51 | #endif |
| 49 | 52 | ||
| 50 | #if !defined(__CYGWIN__) | 53 | #if !defined(__CYGWIN__) |
| 51 | #if !defined(bswap_16) | 54 | #if !defined(bswap_16) |
| 52 | -# warning "Fallback on C functions for bswap_16" | 55 | +# warning "Fallback on C functions for bswap_16" |
| 53 | static inline uint16_t bswap_16(uint16_t x) | 56 | static inline uint16_t bswap_16(uint16_t x) |
| 54 | { | 57 | { |
| 55 | return (x >> 8) | (x << 8); | 58 | return (x >> 8) | (x << 8); |
| @@ -58,7 +61,7 @@ static inline uint16_t bswap_16(uint16_t x) | @@ -58,7 +61,7 @@ static inline uint16_t bswap_16(uint16_t x) | ||
| 58 | #endif | 61 | #endif |
| 59 | 62 | ||
| 60 | #if !defined(bswap_32) | 63 | #if !defined(bswap_32) |
| 61 | -# warning "Fallback on C functions for bswap_32" | 64 | +# warning "Fallback on C functions for bswap_32" |
| 62 | static inline uint32_t bswap_32(uint32_t x) | 65 | static inline uint32_t bswap_32(uint32_t x) |
| 63 | { | 66 | { |
| 64 | return (bswap_16(x & 0xffff) << 16) | (bswap_16(x >> 16)); | 67 | return (bswap_16(x & 0xffff) << 16) | (bswap_16(x >> 16)); |