SubDir PDCLIB_TOP ;\r
+if $(PDCLIB_PLATFORM) {\r
+ SubInclude PDCLIB_TOP platform $(PDCLIB_PLATFORM) ;\r
+ SubDir PDCLIB_TOP ;\r
+}\r
PDCLibConfig ;\r
\r
PDCLIB_SOURCES = [ RecursiveGlob $(PDCLIB_TOP) : [ FDirName functions ] : *.c ] ;\r
\r
Object $(testfile).o : $(file) ;\r
Object $(regtestfile).o : $(file) ;\r
- MainFromObjects $(testfile) : $(testfile).o ;\r
+ MainFromObjects $(testfile) : $(testfile).o $(CRT0) ;\r
MainFromObjects $(regtestfile) : $(regtestfile).o ;\r
CCFLAGS on $(testfile).o += -DTEST $(PDCLIB_TEST_CCFLAGS) ;\r
CCFLAGS on $(regtestfile).o += -DTEST -DREGTEST \r
$(PDCLIB_REGTEST_CCFLAGS) ;\r
+ CCHDRS on $(regtestfile).o = [ FIncludes [ FDirName testing ] ] ;\r
\r
LINKFLAGS on $(testfile)$(SUFEXE) += $(PDCLIB_TEST_LINKFLAGS) ;\r
LINKFLAGS on $(regtestfile)$(SUFEXE) += $(PDCLIB_REGTEST_LINKFLAGS) ;\r
-Wnested-externs -Wstrict-prototypes -Wmissing-prototypes ;\r
PDCLIB_CCFLAGS = \r
-ffreestanding \r
- -nostdinc \r
+ #-nostdinc \r
-std=c11 \r
-g \r
-D_PDCLIB_BUILD\r
$(PDCLIB_WARNINGS) ;\r
PDCLIB_C++FLAGS =\r
-ffreestanding\r
- -nostdinc\r
+ #-nostdinc\r
-std=c++11\r
-g\r
-D_PDCLIB_BUILD\r
Permission is granted to use, modify, and / or redistribute at will.
*/
+#ifndef REGTEST
#include <_PDCLIB_int.h>
#include <string.h>
#include <ctype.h>
}
return ( sign == '+' ) ? rc : -rc;
}
+#endif
#ifdef TEST
#include <_PDCLIB_test.h>
int main( void )
{
+#ifndef REGTEST
/* basic functionality */
TESTCASE( _PDCLIB_atomax( "123" ) == 123 );
/* testing skipping of leading whitespace and trailing garbage */
TESTCASE( _PDCLIB_atomax( " \n\v\t\f123xyz" ) == 123 );
+#endif
return TEST_RESULTS;
}
#include <stdio.h>
+#ifndef REGTEST
extern struct _PDCLIB_file_t * _PDCLIB_filelist;
void _PDCLIB_closeall( void )
stream = next;
}
}
+#endif
#ifdef TEST
#include <_PDCLIB_test.h>
Permission is granted to use, modify, and / or redistribute at will.
*/
+#ifndef REGTEST
#include <_PDCLIB_int.h>
+#endif
char _PDCLIB_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
int main( void )
{
+#ifndef REGTEST
TESTCASE( strcmp( _PDCLIB_digits, "0123456789abcdefghijklmnopqrstuvwxyz" ) == 0 );
TESTCASE( strcmp( _PDCLIB_Xdigits, "0123456789ABCDEF" ) == 0 );
+#endif
return TEST_RESULTS;
}
Permission is granted to use, modify, and / or redistribute at will.
*/
-#include <_PDCLIB_int.h>
-
#ifndef REGTEST
+#include <_PDCLIB_int.h>
int _PDCLIB_errno = 0;
#include <stddef.h>
+#ifndef REGTEST
/* Helper function that parses the C-style mode string passed to fopen() into
the PDCLib flags FREAD, FWRITE, FAPPEND, FRW (read-write) and FBIN (binary
mode).
/* Longer than three chars - invalid. */
return 0;
}
+#endif
#ifdef TEST
#include <_PDCLIB_test.h>
int main( void )
{
+#ifndef REGTEST
TESTCASE( _PDCLIB_filemode( "r" ) == _PDCLIB_FREAD );
TESTCASE( _PDCLIB_filemode( "w" ) == _PDCLIB_FWRITE );
TESTCASE( _PDCLIB_filemode( "a" ) == ( _PDCLIB_FAPPEND | _PDCLIB_FWRITE ) );
TESTCASE( _PDCLIB_filemode( "r++" ) == 0 );
TESTCASE( _PDCLIB_filemode( "wbb" ) == 0 );
TESTCASE( _PDCLIB_filemode( "a+bx" ) == 0 );
+#endif
return TEST_RESULTS;
}
#include <stdio.h>
#include <errno.h>
+#ifndef REGTEST
#include <_PDCLIB_glue.h>
int _PDCLIB_prepread( struct _PDCLIB_file_t * stream )
return 0;
}
}
+#endif
#ifdef TEST
#include <_PDCLIB_test.h>
#include <stdio.h>
#include <errno.h>
+#ifndef REGTEST
int _PDCLIB_prepwrite( struct _PDCLIB_file_t * stream )
{
if ( ( stream->bufidx < stream->bufend ) || ( stream->ungetidx > 0 ) ||
stream->status |= _PDCLIB_FWRITE | _PDCLIB_BYTESTREAM;
return 0;
}
+#endif
#ifdef TEST
#include <_PDCLIB_test.h>
#include <stdlib.h>
#include <stddef.h>
+#ifndef REGTEST
+
/* Using an integer's bits as flags for both the conversion flags and length
modifiers.
*/
return ++spec;
}
+#endif
+
#ifdef TEST
#define _PDCLIB_FILEID "_PDCLIB/print.c"
#define _PDCLIB_STRINGIO
#include <_PDCLIB_test.h>
+#ifndef REGTEST
static int testprintf( char * buffer, const char * format, ... )
{
/* Members: base, flags, n, i, current, s, width, prec, stream, arg */
va_end( status.arg );
return status.i;
}
+#endif
#define TEST_CONVERSION_ONLY
int main( void )
{
+#ifndef REGTEST
char target[100];
#include "printf_testcases.h"
+#endif
return TEST_RESULTS;
}
#include <stddef.h>
#include <limits.h>
+#ifndef REGTEST
+
/* Using an integer's bits as flags for both the conversion flags and length
modifiers.
*/
/* TODO: Floats. */
return NULL;
}
-
+#endif
#ifdef TEST
#define _PDCLIB_FILEID "_PDCLIB/scan.c"
#include <_PDCLIB_test.h>
+#ifndef REGTEST
static int testscanf( char const * s, char const * format, ... )
{
struct _PDCLIB_status_t status;
va_end( status.arg );
return status.n;
}
+#endif
#define TEST_CONVERSION_ONLY
int main( void )
{
+#ifndef REGTEST
char source[100];
#include "scanf_testcases.h"
+#endif
return TEST_RESULTS;
}
Permission is granted to use, modify, and / or redistribute at will.
*/
-#include <_PDCLIB_int.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>
+#ifndef REGTEST
+#include <_PDCLIB_int.h>
_PDCLIB_uintmax_t _PDCLIB_strtox_main( const char ** p, unsigned int base, uintmax_t error, uintmax_t limval, int limdigit, char * sign )
{
_PDCLIB_uintmax_t rc = 0;
}
return rc;
}
+#endif
#ifdef TEST
#include <_PDCLIB_test.h>
int main( void )
{
+#ifndef REGTEST
const char * p;
char test[] = "123_";
char fail[] = "xxx";
sign = '-';
TESTCASE( _PDCLIB_strtox_main( &p, 10u, (uintmax_t)999, (uintmax_t)99, 8, &sign ) == 0 );
TESTCASE( p == NULL );
+#endif
return TEST_RESULTS;
}
#include <ctype.h>
#include <stddef.h>
#include <string.h>
-
+#ifndef REGTEST
const char * _PDCLIB_strtox_prelim( const char * p, char * sign, int * base )
{
/* skipping leading whitespace */
}
return ( ( *base >= 2 ) && ( *base <= 36 ) ) ? p : NULL;
}
+#endif
#ifdef TEST
#include <_PDCLIB_test.h>
int main( void )
{
+#ifndef REGTEST
int base = 0;
char sign = '\0';
char test1[] = " 123";
TESTCASE( _PDCLIB_strtox_prelim( test3, &sign, &base ) == NULL );
base = 37;
TESTCASE( _PDCLIB_strtox_prelim( test3, &sign, &base ) == NULL );
+#endif
return TEST_RESULTS;
}
--- /dev/null
+/* $Id$ */\r
+\r
+/* _PDCLIB_fdopen( _PDCLIB_fd_t fd, const char * )\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
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+#ifndef REGTEST\r
+#include <_PDCLIB_glue.h>\r
+#include <string.h>\r
+\r
+extern struct _PDCLIB_file_t * _PDCLIB_filelist;\r
+\r
+struct _PDCLIB_file_t * _PDCLIB_fdopen( _PDCLIB_fd_t fd, \r
+ int mode,\r
+ const char * _PDCLIB_restrict filename )\r
+{\r
+ size_t filename_len;\r
+ struct _PDCLIB_file_t * rc;\r
+ if ( mode == NULL )\r
+ {\r
+ /* Mode invalid */\r
+ return NULL;\r
+ }\r
+ /* To reduce the number of malloc calls, all data fields are concatenated:\r
+ * the FILE structure itself,\r
+ * ungetc buffer,\r
+ * filename buffer,\r
+ * data buffer.\r
+ Data buffer comes last because it might change in size ( setvbuf() ).\r
+ */\r
+ filename_len = filename ? strlen( filename ) + 1 : 1;\r
+ if ( ( rc = calloc( 1, sizeof( struct _PDCLIB_file_t ) + _PDCLIB_UNGETCBUFSIZE + filename_len + BUFSIZ ) ) == NULL )\r
+ {\r
+ /* no memory */\r
+ return NULL;\r
+ }\r
+ rc->status = mode;\r
+ rc->handle = fd;\r
+ /* Setting pointers into the memory block allocated above */\r
+ rc->ungetbuf = (unsigned char *)rc + sizeof( struct _PDCLIB_file_t );\r
+ rc->filename = (char *)rc->ungetbuf + _PDCLIB_UNGETCBUFSIZE;\r
+ rc->buffer = rc->filename + filename_len;\r
+ /* Copying filename to FILE structure */\r
+ if(filename) strcpy( rc->filename, filename );\r
+ /* Initializing the rest of the structure */\r
+ rc->bufsize = BUFSIZ;\r
+ rc->bufidx = 0;\r
+ rc->ungetidx = 0;\r
+ /* Setting buffer to _IOLBF because "when opened, a stream is fully\r
+ buffered if and only if it can be determined not to refer to an\r
+ interactive device."\r
+ */\r
+ rc->status |= _IOLBF;\r
+ /* TODO: Setting mbstate */\r
+ /* Adding to list of open files */\r
+ rc->next = _PDCLIB_filelist;\r
+ _PDCLIB_filelist = rc;\r
+ return rc;\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ /* Some of the tests are not executed for regression tests, as the libc on\r
+ my system is at once less forgiving (segfaults on mode NULL) and more\r
+ forgiving (accepts undefined modes).\r
+ */\r
+ FILE * fh;\r
+ remove( testfile );\r
+ TESTCASE_NOREG( fopen( NULL, NULL ) == NULL );\r
+ TESTCASE( fopen( NULL, "w" ) == NULL );\r
+ TESTCASE_NOREG( fopen( "", NULL ) == NULL );\r
+ TESTCASE( fopen( "", "w" ) == NULL );\r
+ TESTCASE( fopen( "foo", "" ) == NULL );\r
+ TESTCASE_NOREG( fopen( testfile, "wq" ) == NULL ); /* Undefined mode */\r
+ TESTCASE_NOREG( fopen( testfile, "wr" ) == NULL ); /* Undefined mode */\r
+ TESTCASE( ( fh = fopen( testfile, "w" ) ) != NULL );\r
+ TESTCASE( fclose( fh ) == 0 );\r
+ TESTCASE( remove( testfile ) == 0 );\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif\r
#ifndef REGTEST
#include <_PDCLIB_glue.h>
#include <string.h>
+#include <errno.h>
extern struct _PDCLIB_file_t * _PDCLIB_filelist;
-struct _PDCLIB_file_t * fopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode )
+FILE * fopen( const char * _PDCLIB_restrict filename,
+ const char * _PDCLIB_restrict mode )
{
- struct _PDCLIB_file_t * rc;
- size_t filename_len;
- if ( mode == NULL || filename == NULL || filename[0] == '\0' )
- {
- /* Mode or filename invalid */
+ int imode = _PDCLIB_filemode( mode );
+ _PDCLIB_fd_t fd = _PDCLIB_open( filename, imode );
+ if(fd == _PDCLIB_NOHANDLE) {
return NULL;
}
- /* To reduce the number of malloc calls, all data fields are concatenated:
- * the FILE structure itself,
- * ungetc buffer,
- * filename buffer,
- * data buffer.
- Data buffer comes last because it might change in size ( setvbuf() ).
- */
- filename_len = strlen( filename ) + 1;
- if ( ( rc = calloc( 1, sizeof( struct _PDCLIB_file_t ) + _PDCLIB_UNGETCBUFSIZE + filename_len + BUFSIZ ) ) == NULL )
- {
- /* no memory */
- return NULL;
- }
- if ( ( rc->status = _PDCLIB_filemode( mode ) ) == 0 )
- {
- /* invalid mode */
- free( rc );
- return NULL;
- }
- rc->handle = _PDCLIB_open( filename, rc->status );
- if ( rc->handle == _PDCLIB_NOHANDLE )
- {
- /* OS open() failed */
- free( rc );
- return NULL;
+
+ FILE * f = _PDCLIB_fdopen( fd, imode, filename );
+ if(!f) {
+ int saveErrno = errno;
+ _PDCLIB_close( fd );
+ errno = saveErrno;
}
- /* Setting pointers into the memory block allocated above */
- rc->ungetbuf = (unsigned char *)rc + sizeof( struct _PDCLIB_file_t );
- rc->filename = (char *)rc->ungetbuf + _PDCLIB_UNGETCBUFSIZE;
- rc->buffer = rc->filename + filename_len;
- /* Copying filename to FILE structure */
- strcpy( rc->filename, filename );
- /* Initializing the rest of the structure */
- rc->bufsize = BUFSIZ;
- rc->bufidx = 0;
- rc->ungetidx = 0;
- /* Setting buffer to _IOLBF because "when opened, a stream is fully
- buffered if and only if it can be determined not to refer to an
- interactive device."
- */
- rc->status |= _IOLBF;
- /* TODO: Setting mbstate */
- /* Adding to list of open files */
- rc->next = _PDCLIB_filelist;
- _PDCLIB_filelist = rc;
- return rc;
+ return f;
}
#endif
\r
int main( void )\r
{\r
+#ifndef REGTEST\r
+ /* Missing on Windows. Maybe use conditionals? */\r
const char *teststr = "Hello, world";\r
const char *teststr2 = "\xFE\x8C\n";\r
char *testres, *testres2;\r
TESTCASE(strcmp(testres2, teststr2) == 0);\r
free(testres);\r
free(testres2);\r
- \r
+#endif\r
+\r
return TEST_RESULTS;\r
}\r
\r
--- /dev/null
+/* wcschr( const wchar_t *, wchar_t );\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
+#include <wchar.h>\r
+#include <stddef.h>\r
+\r
+#ifndef REGTEST\r
+\r
+wchar_t *wcschr(const wchar_t * haystack, wchar_t needle)\r
+{\r
+ while(*haystack) {\r
+ if(*haystack == needle) return (wchar_t*) haystack;\r
+ haystack++;\r
+ }\r
+ return NULL;\r
+}\r
+\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif\r
--- /dev/null
+/* wchar_t * wcscpy( wchar_t restrict *, const wchar_t restrict * );\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
+#include <wchar.h>\r
+\r
+#ifndef REGTEST\r
+\r
+wchar_t *wcscpy( wchar_t * _PDCLIB_restrict dest, \r
+ const wchar_t * _PDCLIB_restrict src)\r
+{\r
+ wchar_t * rv = dest;\r
+ while(*src) {\r
+ *(dest++) = *(src++);\r
+ }\r
+\r
+ return rv;\r
+}\r
+\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif\r
--- /dev/null
+/* wcslen( const wchar_t * );\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
+#include <wchar.h>\r
+\r
+#ifndef REGTEST\r
+\r
+size_t wcslen( const wchar_t * str )\r
+{\r
+ size_t n = 0;\r
+ while(*(str++)) n++;\r
+ return n;\r
+}\r
+\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif\r
--- /dev/null
+/* $Id$ */\r
+\r
+/* wcsrchr( const wchar_t *, wchar_t );\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
+#include <wchar.h>\r
+#include <stddef.h>\r
+\r
+#ifndef REGTEST\r
+\r
+wchar_t *wcsrchr(const wchar_t * haystack, wchar_t needle)\r
+{\r
+ wchar_t *found = NULL;\r
+ while(*haystack) {\r
+ if(*haystack == needle) found = haystack;\r
+ haystack++;\r
+ }\r
+ return found;\r
+}\r
+\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif\r
#endif
#ifndef __cplusplus
+#ifndef _PDCLIB_WCHAR_T_DEFINED
+#define _PDCLIB_WCHAR_T_DEFINED _PDCLIB_WCHAR_T_DEFINED
typedef _PDCLIB_wchar_t wchar_t;
#endif
+#endif
#ifndef _PDCLIB_NULL_DEFINED
#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED
#define L_tmpnam _PDCLIB_L_tmpnam
#define TMP_MAX _PDCLIB_TMP_MAX
-/* See fseek(), third argument */
-#define SEEK_CUR _PDCLIB_SEEK_CUR
-#define SEEK_END _PDCLIB_SEEK_END
-#define SEEK_SET _PDCLIB_SEEK_SET
+/* See fseek(), third argument
+ *
+ * Some system headers (e.g. windows) also define the SEEK_* values. Check for
+ * this and validate that they're the same value
+ */
+#if !defined(SEEK_CUR)
+ #define SEEK_CUR _PDCLIB_SEEK_CUR
+#elif SEEK_CUR != _PDCLIB_SEEK_CUR
+ #error SEEK_CUR != _PDCLIB_SEEK_CUR
+#endif
+
+#if !defined(SEEK_END)
+ #define SEEK_END _PDCLIB_SEEK_END
+#elif SEEK_END != _PDCLIB_SEEK_END
+ #error SEEK_END != _PDCLIB_SEEK_END
+#endif
+
+#if !defined(SEEK_SET)
+ #define SEEK_SET _PDCLIB_SEEK_SET
+#elif SEEK_SET != _PDCLIB_SEEK_SET
+ #error SEEK_SET != _PDCLIB_SEEK_SET
+#endif
extern FILE * stdin;
extern FILE * stdout;
*/
FILE * fopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode );
+/* Creates a stream connected to the file descriptor \p fd with mode \p mode.
+ Mode must match the mode with which the file descriptor was opened.
+*/
+FILE * _PDCLIB_fdopen( _PDCLIB_fd_t fd, int mode, const char* filename );
+
/* Close any file currently associated with the given stream. Open the file
identified by the given filename with the given mode (equivalent to fopen()),
and associate it with the given stream. If filename is a NULL pointer,
--- /dev/null
+/* 7. <wchar.h>\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
+\r
+#ifndef _PDCLIB_WCHAR_H\r
+#define _PDCLIB_WCHAR_H\r
+#include <_PDCLIB_int.h>\r
+_PDCLIB_BEGIN_EXTERN_C\r
+/* This is VASTLY incomplete. Functions being implemented as required by other\r
+ portions of the library\r
+ */\r
+\r
+#ifndef _PDCLIB_SIZE_T_DEFINED\r
+#define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED\r
+typedef _PDCLIB_size_t size_t;\r
+#endif\r
+\r
+#ifndef __cplusplus\r
+#ifndef _PDCLIB_WCHAR_T_DEFINED\r
+#define _PDCLIB_WCHAR_T_DEFINED _PDCLIB_WCHAR_T_DEFINED\r
+typedef _PDCLIB_wchar_t wchar_t;\r
+#endif\r
+#endif\r
+\r
+wchar_t *wcschr( const wchar_t * haystack, wchar_t needle );\r
+wchar_t *wcsrchr( const wchar_t * haystack, wchar_t needle );\r
+size_t wcslen( const wchar_t * string);\r
+wchar_t *wcscpy( wchar_t * _PDCLIB_restrict dest, \r
+ const wchar_t * _PDCLIB_restrict src);\r
+\r
+_PDCLIB_END_EXTERN_C\r
+#endif\r
#define _PDCLIB_CXX_MAX(max) _PDCLIB_CXX_MINMAX(0, max)
#define _PDCLIB_XOPEN_MAX(max) _PDCLIB_XOPEN_MINMAX(0, max)
#define _PDCLIB_POSIX_MAX(max) _PDCLIB_POSIX_MINMAX(0, max)
-#if defined(_PDCLIB_ALL) || defined(_PDCLIB_BUILD)
+#if defined(_PDCLIB_EXTENSIONS) || defined(_PDCLIB_BUILD)
#define _PDCLIB_C_MINMAX(min, max) 1
#define _PDCLIB_CXX_MINMAX(min, max) 1
#define _PDCLIB_POSIX_MINMAX(min, max) 1
+#ifndef REGTEST\r
#include <threads.h>\r
\r
void _PDCLIB_call_once(_PDCLIB_once_flag *flag, void (*func)(void))\r
*flag = _PDCLIB_ONCE_FLAG_DONE;\r
}\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
\r
+#ifndef REGTEST\r
static int count = 0;\r
-once_flag once = ONCE_FLAG_INIT;\r
+static once_flag once = ONCE_FLAG_INIT;\r
\r
static void do_once(void)\r
{\r
count++;\r
}\r
+#endif\r
\r
int main( void )\r
{\r
+#ifndef REGTEST\r
TESTCASE(count == 0);\r
call_once(&once, do_once);\r
TESTCASE(count == 1);\r
TESTCASE(count == 1);\r
do_once();\r
TESTCASE(count == 2);\r
+#endif\r
return TEST_RESULTS;\r
}\r
\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
int cnd_init(cnd_t *cond)\r
/* does nothing */\r
return thrd_success;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
int cnd_signal(cnd_t *cond)\r
{\r
return thrd_success;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
int cnd_wait(cnd_t *cond, mtx_t *mtx)\r
{\r
return thrd_error;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
void mtx_destroy(mtx_t *mtx)\r
{}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
int mtx_init(mtx_t *mtx, int type)\r
*mtx = 0;\r
return thrd_success;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
-#include <assert.h>\r
\r
int mtx_lock(mtx_t *mtx)\r
{\r
return thrd_success;\r
} else return thrd_error;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
int mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts)\r
{\r
return mtx_lock(mtx);\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
int mtx_trylock(mtx_t *mtx)\r
return thrd_success;\r
}\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
int mtx_unlock(mtx_t *mtx)\r
return thrd_success;\r
} else return thrd_error;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
void thrd_yield(void)\r
{\r
/* does nothing */\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
int tss_create(tss_t *key, tss_dtor_t dtor)\r
key->value = NULL;\r
return thrd_success;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
void tss_delete(tss_t key)\r
{\r
key.self->self = NULL;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
void *tss_get(tss_t key)\r
{\r
return key.value;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
\r
+#ifndef REGTEST\r
static tss_t key;\r
static char v;\r
+#endif\r
\r
int main( void )\r
{\r
+#ifndef REGTEST\r
TESTCASE(tss_create(&key, NULL) == thrd_success);\r
TESTCASE(tss_get(key) == NULL);\r
TESTCASE(tss_set(key, &v) == thrd_success);\r
TESTCASE(tss_get(key) == &v);\r
tss_delete(key);\r
+#endif\r
return TEST_RESULTS;\r
}\r
\r
+#ifndef REGTEST\r
#include <threads.h>\r
\r
int tss_set(tss_t key, void *val)\r
key.self->value = val;\r
return thrd_success;\r
}\r
+#endif\r
\r
#ifdef TEST\r
#include <_PDCLIB_test.h>\r
struct _PDCLIB_file_t * tmpfile( void )
{
errno = ENOTSUP;
- return 1;
+ return NULL;
}
#endif