From e7bee6b35ea4c9e622209902456be64559b94d17 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Sat, 16 Jan 2016 21:07:26 +0000
Subject: [PATCH] pic16bit: Minor updates to types to allow port to compile
 again.

---
 pic16bit/modpybled.c    | 2 +-
 pic16bit/modpybswitch.c | 4 ++--
 pic16bit/mpconfigport.h | 4 ++++
 pic16bit/unistd.h       | 2 ++
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/pic16bit/modpybled.c b/pic16bit/modpybled.c
index 1610dc568..797246d13 100644
--- a/pic16bit/modpybled.c
+++ b/pic16bit/modpybled.c
@@ -46,7 +46,7 @@ void pyb_led_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t ki
     mp_printf(print, "LED(%u)", LED_ID(self));
 }
 
-STATIC mp_obj_t pyb_led_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t pyb_led_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 1, 1, false);
     mp_int_t led_id = mp_obj_get_int(args[0]);
     if (!(1 <= led_id && led_id <= NUM_LED)) {
diff --git a/pic16bit/modpybswitch.c b/pic16bit/modpybswitch.c
index 901e478cc..aa102e821 100644
--- a/pic16bit/modpybswitch.c
+++ b/pic16bit/modpybswitch.c
@@ -45,7 +45,7 @@ void pyb_switch_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
     mp_printf(print, "Switch(%u)", SWITCH_ID(self));
 }
 
-STATIC mp_obj_t pyb_switch_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t pyb_switch_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 1, 1, false);
     mp_int_t sw_id = mp_obj_get_int(args[0]);
     if (!(1 <= sw_id && sw_id <= NUM_SWITCH)) {
@@ -60,7 +60,7 @@ mp_obj_t pyb_switch_value(mp_obj_t self_in) {
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_switch_value_obj, pyb_switch_value);
 
-mp_obj_t pyb_switch_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
+mp_obj_t pyb_switch_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     mp_arg_check_num(n_args, n_kw, 0, 0, false);
     return pyb_switch_value(self_in);
 }
diff --git a/pic16bit/mpconfigport.h b/pic16bit/mpconfigport.h
index 97267b200..4921d7be2 100644
--- a/pic16bit/mpconfigport.h
+++ b/pic16bit/mpconfigport.h
@@ -108,3 +108,7 @@ extern const struct _mp_obj_module_t pyb_module;
 #define MICROPY_MPHALPORT_H "pic16bit_mphal.h"
 #define MICROPY_HW_BOARD_NAME "dsPICSK"
 #define MICROPY_HW_MCU_NAME "dsPIC33"
+
+// XC16 toolchain doesn't seem to define these
+typedef int intptr_t;
+typedef unsigned int uintptr_t;
diff --git a/pic16bit/unistd.h b/pic16bit/unistd.h
index 5ed9cb410..cdd9fe061 100644
--- a/pic16bit/unistd.h
+++ b/pic16bit/unistd.h
@@ -1,3 +1,5 @@
 // XC16 compiler doesn't seem to have unistd.h file
 
 #define SEEK_CUR 1
+
+typedef int ssize_t;
-- 
GitLab