htons() and ntohs() only for SAMD and STM32, but not for Linux and ESP8266 and ESP32

This commit is contained in:
Nanosonde 2020-11-08 15:44:57 +01:00
parent ebfebaaf71
commit 0d6f746f88

View File

@ -5,7 +5,7 @@
#ifdef __linux__ #ifdef __linux__
#include <arpa/inet.h> #include <arpa/inet.h>
#else #elif ARDUINO_ARCH_SAMD || ARDUINO_ARCH_STM32
#define getbyte(x,n) (*(((uint8_t*)&(x))+n)) #define getbyte(x,n) (*(((uint8_t*)&(x))+n))
#define htons(x) ( (getbyte(x,0)<<8) | getbyte(x,1) ) #define htons(x) ( (getbyte(x,0)<<8) | getbyte(x,1) )
#define htonl(x) ( (getbyte(x,0)<<24) | (getbyte(x,1)<<16) | (getbyte(x,2)<<8) | getbyte(x,3) ) #define htonl(x) ( (getbyte(x,0)<<24) | (getbyte(x,1)<<16) | (getbyte(x,2)<<8) | getbyte(x,3) )