From 0c90eb16586d6c15d619666687449b3351e536fc Mon Sep 17 00:00:00 2001
From: Marcus von Appen <marcus@sysfault.org>
Date: Sat, 7 Jun 2014 09:36:04 +0200
Subject: [PATCH] - FreeBSD provides alloca() via stdlib.h, in contrast to
 Linux and Windows - Move the includes for alloca() intp mpconfigport.h

---
 py/builtinimport.c     | 1 -
 py/objfun.c            | 1 -
 py/runtime.c           | 1 -
 py/vm.c                | 1 -
 unix/modsocket.c       | 1 -
 unix/mpconfigport.h    | 8 ++++++++
 windows/mpconfigport.h | 2 +-
 7 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/py/builtinimport.c b/py/builtinimport.c
index 795d9fd5e..44ba4d554 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -29,7 +29,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
-#include <alloca.h>
 
 #include "mpconfig.h"
 #include "nlr.h"
diff --git a/py/objfun.c b/py/objfun.c
index 77d57821b..5c085f883 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -28,7 +28,6 @@
 #include <stdbool.h>
 #include <string.h>
 #include <assert.h>
-#include <alloca.h>
 
 #include "mpconfig.h"
 #include "nlr.h"
diff --git a/py/runtime.c b/py/runtime.c
index cdbf99d4a..b1fd19499 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -27,7 +27,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
-#include <alloca.h>
 
 #include "mpconfig.h"
 #include "nlr.h"
diff --git a/py/vm.c b/py/vm.c
index d57fbf17e..b24c85a49 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -28,7 +28,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
-#include <alloca.h>
 
 #include "mpconfig.h"
 #include "nlr.h"
diff --git a/unix/modsocket.c b/unix/modsocket.c
index d6f732377..b1a34a39b 100644
--- a/unix/modsocket.c
+++ b/unix/modsocket.c
@@ -37,7 +37,6 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <errno.h>
-#include <alloca.h>
 
 #include "mpconfig.h"
 #include "nlr.h"
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index ace7a419b..fe68b9934 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -98,3 +98,11 @@ extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
 #define MICROPY_PORT_BUILTINS \
     { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
     { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
+
+
+/* We need the correct header for alloca() */
+#ifdef __FreeBSD__
+#include <stdlib.h>
+#else
+#include <alloca.h>
+#endif
diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h
index 94304e20d..831a218fb 100644
--- a/windows/mpconfigport.h
+++ b/windows/mpconfigport.h
@@ -114,7 +114,7 @@ void msec_sleep(double msec);
 
 #include <stddef.h> //for NULL
 #include <assert.h> //for assert
-
+#include <alloca.h> //for alloca()
 
 // Functions implemented in platform code
 
-- 
GitLab