Skip to content

Commit

Permalink
Add support for bare metal embedded platforms (#15)
Browse files Browse the repository at this point in the history
* Add support for bare metal ARM

* remove nonstandard __has_include

* bionic support

* fix indentation

* Simplify codec.c includes
  • Loading branch information
charliewolf authored Aug 22, 2023
1 parent 3c9d52f commit 2442559
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@

#define _GNU_SOURCE

#if defined(__NEWLIB__)
# include <machine/endian.h>
# define htons(_x) __htons(_x)
# define ntohs(_x) __ntohs(_x)
#elif defined(__BIONIC__)
# include <sys/endian.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
18 changes: 17 additions & 1 deletion src/dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,24 @@
# include <wspiapi.h>
# endif
typedef uint32_t in_addr_t;
#else
#elif defined(__unix__)
# include <arpa/inet.h>
#else
// No platform implementation of in6_addr so we'll provide a simple one
typedef uint32_t in_addr_t;
struct in6_addr
{
union
{
uint8_t u6_addr8[16];
uint16_t u6_addr16[8];
uint32_t u6_addr32[4];
} in6_u;

# define s6_addr in6_u.u6_addr8
# define s6_addr16 in6_u.u6_addr16
# define s6_addr32 in6_u.u6_addr32
};
#endif

#ifdef __cplusplus
Expand Down

0 comments on commit 2442559

Please sign in to comment.