From 8bb70d8a905488a8d7212e82001c7daf404c0b5f 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 | 6 ------ kernel/atomport-template.h | 6 ++++++ ports/avr/atomport.h | 2 ++ ports/stm8/atomport.h | 2 ++ ports/stm8/uart.c | 1 - tests/kern1.c | 6 ------ tests/mutex1.c | 7 ------- tests/mutex2.c | 6 ------ tests/mutex7.c | 6 ------ tests/queue1.c | 6 ------ tests/queue4.c | 6 ------ tests/sem1.c | 6 ------ tests/sem2.c | 6 ------ tests/timer1.c | 6 ------ tests/timer3.c | 6 ------ tests/timer5.c | 6 ------ 16 files changed, 10 insertions(+), 74 deletions(-) diff --git a/kernel/atomkernel.c b/kernel/atomkernel.c index 4b53af1..9c0e276 100755 --- a/kernel/atomkernel.c +++ b/kernel/atomkernel.c @@ -143,12 +143,6 @@ * */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #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 c467298..90a3991 100644 --- a/tests/kern1.c +++ b/tests/kern1.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atomtests.h" diff --git a/tests/mutex1.c b/tests/mutex1.c index a2b03e7..4a340d2 100644 --- a/tests/mutex1.c +++ b/tests/mutex1.c @@ -27,13 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif - #include "atom.h" #include "atommutex.h" #include "atomtests.h" diff --git a/tests/mutex2.c b/tests/mutex2.c index 7e90d22..5432ec3 100644 --- a/tests/mutex2.c +++ b/tests/mutex2.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atommutex.h" diff --git a/tests/mutex7.c b/tests/mutex7.c index e9edcb6..7d25fae 100644 --- a/tests/mutex7.c +++ b/tests/mutex7.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atomtests.h" diff --git a/tests/queue1.c b/tests/queue1.c index 50089c6..8b50f91 100644 --- a/tests/queue1.c +++ b/tests/queue1.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atomqueue.h" diff --git a/tests/queue4.c b/tests/queue4.c index 46703d4..e5c5d94 100644 --- a/tests/queue4.c +++ b/tests/queue4.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atomqueue.h" diff --git a/tests/sem1.c b/tests/sem1.c index 69623eb..54b7ddc 100644 --- a/tests/sem1.c +++ b/tests/sem1.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atomsem.h" diff --git a/tests/sem2.c b/tests/sem2.c index d7f0e40..f025e50 100644 --- a/tests/sem2.c +++ b/tests/sem2.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atomsem.h" diff --git a/tests/timer1.c b/tests/timer1.c index d1bbf39..6cc57d9 100644 --- a/tests/timer1.c +++ b/tests/timer1.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atomsem.h" diff --git a/tests/timer3.c b/tests/timer3.c index e6f9104..be81c14 100644 --- a/tests/timer3.c +++ b/tests/timer3.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atomsem.h" diff --git a/tests/timer5.c b/tests/timer5.c index acf56b1..080a5b8 100644 --- a/tests/timer5.c +++ b/tests/timer5.c @@ -27,12 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef STAND_ALONE -#include -#else -#include -#include -#endif #include "atom.h" #include "atomsem.h"