]> pd.if.org Git - pdclib.old/commitdiff
Initial stab at gandr platform
authorOwen Shepherd <owen.shepherd@e43.eu>
Mon, 14 Jul 2014 15:21:25 +0000 (16:21 +0100)
committerOwen Shepherd <owen.shepherd@e43.eu>
Mon, 14 Jul 2014 15:21:25 +0000 (16:21 +0100)
12 files changed:
platform/gandr/Config.jam [new file with mode: 0644]
platform/gandr/Jamfile [new file with mode: 0644]
platform/gandr/functions/_PDCLIB/_PDCLIB_Exit.c [new file with mode: 0644]
platform/gandr/functions/_PDCLIB/_PDCLIB_allocpages.c [new file with mode: 0644]
platform/gandr/functions/_PDCLIB/_PDCLIB_freepages.c [new file with mode: 0644]
platform/gandr/functions/_PDCLIB/_PDCLIB_stdinit.c [new file with mode: 0644]
platform/gandr/functions/signal/raise.c [new file with mode: 0644]
platform/gandr/functions/signal/signal.c [new file with mode: 0644]
platform/gandr/functions/stdio/_PDCLIB_fileops.c [new file with mode: 0644]
platform/gandr/functions/stdio/remove.c [new file with mode: 0644]
platform/gandr/includes/_PDCLIB_config.h [new file with mode: 0644]
platform/gandr/includes/signal.h [new file with mode: 0644]

diff --git a/platform/gandr/Config.jam b/platform/gandr/Config.jam
new file mode 100644 (file)
index 0000000..461e5f1
--- /dev/null
@@ -0,0 +1,14 @@
+rule PDCLibTargetConfig { }
+rule PDCLibTargetHeaders {
+    SubDirHdrs $(PDCLIB_TOP) platform gandr includes ;
+}
+
+PDCLIB_OPTIONS = 
+    nothread
+    notime 
+    dlmalloc 
+    mincoll 
+    tss_errno 
+    basecodecs 
+    c_locale 
+    ;
\ No newline at end of file
diff --git a/platform/gandr/Jamfile b/platform/gandr/Jamfile
new file mode 100644 (file)
index 0000000..d1f9d2a
--- /dev/null
@@ -0,0 +1,2 @@
+SubDir PDCLIB_TOP platform gandr ;
+PDCLibConfig ;
\ No newline at end of file
diff --git a/platform/gandr/functions/_PDCLIB/_PDCLIB_Exit.c b/platform/gandr/functions/_PDCLIB/_PDCLIB_Exit.c
new file mode 100644 (file)
index 0000000..b0178c2
--- /dev/null
@@ -0,0 +1,36 @@
+/* $Id$ */
+
+/* _PDCLIB_exit( int )
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+/* This is a stub implementation of _PDCLIB_Exit
+*/
+
+#include <stdlib.h>
+
+#ifndef REGTEST
+#include <_PDCLIB_glue.h>
+#include <errno.h>
+
+void _PDCLIB_Exit( int status )
+{
+    for(;;);
+}
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    int UNEXPECTED_RETURN = 0;
+    _PDCLIB_Exit( 0 );
+    TESTCASE( UNEXPECTED_RETURN );
+    return TEST_RESULTS;
+}
+
+#endif
diff --git a/platform/gandr/functions/_PDCLIB/_PDCLIB_allocpages.c b/platform/gandr/functions/_PDCLIB/_PDCLIB_allocpages.c
new file mode 100644 (file)
index 0000000..bdcd525
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$ */
+
+/* _PDCLIB_allocpages( int const )
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+/* This is a stub implementation of _PDCLIB_allocpages
+*/
+
+#include <stdint.h>
+#include <stddef.h>
+#include <_PDCLIB_glue.h>
+#include <errno.h>
+
+void * _PDCLIB_allocpages( size_t n )
+{
+    errno = ENOTSUP;
+    return NULL;
+}
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    return TEST_RESULTS;
+}
+
+#endif
diff --git a/platform/gandr/functions/_PDCLIB/_PDCLIB_freepages.c b/platform/gandr/functions/_PDCLIB/_PDCLIB_freepages.c
new file mode 100644 (file)
index 0000000..c776876
--- /dev/null
@@ -0,0 +1,30 @@
+/* $Id$ */\r
+\r
+/* _PDCLIB_allocpages( int const )\r
+\r
+   This file is part of the Public Domain C Library (PDCLib).\r
+   Permission is granted to use, modify, and / or redistribute at will.\r
+*/\r
+\r
+/* This is a stub implementation of _PDCLIB_allocpages\r
+*/\r
+\r
+#include <stdint.h>\r
+#include <stddef.h>\r
+#include <_PDCLIB_glue.h>\r
+#include <errno.h>\r
+\r
+void _PDCLIB_freepages( void * p, size_t n )\r
+{\r
+    return;\r
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    return TEST_RESULTS;\r
+}\r
+\r
+#endif\r
diff --git a/platform/gandr/functions/_PDCLIB/_PDCLIB_stdinit.c b/platform/gandr/functions/_PDCLIB/_PDCLIB_stdinit.c
new file mode 100644 (file)
index 0000000..b6b378e
--- /dev/null
@@ -0,0 +1,401 @@
+/* _PDCLIB_stdinit
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#include <stdio.h>
+#include <locale.h>
+#include <limits.h>
+
+#ifndef REGTEST
+#include <_PDCLIB_io.h>
+#include <_PDCLIB_locale.h>
+#include <_PDCLIB_clocale.h>
+#include <threads.h>
+
+/* TODO: This is proof-of-concept, requires finetuning. */
+static char _PDCLIB_sin_buffer[BUFSIZ];
+static char _PDCLIB_sout_buffer[BUFSIZ];
+static char _PDCLIB_serr_buffer[BUFSIZ];
+
+static unsigned char _PDCLIB_sin_ungetbuf[_PDCLIB_UNGETCBUFSIZE];
+static unsigned char _PDCLIB_sout_ungetbuf[_PDCLIB_UNGETCBUFSIZE];
+static unsigned char _PDCLIB_serr_ungetbuf[_PDCLIB_UNGETCBUFSIZE];
+
+extern _PDCLIB_fileops_t _PDCLIB_fileops;
+
+static FILE _PDCLIB_serr = { 
+    .ops        = &_PDCLIB_fileops, 
+    .handle     = { .pointer = NULL }, 
+    .buffer     = _PDCLIB_serr_buffer, 
+    .bufsize    = BUFSIZ, 
+    .bufidx     = 0, 
+    .bufend     = 0, 
+    .ungetidx   = 0, 
+    .ungetbuf   = _PDCLIB_serr_ungetbuf, 
+    .status     = _IONBF | _PDCLIB_FWRITE | _PDCLIB_STATIC, 
+    .filename   = NULL, 
+    .next       = NULL,
+};
+static FILE _PDCLIB_sout = { 
+    .ops        = &_PDCLIB_fileops, 
+    .handle     = { .pointer = NULL },
+    .buffer     = _PDCLIB_sout_buffer, 
+    .bufsize    = BUFSIZ, 
+    .bufidx     = 0, 
+    .bufend     = 0, 
+    .ungetidx   = 0, 
+    .ungetbuf   = _PDCLIB_sout_ungetbuf, 
+    .status     = _IOLBF | _PDCLIB_FWRITE | _PDCLIB_STATIC, 
+    .filename   = NULL, 
+    .next       = &_PDCLIB_serr 
+};
+static FILE _PDCLIB_sin  = { 
+    .ops        = &_PDCLIB_fileops, 
+    .handle     = { .pointer = NULL }, 
+    .buffer     = _PDCLIB_sin_buffer, 
+    .bufsize    = BUFSIZ, 
+    .bufidx     = 0, 
+    .bufend     = 0, 
+    .ungetidx   = 0, 
+    .ungetbuf   = _PDCLIB_sin_ungetbuf, 
+    .status     = _IOLBF | _PDCLIB_FREAD | _PDCLIB_STATIC, 
+    .filename   = NULL, 
+    .next       = &_PDCLIB_sout 
+};
+
+FILE * stdin  = &_PDCLIB_sin;
+FILE * stdout = &_PDCLIB_sout;
+FILE * stderr = &_PDCLIB_serr;
+
+tss_t _PDCLIB_locale_tss;
+
+/* FIXME: This approach is a possible attack vector. */
+FILE * _PDCLIB_filelist = &_PDCLIB_sin;
+
+/* "C" locale - defaulting to ASCII-7.
+   1 kByte (+ 4 byte) of <ctype.h> data.
+   Each line: flags, lowercase, uppercase, collation.
+*/
+static const _PDCLIB_ctype_t global_ctype[] = {
+    { /* EOF */    0,    0,    0,    0 },
+    { /* NUL */ _PDCLIB_CTYPE_CNTRL,                                             0x00, 0x00, 0x00 },
+    { /* SOH */ _PDCLIB_CTYPE_CNTRL,                                             0x01, 0x01, 0x01 },
+    { /* STX */ _PDCLIB_CTYPE_CNTRL,                                             0x02, 0x02, 0x02 },
+    { /* ETX */ _PDCLIB_CTYPE_CNTRL,                                             0x03, 0x03, 0x03 },
+    { /* EOT */ _PDCLIB_CTYPE_CNTRL,                                             0x04, 0x04, 0x04 },
+    { /* ENQ */ _PDCLIB_CTYPE_CNTRL,                                             0x05, 0x05, 0x05 },
+    { /* ACK */ _PDCLIB_CTYPE_CNTRL,                                             0x06, 0x06, 0x06 },
+    { /* BEL */ _PDCLIB_CTYPE_CNTRL,                                             0x07, 0x07, 0x07 },
+    { /*  BS */ _PDCLIB_CTYPE_CNTRL,                                             0x08, 0x08, 0x08 },
+    { /*  HT */ _PDCLIB_CTYPE_CNTRL | _PDCLIB_CTYPE_BLANK | _PDCLIB_CTYPE_SPACE, 0x09, 0x09, 0x09 },
+    { /*  LF */ _PDCLIB_CTYPE_CNTRL | _PDCLIB_CTYPE_SPACE,                       0x0A, 0x0A, 0x0A },
+    { /*  VT */ _PDCLIB_CTYPE_CNTRL | _PDCLIB_CTYPE_SPACE,                       0x0B, 0x0B, 0x0B },
+    { /*  FF */ _PDCLIB_CTYPE_CNTRL | _PDCLIB_CTYPE_SPACE,                       0x0C, 0x0C, 0x0C },
+    { /*  CR */ _PDCLIB_CTYPE_CNTRL | _PDCLIB_CTYPE_SPACE,                       0x0D, 0x0D, 0x0D },
+    { /*  SO */ _PDCLIB_CTYPE_CNTRL,                                             0x0E, 0x0E, 0x0E },
+    { /*  SI */ _PDCLIB_CTYPE_CNTRL,                                             0x0F, 0x0F, 0x0F },
+    { /* DLE */ _PDCLIB_CTYPE_CNTRL,                                             0x10, 0x10, 0x10 },
+    { /* DC1 */ _PDCLIB_CTYPE_CNTRL,                                             0x11, 0x11, 0x11 },
+    { /* DC2 */ _PDCLIB_CTYPE_CNTRL,                                             0x12, 0x12, 0x12 },
+    { /* DC3 */ _PDCLIB_CTYPE_CNTRL,                                             0x13, 0x13, 0x13 },
+    { /* DC4 */ _PDCLIB_CTYPE_CNTRL,                                             0x14, 0x14, 0x14 },
+    { /* NAK */ _PDCLIB_CTYPE_CNTRL,                                             0x15, 0x15, 0x15 },
+    { /* SYN */ _PDCLIB_CTYPE_CNTRL,                                             0x16, 0x16, 0x16 },
+    { /* ETB */ _PDCLIB_CTYPE_CNTRL,                                             0x17, 0x17, 0x17 },
+    { /* CAN */ _PDCLIB_CTYPE_CNTRL,                                             0x18, 0x18, 0x18 },
+    { /*  EM */ _PDCLIB_CTYPE_CNTRL,                                             0x19, 0x19, 0x19 },
+    { /* SUB */ _PDCLIB_CTYPE_CNTRL,                                             0x1A, 0x1A, 0x1A },
+    { /* ESC */ _PDCLIB_CTYPE_CNTRL,                                             0x1B, 0x1B, 0x1B },
+    { /*  FS */ _PDCLIB_CTYPE_CNTRL,                                             0x1C, 0x1C, 0x1C },
+    { /*  GS */ _PDCLIB_CTYPE_CNTRL,                                             0x1D, 0x1D, 0x1D },
+    { /*  RS */ _PDCLIB_CTYPE_CNTRL,                                             0x1E, 0x1E, 0x1E },
+    { /*  US */ _PDCLIB_CTYPE_CNTRL,                                             0x1F, 0x1F, 0x1F },
+    { /*  SP */ _PDCLIB_CTYPE_BLANK | _PDCLIB_CTYPE_SPACE,                       0x20, 0x20, 0x20 },
+    { /* '!' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x21, 0x21, 0x21 },
+    { /* '"' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x22, 0x22, 0x22 },
+    { /* '#' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x23, 0x23, 0x23 },
+    { /* '$' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x24, 0x24, 0x24 },
+    { /* '%' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x25, 0x25, 0x25 },
+    { /* '&' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x26, 0x26, 0x26 },
+    { /* ''' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x27, 0x27, 0x27 },
+    { /* '(' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x28, 0x28, 0x28 },
+    { /* ')' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x29, 0x29, 0x29 },
+    { /* '*' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x2A, 0x2A, 0x2A },
+    { /* '+' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x2B, 0x2B, 0x2B },
+    { /* ',' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x2C, 0x2C, 0x2C },
+    { /* '-' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x2D, 0x2D, 0x2D },
+    { /* '.' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x2E, 0x2E, 0x2E },
+    { /* '/' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x2F, 0x2F, 0x2F },
+    { /* '0' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x30, 0x30, 0x30 },
+    { /* '1' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x31, 0x31, 0x31 },
+    { /* '2' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x32, 0x32, 0x32 },
+    { /* '3' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x33, 0x33, 0x33 },
+    { /* '4' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x34, 0x34, 0x34 },
+    { /* '5' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x35, 0x35, 0x35 },
+    { /* '6' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x36, 0x36, 0x36 },
+    { /* '7' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x37, 0x37, 0x37 },
+    { /* '8' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x38, 0x38, 0x38 },
+    { /* '9' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_DIGIT | _PDCLIB_CTYPE_XDIGT, 0x39, 0x39, 0x39 },
+    { /* ':' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x3A, 0x3A, 0x3A },
+    { /* ';' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x3B, 0x3B, 0x3B },
+    { /* '<' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x3C, 0x3C, 0x3C },
+    { /* '=' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x3D, 0x3D, 0x3D },
+    { /* '>' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x3E, 0x3E, 0x3E },
+    { /* '?' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x3F, 0x3F, 0x3F },
+    { /* '@' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x40, 0x40, 0x40 },
+    { /* 'A' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER | _PDCLIB_CTYPE_XDIGT, 0x41, 0x61, 0x41 },
+    { /* 'B' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER | _PDCLIB_CTYPE_XDIGT, 0x42, 0x62, 0x42 },
+    { /* 'C' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER | _PDCLIB_CTYPE_XDIGT, 0x43, 0x63, 0x43 },
+    { /* 'D' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER | _PDCLIB_CTYPE_XDIGT, 0x44, 0x64, 0x44 },
+    { /* 'E' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER | _PDCLIB_CTYPE_XDIGT, 0x45, 0x65, 0x45 },
+    { /* 'F' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER | _PDCLIB_CTYPE_XDIGT, 0x46, 0x66, 0x46 },
+    { /* 'G' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x47, 0x67, 0x47 },
+    { /* 'H' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x48, 0x68, 0x48 },
+    { /* 'I' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x49, 0x69, 0x49 },
+    { /* 'J' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x4A, 0x6A, 0x4A },
+    { /* 'K' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x4B, 0x6B, 0x4B },
+    { /* 'L' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x4C, 0x6C, 0x4C },
+    { /* 'M' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x4D, 0x6D, 0x4D },
+    { /* 'N' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x4E, 0x6E, 0x4E },
+    { /* 'O' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x4F, 0x6F, 0x4F },
+    { /* 'P' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x50, 0x70, 0x50 },
+    { /* 'Q' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x51, 0x71, 0x51 },
+    { /* 'R' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x52, 0x72, 0x52 },
+    { /* 'S' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x53, 0x73, 0x53 },
+    { /* 'T' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x54, 0x74, 0x54 },
+    { /* 'U' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x55, 0x75, 0x55 },
+    { /* 'V' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x56, 0x76, 0x56 },
+    { /* 'W' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x57, 0x77, 0x57 },
+    { /* 'X' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x58, 0x78, 0x58 },
+    { /* 'Y' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x59, 0x79, 0x59 },
+    { /* 'Z' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x5A, 0x7A, 0x5A },
+    { /* '[' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x5B, 0x5B, 0x5B },
+    { /* '\' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x5C, 0x5C, 0x5C },
+    { /* ']' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x5D, 0x5D, 0x5D },
+    { /* '^' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x5E, 0x5E, 0x5E },
+    { /* '_' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x5F, 0x5F, 0x5F },
+    { /* '`' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x60, 0x60, 0x60 },
+    { /* 'a' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER | _PDCLIB_CTYPE_XDIGT, 0x41, 0x61, 0x61 },
+    { /* 'b' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER | _PDCLIB_CTYPE_XDIGT, 0x42, 0x62, 0x62 },
+    { /* 'c' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER | _PDCLIB_CTYPE_XDIGT, 0x43, 0x63, 0x63 },
+    { /* 'd' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER | _PDCLIB_CTYPE_XDIGT, 0x44, 0x64, 0x64 },
+    { /* 'e' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER | _PDCLIB_CTYPE_XDIGT, 0x45, 0x65, 0x65 },
+    { /* 'f' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER | _PDCLIB_CTYPE_XDIGT, 0x46, 0x66, 0x66 },
+    { /* 'g' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x47, 0x67, 0x67 },
+    { /* 'h' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x48, 0x68, 0x68 },
+    { /* 'i' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x49, 0x69, 0x69 },
+    { /* 'j' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x4A, 0x6A, 0x6A },
+    { /* 'k' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x4B, 0x6B, 0x6B },
+    { /* 'l' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x4C, 0x6C, 0x6C },
+    { /* 'm' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x4D, 0x6D, 0x6D },
+    { /* 'n' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x4E, 0x6E, 0x6E },
+    { /* 'o' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x4F, 0x6F, 0x6F },
+    { /* 'p' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x50, 0x70, 0x70 },
+    { /* 'q' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x51, 0x71, 0x71 },
+    { /* 'r' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x52, 0x72, 0x72 },
+    { /* 's' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x53, 0x73, 0x73 },
+    { /* 't' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x54, 0x74, 0x74 },
+    { /* 'u' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x55, 0x75, 0x75 },
+    { /* 'v' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x56, 0x76, 0x76 },
+    { /* 'w' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x57, 0x77, 0x77 },
+    { /* 'x' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x58, 0x78, 0x78 },
+    { /* 'y' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x59, 0x79, 0x79 },
+    { /* 'z' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x5A, 0x7A, 0x7A },
+    { /* '{' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x7B, 0x7B, 0x7B },
+    { /* '|' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x7C, 0x7C, 0x7C },
+    { /* '}' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x7D, 0x7D, 0x7D },
+    { /* '~' */ _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_PUNCT,                       0x7E, 0x7E, 0x7E },
+    { /* DEL */ _PDCLIB_CTYPE_CNTRL,                                             0x7F, 0x7F, 0x7F },
+    { 0x00, 0x80, 0x80, 0x80 },
+    { 0x00, 0x81, 0x81, 0x81 },
+    { 0x00, 0x82, 0x82, 0x82 },
+    { 0x00, 0x83, 0x83, 0x83 },
+    { 0x00, 0x84, 0x84, 0x84 },
+    { 0x00, 0x85, 0x85, 0x85 },
+    { 0x00, 0x86, 0x86, 0x86 },
+    { 0x00, 0x87, 0x87, 0x87 },
+    { 0x00, 0x88, 0x88, 0x88 },
+    { 0x00, 0x89, 0x89, 0x89 },
+    { 0x00, 0x8A, 0x8A, 0x8A },
+    { 0x00, 0x8B, 0x8B, 0x8B },
+    { 0x00, 0x8C, 0x8C, 0x8C },
+    { 0x00, 0x8D, 0x8D, 0x8D },
+    { 0x00, 0x8E, 0x8E, 0x8E },
+    { 0x00, 0x8F, 0x8F, 0x8F },
+    { 0x00, 0x90, 0x90, 0x90 },
+    { 0x00, 0x91, 0x91, 0x91 },
+    { 0x00, 0x92, 0x92, 0x92 },
+    { 0x00, 0x93, 0x93, 0x93 },
+    { 0x00, 0x94, 0x94, 0x94 },
+    { 0x00, 0x95, 0x95, 0x95 },
+    { 0x00, 0x96, 0x96, 0x96 },
+    { 0x00, 0x97, 0x97, 0x97 },
+    { 0x00, 0x98, 0x98, 0x98 },
+    { 0x00, 0x99, 0x99, 0x99 },
+    { 0x00, 0x9A, 0x9A, 0x9A },
+    { 0x00, 0x9B, 0x9B, 0x9B },
+    { 0x00, 0x9C, 0x9C, 0x9C },
+    { 0x00, 0x9D, 0x9D, 0x9D },
+    { 0x00, 0x9E, 0x9E, 0x9E },
+    { 0x00, 0x9F, 0x9F, 0x9F },
+    { 0x00, 0xA0, 0xA0, 0xA0 },
+    { 0x00, 0xA1, 0xA1, 0xA1 },
+    { 0x00, 0xA2, 0xA2, 0xA2 },
+    { 0x00, 0xA3, 0xA3, 0xA3 },
+    { 0x00, 0xA4, 0xA4, 0xA4 },
+    { 0x00, 0xA5, 0xA5, 0xA5 },
+    { 0x00, 0xA6, 0xA6, 0xA6 },
+    { 0x00, 0xA7, 0xA7, 0xA7 },
+    { 0x00, 0xA8, 0xA8, 0xA8 },
+    { 0x00, 0xA9, 0xA9, 0xA9 },
+    { 0x00, 0xAA, 0xAA, 0xAA },
+    { 0x00, 0xAB, 0xAB, 0xAB },
+    { 0x00, 0xAC, 0xAC, 0xAC },
+    { 0x00, 0xAD, 0xAD, 0xAD },
+    { 0x00, 0xAE, 0xAE, 0xAE },
+    { 0x00, 0xAF, 0xAF, 0xAF },
+    { 0x00, 0xB0, 0xB0, 0xB0 },
+    { 0x00, 0xB1, 0xB1, 0xB1 },
+    { 0x00, 0xB2, 0xB2, 0xB2 },
+    { 0x00, 0xB3, 0xB3, 0xB3 },
+    { 0x00, 0xB4, 0xB4, 0xB4 },
+    { 0x00, 0xB5, 0xB5, 0xB5 },
+    { 0x00, 0xB6, 0xB6, 0xB6 },
+    { 0x00, 0xB7, 0xB7, 0xB7 },
+    { 0x00, 0xB8, 0xB8, 0xB8 },
+    { 0x00, 0xB9, 0xB9, 0xB9 },
+    { 0x00, 0xBA, 0xBA, 0xBA },
+    { 0x00, 0xBB, 0xBB, 0xBB },
+    { 0x00, 0xBC, 0xBC, 0xBC },
+    { 0x00, 0xBD, 0xBD, 0xBD },
+    { 0x00, 0xBE, 0xBE, 0xBE },
+    { 0x00, 0xBF, 0xBF, 0xBF },
+    { 0x00, 0xC0, 0xC0, 0xC0 },
+    { 0x00, 0xC1, 0xC1, 0xC1 },
+    { 0x00, 0xC2, 0xC2, 0xC2 },
+    { 0x00, 0xC3, 0xC3, 0xC3 },
+    { 0x00, 0xC4, 0xC4, 0xC4 },
+    { 0x00, 0xC5, 0xC5, 0xC5 },
+    { 0x00, 0xC6, 0xC6, 0xC6 },
+    { 0x00, 0xC7, 0xC7, 0xC7 },
+    { 0x00, 0xC8, 0xC8, 0xC8 },
+    { 0x00, 0xC9, 0xC9, 0xC9 },
+    { 0x00, 0xCA, 0xCA, 0xCA },
+    { 0x00, 0xCB, 0xCB, 0xCB },
+    { 0x00, 0xCC, 0xCC, 0xCC },
+    { 0x00, 0xCD, 0xCD, 0xCD },
+    { 0x00, 0xCE, 0xCE, 0xCE },
+    { 0x00, 0xCF, 0xCF, 0xCF },
+    { 0x00, 0xD0, 0xD0, 0xD0 },
+    { 0x00, 0xD1, 0xD1, 0xD1 },
+    { 0x00, 0xD2, 0xD2, 0xD2 },
+    { 0x00, 0xD3, 0xD3, 0xD3 },
+    { 0x00, 0xD4, 0xD4, 0xD4 },
+    { 0x00, 0xD5, 0xD5, 0xD5 },
+    { 0x00, 0xD6, 0xD6, 0xD6 },
+    { 0x00, 0xD7, 0xD7, 0xD7 },
+    { 0x00, 0xD8, 0xD8, 0xD8 },
+    { 0x00, 0xD9, 0xD9, 0xD9 },
+    { 0x00, 0xDA, 0xDA, 0xDA },
+    { 0x00, 0xDB, 0xDB, 0xDB },
+    { 0x00, 0xDC, 0xDC, 0xDC },
+    { 0x00, 0xDD, 0xDD, 0xDD },
+    { 0x00, 0xDE, 0xDE, 0xDE },
+    { 0x00, 0xDF, 0xDF, 0xDF },
+    { 0x00, 0xE0, 0xE0, 0xE0 },
+    { 0x00, 0xE1, 0xE1, 0xE1 },
+    { 0x00, 0xE2, 0xE2, 0xE2 },
+    { 0x00, 0xE3, 0xE3, 0xE3 },
+    { 0x00, 0xE4, 0xE4, 0xE4 },
+    { 0x00, 0xE5, 0xE5, 0xE5 },
+    { 0x00, 0xE6, 0xE6, 0xE6 },
+    { 0x00, 0xE7, 0xE7, 0xE7 },
+    { 0x00, 0xE8, 0xE8, 0xE8 },
+    { 0x00, 0xE9, 0xE9, 0xE9 },
+    { 0x00, 0xEA, 0xEA, 0xEA },
+    { 0x00, 0xEB, 0xEB, 0xEB },
+    { 0x00, 0xEC, 0xEC, 0xEC },
+    { 0x00, 0xED, 0xED, 0xED },
+    { 0x00, 0xEE, 0xEE, 0xEE },
+    { 0x00, 0xEF, 0xEF, 0xEF },
+    { 0x00, 0xF0, 0xF0, 0xF0 },
+    { 0x00, 0xF1, 0xF1, 0xF1 },
+    { 0x00, 0xF2, 0xF2, 0xF2 },
+    { 0x00, 0xF3, 0xF3, 0xF3 },
+    { 0x00, 0xF4, 0xF4, 0xF4 },
+    { 0x00, 0xF5, 0xF5, 0xF5 },
+    { 0x00, 0xF6, 0xF6, 0xF6 },
+    { 0x00, 0xF7, 0xF7, 0xF7 },
+    { 0x00, 0xF8, 0xF8, 0xF8 },
+    { 0x00, 0xF9, 0xF9, 0xF9 },
+    { 0x00, 0xFA, 0xFA, 0xFA },
+    { 0x00, 0xFB, 0xFB, 0xFB },
+    { 0x00, 0xFC, 0xFC, 0xFC },
+    { 0x00, 0xFD, 0xFD, 0xFD },
+    { 0x00, 0xFE, 0xFE, 0xFE },
+    { 0x00, 0xFF, 0xFF, 0xFF }
+};
+
+extern const struct _PDCLIB_charcodec _PDCLIB_ascii_codec;
+struct _PDCLIB_locale _PDCLIB_global_locale = {
+    ._Codec = &_PDCLIB_ascii_codec,
+    ._Conv  = { 
+        /* decimal_point      */ (char *)".",
+        /* thousands_sep      */ (char *)"",
+        /* grouping           */ (char *)"",
+        /* mon_decimal_point  */ (char *)"",
+        /* mon_thousands_sep  */ (char *)"",
+        /* mon_grouping       */ (char *)"",
+        /* positive_sign      */ (char *)"",
+        /* negative_sign      */ (char *)"",
+        /* currency_symbol    */ (char *)"",
+        /* int_curr_symbol    */ (char *)"",
+        /* frac_digits        */ CHAR_MAX,
+        /* p_cs_precedes      */ CHAR_MAX,
+        /* n_cs_precedes      */ CHAR_MAX,
+        /* p_sep_by_space     */ CHAR_MAX,
+        /* n_sep_by_space     */ CHAR_MAX,
+        /* p_sign_posn        */ CHAR_MAX,
+        /* n_sign_posn        */ CHAR_MAX,
+        /* int_frac_digits    */ CHAR_MAX,
+        /* int_p_cs_precedes  */ CHAR_MAX,
+        /* int_n_cs_precedes  */ CHAR_MAX,
+        /* int_p_sep_by_space */ CHAR_MAX,
+        /* int_n_sep_by_space */ CHAR_MAX,
+        /* int_p_sign_posn    */ CHAR_MAX,
+        /* int_n_sign_posn    */ CHAR_MAX,
+    },
+    ._CType = &global_ctype[1],
+    ._ErrnoStr = {
+        /* no error */ (char *)"",
+        /* ERANGE   */ (char *)"ERANGE (Range error)",
+        /* EDOM     */ (char *)"EDOM (Domain error)",
+        /* EILSEQ   */ (char *)"EILSEQ (Illegal sequence)"
+    },
+};
+
+/* Todo: Better solution than this! */
+__attribute__((constructor)) void init_stdio(void)
+{
+    _PDCLIB_initclocale( &_PDCLIB_global_locale );
+    mtx_init(&stdin->lock,  mtx_recursive);
+    mtx_init(&stdout->lock, mtx_recursive);
+    mtx_init(&stderr->lock, mtx_recursive);
+}
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    /* Testing covered by several other testdrivers using stdin / stdout / 
+       stderr.
+    */
+    return TEST_RESULTS;
+}
+
+#endif
diff --git a/platform/gandr/functions/signal/raise.c b/platform/gandr/functions/signal/raise.c
new file mode 100644 (file)
index 0000000..8d7080b
--- /dev/null
@@ -0,0 +1,114 @@
+/* $Id$ */
+
+/* raise( int )
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#include <signal.h>
+
+#ifndef REGTEST
+
+#include <stdio.h>
+#include <stdlib.h>
+
+extern void (*_PDCLIB_sigabrt)( int );
+extern void (*_PDCLIB_sigfpe)( int );
+extern void (*_PDCLIB_sigill)( int );
+extern void (*_PDCLIB_sigint)( int );
+extern void (*_PDCLIB_sigsegv)( int );
+extern void (*_PDCLIB_sigterm)( int );
+
+int raise( int sig )
+{
+    void (*sighandler)( int );
+    char const * message;
+    switch ( sig )
+    {
+        case SIGABRT:
+            sighandler = _PDCLIB_sigabrt;
+            message = "Abnormal termination (SIGABRT)";
+            break;
+        case SIGFPE:
+            sighandler = _PDCLIB_sigfpe;
+            message = "Arithmetic exception (SIGFPE)";
+            break;
+        case SIGILL:
+            sighandler = _PDCLIB_sigill;
+            message = "Illegal instruction (SIGILL)";
+            break;
+        case SIGINT:
+            sighandler = _PDCLIB_sigint;
+            message = "Interactive attention signal (SIGINT)";
+            break;
+        case SIGSEGV:
+            sighandler = _PDCLIB_sigsegv;
+            message = "Invalid memory access (SIGSEGV)";
+            break;
+        case SIGTERM:
+            sighandler = _PDCLIB_sigterm;
+            message = "Termination request (SIGTERM)";
+            break;
+        default:
+            fprintf( stderr, "Unknown signal #%d\n", sig );
+            _Exit( EXIT_FAILURE );
+    }
+    if ( sighandler == SIG_DFL )
+    {
+        fputs( message, stderr );
+        _Exit( EXIT_FAILURE );
+    }
+    else if ( sighandler != SIG_IGN )
+    {
+        sighandler = signal( sig, SIG_DFL );
+        sighandler( sig );
+    }
+    return 0;
+}
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+#include <stdlib.h>
+
+static volatile sig_atomic_t flag = 0;
+
+static int expected_signal = 0;
+
+static void test_handler( int sig )
+{
+    TESTCASE( sig == expected_signal );
+    flag = 1;
+}
+
+int main( void )
+{
+    /* Could be other than SIG_DFL if you changed the implementation. */
+    TESTCASE( signal( SIGABRT, SIG_IGN ) == SIG_DFL );
+    /* Should be ignored. */
+    TESTCASE( raise( SIGABRT ) == 0 );
+    /* Installing test handler, old handler should be returned */
+    TESTCASE( signal( SIGABRT, test_handler ) == SIG_IGN );
+    /* Raising and checking SIGABRT */
+    expected_signal = SIGABRT;
+    TESTCASE( raise( SIGABRT ) == 0 );
+    TESTCASE( flag == 1 );
+    /* Re-installing test handler, should have been reset to default */
+    /* Could be other than SIG_DFL if you changed the implementation. */
+    TESTCASE( signal( SIGABRT, test_handler ) == SIG_DFL );
+    /* Raising and checking SIGABRT */
+    flag = 0;
+    TESTCASE( raise( SIGABRT ) == 0 );
+    TESTCASE( flag == 1 );
+    /* Installing test handler for different signal... */
+    TESTCASE( signal( SIGTERM, test_handler ) == SIG_DFL );
+    /* Raising and checking SIGTERM */
+    expected_signal = SIGTERM;
+    TESTCASE( raise( SIGTERM ) == 0 );
+    TESTCASE( flag == 1 );
+    return TEST_RESULTS;
+}
+#endif
diff --git a/platform/gandr/functions/signal/signal.c b/platform/gandr/functions/signal/signal.c
new file mode 100644 (file)
index 0000000..aae95a9
--- /dev/null
@@ -0,0 +1,73 @@
+/* $Id$ */
+
+/* signal( int sig, void (*func)( int ) )
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#include <signal.h>
+
+#ifndef REGTEST
+
+#include <stdlib.h>
+#include <errno.h>
+
+void (*_PDCLIB_sigabrt)( int ) = SIG_DFL;
+void (*_PDCLIB_sigfpe)( int )  = SIG_DFL;
+void (*_PDCLIB_sigill)( int )  = SIG_DFL;
+void (*_PDCLIB_sigint)( int )  = SIG_DFL;
+void (*_PDCLIB_sigsegv)( int ) = SIG_DFL;
+void (*_PDCLIB_sigterm)( int ) = SIG_DFL;
+
+void (*signal( int sig, void (*func)( int ) ) )( int )
+{
+    void (*oldhandler)( int );
+    if ( sig <= 0 || func == SIG_ERR )
+    {
+        return SIG_ERR;
+    }
+    switch ( sig )
+    {
+        case SIGABRT:
+            oldhandler = _PDCLIB_sigabrt;
+            _PDCLIB_sigabrt = func;
+            break;
+        case SIGFPE:
+            oldhandler = _PDCLIB_sigfpe;
+            _PDCLIB_sigfpe = func;
+            break;
+        case SIGILL:
+            oldhandler = _PDCLIB_sigill;
+            _PDCLIB_sigill = func;
+            break;
+        case SIGINT:
+            oldhandler = _PDCLIB_sigint;
+            _PDCLIB_sigint = func;
+            break;
+        case SIGSEGV:
+            oldhandler = _PDCLIB_sigsegv;
+            _PDCLIB_sigsegv = func;
+            break;
+        case SIGTERM:
+            oldhandler = _PDCLIB_sigterm;
+            _PDCLIB_sigterm = func;
+            break;
+        default:
+            errno = EINVAL;
+            return SIG_ERR;
+    }
+    return oldhandler;
+}
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    /* Testing covered by raise.c */
+    return TEST_RESULTS;
+}
+#endif
diff --git a/platform/gandr/functions/stdio/_PDCLIB_fileops.c b/platform/gandr/functions/stdio/_PDCLIB_fileops.c
new file mode 100644 (file)
index 0000000..9dff0ce
--- /dev/null
@@ -0,0 +1,61 @@
+/* _PDCLIB_fileops
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#ifndef REGTEST
+#include <stdio.h>
+#include <stdint.h>
+#include <_PDCLIB_glue.h>
+#include <errno.h>
+#include <gd_bal.h>
+
+static bool readf( _PDCLIB_fd_t fd, void * buf, size_t length, 
+                   size_t * numBytesRead )
+{
+    int rv = gd_read(fd.pointer, buf, length, numBytesRead );
+
+    return rv >= 0;
+}
+
+static bool writef( _PDCLIB_fd_t fd, const void * buf, size_t length, 
+                   size_t * numBytesWritten )
+{
+    int rv = gd_write(fd.pointer, buf, length, numBytesWritten );
+
+    return rv >= 0;
+}
+
+static bool seekf( _PDCLIB_fd_t fd, int_fast64_t offset, int whence,
+    int_fast64_t* newPos )
+{
+    int rv = gd_seek( fd.pointer, offset, whence, &newPos );
+
+    return rv >= 0;
+}
+
+static void closef( _PDCLIB_fd_t self )
+{
+    gd_close( self.pointer );
+}
+
+const _PDCLIB_fileops_t _PDCLIB_fileops = {
+    .read  = readf,
+    .write = writef,
+    .seek  = seekf,
+    .close = closef,
+};
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    // Tested by stdio test cases
+    return TEST_RESULTS;
+}
+
+#endif
diff --git a/platform/gandr/functions/stdio/remove.c b/platform/gandr/functions/stdio/remove.c
new file mode 100644 (file)
index 0000000..0c4f050
--- /dev/null
@@ -0,0 +1,39 @@
+/* $Id$ */
+
+/* remove( const char * )
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+/* This is an example implementation of remove() fit for use with POSIX kernels.
+*/
+
+#include <stdio.h>
+
+#ifndef REGTEST
+
+#include <string.h>
+#include <errno.h>
+
+extern struct _PDCLIB_file_t * _PDCLIB_filelist;
+
+int remove( const char * pathname )
+{
+    errno = ENOTSUP;
+    return 1;
+}
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    /* Testing covered by ftell.c (and several others) */
+    return TEST_RESULTS;
+}
+
+#endif
+
diff --git a/platform/gandr/includes/_PDCLIB_config.h b/platform/gandr/includes/_PDCLIB_config.h
new file mode 100644 (file)
index 0000000..598b216
--- /dev/null
@@ -0,0 +1,289 @@
+#ifndef _PDCLIB_CONFIG_H
+#define _PDCLIB_CONFIG_H
+/* Internal PDCLib configuration <_PDCLIB_config.h>
+   (Gandr platform)
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+
+
+/* end of line */
+#define _PDCLIB_endl "\n"
+
+/* exit() */
+#define _PDCLIB_SUCCESS 0
+#define _PDCLIB_FAILURE -1
+
+/* trivial memswp */
+#define _PDCLIB_memswp( i, j, size ) char tmp; do { tmp = *i; *i++ = *j; *j++ = tmp; } while ( --size );
+
+
+#if defined(__arm__)
+  #define _PDCLIB_CHAR_SIGNED 0
+#else
+  #define _PDCLIB_CHAR_SIGNED 1
+#endif
+
+/* Width of the integer types short, int, long, and long long, in bytes.      */
+/* SHRT == 2, INT >= SHRT, LONG >= INT >= 4, LLONG >= LONG - check your       */
+/* compiler manuals.                                                          */
+#define _PDCLIB_SHRT_BYTES  2
+#define _PDCLIB_INT_BYTES 4
+#if defined(__lp64__)
+  #define _PDCLIB_LONG_BYTES 8
+#else
+  #define _PDCLIB_LONG_BYTES 4
+#endif
+#define _PDCLIB_LLONG_BYTES 8
+
+/* layout of div_t, ldiv_t, lldiv_t */
+struct _PDCLIB_div_t   { int quot;            int rem; };
+struct _PDCLIB_ldiv_t  { long int quot;       long int rem; };
+struct _PDCLIB_lldiv_t { long long int quot;  long long int rem; };
+
+/* fast* datatypes. This is a bit of a blunt instrument. */
+#define _PDCLIB_FAST8 CHAR
+#define _PDCLIB_fast8 char
+#define _PDCLIB_FAST8_CONV hh
+
+#define _PDCLIB_FAST16 SHRT
+#define _PDCLIB_fast16 short
+#define _PDCLIB_FAST16_CONV h
+
+#define _PDCLIB_FAST32 INT
+#define _PDCLIB_fast32 int
+#define _PDCLIB_FAST32_CONV
+
+#define _PDCLIB_FAST64 LLONG
+#define _PDCLIB_fast64 long long
+#define _PDCLIB_FAST64_CONV ll
+
+/* ptrdiff_t */
+#define _PDCLIB_ptrdiff long
+#define _PDCLIB_PTRDIFF LONG
+#define _PDCLIB_PTR_CONV l
+
+/* Result type of the 'sizeof' operator (must be unsigned) */
+#define _PDCLIB_size unsigned long
+#define _PDCLIB_SIZE ULONG
+
+/* intptr_t */
+#define _PDCLIB_intptr long
+#define _PDCLIB_INTPTR LONG
+
+/* sig_atomic_t */
+#define _PDCLIB_sig_atomic char
+#define _PDCLIB_SIG_ATOMIC CHAR
+
+/* wint_t, wchar_t */
+#define _PDCLIB_wint  signed int
+#define _PDCLIB_wchar unsigned int
+#define _PDCLIB_WCHAR UINT
+
+
+/* Largest supported integer type */
+#define _PDCLIB_intmax long long int
+#define _PDCLIB_INTMAX LLONG
+#define _PDCLIB_MAX_CONV ll
+#define _PDCLIB_INTMAX_LITERAL ll
+
+struct _PDCLIB_imaxdiv_t { _PDCLIB_intmax quot; _PDCLIB_intmax rem; };
+
+/* time_t */
+#define _PDCLIB_time  unsigned long long
+
+/* clock_t */
+#define _PDCLIB_clock unsigned
+#define _PDCLIB_CLOCKS_PER_SEC 1000000
+
+/* timespec_get */
+#define _PDCLIB_TIME_UTC 1
+
+/* -------------------------------------------------------------------------- */
+/* Floating Point                                                             */
+/* -------------------------------------------------------------------------- */
+
+/* Whether the implementation rounds toward zero (0), to nearest (1), toward
+   positive infinity (2), or toward negative infinity (3). (-1) signifies
+   indeterminable rounding, any other value implementation-specific rounding.
+*/
+#define _PDCLIB_FLT_ROUNDS -1
+
+/* Whether the implementation uses exact-width precision (0), promotes float
+   to double (1), or promotes float and double to long double (2). (-1)
+   signifies indeterminable behaviour, any other value implementation-specific
+   behaviour.
+*/
+#define _PDCLIB_FLT_EVAL_METHOD -1
+
+/* "Number of the decimal digits (n), such that any floating-point number in the
+   widest supported floating type with p(max) radix (b) digits can be rounded to
+   a floating-point number with (n) decimal digits and back again without change
+   to the value p(max) log(10)b if (b) is a power of 10, [1 + p(max) log(10)b]
+   otherwise."
+   64bit IEC 60559 double format (53bit mantissa) is DECIMAL_DIG 17.
+   80bit IEC 60559 double-extended format (64bit mantissa) is DECIMAL_DIG 21.
+*/
+#define _PDCLIB_DECIMAL_DIG 17
+
+/* Floating point types
+ *
+ * PDCLib (at present) assumes IEEE 754 floating point formats
+ * The following names are used:
+ *    SINGLE:   IEEE 754 single precision (32-bit)
+ *    DOUBLE:   IEEE 754 double precision (64-bit)
+ *    EXTENDED: IEEE 754 extended precision (80-bit, as x87)
+ */
+#define _PDCLIB_FLOAT_TYPE   SINGLE
+#define _PDCLIB_DOUBLE_TYPE  DOUBLE
+#if defined(__i386__) || defined(__amd64__)
+  #define _PDCLIB_LDOUBLE_TYPE EXTENDED
+#else
+  #define _PDCLIB_LDOUBLE_TYPE DOUBLE
+#endif
+
+/* -------------------------------------------------------------------------- */
+/* Platform-dependent macros defined by the standard headers.                 */
+/* -------------------------------------------------------------------------- */
+
+/* offsetof */
+#define _PDCLIB_offsetof( type, member ) __builtin_offsetof( type, member )
+
+/* stdarg.h */
+typedef __builtin_va_list _PDCLIB_va_list;
+#define _PDCLIB_va_arg( ap, type ) (__builtin_va_arg( (ap), type ))
+#define _PDCLIB_va_copy( dest, src ) (__builtin_va_copy( (dest), (src) ))
+#define _PDCLIB_va_end( ap ) (__builtin_va_end( ap ) )
+#define _PDCLIB_va_start( ap, parmN ) (__builtin_va_start( (ap), (parmN) ))
+
+/* "OS glue" */
+
+/* Memory management -------------------------------------------------------- */
+
+#define _PDCLIB_MALLOC_PAGESIZE 4096
+#define _PDCLIB_MALLOC_ALIGN 16
+#define _PDCLIB_MALLOC_GRANULARITY 4096
+#define _PDCLIB_MALLOC_TRIM_THRESHOLD 2*1024*1024
+#define _PDCLIB_MALLOC_MMAP_THRESHOLD 256*1024
+#define _PDCLIB_MALLOC_RELEASE_CHECK_RATE 4095
+
+/* Locale --------------------------------------------------------------------*/
+
+/* Locale method. See _PDCLIB_locale.h. If undefined, POSIX per-thread locales
+ * will be disabled
+ */
+/* #define _PDCLIB_LOCALE_METHOD _PDCLIB_LOCALE_METHOD_TSS */
+
+/* wchar_t encoding */
+#define _PDCLIB_WCHAR_ENCODING _PDCLIB_WCHAR_ENCODING_UCS4
+
+/* I/O ---------------------------------------------------------------------- */
+
+/* The default size for file buffers. Must be at least 256. */
+#define _PDCLIB_BUFSIZ 1024
+
+/* Minimum number of files we can open simultaneously. C says this must be >= 8,
+ * so we say that. May actually be a lie in some cases...
+ */
+#define _PDCLIB_FOPEN_MAX 8
+
+/* Length of the longest filename the implementation guarantees to support. */
+#define _PDCLIB_FILENAME_MAX 260
+
+/* Maximum length of filenames generated by tmpnam(). (See tmpfile.c.) */
+#define _PDCLIB_L_tmpnam 260
+
+/* Number of distinct file names that can be generated by tmpnam(). */
+#define _PDCLIB_TMP_MAX 50
+
+/* SEEK_SET, CUR, END */
+#define _PDCLIB_SEEK_SET 0
+#define _PDCLIB_SEEK_CUR 1
+#define _PDCLIB_SEEK_END 2
+
+/* How much can you ungetc? Not much, thankfully */
+#define _PDCLIB_UNGETCBUFSIZE 1
+
+/* errno -------------------------------------------------------------------- */
+
+/* errno values as per C++11 */
+#define _PDCLIB_ERANGE 1
+#define _PDCLIB_EDOM   2
+#define _PDCLIB_EILSEQ 3
+#define _PDCLIB_E2BIG 4
+#define _PDCLIB_ECONNRESET 5
+#define _PDCLIB_EISCONN 6
+#define _PDCLIB_ENOENT 7
+#define _PDCLIB_ENOTRECOVERABLE 8
+#define _PDCLIB_EROFS 9
+#define _PDCLIB_EACCES 10
+#define _PDCLIB_EDEADLK 11
+#define _PDCLIB_EISDIR 12
+#define _PDCLIB_ENOEXEC 13
+#define _PDCLIB_ENOTSOCK 14
+#define _PDCLIB_ESPIPE 15
+#define _PDCLIB_EADDRINUSE 16
+#define _PDCLIB_EDESTADDRREQ 17
+#define _PDCLIB_ELOOP 18
+#define _PDCLIB_ENOLCK 19
+#define _PDCLIB_ENOTSUPP 20
+#define _PDCLIB_ESRCH 21
+#define _PDCLIB_EADDRNOTAVAIL 22
+#define _PDCLIB_EMFILE 23
+#define _PDCLIB_ENOLINK 24
+#define _PDCLIB_ENOTTY 25
+#define _PDCLIB_ETIME 26
+#define _PDCLIB_EAFNOSUPPORT 27
+#define _PDCLIB_EEXIST 28
+#define _PDCLIB_EMLINK 29
+#define _PDCLIB_ENOMEM 30
+#define _PDCLIB_ENXIO 31
+#define _PDCLIB_ETIMEDOUT 32
+#define _PDCLIB_EAGAIN 33
+#define _PDCLIB_EFAULT 34
+#define _PDCLIB_EMSGSIZE 35
+#define _PDCLIB_ENOMSG 36
+#define _PDCLIB_EOPNOTSUPP 37
+#define _PDCLIB_ETXTBSY 38
+#define _PDCLIB_EALREADY 39
+#define _PDCLIB_EFBIG 40
+#define _PDCLIB_ENAMETOOLONG 41
+#define _PDCLIB_ENOPROTOOPT 42
+#define _PDCLIB_EOVERFLOW 43
+#define _PDCLIB_EWOULDBLOCK _PDCLIB_EAGAIN
+#define _PDCLIB_EBADF 44
+#define _PDCLIB_EHOSTUNREACH 45
+#define _PDCLIB_ENETDOWN 46
+#define _PDCLIB_ENOSPC 47
+#define _PDCLIB_EOWNERDEAD 48
+#define _PDCLIB_EXDEV 49
+#define _PDCLIB_EBADMSG 50
+#define _PDCLIB_EIDRM 51
+#define _PDCLIB_ENETRESET 52
+#define _PDCLIB_ENOSR 53
+#define _PDCLIB_EPERM 54
+#define _PDCLIB_EBUSY 55
+#define _PDCLIB_ENETUNREACH 56
+#define _PDCLIB_ENOSTR 57
+#define _PDCLIB_EPIPE 58
+#define _PDCLIB_ECANCELED 59
+#define _PDCLIB_EINPROGRESS 60
+#define _PDCLIB_ENFILE 61
+#define _PDCLIB_ENOSYS 62
+#define _PDCLIB_EPROTO 63
+#define _PDCLIB_ECHILD 64
+#define _PDCLIB_EINTR 65
+#define _PDCLIB_ENOBUFS 66
+#define _PDCLIB_ENOTCONN 67
+#define _PDCLIB_EPROTONOSUPPORT 68
+#define _PDCLIB_ECONNABORTED 69
+#define _PDCLIB_EINVAL 70
+#define _PDCLIB_ENODATA 71
+#define _PDCLIB_ENOTDIR 72
+#define _PDCLIB_EPROTOTYPE 73
+
+#define _PDCLIB_ERRNO_MAX 73
+
+#endif
diff --git a/platform/gandr/includes/signal.h b/platform/gandr/includes/signal.h
new file mode 100644 (file)
index 0000000..8e6df09
--- /dev/null
@@ -0,0 +1,82 @@
+/* 7.14 Signal handling <string.h>
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#ifndef _PDCLIB_SIGNAL_H
+#define _PDCLIB_SIGNAL_H _PDCLIB_SIGNAL_H
+#include <_PDCLIB_config.h>
+
+/* Signals ------------------------------------------------------------------ */
+
+/* A word on signals, to the people using PDCLib in their OS projects.
+
+   The definitions of the C standard leave about everything that *could* be
+   useful to be "implementation defined". Without additional, non-standard
+   arrangements, it is not possible to turn them into a useful tool.
+
+   This example implementation chose to "not generate any of these signals,
+   except as a result of explicit calls to the raise function", which is
+   allowed by the standard but of course does nothing for the usefulness of
+   <signal.h>.
+
+   A useful signal handling would:
+   1) make signal() a system call that registers the signal handler with the OS
+   2) make raise() a system call triggering an OS signal to the running process
+   3) make provisions that further signals of the same type are blocked until
+      the signal handler returns (optional for SIGILL)
+*/
+
+/* Abnormal termination / abort() */
+#define SIGABRT 1
+/* Arithmetic exception / division by zero / overflow */
+#define SIGFPE  2
+/* Illegal instruction */
+#define SIGILL  3
+/* Interactive attention signal */
+#define SIGINT  4
+/* Invalid memory access */
+#define SIGSEGV 5
+/* Termination request */
+#define SIGTERM 6
+
+/* The following should be defined to pointer values that could NEVER point to
+   a valid signal handler function. (They are used as special arguments to
+   signal().) Again, these are the values used by Linux.
+*/
+#define SIG_DFL (void (*)( int ))0
+#define SIG_ERR (void (*)( int ))-1
+#define SIG_IGN (void (*)( int ))1
+
+typedef _PDCLIB_sig_atomic sig_atomic_t;
+
+/* Installs a signal handler "func" for the given signal.
+   A signal handler is a function that takes an integer as argument (the signal
+   number) and returns void.
+
+   Note that a signal handler can do very little else than:
+   1) assign a value to a static object of type "volatile sig_atomic_t",
+   2) call signal() with the value of sig equal to the signal received,
+   3) call _Exit(),
+   4) call abort().
+   Virtually everything else is undefind.
+
+   The signal() function returns the previous installed signal handler, which
+   at program start may be SIG_DFL or SIG_ILL. (This implementation uses
+   SIG_DFL for all handlers.) If the request cannot be honored, SIG_ERR is
+   returned and errno is set to an unspecified positive value.
+*/
+void (*signal( int sig, void (*func)( int ) ) )( int );
+
+/* Raises the given signal (executing the registered signal handler with the
+   given signal number as parameter).
+   This implementation does not prevent further signals of the same time from
+   occuring, but executes signal( sig, SIG_DFL ) before entering the signal
+   handler (i.e., a second signal before the signal handler re-registers itself
+   or SIG_IGN will end the program).
+   Returns zero if successful, nonzero otherwise. */
+int raise( int sig );
+
+#endif
+