1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

native: update support for FreeBSD

works with FreeBSD 10.0 amd64/i386

fixes: #505
This commit is contained in:
Ludwig Ortmann 2014-04-10 14:58:12 +02:00
parent b22f0e6a09
commit 42aa3d9f5b
5 changed files with 51 additions and 25 deletions

View File

@ -25,7 +25,20 @@ export GPROF ?= gprof
# flags:
export CFLAGS += -Wall -Wextra -pedantic -m32
export LINKFLAGS += -m32 -gc -ldl
ifeq ($(shell uname -s),FreeBSD)
ifeq ($(shell uname -m),amd64)
export CFLAGS += -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
endif
endif
export LINKFLAGS += -m32 -gc
ifeq ($(shell uname -s),FreeBSD)
ifeq ($(shell uname -m),amd64)
export LINKFLAGS += -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
endif
export LINKFLAGS += -L $(BINDIR)
else
export LINKFLAGS += -ldl
endif
export ASFLAGS =
export DEBUGGER_FLAGS = $(ELF)
term-memcheck: export VALGRIND_FLAGS ?= --track-origins=yes

View File

@ -13,6 +13,28 @@
#define _NATIVE_INTERNAL_H
#include <signal.h>
/* enable signal handler register access on different platforms
* check here for more:
* http://sourceforge.net/p/predef/wiki/OperatingSystems/
*/
#if (defined(__FreeBSD__) || defined(__MACH__))
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#include <ucontext.h>
#undef _XOPEN_SOURCE
#else
#include <ucontext.h>
#endif
#elif defined(__linux__)
#ifndef _GNU_SOURCE
#define GNU_SOURCE
#include <ucontext.h>
#undef GNU_SOURCE
#else
#include <ucontext.h>
#endif
#endif // BSD/Linux
/**
* internal functions
@ -76,28 +98,6 @@ int unregister_interrupt(int sig);
//#include <sys/param.h>
/* enable signal handler register access on different platforms
* check here for more:
* http://sourceforge.net/p/predef/wiki/OperatingSystems/
*/
#ifdef BSD // BSD = (FreeBSD, Darwin, ...)
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#include <ucontext.h>
#undef _XOPEN_SOURCE
#else
#include <ucontext.h>
#endif
#elif defined(__linux__)
#ifndef _GNU_SOURCE
#define GNU_SOURCE
#include <ucontext.h>
#undef GNU_SOURCE
#else
#include <ucontext.h>
#endif
#endif // BSD/Linux
#include "kernel_internal.h"
#include "sched.h"

View File

@ -340,7 +340,7 @@ void native_isr_entry(int sig, siginfo_t *info, void *context)
#ifdef __MACH__
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext->__ss.__eip;
((ucontext_t *)context)->uc_mcontext->__ss.__eip = (unsigned int)&_native_sig_leave_tramp;
#elif BSD
#elif defined(__FreeBSD__)
_native_saved_eip = ((struct sigcontext *)context)->sc_eip;
((struct sigcontext *)context)->sc_eip = (unsigned int)&_native_sig_leave_tramp;
#else

View File

@ -31,6 +31,13 @@
#undef _POSIX_C_SOURCE
#include <ifaddrs.h>
#include <net/if_dl.h>
#elif defined(__FreeBSD__)
#include <sys/socket.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <net/if_dl.h>
#else
#include <net/if.h>
#include <linux/if_tun.h>
@ -232,6 +239,9 @@ int tap_init(char *name)
#ifdef __MACH__ /* OSX */
char clonedev[255] = "/dev/"; /* XXX bad size */
strncpy(clonedev+5, name, 250);
#elif defined(__FreeBSD__)
char clonedev[255] = "/dev/"; /* XXX bad size */
strncpy(clonedev+5, name, 250);
#else /* Linux */
struct ifreq ifr;
const char *clonedev = "/dev/net/tun";
@ -242,7 +252,7 @@ int tap_init(char *name)
err(EXIT_FAILURE, "open(%s)", clonedev);
}
#ifdef __MACH__ /* OSX */
#if (defined(__MACH__) || defined(__FreeBSD__)) /* OSX/FreeBSD */
struct ifaddrs* iflist;
if (getifaddrs(&iflist) == 0) {
for (struct ifaddrs *cur = iflist; cur; cur = cur->ifa_next) {

View File

@ -163,6 +163,9 @@ ssize_t _native_write(int fd, const void *buf, size_t count)
return r;
}
#if defined(__FreeBSD__)
#undef putchar
#endif
int putchar(int c) {
_native_write(STDOUT_FILENO, &c, 1);
return 0;