--- /dev/null
+syntax: glob\r
+*.o\r
+*.exe\r
+*.d\r
+*.a\r
+*.dll\r
+*.so\r
+*.dylib\r
+*.dso\r
+*~
\ No newline at end of file
improvement at the expense of carrying around more memory.\r
*/\r
\r
+#ifndef REGTEST\r
#include "dlmalloc.h"\r
\r
/* Version identifier to allow people to support multiple versions */\r
structure of old version, but most details differ.)\r
\r
*/\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+/* TODO: TEST ME */\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
#define MREMAP(a, osz, nsz, mv) _PDCLIB_reallocpages((a), (osz)/_PDCLIB_MALLOC_PAGESIZE, (nsz)/_PDCLIB_MALLOC_PAGESIZE, (mv))\r
\r
#undef WIN32\r
+#undef _WIN32\r
#define DLMALLOC_EXPORT _PDCLIB_API\r
#define MALLOC_ALIGNMENT _PDCLIB_MALLOC_ALIGN\r
#define MSPACES 0\r
func();\r
*flag = _PDCLIB_ONCE_FLAG_DONE;\r
}\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+static int count = 0;\r
+once_flag once = ONCE_FLAG_INIT;\r
+\r
+static void do_once(void)\r
+{\r
+ count++;\r
+}\r
+\r
+int main( void )\r
+{\r
+ TESTCASE(count == 0);\r
+ call_once(&once, do_once);\r
+ TESTCASE(count == 1);\r
+ call_once(&once, do_once);\r
+ TESTCASE(count == 1);\r
+ do_once();\r
+ TESTCASE(count == 2);\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif\r
/* does nothing */\r
return thrd_success;\r
}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
int cnd_signal(cnd_t *cond)\r
{\r
return thrd_success;\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
int cnd_wait(cnd_t *cond, mtx_t *mtx)\r
{\r
return thrd_error;\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
\r
void mtx_destroy(mtx_t *mtx)\r
{}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
*mtx = 0;\r
return thrd_success;\r
}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
*mtx = 1;\r
return thrd_success;\r
} else return thrd_error;\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
int mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts)\r
{\r
return mtx_lock(mtx);\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
return thrd_success;\r
}\r
}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
*mtx = 0;\r
return thrd_success;\r
} else return thrd_error;\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
void thrd_yield(void)\r
{\r
/* does nothing */\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
key->self = key;\r
key->value = NULL;\r
return thrd_success;\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+/* Tested in tss_get.c */\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
{\r
key.self->self = NULL;\r
}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+/* Tested in tss_get.c */\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
void *tss_get(tss_t key)\r
{\r
return key.value;\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+static tss_t key;\r
+static char v;\r
+\r
+int main( void )\r
+{\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
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
{\r
key.self->value = val;\r
return thrd_success;\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+/* Tested in tss_get.c */\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
{\r
if(t) *t = -1;\r
return -1;\r
-}
\ No newline at end of file
+}\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+ return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+/* $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
to an appropriate value. (Too small, and malloc() will call the kernel too
often. Too large, and you will waste memory.)
*/
-#define _PDCLIB_PAGESIZE 4096
-
-/* Set this to the minimum memory node size. Any malloc() for a smaller size
- will be satisfied by a malloc() of this size instead (to avoid excessive
- fragmentation).
-*/
-#define _PDCLIB_MINALLOC 8
+#define _PDCLIB_MALLOC_PAGESIZE 4096
+#define _PDCLIB_MALLOC_ALIGN 16
+#define _PDCLIB_MALLOC_GRANULARITY 64*1024
+#define _PDCLIB_MALLOC_TRIM_THRESHOLD 2*1024*1024
+#define _PDCLIB_MALLOC_MMAP_THRESHOLD 256*1024
+#define _PDCLIB_MALLOC_RELEASE_CHECK_RATE 4095
+
+/* TODO: Better document these */
/* I/O ---------------------------------------------------------------------- */