Allow platform to *not* include some header files upstream
authorKeith Packard <keithp@keithp.com>
Thu, 10 Oct 2013 06:21:27 +0000 (23:21 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 10 Oct 2013 06:26:54 +0000 (23:26 -0700)
If the underlying platform compiler provides header files, then use
those instead of the ones here.

Signed-off-by: Keith Packard <keithp@keithp.com>
Makefile
functions/_PDCLIB/filemode.c
includes/inttypes.h
platform/altos/include-exclude [new file with mode: 0644]
platform/altos/internals/_PDCLIB_config.h

index ad3fb387cd14360816cae2d37157cac9b39f08ff..4796dfb58065cdbb3a09ba90d9ef85aec3945a6e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -49,8 +49,8 @@ REGDEPFILES := $(patsubst %,%.d,$(REGFILES))
 ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES)
 
 WARNINGS := -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wuninitialized -Wstrict-prototypes 
-PLATFORM_FLAGS=-nostdinc -mlittle-endian -mthumb -mcpu=$(CPU) -ffreestanding -nostdlib
-CFLAGS := -fno-builtin -Os -g -std=c99 -I./$(BUILD)/internals -I./testing $(WARNINGS) $(USERFLAGS) $(PLATFORM_FLAGS)
+PLATFORM_FLAGS=-mlittle-endian -mthumb -mcpu=$(CPU) -ffreestanding
+CFLAGS := -Os -g -std=c99 -I./$(BUILD)/internals -I./testing $(WARNINGS) $(USERFLAGS) $(PLATFORM_FLAGS)
 
 .PHONY: all clean srcdist bindist test tests testdrivers regtests regtestdrivers todos fixmes find links unlink help
 
@@ -58,7 +58,7 @@ PDCLIBNAME=libpdclib
 PDCLIB=$(PDCLIBNAME)-$(CPU).a
 
 all:
-       +for i in $(CPUS); do make CPU=$$i links $(PDCLIBNAME)-$$i.a; done
+       +for i in $(CPUS); do make CPU=$$i links; make CPU=$$i $(PDCLIBNAME)-$$i.a; done
 
 install: install-hdr
        @echo '######' install
@@ -140,6 +140,7 @@ links: $(BUILD)
        @for dir in $$(find functions includes internals -type d); do mkdir -p $(BUILD)/$$dir; done
        @for file in $$(find platform/$(PLATFORM) -mindepth 2 -type f ! -path *.svn* -printf "%P\n"); do if [ ! -f $(BUILD)/$$file ]; then ln -s $$(dirname $$file | sed "s@[^/]*@..@g")/../platform/$(PLATFORM)/$$file $(BUILD)/$$file; fi; done
        @for super in $(PROJDIRS); do for file in $$(find $$super -type f ! -path *.svn* -printf "%P\n"); do if [ ! -f $(BUILD)/$$super/$$file ]; then ln -s $$(echo $$file | sed "s@[^/]*@..@g")/../$$super/$$file $(BUILD)/$$super/$$file; fi; done; done
+       if [ -f platform/$(PLATFORM)/include-exclude ]; then for ex in `cat platform/$(PLATFORM)/include-exclude`; do echo exclude $$ex; rm -f $(BUILD)/includes/$$ex; done; fi; true
 
 unlink: $(BUILD)
        @echo "Unlinking platform files..."
index 0e293aba2cfc55a6a4f1487b569b20efb8cd70c7..10630cb84cf5cf60ad4cb8c0d6f881c8e937bc08 100644 (file)
@@ -6,6 +6,7 @@
    Permission is granted to use, modify, and / or redistribute at will.
 */
 
+#include <stdio.h>
 #include <stddef.h>
 
 /* Helper function that parses the C-style mode string passed to fopen() into
index dc9af3540b99894c3bb7acfb5138f31b3a43681b..1d35111e32d44d6d05d0012f4610e449a8fae50c 100644 (file)
@@ -9,6 +9,11 @@
 #ifndef _PDCLIB_INTTYPES_H
 #define _PDCLIB_INTTYPES_H _PDCLIB_INTTYPES_H
 
+#ifndef _PDCLIB_INT_H
+#define _PDCLIB_INT_H _PDCLIB_INT_H
+#include <_PDCLIB_int.h>
+#endif
+
 #include <stdint.h>
 
 typedef struct _PDCLIB_imaxdiv_t imaxdiv_t;
diff --git a/platform/altos/include-exclude b/platform/altos/include-exclude
new file mode 100644 (file)
index 0000000..018c7c0
--- /dev/null
@@ -0,0 +1,6 @@
+float.h
+iso646.h
+stdarg.h
+stdbool.h
+stddef.h
+stdint.h
index 64cc98dc73411bcc4e854ff936e09ab0d2e76f63..985fc6d4b6aa7db042c59212c1150b25579d2fd8 100644 (file)
@@ -156,6 +156,7 @@ struct _PDCLIB_lldiv_t
 
 /* Largest supported integer type. Implementation note: see _PDCLIB_atomax(). */
 #define _PDCLIB_intmax long long int
+typedef _PDCLIB_intmax intmax_t;
 #define _PDCLIB_INTMAX LLONG
 #define _PDCLIB_MAX_CONV ll
 /* You are also required to state the literal suffix for the intmax type      */
@@ -224,11 +225,13 @@ struct _PDCLIB_imaxdiv_t
 /* Internal helper macro. va_round is not part of <stdarg.h>. */
 #define _PDCLIB_va_round( type ) ( (sizeof(type) + sizeof(void *) - 1) & ~(sizeof(void *) - 1) )
 
-typedef char * _PDCLIB_va_list;
-#define _PDCLIB_va_arg( ap, type ) ( (ap) += (_PDCLIB_va_round(type)), ( *(type*) ( (ap) - (_PDCLIB_va_round(type)) ) ) )
-#define _PDCLIB_va_copy( dest, src ) ( (dest) = (src), (void)0 )
-#define _PDCLIB_va_end( ap ) ( (ap) = (void *)0, (void)0 )
-#define _PDCLIB_va_start( ap, parmN ) ( (ap) = (char *) &parmN + ( _PDCLIB_va_round(parmN) ), (void)0 )
+#include <stdarg.h>
+
+#define _PDCLIB_va_list va_list
+#define _PDCLIB_va_arg( ap, type ) va_arg(ap, type)
+#define _PDCLIB_va_copy( dest, src ) va_copy(dest, src)
+#define _PDCLIB_va_end( ap ) va_end(ap)
+#define _PDCLIB_va_start( ap, parmN ) va_start(ap, parmN)
 
 /* -------------------------------------------------------------------------- */
 /* OS "glue", part 1                                                          */