From be6e60bf2fc6632497cd895cd6d9f150b0b5af8f Mon Sep 17 00:00:00 2001 From: Kelvin Lawson Date: Wed, 25 May 2011 23:52:11 +0100 Subject: [PATCH] Improve support for platforms without stddef.h. NULL definition should now be provided by architecture port file atomport.h, which in most cases can just include stddef.h. --- kernel/atomkernel.c | 1 - kernel/atomport-template.h | 6 ++++++ ports/avr/atomport.h | 2 ++ ports/stm8/atomport.h | 2 ++ ports/stm8/uart.c | 1 - tests/kern1.c | 1 - tests/mutex1.c | 1 - tests/mutex2.c | 1 - tests/mutex7.c | 1 - tests/queue1.c | 1 - tests/queue4.c | 1 - tests/sem1.c | 1 - tests/sem2.c | 3 +-- tests/timer1.c | 3 +-- tests/timer3.c | 3 +-- tests/timer5.c | 3 +-- 16 files changed, 14 insertions(+), 17 deletions(-) diff --git a/kernel/atomkernel.c b/kernel/atomkernel.c index 97daac4..8f4af3e 100755 --- a/kernel/atomkernel.c +++ b/kernel/atomkernel.c @@ -144,7 +144,6 @@ */ -#include #include "atom.h" diff --git a/kernel/atomport-template.h b/kernel/atomport-template.h index 07671ea..4f47cb4 100755 --- a/kernel/atomport-template.h +++ b/kernel/atomport-template.h @@ -34,6 +34,12 @@ /* Required number of system ticks per second (normally 100 for 10ms tick) */ #define SYSTEM_TICKS_PER_SEC 100 +/** + * Definition of NULL. + * If stddef.h is available on the platform it is simplest to include it + * from this header, otherwise define below. + */ +#define NULL ((void *)(0)) /** * Architecture-specific types. diff --git a/ports/avr/atomport.h b/ports/avr/atomport.h index ec1cc78..094e17e 100644 --- a/ports/avr/atomport.h +++ b/ports/avr/atomport.h @@ -37,6 +37,8 @@ /* Portable uint8_t and friends available from stdint.h on this platform */ #include +/* Definition of NULL is available from stddef.h on this platform */ +#include /* Required number of system ticks per second (normally 100 for 10ms tick) */ #define SYSTEM_TICKS_PER_SEC 100 diff --git a/ports/stm8/atomport.h b/ports/stm8/atomport.h index 119c2b5..bcd36e1 100644 --- a/ports/stm8/atomport.h +++ b/ports/stm8/atomport.h @@ -39,6 +39,8 @@ #include #endif +/* Definition of NULL is available from stddef.h on this platform */ +#include /* Required number of system ticks per second (normally 100 for 10ms tick) */ #define SYSTEM_TICKS_PER_SEC 100 diff --git a/ports/stm8/uart.c b/ports/stm8/uart.c index 352ea13..90515ac 100644 --- a/ports/stm8/uart.c +++ b/ports/stm8/uart.c @@ -1,5 +1,4 @@ #include -#include #include "stm8s.h" diff --git a/tests/kern1.c b/tests/kern1.c index 1695039..90a3991 100644 --- a/tests/kern1.c +++ b/tests/kern1.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atomtests.h" diff --git a/tests/mutex1.c b/tests/mutex1.c index e3bc16a..015e8e2 100644 --- a/tests/mutex1.c +++ b/tests/mutex1.c @@ -27,7 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "atom.h" #include "atommutex.h" #include "atomtests.h" diff --git a/tests/mutex2.c b/tests/mutex2.c index 9725f44..5432ec3 100644 --- a/tests/mutex2.c +++ b/tests/mutex2.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atommutex.h" #include "atomtests.h" diff --git a/tests/mutex7.c b/tests/mutex7.c index 9189dee..7d25fae 100644 --- a/tests/mutex7.c +++ b/tests/mutex7.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atomtests.h" #include "atommutex.h" diff --git a/tests/queue1.c b/tests/queue1.c index f3a8938..8b50f91 100644 --- a/tests/queue1.c +++ b/tests/queue1.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atomqueue.h" #include "atomtests.h" diff --git a/tests/queue4.c b/tests/queue4.c index 3420882..e5c5d94 100644 --- a/tests/queue4.c +++ b/tests/queue4.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atomqueue.h" #include "atomtests.h" diff --git a/tests/sem1.c b/tests/sem1.c index b7b6335..54b7ddc 100644 --- a/tests/sem1.c +++ b/tests/sem1.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atomsem.h" #include "atomtests.h" diff --git a/tests/sem2.c b/tests/sem2.c index b83f8cf..f025e50 100644 --- a/tests/sem2.c +++ b/tests/sem2.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atomsem.h" #include "atomtests.h" @@ -321,4 +320,4 @@ static void testCallback (POINTER cb_data) */ } -} \ No newline at end of file +} diff --git a/tests/timer1.c b/tests/timer1.c index 2e2d940..6cc57d9 100644 --- a/tests/timer1.c +++ b/tests/timer1.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atomsem.h" #include "atomtimer.h" @@ -246,4 +245,4 @@ static void testCallback (POINTER cb_data) */ } -} \ No newline at end of file +} diff --git a/tests/timer3.c b/tests/timer3.c index 0ea7a50..be81c14 100644 --- a/tests/timer3.c +++ b/tests/timer3.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atomsem.h" #include "atomtimer.h" @@ -240,4 +239,4 @@ static void testCallback (POINTER cb_data) */ } -} \ No newline at end of file +} diff --git a/tests/timer5.c b/tests/timer5.c index 02ca33c..080a5b8 100644 --- a/tests/timer5.c +++ b/tests/timer5.c @@ -28,7 +28,6 @@ */ -#include #include "atom.h" #include "atomsem.h" #include "atomtimer.h" @@ -138,4 +137,4 @@ static void testCallback (POINTER cb_data) { /* Callback was called */ callback_ran_flag = TRUE; -} \ No newline at end of file +}