Browse Source

Build unix port on MacOS/clang

Add support to use Darwin byte order functions instead of LwIP's macros.
These were being pulled in through system includes used in the Unix port files.
Pull sys/types.h in cc.h to get the Darwin macros and use them throughout

In sio.c a number of non-POSIX types/symbols are used, by default MacOS is compiling
with _POSIX_C_SOURCE which guards these additional items. To enable them, we define
_DARWIN_C_SOURCE before any system includes

In unixif.c string.h was not included yet memset and friends are being used. This
caused Wimplicit-function-declaration warnings with clang

This only fixes issue seen in the source, the Makefiles need additional changes to
build with MacOS
master
Joel Cunningham 9 years ago
parent
commit
0f96523fa4
  1. 8
      ports/unix/port/include/arch/cc.h
  2. 8
      ports/unix/port/netif/sio.c
  3. 1
      ports/unix/port/netif/unixif.c

8
ports/unix/port/include/arch/cc.h

@ -62,6 +62,14 @@
typedef __kernel_fd_set fd_set;
#endif
#if defined(LWIP_UNIX_MACH)
/* sys/types.h and signal.h bring in Darwin byte order macros. pull the
header here and disable LwIP's version so that apps still can get
the macros via LwIP headers and use system headers */
#include <sys/types.h>
#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
#endif
struct sio_status_s;
typedef struct sio_status_s sio_status_t;
#define sio_fd_t sio_status_t*

8
ports/unix/port/netif/sio.c

@ -4,6 +4,14 @@
#define _XOPEN_SOURCE 600
#define _GNU_SOURCE
/* build with Darwin C extensions not part of POSIX, i.e. FASYNC, SIGIO.
we can't use LWIP_UNIX_MACH because extensions need to be turned
on before any system headers (which are pulled in through cc.h)
are included */
#if defined(__APPLE__)
#define _DARWIN_C_SOURCE
#endif
#include "netif/sio.h"
#include "netif/fifo.h"
#include "lwip/debug.h"

1
ports/unix/port/netif/unixif.c

@ -35,6 +35,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/uio.h>

Loading…
Cancel
Save