Index: trunk/src/libctests/libc/include/PrfTiming.h
===================================================================
--- trunk/src/libctests/libc/include/PrfTiming.h	(revision 2055)
+++ trunk/src/libctests/libc/include/PrfTiming.h	(revision 2055)
@@ -0,0 +1,185 @@
+/* $Id$
+ *
+ * Common timing code.
+ *
+ * Copyright (c) 2001-2003 knut st. osmundsen (bird@anduin.net)
+ *
+ * GPL
+ *
+ */
+
+#include <stdio.h>
+#if !defined(__WINNT__)
+#include <sys/time.h>
+#endif
+#ifndef __NOTPC__
+#include <process.h>
+#endif
+
+#ifdef __OS2__
+#define INCL_BASE
+#define INCL_DOSPROFILE
+#include <os2.h>
+
+static inline long double gettime(void)
+{
+    QWORD   qw;
+    DosTmrQueryTime(&qw);
+    return (long double)qw.ulHi * (4294967296.00) + qw.ulLo;
+}
+
+static inline unsigned getHz(void)
+{
+    ULONG ul = -1;
+    DosTmrQueryFreq(&ul);
+    return ul;
+}
+
+static inline void printSystemInfo(void)
+{
+}
+
+#elif defined(__WINNT__)
+#include <windows.h>
+/*
+ * Windows
+ */
+unsigned long __stdcall GetTickCount(void);
+
+static inline long double gettime(void)
+{
+    //return (long double)GetTickCount();
+    LARGE_INTEGER ullCounter;
+    ullCounter.QuadPart = 0;
+    QueryPerformanceCounter(&ullCounter);
+    return (long double)ullCounter.QuadPart;
+}
+
+static inline unsigned getHz(void)
+{
+    //return 1000;
+    LARGE_INTEGER ullFrequency;
+    ullFrequency.QuadPart = 0;
+    QueryPerformanceFrequency(&ullFrequency);
+    return (unsigned)ullFrequency.QuadPart;
+}
+
+static inline void printSystemInfo(void)
+{
+    LONG        lrc;
+    SYSTEM_INFO si;
+    HKEY        hProcessor0;
+    char        szMhz[16];
+    szMhz[0] = '\0';
+
+    lrc = RegOpenKey(HKEY_LOCAL_MACHINE,
+                     "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
+                     &hProcessor0);
+    if (!lrc)
+    {
+        LONG    cchMhz = sizeof(szMhz);
+        DWORD   iKey;
+        CHAR    szValueName[256];
+        DWORD   cchValueName = sizeof(szValueName);
+        DWORD   dwType;
+        BYTE    abData[256];
+        DWORD   cbData;
+
+        iKey = 0;
+        szMhz[0] = '\0';
+        while ((lrc = RegEnumValue(hProcessor0,
+                                   iKey,
+                                   szValueName,
+                                   &cchValueName,
+                                   NULL,
+                                   &dwType,
+                                   &abData,
+                                   &cbData)) == 0
+               || lrc == ERROR_MORE_DATA)
+        {
+            switch (dwType)
+            {
+                case REG_SZ:
+                case REG_EXPAND_SZ:
+                    /*
+                    printf("%-24s =  type: %1x  namesize: %2d  data size: %3d bytes\n          %s\n",
+                           szValueName, dwType, cchValueName, cbData, &abData[0]);
+                    */
+                    break;
+
+                default:
+                {
+                    /*
+                    int i,j;
+                    printf("%-24s =  type: %1x  namesize: %2d  data size: %3d bytes\n",
+                           szValueName, dwType, cchValueName, cbData);
+                    for (i = 0; i < cbData; i += 16)
+                    {
+                        printf("    %04x ", i);
+                        for (j = 0; j < 16; j++)
+                        {
+                            if (j + i < cbData)
+                                printf(j == 8 ? "-  %02x " : "%02x ",
+                                       (BYTE)abData[i+j]);
+                            else
+                                printf(j == 8 ? "    " : "   ");
+                        }
+                        putc(' ', stdout);
+                        for (j = 0; j < 16; j++)
+                        {
+                            if (j+i < cbData)
+                                putc(isprint(abData[j]) ? abData[j] : '.', stdout);
+                            else
+                                putc(' ', stdout);
+                        }
+                        putc('\n', stdout);
+                    }
+                    */
+                    if (   !szMhz[0]
+                        && stricmp(szValueName, "~MHz") == 0
+                        && dwType == REG_DWORD
+                        && cbData == sizeof(DWORD))
+                        sprintf(szMhz, "%d", *(PDWORD)&abData[0]);
+                }
+            }
+
+            /* next */
+            iKey++;
+            dwType = 0;
+            cchValueName = sizeof(szValueName);
+            szValueName[0] = '\0';
+        }
+        RegCloseKey(hProcessor0);
+    }
+
+    GetSystemInfo(&si);
+    printf("  %d %d CPUs  %s Mhz\n",
+           si.dwNumberOfProcessors,
+           si.dwProcessorType,
+           szMhz
+           );
+}
+
+#else
+
+static inline long double gettime(void)
+{
+    struct  timeval tp;
+    long    sec = 0L;
+
+    if (gettimeofday(&tp, NULL))
+        return -1;
+    return tp.tv_usec / 1000000.00 + tp.tv_sec;
+}
+
+static inline unsigned getHz(void)
+{
+    return 1;//000000;
+}
+
+static inline void printSystemInfo(void)
+{
+}
+
+#endif
+
Index: trunk/src/libctests/libc/smoketests/64bitio-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/64bitio-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/64bitio-1.c	(revision 2055)
@@ -0,0 +1,151 @@
+/* $Id$ */
+/** @file
+ *
+ * 64-bit I/O testing (microscopical part of it).
+ *
+ *
+ * Copyright (c) 2004 InnoTek Systemberatung GmbH
+ * Author: knut st. osmundsen <bird-srcspam@anduin.net>
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <limits.h>
+#include <io.h>
+
+#define FILENAME "2gb.file"
+#define SIZE     (0x8000ffffULL)
+
+int main(int argc, char **argv)
+{
+    int         cErrors = 0;
+    FILE       *pFile;
+    struct stat s;
+    int         rc;
+    const char *pszFilename = FILENAME;
+    if (argc > 2)
+        pszFilename = argv[1];
+
+    /*
+     * Check for 64bit support.
+     */
+    if (sizeof(off_t) != sizeof(long long))
+    {
+        printf("64bitio: sizeof(off_t) != sizeof(long long) (%d != %d)\n",
+               sizeof(off_t), sizeof(long long));
+        return 1;
+    }
+    if (sizeof(off_t) == sizeof(long))
+    {
+        printf("64bitio: sizeof(off_t) == sizeof(long) (%d)\n",
+               sizeof(long));
+        return 1;
+    }
+    if (OFF_MAX <= LONG_MAX)
+    {
+        printf("64bitio: OFF_MAX <= LONG_MAX; LONG_MAX=%lld OFF_MAX=%lld\n",
+               (long long)LONG_MAX, (long long)OFF_MAX);
+        return 1;
+    }
+    #if OFF_MAX > LONG_MAX
+    #else
+    printf("64bitio: #if OFF_MAX > LONG_MAX failed\n");
+    return 1;
+    #endif
+    #if LONG_MAX < OFF_MAX
+    #else
+    printf("64bitio: #if LONG_MAX < OFF_MAX failed\n");
+    return 1;
+    #endif
+
+    /*
+     * Handle based tests.
+     */
+    pFile = fopen(pszFilename, "w");
+    if (!pFile)
+    {
+        printf("64bitio: couldn't open file\n");
+        return 1;
+    }
+
+    rc = chsize(fileno(pFile), SIZE);
+    if (!rc)
+    {
+        /* remember to delete file! */
+        if (!fstat(fileno(pFile), &s))
+        {
+            if (s.st_size != SIZE)
+            {
+                printf("64bitio: fstat reports wrong filesize. %lld != %lld\n",
+                       s.st_size, SIZE);
+                cErrors++;
+            }
+        }
+        else
+        {
+            printf("64bitio: fstat failed. errno=%d\n", errno);
+            cErrors++;
+        }
+
+        fclose(pFile);
+
+        /*
+         * Tests on filename.
+         */
+        if (!stat(pszFilename, &s))
+        {
+            if (s.st_size != SIZE)
+            {
+                printf("64bitio: stat reports wrong filesize. %lld != %lld\n",
+                       s.st_size, SIZE);
+                cErrors++;
+            }
+        }
+        else
+        {
+            printf("64bitio: stat failed. errno=%d\n", errno);
+            cErrors++;
+        }
+    }
+    else
+    {
+        printf("64bitio: failed to extend file to 2.01GB. running on JFS? errno=%d %s\n", errno, strerror(errno));
+        cErrors++;
+        fclose(pFile);
+    }
+
+    /*
+     * Kill it.
+     */
+    if (unlink(pszFilename))
+    {
+        printf("64bitio: unlink failed! errno=%d\n", errno);
+        cErrors++;
+    }
+
+    if (cErrors)
+        printf("64bitio: %d errors\n", cErrors);
+    else
+        printf("64bitio: success\n", cErrors);
+    return !!cErrors;
+}
+
Index: trunk/src/libctests/libc/smoketests/access-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/access-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/access-1.c	(revision 2055)
@@ -0,0 +1,143 @@
+/* $Id$ */
+/** @file
+ *
+ * Testcase for access*().
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+
+
+int main(int argc, char **argv)
+{
+    int cErrors = 0;
+    char szDir[260];
+
+    /*
+     * Check access to the .exe file.
+     */
+    if (access(argv[0], R_OK))
+    {
+        printf("access: R_OK check on .exe failed\n");
+        cErrors++;
+    }
+    if (access(argv[0], F_OK))
+    {
+        printf("access: F_OK check on .exe failed\n");
+        cErrors++;
+    }
+    if (!access(argv[0], W_OK))
+    {
+        printf("access: W_OK check on .exe failed - expected ignoring\n");
+        //cErrors++;
+    }
+    if (!access(argv[0], W_OK|R_OK))
+    {
+        printf("access: W_OK check on .exe failed - expected ignoring\n");
+        //cErrors++;
+    }
+
+    /*
+     * Check the current directory.
+     */
+    if (access(".", R_OK))
+    {
+        printf("access: R_OK check on . failed\n");
+        cErrors++;
+    }
+    if (access(".", F_OK))
+    {
+        printf("access: F_OK check on . failed\n");
+        cErrors++;
+    }
+    if (access(".", W_OK))
+    {
+        printf("access: W_OK check on . failed\n");
+        cErrors++;
+    }
+    if (access(".", W_OK|R_OK))
+    {
+        printf("access: W_OK check on . failed\n");
+        cErrors++;
+    }
+
+    /*
+     * Check the current directory.
+     */
+    if (access("./", R_OK))
+    {
+        printf("access: R_OK check on ./ failed\n");
+        cErrors++;
+    }
+    if (access("./", F_OK))
+    {
+        printf("access: F_OK check on ./ failed\n");
+        cErrors++;
+    }
+    if (access("./", W_OK))
+    {
+        printf("access: W_OK check on ./ failed\n");
+        cErrors++;
+    }
+    if (access("./", W_OK|R_OK))
+    {
+        printf("access: W_OK check on ./ failed\n");
+        cErrors++;
+    }
+
+
+    /*
+     * Check the current directory.
+     */
+    getcwd(&szDir[0], sizeof(szDir));
+    if (access(&szDir[0], R_OK))
+    {
+        printf("access: R_OK check on . failed\n");
+        cErrors++;
+    }
+    if (access(&szDir[0], F_OK))
+    {
+        printf("access: F_OK check on . failed\n");
+        cErrors++;
+    }
+    if (access(&szDir[0], W_OK))
+    {
+        printf("access: W_OK check on . failed\n");
+        cErrors++;
+    }
+    if (access(&szDir[0], W_OK|R_OK))
+    {
+        printf("access: W_OK check on . failed\n");
+        cErrors++;
+    }
+
+
+    /*
+     * Report results.
+     */
+    if (cErrors)
+        printf("access: %d failures\n", cErrors);
+    else
+        printf("access: succeeded\n");
+    return cErrors ? 1 : 0;
+}
Index: trunk/src/libctests/libc/smoketests/alloca-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/alloca-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/alloca-1.c	(revision 2055)
@@ -0,0 +1,139 @@
+/* $Id$ */
+/** @file
+ *
+ * alloca testcase.
+ *
+ * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/*******************************************************************************
+*   Global Variables                                                           *
+*******************************************************************************/
+/** Array with sizes to alloca. */
+static const size_t g_acb[] =
+{
+    0,
+    1,
+    2,
+    3,
+    4,
+    5,
+    6,
+    7,
+    8,
+    0,
+    9,
+    10,
+    11,
+    12,
+    13,
+    14,
+    15,
+    16,
+    17,
+    18,
+    19,
+    20,
+    21,
+    22,
+    23,
+    24,
+    25,
+    26,
+    27,
+    28,
+    29,
+    31,
+    32,
+    33,
+    1,
+    127,
+    128,
+    0,
+    129,
+    130,
+    131,
+    132,
+    133,
+    256,
+    2047,
+    2048,
+    2049,
+    4090,
+    4095,
+    4096,
+    4097,
+    8192,
+    16384,
+    32763,
+    32767,
+    32768,
+    32774
+};
+
+
+static int verify(void *pv, int ch, size_t cb)
+{
+    size_t cbLeft = cb;
+    char *pch;
+    for (pch = (char *)pv; cbLeft > 0; cbLeft--, pch++)
+        if (*pch != ch)
+        {
+            printf("alloca: FAILURE - ch=%d *pch=%d cb=%d off=%d\n", ch, *pch, cb, pch - (char *)pv);
+            return 1;
+        }
+    return 0;
+}
+
+
+int main()
+{
+    void   *apv[sizeof(g_acb) / sizeof(g_acb[0])] = {0};
+    int     rcRet = 0;
+    int     i;
+    for (i = 0; i < sizeof(g_acb) / sizeof(g_acb[0]); i++)
+    {
+        apv[i] = alloca(g_acb[i]);
+        memset(apv[i], i, g_acb[i]);
+        verify(apv[i], i, g_acb[i]);
+        if (i > 0)
+            verify(apv[i - 1], i - 1, g_acb[i - 1]);
+    }
+
+    for (i = 0; i < sizeof(g_acb) / sizeof(g_acb[0]); i++)
+        rcRet += verify(apv[i], i, g_acb[i]);
+
+    if (!rcRet)
+        printf("alloca: SUCCESS\n");
+    else
+        printf("alloca: FAILURE - %d errors\n", rcRet);
+
+    return !!rcRet;
+}
Index: trunk/src/libctests/libc/smoketests/builtin-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/builtin-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/builtin-1.c	(revision 2055)
@@ -0,0 +1,155 @@
+/* $Id$ */
+/** @file
+ *
+ * Testcase for 386/builtin.h (parts of it anyway).
+ *
+ * Copyright (c) 2005 knut st. osmundsen <bird@innotek.de>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <386/builtin.h>
+#include <stdio.h>
+
+int main()
+{
+    unsigned rc;
+#define CHECKRET(val, rc)  do { if ((rc) != (val)) { printf("tstAtomic: FAILURE rc=%d (%#x) expected %d (%#x), line %d\n", rc, rc, (val), (val), __LINE__); return 1; } } while (0)
+#define CHECKRC(val)  CHECKRET(val,rc)
+#define CHECKU32(val) do { if (u32 != (val)) { printf("tstAtomic: FAILURE u32=%d (%#x) expected %d (%#x), line %d\n", u32, u32, (val), (val), __LINE__); return 1; } } while (0)
+#define CHECKS32(val) do { if (i32 != (val)) { printf("tstAtomic: FAILURE i32=%d (%#x) expected %d (%#x), line %d\n", i32, i32, (val), (val), __LINE__); return 1; } } while (0)
+    static uint32_t u32;
+    static int32_t  i32;
+    rc = __atomic_cmpxchg32(&u32, 0, 0);
+    CHECKRC(1); CHECKU32(0);
+    rc = __atomic_cmpxchg32(&u32, 1, 0);
+    CHECKRC(1); CHECKU32(1);
+    rc = __atomic_cmpxchg32(&u32, 2, 0);
+    CHECKRC(0); CHECKU32(1);
+    rc = __atomic_cmpxchg32(&u32, 32, 3);
+    CHECKRC(0); CHECKU32(1);
+    rc = __atomic_cmpxchg32(&u32, 32, 1);
+    CHECKRC(1); CHECKU32(32);
+
+    u32 = 1;
+    rc = __atomic_decrement_min(&u32, 1);
+    CHECKRC(1); CHECKU32(1);
+    rc = __atomic_increment_max(&u32, 16);
+    CHECKRC(0); CHECKU32(2);
+    rc = __atomic_increment_max(&u32, 16);
+    CHECKRC(0); CHECKU32(3);
+    rc = __atomic_increment_max(&u32, 16);
+    CHECKRC(0); CHECKU32(4);
+    rc = __atomic_decrement_min(&u32, 1);
+    CHECKRC(0); CHECKU32(3);
+    rc = __atomic_decrement_min(&u32, 1);
+    CHECKRC(0); CHECKU32(2);
+    rc = __atomic_decrement_min(&u32, 1);
+    CHECKRC(0); CHECKU32(1);
+    rc = __atomic_decrement_min(&u32, 1);
+    CHECKRC(1); CHECKU32(1);
+    rc = __atomic_decrement_min(&u32, 0xcddf);
+    CHECKRC(1); CHECKU32(1);
+    rc = __atomic_decrement_min(&u32, 0);
+    CHECKRC(0); CHECKU32(0);
+    rc = __atomic_decrement_min(&u32, 0);
+    CHECKRC(0); CHECKU32(0);
+
+    u32 = 15;
+    rc = __atomic_increment_max(&u32, 16);
+    CHECKRC(0); CHECKU32(16);
+    rc = __atomic_increment_max(&u32, 16);
+    CHECKRC(16); CHECKU32(16);
+    u32 = ~0 - 1;
+    rc = __atomic_increment_max(&u32, ~0);
+    CHECKRC(0); CHECKU32(~0);
+    rc = __atomic_increment_max(&u32, ~0);
+    CHECKRC(~0); CHECKU32(~0);
+
+
+
+#define CHECKU16(val) do { if (u16 != (val)) { printf("tstAtomic: FAILURE u16=%d (%#x) expected %d (%#x), line %d\n", u16, u16, (val), (val), __LINE__); return 1; } } while (0)
+    static uint16_t u16;
+    CHECKU16(0);
+    rc = __atomic_increment_word_max(&u16, 0x777f);
+    CHECKRC(1);
+    rc = __atomic_increment_word_max(&u16, 0x777f);
+    CHECKRC(2);
+    rc = __atomic_increment_word_max(&u16, 0x777f);
+    CHECKRC(3);
+    rc = __atomic_decrement_word_min(&u16, 0);
+    CHECKRC(2);
+    rc = __atomic_decrement_word_min(&u16, 0);
+    CHECKRC(1);
+    rc = __atomic_decrement_word_min(&u16, 0);
+    CHECKRC(0);
+    rc = __atomic_decrement_word_min(&u16, 0);
+    CHECKRC(0xffff0000); CHECKU16(0);
+    rc = __atomic_decrement_word_min(&u16, 0);
+    CHECKRC(0xffff0000); CHECKU16(0);
+    rc = __atomic_decrement_word_min(&u16, 0);
+    CHECKRC(0xffff0000); CHECKU16(0);
+    rc = __atomic_decrement_word_min(&u16, 0);
+    CHECKRC(0xffff0000); CHECKU16(0);
+
+    u16 = 0xfffd;
+    rc = __atomic_increment_word_max(&u16, 0xffff);
+    CHECKRC(0xfffe); CHECKU16(0xfffe);
+    rc = __atomic_increment_word_max(&u16, 0xffff);
+    CHECKRC(0xffff); CHECKU16(0xffff);
+    rc = __atomic_increment_word_max(&u16, 0xffff);
+    CHECKRC(0xffffffff); CHECKU16(0xffff);
+
+    uint32_t u32Ret;
+    u32 = 1;
+    u32Ret = __atomic_decrement_u32(&u32);
+    CHECKRET(0,u32Ret); CHECKU32(0);
+    u32Ret = __atomic_increment_u32(&u32);
+    CHECKRET(1,u32Ret); CHECKU32(1);
+    u32Ret = __atomic_increment_u32(&u32);
+    CHECKRET(2,u32Ret); CHECKU32(2);
+    u32Ret = __atomic_increment_u32(&u32);
+    CHECKRET(3,u32Ret); CHECKU32(3);
+    u32Ret = __atomic_increment_u32(&u32);
+    CHECKRET(4,u32Ret); CHECKU32(4);
+    u32Ret = __atomic_decrement_u32(&u32);
+    CHECKRET(3,u32Ret); CHECKU32(3);
+    u32Ret = __atomic_decrement_u32(&u32);
+    CHECKRET(2,u32Ret); CHECKU32(2);
+
+    int32_t i32Ret;
+    i32 = 1;
+    i32Ret = __atomic_decrement_s32(&i32);
+    CHECKRET(0,i32Ret); CHECKS32(0);
+    i32Ret = __atomic_increment_s32(&i32);
+    CHECKRET(1,i32Ret); CHECKS32(1);
+    i32Ret = __atomic_increment_s32(&i32);
+    CHECKRET(2,i32Ret); CHECKS32(2);
+    i32Ret = __atomic_increment_s32(&i32);
+    CHECKRET(3,i32Ret); CHECKS32(3);
+    i32Ret = __atomic_increment_s32(&i32);
+    CHECKRET(4,i32Ret); CHECKS32(4);
+    i32Ret = __atomic_decrement_s32(&i32);
+    CHECKRET(3,i32Ret); CHECKS32(3);
+    i32Ret = __atomic_decrement_s32(&i32);
+    CHECKRET(2,i32Ret); CHECKS32(2);
+
+    return 0;
+}
+
Index: trunk/src/libctests/libc/smoketests/fork-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/fork-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/fork-1.c	(revision 2055)
@@ -0,0 +1,127 @@
+/* $Id$ */
+/** @file
+ *
+ * Massive forking.
+ *
+ * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of kBuild.
+ *
+ * kBuild is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * kBuild is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with kBuild; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/wait.h>
+
+int main(int argc, char **argv)
+{
+    int cChildren = 0;
+    int cErrors = 0;
+    int i;
+    for (i = 0; i < 5000; i++)
+    {
+        int pid = fork();
+        switch (pid)
+        {
+            case -1:
+                printf("Error errno=%d %s\n", errno, strerror(errno));
+                cErrors++;
+                break;
+            case 0:
+                //printf("I'm child %#x i=%d.\n", getpid(), i);
+                exit(0);
+                break;
+
+            default:
+            {
+                cChildren++;
+
+                /* don't spawn for ever! */
+                if (!(i % 25))
+                {
+                    usleep(1000); /* be kind to the host */
+                    if (!(i % 100))
+                        printf("forked %#x i=%d cChildren=%d\n", pid, i, cChildren);
+                }
+
+                if (i % 3)
+                    break;
+
+                /* reap */
+                int iStatus = -1;
+                pid_t pid;
+                while ((pid = wait4(-1, &iStatus, WNOHANG, NULL)) > 0)
+                {
+                    if (cChildren > 0)
+                        cChildren--;
+                    else
+                    {
+                        printf("wtf!?! no children officially running, but pid=%d arrived!\n", pid);
+                        cErrors++;
+                    }
+                    if (!WIFEXITED(iStatus) || WEXITSTATUS(iStatus))
+                    {
+                        printf("child %d -> iStatus=%#x\n", pid, iStatus);
+                        cErrors++;
+                    }
+                }
+                break;
+            }
+        }
+    }
+
+    /*
+     * Wait for the rest of the children.
+     */
+    int cLoops = 30;
+    while (cChildren > 0 && cLoops-- > 0)
+    {
+        usleep(32000);
+
+        /* reap */
+        int iStatus = -1;
+        pid_t pid;
+        while ((pid = wait4(-1, &iStatus, WNOHANG, NULL)) > 0)
+        {
+            if (cChildren > 0)
+                cChildren--;
+            else
+            {
+                printf("wtf!?! no children officially running, but pid=%d arrived!\n", pid);
+                cErrors++;
+            }
+            if (!WIFEXITED(iStatus) || WEXITSTATUS(iStatus))
+            {
+                printf("child %d -> iStatus=%#x\n", pid, iStatus);
+                cErrors++;
+            }
+        }
+    }
+
+    if (!cErrors)
+        printf("fork-1: SUCCESS\n");
+    else
+        printf("fork-1: FAILURE - %d errors\n", cErrors);
+    return !!cErrors;
+}
Index: trunk/src/libctests/libc/smoketests/fork-2.c
===================================================================
--- trunk/src/libctests/libc/smoketests/fork-2.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/fork-2.c	(revision 2055)
@@ -0,0 +1,202 @@
+/* $Id$ */
+/** @file
+ *
+ * Simple fork testcase.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/fcntl.h>
+#include <locale.h>
+#include <sys/socket.h>
+#include <ctype.h>
+#include <iconv.h>
+#include <string.h>
+#include <sys/wait.h>
+
+/*******************************************************************************
+*   Internal Functions                                                         *
+*******************************************************************************/
+static int tstLocale(const char *pszCtx);
+static int tstIconv(iconv_t pConv, const char *pszCtx);
+
+/* fixme! */
+static int tstLocale(const char *pszCtx)
+{
+#ifdef OTHER
+    static char szTest[] = "\t\t\n"; /* 850 */
+#else
+    static char szTest[] = "tæøå\tÆØÅ\täÄöÖ\n"; /* 8859-1 */
+#endif
+    char   *psz;
+
+    printf("%s: ", pszCtx);
+    for (psz = szTest; *psz; psz++)
+    {
+        if (*psz == '\t')
+            printf("\n%s: ", pszCtx);
+        else if (*psz == '\n')
+            printf("\n");
+        else
+        {
+            printf("'%c'(%02x): %d,%d,%d%s",
+                   *psz, (unsigned char)*psz, !!isalpha(*psz), !!isupper(*psz), !!islower(*psz), psz[1] ? " " : "");
+        }
+    }
+    return 0;
+}
+
+
+static int tstIconv(iconv_t pIconv, const char *pszCtx)
+{
+    size_t  cbIn = 4;
+    char    achOut[20];
+    size_t  cbOut = sizeof(achOut);
+    size_t  cb;
+    const char *pszIn = "abc";
+    char   *pszOut = &achOut[0];
+    cb = iconv(pIconv, &pszIn, &cbIn, &pszOut, &cbOut);
+    if (!cb && !strcmp(achOut, "abc"))
+        return 0;
+    printf("error (%s): iconv failed. cb=%d errno=%d\n", pszCtx, cb, errno);
+    return 1;
+}
+
+
+int main(int argc, char **argv)
+{
+    int     rcRet = 0;
+    int     afds[2] = {-1,-1};
+    int     fh;
+    pid_t   pid;
+    int     rc;
+    iconv_t pIconv;
+
+    /* filehandles */
+    fh = open(argv[0], O_RDONLY
+#ifdef O_BINARY
+              | O_BINARY
+#endif
+              , 0777);
+    if (fh < 0)
+    {
+        printf("fatal error: failed to set locale to en_US.UTF-8!\n");
+        return 1;
+    }
+    if (fcntl(fh, F_SETFD, FD_CLOEXEC))
+        printf("fcntl(%d,) failed! errno=%d\n", fh, errno), rcRet++;
+
+    /* locale */
+    if (!setlocale(LC_ALL, "en_US.UTF-8"))
+    {
+        printf("fatal error: failed to set locale to en_US.UTF-8!\n");
+        return 1;
+    }
+
+    /* sockets */
+    rcRet = socketpair(PF_LOCAL, SOCK_STREAM, 0, &afds[0]);
+    if (rcRet)
+    {
+        printf("fatal error: socketpair failed! errno=%d\n", errno);
+        return 1;
+    }
+    printf("info: created socket pair %d %d\n", afds[0], afds[1]);
+    if (fcntl(afds[0], F_SETFD, FD_CLOEXEC))
+        printf("error: fcntl(%d,) failed! errno=%d\n", afds[0], errno), rcRet++;
+    if ((rc = fcntl(afds[0], F_GETFD, 0)) != FD_CLOEXEC)
+        printf("error: the filehandle %d (socket) was messed up! (flags=%d)\n", afds[0], rc), rcRet++;
+    if ((rc = fcntl(afds[1], F_GETFD, 0)) != 0)
+        printf("error: the filehandle %d (socket) was messed up! (flags=%d)\n", afds[1], rc), rcRet++;
+
+    /* iconv */
+    pIconv = iconv_open("IBM850", "UTF-8");
+    if (!pIconv)
+    {
+        printf("fatal error: iconv_open(\"IBM850\", \"UTF-8\") failed! errno=%d\n", errno);
+        return 1;
+    }
+
+
+    /*
+     * fork the child process.
+     */
+    pid = fork();
+    if (!pid)
+    {
+        /* child */
+        printf("child!\n");
+        if ((rc = fcntl(afds[0], F_GETFD, 0)) != FD_CLOEXEC)
+            printf("error (child): the filehandle %d (socket) was messed up! (flags=%d)\n", afds[0], rc), rcRet++;
+        #if 0
+        close(afds[0]);
+        usleep(100000);
+        #endif
+        if ((rc = fcntl(afds[1], F_GETFD, 0)) != 0)
+            printf("error (child): the filehandle %d (socket) was messed up! (flags=%d)\n", afds[1], rc), rcRet++;
+        if ((rc = fcntl(fh, F_GETFD, 0)) != FD_CLOEXEC)
+            printf("error (child): the filehandle %d was messed up! (flags=%d)\n", fh, rc), rcRet++;
+
+        rcRet += tstLocale("child");
+        rcRet += tstIconv(pIconv, "child");
+    }
+    else if (pid < 0)
+    {
+        printf("error: fork() failed pid=%d errno=%d\n", pid, errno);
+        return 1;
+    }
+    else
+    {
+        /* parent */
+        printf("created child %d\n", pid);
+        if ((rc = fcntl(afds[0], F_GETFD, 0)) != FD_CLOEXEC)
+            printf("error (parent): the filehandle %d (socket) was messed up! (flags=%d)\n", afds[0], rc), rcRet++;
+        if ((rc = fcntl(afds[1], F_GETFD, 0)) != 0)
+            printf("error (parent): the filehandle %d (socket) was messed up! (flags=%d)\n", afds[1], rc), rcRet++;
+        if ((rc = fcntl(fh, F_GETFD, 0)) != FD_CLOEXEC)
+            printf("error (parent): the filehandle %d was messed up! (flags=%d)\n", fh, rc), rcRet++;
+
+        /* check if the socket is still around after the child closed its handle. */
+        waitpid(pid, NULL, 0);
+        rc = write(afds[0], "howdy!", 6);
+        if (rc <= 0)
+            printf("error (parent): write(%d,,) -> %d errno=%d\n", afds[0], rc, errno), rcRet++;
+
+        rcRet += tstLocale("parent");
+        rcRet += tstIconv(pIconv, "parent");
+    }
+
+    /*
+     * Summary
+     */
+    if (rcRet)
+        printf(" %d failed tests\n", rcRet);
+    else
+        printf("all tests completed successfully\n");
+
+    return !!rcRet;
+}
Index: trunk/src/libctests/libc/smoketests/fsinternals-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/fsinternals-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/fsinternals-1.c	(revision 2055)
@@ -0,0 +1,110 @@
+/* $Id$ */
+/** @file
+ *
+ * LIBC - Path resolver testcase - highly internal.
+ *
+ * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of kBuild.
+ *
+ * kBuild is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * kBuild is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with kBuild; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include "sys/b_fs.h"
+
+/**
+ * Do one call, check and report the result.
+ */
+static int testit(const char *pszPath, unsigned fFlags, int rcCorrect)
+{
+    char    szNativePath[300];
+    int     rc;
+
+    memset(szNativePath, 0xAA, sizeof(szNativePath));
+    szNativePath[sizeof(szNativePath) - 1] = '\0';
+    errno = 0;
+    rc = __libc_back_fsResolve(pszPath, fFlags, szNativePath, NULL);
+    if (errno != 0)
+        printf("FAILURE: flags=%#02x path='%s' -> rc=%d errno=%d szNativePath='%s' ERRNO CHANGED!\n", fFlags, pszPath, rc, errno, szNativePath);
+    else if (!rcCorrect)
+    {
+        /*
+         * Positive test.
+         */
+        if (!rc)
+        {
+            if (!strchr(szNativePath, 0xAA))
+            {
+                printf("SUCCESS: flags=%#02x path='%s' -> szNativePath='%s'\n", fFlags, pszPath, szNativePath);
+                return 0;
+            }
+            else
+                printf("FAILURE: flags=%#02x path='%s' -> rc=%d szNativePath='%s' PADDING!\n", fFlags, pszPath, rc, szNativePath);
+        }
+        else
+            printf("FAILURE: flags=%#02x path='%s' -> rc=%d szNativePath='%s' (failed)\n", fFlags, pszPath, rc, szNativePath);
+    }
+    else
+    {
+        /*
+         * Negative test.
+         */
+        if (rc == rcCorrect)
+        {
+            printf("SUCCESS: flags=%#02x path='%s' -> rc=%d (negative)\n", fFlags, pszPath, rc);
+            return 0;
+        }
+        else
+            printf("FAILURE: flags=%#02x path='%s' -> rc=%d not %d! (negative)\n", fFlags, pszPath, rc, rcCorrect);
+    }
+    return 1;
+}
+
+
+int main (int argc, char *argv[])
+{
+    int     rcRet = 0;
+    struct stat s;
+
+    rcRet += testit(".", BACKFS_FLAGS_RESOLVE_FULL, -ENOENT);
+    rcRet += testit(".", BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, 0);
+    rcRet += testit(".", BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, 0);
+    rcRet += testit("/", BACKFS_FLAGS_RESOLVE_FULL, 0);
+    if (!stat("/tmp", &s))
+    {
+        rcRet += testit("/tmp", BACKFS_FLAGS_RESOLVE_FULL, 0);
+        rcRet += testit("/tmp/", BACKFS_FLAGS_RESOLVE_FULL, -ENOENT);
+        rcRet += testit("/tmp/", BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, 0);
+        rcRet += testit("/tmp", BACKFS_FLAGS_RESOLVE_PARENT, 0);
+        rcRet += testit("/tmp/", BACKFS_FLAGS_RESOLVE_PARENT, 0);
+        rcRet += testit("/tmp/", BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, 0);
+        rcRet += testit("/tmp/NoSuchSubDir", BACKFS_FLAGS_RESOLVE_PARENT, 0);
+        rcRet += testit("/tmp/NoSuchSubDir/", BACKFS_FLAGS_RESOLVE_PARENT, -ENOENT);
+        rcRet += testit("/tmp/NoSuchSubDir/", BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, 0);
+    }
+    else
+        printf("skipping /tmp tests - no such directory\n");
+    rcRet += testit("/nosuchdir", BACKFS_FLAGS_RESOLVE_PARENT, 0);
+    rcRet += testit("/nosuchdir/nosuchsubdir", BACKFS_FLAGS_RESOLVE_PARENT, -ENOENT);
+
+    return !!rcRet;
+}
+
Index: trunk/src/libctests/libc/smoketests/fsinternals-2.c
===================================================================
--- trunk/src/libctests/libc/smoketests/fsinternals-2.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/fsinternals-2.c	(revision 2055)
@@ -0,0 +1,407 @@
+/* $Id$ */
+/** @file
+ *
+ * LIBC SYS Backend - testcase for the Unix fsResolver.
+ *
+ * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+/**
+ * Commandline for simple standalone testing:
+ * gcc -D STANDALONE_TEST -o fsResolver.exe -Zomf fsResolver.c ..\..\..\..\src\lib\sys\fs.c -I \Coding\gcc2\tree\obj\OS2\DEBUG\emx -I ..\..\..\..\src\include\ ..\..\..\..\src\lib\sys\seterrno.c
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include "sys/b_fs.h"
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int __libc_gfNoUnix = 0;
+
+char g_aszCleanupDirs[PATH_MAX][5];
+
+
+static int isValid(const char *pszDir)
+{
+    if (strchr(pszDir, '\\'))
+    {
+        printf("bad slashing in '%s'!\n", pszDir);
+        return 0;
+    }
+    if (*pszDir == '/')
+    {
+        if (pszDir[1] != '/')
+        {
+            printf("Root slash in '%s'! - don't execute this test in a chroot env!\n", pszDir);
+            return 0;
+        }
+        if (pszDir[2] == '/')
+        {
+            printf("Too many slashes for UNC in '%s'!\n", pszDir);
+            return 0;
+        }
+    }
+    else
+    {
+        if (pszDir[0] < 'A' || pszDir[0] > 'Z')
+        {
+            printf("Driver letter is not upper case in '%s'!\n", pszDir);
+            return 0;
+        }
+        if (pszDir[1] != ':')
+        {
+            printf("Driver letter is not upper case in '%s'!\n", pszDir);
+            return 0;
+        }
+        if (pszDir[2] != '/')
+        {
+            printf("No root slash in '%s'!\n", pszDir);
+            return 0;
+        }
+    }
+
+    int cch = strlen(pszDir);
+    if (cch > 3 && pszDir[cch - 1] == '/')
+    {
+        printf("Trailing slash in '%s'!\n", pszDir);
+        return 0;
+    }
+
+    return 1;
+}
+
+
+
+static int tstDir(const char *pszDir)
+{
+    char szPathCorrect[PATH_MAX] = {0};
+    char szPath1[PATH_MAX];
+    char szPath2[PATH_MAX];
+    char szPath3[PATH_MAX];
+    int rc;
+
+    /*
+     * Get the correct path using chdir.
+     */
+    getcwd(szPath1, sizeof(szPath1));
+    if (_chdir2(pszDir))
+    {
+        printf("failed to chdir to %s, errno=%d\n", pszDir, errno);
+        return 1;
+    }
+    getcwd(szPathCorrect, sizeof(szPathCorrect));
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    rc = __libc_back_fsResolve(".", BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (_chdir2(szPath1))
+    {
+        printf("failed to chdir to %s, errno=%d\n", szPath1, errno);
+        return 1;
+    }
+    if (!isValid(szPathCorrect))
+    {
+        printf("Invalid getcwd() return '%s'\n", szPathCorrect);
+        return 1;
+    }
+    if (rc || strcmp(szPath2, szPathCorrect))
+    {
+        printf("Resolving '.' failed. got rc=%d '%s', expected '%s'\n", rc, szPath2, szPathCorrect);
+        return 1;
+    }
+
+    /*
+     * Check slash trailing and dots and such stuff.
+     */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, pszDir), "\\");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPathCorrect))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPathCorrect);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, pszDir), "\\.\\./.\\\\./.\\.///.\\./.\\\\////");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPathCorrect))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPathCorrect);
+        return 1;
+    }
+
+    /*
+     * Quick symlink check.
+     */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, pszDir), "\\");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPathCorrect))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPathCorrect);
+        return 1;
+    }
+
+    /*
+     * Try non-existing filename/dir (as for create).
+     */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL, szPath2, NULL);
+    if (rc != -ENOENT)
+    {
+        printf("(negative) Resolving '%s' failed!. Got rc=%d and '%s' expected rc=%d\n", szPath1, rc, szPath2, -ENOENT);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc != -ENOENT)
+    {
+        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/\\//my-not-Existing-file---");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "//my-not-Existing-file---");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+#if 0
+    /* negative */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT, szPath2, NULL);
+    if (rc != -ENOTDIR)
+    {
+        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
+        return 1;
+    }
+#endif
+
+    /*
+     * Create a directory and play with casing and 'maybe' expansion.
+     */
+    strcat(strcpy(szPath3, szPathCorrect), "/--Testase--fsResolver--TmpDir--");
+    rc = mkdir(szPath3, 0777);
+    if (rc)
+    {
+        printf("Failed to create subdir '%s', errno=%d\n", szPath3, errno);
+        return 1;
+    }
+    strcpy(g_aszCleanupDirs[0], szPath3);
+
+    /* mismatching casing. */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    /* dirslash */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+#if 0
+    /* negative */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK, szPath2, NULL);
+    if (rc != -ENOTDIR)
+    {
+        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK, szPath2, NULL);
+    if (rc != -ENOTDIR)
+    {
+        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
+        return 1;
+    }
+#endif
+
+    /* more later */
+    return 0;
+}
+
+
+static void cleanup(void)
+{
+    int i = sizeof(g_aszCleanupDirs) / sizeof(g_aszCleanupDirs[0]);
+    while (i-- > 0)
+        if (g_aszCleanupDirs[i])
+            rmdir(g_aszCleanupDirs[i]);
+}
+
+
+int main(int argc, char **argv)
+{
+    int cErrors = 0;
+    if (argc == 1)
+    {
+        cErrors += tstDir(".");
+        cleanup();
+    }
+    else
+    {
+        int i;
+        for (i = 1; i < argc; i++)
+        {
+            cErrors += tstDir(argv[i]);
+            cleanup();
+        }
+    }
+
+    if (!cErrors)
+        printf("fsResolver: SUCCESS\n");
+    else
+        printf("fsResolver: FAILURE - %d errors\n", cErrors);
+
+    return !!cErrors;
+}
Index: trunk/src/libctests/libc/smoketests/highmalloc-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/highmalloc-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/highmalloc-1.c	(revision 2055)
@@ -0,0 +1,42 @@
+#include <stdlib.h>
+#include <stdio.h>
+#define INCL_BASE
+#include <os2.h>
+
+
+
+int main()
+{
+    ULONG ul;
+    if (DosQuerySysInfo(QSV_VIRTUALADDRESSLIMIT, QSV_VIRTUALADDRESSLIMIT, &ul, sizeof(ul)))
+        ul = 512;
+    if (ul > 768)
+    {
+        printf("highmalloc: %d MB of virtual memory\n", ul);
+        static void *apv[1000];
+        int         i;
+        void *pv1 = malloc(34*1024*1024);
+        void *pv2 = malloc(34*1024*1024);
+        void *pv3 = malloc(34*1024*1024);
+
+        printf("pv1=%p pv2=%p pv3=%p\n", pv1, pv2, pv3);
+        free(pv1);
+        _heapmin();
+        free(pv2);
+        _heapmin();
+        free(pv3);
+        _heapmin();
+
+        for (i = 0; i < 1000; i++)
+            apv[i] = malloc(2048 * i);
+
+        for (i = 0; i < 1000; i++)
+        {
+            free(apv[i]);
+            _heapmin();
+        }
+    }
+    else
+        printf("skipping: no high memory support.\n");
+    return 0;
+}
Index: trunk/src/libctests/libc/smoketests/mbstuff-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/mbstuff-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/mbstuff-1.c	(revision 2055)
@@ -0,0 +1,319 @@
+#include <wctype.h>
+#include <wchar.h>
+#include <stdio.h>
+#include <locale.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+
+static int testSingleChar1(const char *pszMBCS, size_t cbMBCS, const wchar_t *pwcsFacit, size_t cwcFacit, const char *pszTest)
+{
+    int         i;
+    int         rc = 0;
+    mbstate_t   mbs;
+    mbstate_t   mbsLen1;
+    size_t      cbLeft = cbMBCS;
+    memset(&mbs, 0, sizeof(mbs));
+    memset(&mbsLen1, 0, sizeof(mbsLen1));
+
+    for (i = 0; i < cwcFacit; i++)
+    {
+        size_t  cbLen1;
+        size_t  cbLen2;
+
+        /* convert */
+        wchar_t wc = 0xfffe;
+        size_t cb = mbrtowc(&wc, pszMBCS, cbLeft, &mbs);
+        if ((int)cb < 0)
+        {
+            printf("error: Pos %d on test %s. mbrtowc -> %d errno=%d\n", i, pszTest, cb, errno);
+            return rc + 1;
+        }
+        if (cb == 0 && i + 1 != cwcFacit)
+        {
+            printf("error: Pos %d on test %s. Early end!\n", i, pszTest);
+            return rc + 1;
+        }
+
+        /* check */
+        if (wc != *pwcsFacit)
+        {
+            printf("error: Pos %d on test %s. 0x%04x != 0x%04x\n", i, pszTest, wc, *pwcsFacit);
+            rc++;
+        }
+
+        /* check length */
+        cbLen1 = mbrlen(pszMBCS, cbLeft, NULL);
+        if (cb != cbLen1)
+        {
+            printf("error: Pos %d on test %s. cb=%d mbrlen=%d (1)\n", i, pszTest, cb, cbLen1);
+            rc++;
+        }
+        cbLen2 = mbrlen(pszMBCS, cbLeft, &mbsLen1);
+        if (cb != cbLen2)
+        {
+            printf("error: Pos %d on test %s. cb=%d mbrlen=%d (2)\n", i, pszTest, cb, cbLen2);
+            rc++;
+        }
+
+        /* advance */
+        pwcsFacit++;
+        pszMBCS += cb;
+        cbLeft -= cb;
+    }
+
+    return rc;
+}
+
+
+static int testSingleChar2(const char *pszMBCS, size_t cbMBCS, const wchar_t *pwcsFacit, size_t cwcFacit, const char *pszTest)
+{
+    int         i;
+    int         rc = 0;
+    mbstate_t   mbs;
+    size_t      cbLeft = cbMBCS;
+    memset(&mbs, 0, sizeof(mbs));
+
+    for (i = 0; i < cwcFacit; i++)
+    {
+        /* convert */
+        char    ach[MB_LEN_MAX];
+        size_t cb = wcrtomb(ach, *pwcsFacit, &mbs);
+        if ((int)cb <= 0)
+        {
+            printf("error: Pos %d on test %s. wcrtomb -> %d errno=%d\n", i, pszTest, cb, errno);
+            return rc + 1;
+        }
+
+        /* check */
+        if (memcmp(ach, pszMBCS, cb))
+        {
+            printf("error: Pos %d on test %s. Mismatch! wc=0x%04x\n", i, pszTest, *pwcsFacit);
+            rc++;
+        }
+
+        /* advance */
+        pwcsFacit++;
+        pszMBCS += cb;
+        cbLeft -= cb;
+    }
+
+    return rc;
+}
+
+
+static int testString1(const char *pszMBCS, size_t cbMBCS, const wchar_t *pwcsFacit, size_t cwcFacit, const char *pszTest)
+{
+    int         rc = 0;
+    mbstate_t   mbs;
+    mbstate_t   mbsLen1;
+    size_t      cb;
+    size_t      cbLen1;
+    size_t      cbLen2;
+    wchar_t    *pwcsOut = alloca((cwcFacit + 4) * sizeof(wchar_t));
+    const char *pszIn = pszMBCS;
+    memset(&mbs, 0, sizeof(mbs));
+    memset(&mbsLen1, 0, sizeof(mbsLen1));
+
+    /* convert it as a full string. */
+    pwcsOut[cwcFacit + 1] = 0xfffe;
+    pwcsOut[cwcFacit + 0] = 0x3432;
+    pwcsOut[cwcFacit + 1] = 0x3031;
+    cb = mbsrtowcs(pwcsOut, &pszIn, cbMBCS, &mbs);
+    if ((int)cb <= 0)
+    {
+        printf("error: String conversion (to wc) failed, testcase %s. cb=%d errno=%d\n", pszTest, cb, errno);
+        return 1;
+    }
+    if (cb + 1 != cbMBCS)
+    {
+        printf("error: String conversion (to wc) testcase %s, length mismatch cb=%d cbMBCS=%d\n", pszTest, cb, cbMBCS);
+        return 1;
+    }
+    if (pszIn)
+    {
+        printf("error: String conversion (to wc) testcase %s, incorrect stop pointer. pszIn=%p expected=NULL\n", pszTest, (void *)pszIn);
+        return 1;
+    }
+    if (memcmp(pwcsOut, pwcsFacit, cwcFacit * sizeof(wchar_t)))
+    {
+        printf("error: String conversion (to wc) testcase %s, failed. Incorrect output!\n", pszTest);
+        return 1;
+    }
+    if (    pwcsOut[cwcFacit + 0] != 0x3432
+        ||  pwcsOut[cwcFacit + 1] != 0x3031)
+    {
+        printf("error: String conversion (to wc) testcase %s, failed. Wrote to much.\n", pszTest);
+        return 1;
+    }
+    if (pwcsOut[cwcFacit - 1])
+    {
+        printf("error: String conversion (to wc) testcase %s, failed. not terminated.\n", pszTest);
+        return 1;
+    }
+
+    /* lengths */
+    pszIn = pszMBCS;
+    cbLen1 = mbsrtowcs(NULL, &pszIn, cbMBCS, NULL);
+    if (cbLen1 != cb)
+    {
+        printf("error: String length 1 mismatched for testcase %s. cbLen1=%d cb=%d\n", pszTest, cbLen1, cb);
+        rc++;
+    }
+
+    pszIn = pszMBCS;
+    cbLen2 = mbsrtowcs(NULL, &pszIn, cbMBCS, &mbsLen1);
+    if (cbLen2 != cb)
+    {
+        printf("error: String length 2 mismatched for testcase %s. cbLen2=%d cb=%d\n", pszTest, cbLen2, cb);
+        rc++;
+    }
+
+    return rc;
+}
+
+static int testString2(const char *pszMBCS, size_t cbMBCS, const wchar_t *pwcsFacit, size_t cwcFacit, const char *pszTest)
+{
+    int         rc = 0;
+    mbstate_t   mbs;
+    mbstate_t   mbsLen1;
+    size_t      cb;
+    size_t      cbLen1;
+    size_t      cbLen2;
+    const wchar_t *pwcsIn = pwcsFacit;
+    char       *pszOut = (char *)alloca(cbMBCS + 4);
+    memset(&mbs, 0, sizeof(mbs));
+    memset(&mbsLen1, 0, sizeof(mbsLen1));
+
+    /* convert it as a full string. */
+    pszOut[cbMBCS - 1] = 0x7e;
+    pszOut[cbMBCS + 0] = 0x34;
+    pszOut[cbMBCS + 1] = 0x32;
+    cb = wcsrtombs(pszOut, &pwcsIn, cbMBCS, &mbs);
+    if ((int)cb <= 0)
+    {
+        printf("error: String conversion (to mb) failed, testcase %s. cb=%d errno=%d\n", pszTest, cb, errno);
+        return 1;
+    }
+    if (cb + 1 != cbMBCS)
+    {
+        printf("error: String conversion (to mb) testcase %s, length mismatch cb=%d cbMBCS=%d\n", pszTest, cb, cbMBCS);
+        return 1;
+    }
+    if (pwcsIn)
+    {
+        printf("error: String conversion (to mb) testcase %s, incorrect stop pointer. pwcsIn=%p expected=NULL\n", pszTest, (void *)pwcsIn);
+        return 1;
+    }
+    if (memcmp(pszOut, pszMBCS, cbMBCS))
+    {
+        printf("error: String conversion (to mb) testcase %s, failed. Incorrect output!\n", pszTest);
+        return 1;
+    }
+    if (    pszOut[cbMBCS + 0] != 0x34
+        ||  pszOut[cbMBCS + 1] != 0x32)
+    {
+        printf("error: String conversion (to mb) testcase %s, failed. Wrote to much.\n", pszTest);
+        return 1;
+    }
+    if (pszOut[cbMBCS - 1])
+    {
+        printf("error: String conversion (to mb) testcase %s, failed. Not terminated.\n", pszTest);
+        return 1;
+    }
+
+    /* lengths */
+    pwcsIn = pwcsFacit;
+    cbLen1 = wcsrtombs(NULL, &pwcsIn, cbMBCS, NULL);
+    if (cbLen1 != cb)
+    {
+        printf("error: String length 1 mismatched for testcase %s. cbLen1=%d cb=%d\n", pszTest, cbLen1, cb);
+        rc++;
+    }
+
+    pwcsIn = pwcsFacit;
+    cbLen2 = wcsrtombs(NULL, &pwcsIn, cbMBCS, &mbsLen1);
+    if (cbLen2 != cb)
+    {
+        printf("error: String length 2 mismatched for testcase %s. cbLen2=%d cb=%d\n", pszTest, cbLen2, cb);
+        rc++;
+    }
+
+    return rc;
+}
+
+
+
+static int test(const unsigned char *pszMBCS, size_t cbMBCS, const wchar_t *pwcsFacit, size_t cwcFacit, const char *pszTest)
+{
+    int rc = testSingleChar1((const char *)pszMBCS, cbMBCS, pwcsFacit, cwcFacit, pszTest);
+    rc += testSingleChar2((const char *)pszMBCS, cbMBCS, pwcsFacit, cwcFacit, pszTest);
+    rc += testString1((const char *)pszMBCS, cbMBCS, pwcsFacit, cwcFacit, pszTest);
+    rc += testString2((const char *)pszMBCS, cbMBCS, pwcsFacit, cwcFacit, pszTest);
+    return rc;
+}
+
+
+int main(void)
+{
+    /* -- ASSUMES wchar is unicode. */
+    static const wchar_t        wcsTestUCS2[14]   = { 0x00E6, 0x00F8, 0x00E5, 0x0a,
+                                                      0x00C6, 0x00D8, 0x00C5, 0x0a,
+                                                      0x00E4, 0x00C4, 0x00F6, 0x00D6, 0x0a, 0};
+    static const unsigned char  szTest850[14]     = { 0x91, 0x9b, 0x86, 0x0a,
+                                                      0x92, 0x9d, 0x8f, 0x0a,
+                                                      0x84, 0x8e, 0x94, 0x99, 0x0a, 0 }; /* "\n\n\n" */
+    static const unsigned char  szTest8859_1[14]  = { 0xe6, 0xf8, 0xe5, 0x0a,
+                                                      0xc6, 0xd8, 0xc5, 0x0a,
+                                                      0xe4, 0xc4, 0xf6, 0xd6, 0x0a, 0 }; /* "æøå\nÆØÅ\näÄöÖ\n" */
+    static const unsigned char  szTestUTF_8[]     = { 0xc3, 0xa6, 0xc3, 0xb8, 0xc3, 0xa5, 0x0a,
+                                                      0xc3, 0x86, 0xc3, 0x98, 0xc3, 0x85, 0x0a,
+                                                      0xc3, 0xa4, 0xc3, 0x84, 0xc3, 0xb6, 0xc3, 0x96, 0x0a, 0 };
+    int rc = 0;
+    printf("mbstuff-1: TESTING\n");
+
+
+    /*
+     * The tests.
+     */
+    if (    setlocale(LC_CTYPE, "no_NO.IBM-850")
+        ||  setlocale(LC_CTYPE, "no_NO.IBM850")
+        ||  setlocale(LC_CTYPE, "no_NO.CP850")
+        ||  setlocale(LC_CTYPE, "de_DE.CP850"))
+    {
+        rc += test(&szTest850[0], sizeof(szTest850), &wcsTestUCS2[0], sizeof(wcsTestUCS2) / sizeof(wcsTestUCS2[0]), "IBM-850");
+    }
+    else
+        printf("warning! Couldn't set LC_CTYPE to any IBM-850 base locale. :/\n");
+
+    if (    setlocale(LC_CTYPE, "en_US.ISO8859-1")
+        ||  setlocale(LC_CTYPE, "en_US.ISO-8859-1")
+        ||  setlocale(LC_CTYPE, "en_US.IBM-819")
+        ||  setlocale(LC_CTYPE, "en_US.IBM-819"))
+    {
+        rc += test(&szTest8859_1[0], sizeof(szTest8859_1), &wcsTestUCS2[0], sizeof(wcsTestUCS2) / sizeof(wcsTestUCS2[0]), "ISO8859-1");
+    }
+    else
+        printf("warning! Couldn't set LC_CTYPE to any ISO-8859-1 based locale. :/\n");
+
+    if (    setlocale(LC_CTYPE, "en_US.UTF-8")
+        ||  setlocale(LC_CTYPE, "en_US.UTF8")
+        ||  setlocale(LC_CTYPE, "en_US.IBM1208")
+        ||  setlocale(LC_CTYPE, "en_US.IBM-1208")
+        ||  setlocale(LC_CTYPE, "ja_JP.UTF-8")
+        ||  setlocale(LC_CTYPE, "ja_JP.UTF8"))
+    {
+        rc += test(&szTestUTF_8[0], sizeof(szTestUTF_8), &wcsTestUCS2[0], sizeof(wcsTestUCS2) / sizeof(wcsTestUCS2[0]), "UTF-8");
+    }
+    else
+        printf("warning! Couldn't set LC_CTYPE to any UTF-8 based locale. :/\n");
+
+    /* test summary. */
+    if (!rc)
+        printf("mbstuff-1: SUCCESS\n");
+    else
+        printf("mbstuff-1: FAILURE. %d errors\n", rc);
+    return !!rc;
+}
Index: trunk/src/libctests/libc/smoketests/nl_langinfo-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/nl_langinfo-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/nl_langinfo-1.c	(revision 2055)
@@ -0,0 +1,60 @@
+/* $Id$ */
+/** @file
+ *
+ * nl_langinfo(CODESET) testcase.
+ *
+ * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include <locale.h>
+#include <langinfo.h>
+
+
+int main (int argc, char *argv[])
+{
+    int rcRet = 0;
+    const char *psz1 = setlocale(LC_ALL, "");
+    const char *psz2 = setlocale(LC_ALL, NULL);
+    const char *psz3 = nl_langinfo(CODESET);
+    if (!psz1 || !psz2 || strcmp(psz1, psz2))
+    {
+        printf("nl_langinfo-1: FAILURE - setlocale(LC_ALL, \"\") -> %s ; setlocale(LC_ALL, NULL) -> %s\n", psz1, psz2);
+        rcRet++;
+    }
+    if (!psz2 || !psz3 || !strstr(psz2, psz3))
+    {
+        printf("nl_langinfo-1: FAILURE - setlocale(LC_ALL, NULL) -> %s ; nl_langinfo(CODESET) -> %s\n", psz2, psz3);
+        rcRet++;
+    }
+
+    /*
+     * Summary.
+     */
+    if (!rcRet)
+        printf("nl_langinfo-1: SUCCESS\n");
+    else
+        printf("nl_langinfo-1: FAILURE - %d errors\n", rcRet);
+    return rcRet;
+}
+
Index: trunk/src/libctests/libc/smoketests/open-dev-null-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/open-dev-null-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/open-dev-null-1.c	(revision 2055)
@@ -0,0 +1,62 @@
+/* $Id$ */
+/** @file
+ *
+ * Simple open() testcase.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/fcntl.h>
+
+int main()
+{
+    int fh = open("/dev/null", O_RDWR);
+    if (fh < 0)
+    {
+        printf("open-1: FAILURE - errno=%d\n", errno);
+        return 1;
+    }
+    close(fh);
+
+    fh = open("/dev/null", O_RDONLY);
+    if (fh < 0)
+    {
+        printf("open-1: FAILURE - O_RD errno=%d\n", errno);
+        return 1;
+    }
+    close(fh);
+
+    fh = open("/dev/null", O_WRONLY);
+    if (fh < 0)
+    {
+        printf("open-1: FAILURE - O_WR errno=%d\n", errno);
+        return 1;
+    }
+    close(fh);
+
+    printf("open-1: SUCCESS\n");
+    return 0;
+}
+
Index: trunk/src/libctests/libc/smoketests/opendir-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/opendir-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/opendir-1.c	(revision 2055)
@@ -0,0 +1,87 @@
+/* $Id$ */
+/** @file
+ *
+ * LIBC - simple opendir test.
+ *
+ * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of kBuild.
+ *
+ * kBuild is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * kBuild is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with kBuild; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <dirent.h>
+#include <stdio.h>
+#include <errno.h>
+
+int main(int argc, char **argv)
+{
+    DIR    *pDir;
+    int     rc = 0;
+    printf("opendir-1: TESTING\n");
+
+    errno = 4242;
+    pDir = opendir(".");
+    if (pDir)
+        closedir(pDir);
+    else
+    {
+        printf("failed to open '.'. errno=%d\n", errno);
+        rc++;
+    }
+
+    errno = 4242;
+    pDir = opendir("./");
+    if (pDir)
+        closedir(pDir);
+    else
+    {
+        printf("failed to open './'. errno=%d\n", errno);
+        rc++;
+    }
+
+    errno = 4242;
+    pDir = opendir(".//");
+    if (pDir)
+        closedir(pDir);
+    else
+    {
+        printf("failed to open './/'. errno=%d\n", errno);
+        rc++;
+    }
+
+    errno = 4242;
+    pDir = opendir("/");
+    if (pDir)
+        closedir(pDir);
+    else
+    {
+        printf("failed to open '/'. errno=%d\n", errno);
+        rc++;
+    }
+
+
+    /*
+     * Summary.
+     */
+    if (!rc)
+        printf("opendir-1: SUCCESS\n");
+    else
+        printf("opendir-1: FAILURE %d failures\n", rc);
+    return rc;
+}
+
Index: trunk/src/libctests/libc/smoketests/pathrewrite-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/pathrewrite-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/pathrewrite-1.c	(revision 2055)
@@ -0,0 +1,135 @@
+/* $Id$ */
+/** @file
+ *
+ * InnoTek LIBC Testcase - Path Rewrite Feature.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <InnoTekLIBC/pathrewrite.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+
+
+/*******************************************************************************
+*   Global Variables                                                           *
+*******************************************************************************/
+/** buffer for dynamically getting the right ETC. */
+char                gszEtcTo[256];
+/** rewrite the /etc directory. */
+__LIBC_PATHREWRITE  gEtcRule =
+{
+    __LIBC_PRWF_TYPE_DIR | __LIBC_PRWF_CASE_SENSITIVE,
+    "/etc",  4,
+    &gszEtcTo[0], 0
+};
+
+__LIBC_PATHREWRITE  gEtcRuleBad =
+{
+    __LIBC_PRWF_TYPE_DIR | __LIBC_PRWF_CASE_SENSITIVE,
+    "/etc/",  5,
+    "c:/mptn/etc", -1
+};
+
+
+
+
+
+int main(int argc, char **argv)
+{
+    int     rcRet = 0;
+    FILE    *pFile;
+
+    /*
+     * Test default rewriters.
+     */
+    pFile = fopen("/dev/null", "r");
+    if (pFile)
+        fclose(pFile);
+    else
+    {
+        printf("pathrewrite: /dev/null is not rewrittend\n");
+        rcRet++;
+    }
+
+    pFile = fopen("/dev/tty", "r");
+    if (pFile)
+        fclose(pFile);
+    else
+    {
+        printf("pathrewrite: /dev/tty is not rewrittend\n");
+        rcRet++;
+    }
+
+
+    /*
+     * Add rules.
+     */
+    if (    __libc_PathRewriteAdd(&gEtcRuleBad, 1) != -1
+        &&  errno == EINVAL)
+    {
+        printf("pathrewrite: negative add test failed\n");
+        rcRet++;
+    }
+
+    strcpy(&gszEtcTo[0], getenv("ETC"));
+    gEtcRule.cchTo = strlen(gEtcRule.pszTo);
+    if (__libc_PathRewriteAdd(&gEtcRule, 1))
+    {
+        printf("pathrewrite: add test failed\n");
+        rcRet++;
+    }
+
+    pFile = fopen("/etc/hosts", "r");
+    if (pFile)
+        fclose(pFile);
+    else
+    {
+        printf("pathrewrite: /etc/hosts is not rewrittend\n");
+        rcRet++;
+    }
+
+
+    /*
+     * Remove rules.
+     */
+    if (__libc_PathRewriteRemove(&gEtcRule, 1))
+    {
+        printf("pathrewrite: remove test failed\n");
+        rcRet++;
+    }
+
+    /*
+     * Status and exit.
+     */
+    if (!rcRet)
+        printf("pathrewrite: Successfully executed all tests\n");
+    else
+        printf("pathrewrite: %d tests failed\n", rcRet);
+    return rcRet;
+}
Index: trunk/src/libctests/libc/smoketests/paths-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/paths-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/paths-1.c	(revision 2055)
@@ -0,0 +1,109 @@
+/* $Id$ */
+/** @file
+ *
+ * Some testing of path/dir/file related functions.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+#include <limits.h>
+
+
+
+int main(int argc, char **argv)
+{
+    int     rcRet = 0;
+    int     rc;
+    char   *psz;
+    char    szPath[PATH_MAX];
+    struct stat s1,s2;
+
+
+    /* a bit of existing stuff */
+    psz = realpath(argv[0], szPath);
+    if (psz)
+    {
+        rc = lstat(szPath, &s1);
+        if (rc)
+            printf("lstat(%s) failed errno=%d\n", szPath, errno), rcRet++;
+        rc = open(szPath, O_RDONLY);
+        if (rc > 0)
+            close(rc);
+        else
+            printf("open(%s) failed errno=%d\n", szPath, errno), rcRet++;
+    }
+    else
+        printf("realpath(%s) failed errno=%d\n", argv[0], errno), rcRet++;
+
+    rc = lstat(".", &s1);
+    if (!rc)
+    {
+        rc = stat(".", &s2);
+        if (!rc)
+        {
+           /* compare the two. */
+        }
+        else
+            printf("stat(%s) failed errno=%d\n", ".", errno), rcRet++;
+    }
+    else
+        printf("lstat(%s) failed errno=%d\n", ".", errno), rcRet++;
+
+
+    /* test ENOENT */
+    rc = lstat(strcpy(szPath, "/........./........./....../foo"), &s1);
+    if (rc != -1 || errno != ENOENT)
+        printf("stat(%s) failed rc=%d errno=%d - expected %d (ENOENT)\n", szPath, rc, errno, ENOENT), rcRet++;
+    rc = open(szPath, O_RDONLY);
+    if (rc != -1 || errno != ENOENT)
+        printf("open(%s) failed rc=%d errno=%d - expected %d (ENOENT)\n", szPath, rc, errno, ENOENT), rcRet++;
+
+    /* test ENOTDIR */
+    if (!realpath(argv[0], szPath))
+        strcpy(szPath, argv[0]);
+    rc = lstat(strcat(szPath, "/parent-is-afile"), &s1);
+    if (rc != -1 || errno != ENOTDIR)
+        printf("stat(%s) failed rc=%d errno=%d - expected %d (ENOTDIR)\n", szPath, rc, errno, ENOTDIR), rcRet++;
+    rc = open(szPath, O_RDONLY);
+    if (rc != -1 || errno != ENOTDIR)
+        printf("open(%s) failed rc=%d errno=%d - expected %d (ENOTDIR)\n", szPath, rc, errno, ENOTDIR), rcRet++;
+
+    /*
+     * Report result.
+     */
+    if (!rcRet)
+        printf("paths: SUCCESS\n", rcRet);
+    else
+        printf("paths: FAILURE - %d errors\n", rcRet);
+    return !!rcRet;
+}
Index: trunk/src/libctests/libc/smoketests/setlocale-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/setlocale-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/setlocale-1.c	(revision 2055)
@@ -0,0 +1,104 @@
+#include <stdio.h>
+#include <locale.h>
+#include <ctype.h>
+#include <errno.h>
+#include <string.h>
+
+#define TESTCASENAME    "setlocale"
+
+
+static int tst(const char *pszLocale)
+{
+#ifdef OTHER
+    static char szTest[] = "\n\n\n"; /* 850 */
+#else
+    static char szTest[] =   "æøå\nÆØÅ\näÄöÖ\n"; /* 8859-1 */
+#endif
+    char   *psz;
+
+    psz = setlocale(LC_ALL, pszLocale);
+    printf("setlocale(LC_ALL, %s) -> %s  errno=%d\n", pszLocale, psz, errno);
+    for (psz = szTest; *psz; psz++)
+    {
+        if (*psz == '\n')
+            printf("\n");
+        else
+        {
+            printf("'%c'(%02x): %d,%d,%d%s",
+                   *psz, (unsigned char)*psz, !!isalpha(*psz), !!isupper(*psz), !!islower(*psz), psz[1] ? " " : "");
+
+        }
+    }
+    return 0;
+}
+
+static int tst2(void)
+{
+    char   *psz1;
+    char   *psz2;
+    int     rc = 0;
+
+    printf(TESTCASENAME "\n");
+
+    setlocale(LC_ALL, "en_US");
+    setlocale(LC_CTYPE, "de_DE");
+
+    psz1 = setlocale(LC_ALL, NULL);
+    psz2 = setlocale(LC_CTYPE, NULL);
+    if (psz1 && psz2 && strcmp(psz1, psz2))
+        printf("LC_ALL != LC_CTYPE - ok (%s != %s) errno=%d\n", psz1, psz2, errno);
+    else
+    {
+        printf("error: LC_ALL == LC_CTYPE - %s errno=%d\n", psz1, errno);
+        rc++;
+    }
+
+    return rc;
+}
+
+
+static int tst3(void)
+{
+    char   *psz1;
+    char   *psz2;
+    int     rc = 0;
+
+    setlocale(LC_ALL, "en_US");
+    psz1 = setlocale(LC_CTYPE, "de_DE");
+    psz2 = setlocale(LC_CTYPE, "de_DE");
+    if (psz1 && psz2 && !strcmp(psz1, psz2))
+        printf("2nd setlocale returns the same. %s errno=%d\n", psz1, errno);
+    else
+    {
+        printf("error: 2nd setlocale returns differntly. %s != %s errno=%d\n", psz1, psz2, errno);
+        rc++;
+    }
+
+    return rc;
+}
+
+
+int main()
+{
+    int rc = 0;
+
+    rc += tst("");
+    rc += tst("POSIX");
+#ifdef OTHER
+    rc += tst("en_US.IBM850");
+#else
+    rc += tst("en_US.ISO8859-1");
+#endif
+    rc += tst("C");
+    rc += tst("en_US");
+    rc += tst2();
+    rc += tst3();
+
+    /* .. done .. */
+    if (!rc)
+        printf(TESTCASENAME ": testcase executed successfully.\n");
+    else
+        printf(TESTCASENAME ": testcase failed. %d failed\n", rc);
+    return !!rc;
+}
+
Index: trunk/src/libctests/libc/smoketests/spm-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/spm-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/spm-1.c	(revision 2055)
@@ -0,0 +1,109 @@
+/* $Id$ */
+/** @file
+ *
+ * Test SPM allocation.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <InnoTekLIBC/sharedpm.h>
+
+
+static int randmax(int c, int mask)
+{
+    int i;
+    do i = rand() & mask; while (i > c);
+    return i;
+}
+
+int main()
+{
+    static void    *apv[0x10000];
+    int             i;
+    int             c;
+    int             cLeft;
+
+    /* exhaust the shared heap with small blocks. */
+    for (i = 0; i < sizeof(apv) / sizeof(apv[0]); i++)
+    {
+        size_t cb = 64 - i % 49;
+        if (i % 19)
+            cb = 256;
+        apv[i] = __libc_spmAlloc(cb);
+        if (!apv[i])
+            break;
+        memset(apv[i], 0xfa, cb);
+    }
+
+    __libc_SpmCheck(1, 0);
+
+    /* cleanup */
+    c = cLeft = i;
+    while (cLeft > c / 4)
+    {
+        i = randmax(c, 0xffff);
+        if (apv[i])
+        {
+            __libc_spmFree(apv[i]);
+            apv[i] = NULL;
+            cLeft--;
+        }
+    }
+    //__libc_SpmCheck(1, 1);
+    i = c;
+    while (i-- > 0)
+    {
+        __libc_spmFree(apv[i]);
+        apv[i] = NULL;
+    }
+
+    __libc_SpmCheck(1, 0);
+
+
+    /* exhaust the shared heap with larger blocks. */
+    for (i = 0; i < sizeof(apv) / sizeof(apv[0]); i++)
+    {
+        size_t cb = 1000 - (i * 7 % 511);
+        if (i % 11)
+            cb = 256;
+        apv[i] = __libc_spmAlloc(cb);
+        if (!apv[i])
+            break;
+        memset(apv[i], 0xfa, cb);
+    }
+
+    __libc_SpmCheck(1, 0);
+
+    /* cleanup */
+    while (i-- > 0)
+    {
+        __libc_spmFree(apv[i]);
+        apv[i] = NULL;
+    }
+
+    __libc_SpmCheck(1, 0);
+
+    return 0;
+}
Index: trunk/src/libctests/libc/smoketests/stat-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/stat-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/stat-1.c	(revision 2055)
@@ -0,0 +1,54 @@
+#include <unistd.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <errno.h>
+
+
+int main(int argc, char **argv)
+{
+    int             cErrors = 0;
+    int             rc;
+    struct stat     s;
+    printf("stat-1: TESTING\n");
+
+
+    /*
+     * Current dir.
+     */
+    rc = stat(".", &s);
+    if (rc != 0)
+    {
+        printf("stat(%s) -> %d errno=%d\n", ".", rc, errno);
+        cErrors++;
+    }
+
+    /*
+     * Parent dir.
+     */
+    rc = stat("..", &s);
+    if (rc != 0)
+    {
+        printf("stat(%s) -> %d errno=%d\n", "..", rc, errno);
+        cErrors++;
+    }
+
+
+    /*
+     * Executable.
+     */
+    rc = stat(argv[0], &s);
+    if (rc != 0)
+    {
+        printf("stat(%s) -> %d errno=%d\n", argv[0], rc, errno);
+        cErrors++;
+    }
+
+    /*
+     * Summary.
+     */
+    if (cErrors)
+        printf("stat-1: FAILURE %d failures\n", cErrors);
+    else
+        printf("stat-1: SUCCESS\n");
+    return cErrors;
+}
Index: trunk/src/libctests/libc/smoketests/strnlen-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/strnlen-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/strnlen-1.c	(revision 2055)
@@ -0,0 +1,27 @@
+/* confdefs.h.  */
+#undef _GNU_SOURCE
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+
+int main ()
+{
+
+#define S "foobar"
+#define S_LEN (sizeof S - 1)
+
+  /* At least one implementation is buggy: that of AIX 4.3 would
+     give strnlen (S, 1) == 3.  */
+
+  int i;
+  for (i = 0; i < S_LEN + 1; ++i)
+    {
+      int expected = i <= S_LEN ? i : S_LEN;
+      if (strnlen (S, i) != expected)
+	exit (1);
+    }
+  exit (0);
+
+  return 0;
+}
+
Index: trunk/src/libctests/libc/smoketests/strtof-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/strtof-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/strtof-1.c	(revision 2055)
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <float.h>
+
+int main(void)
+{
+    char *pszEnd = NULL;
+    float th = strtof("-30", &pszEnd);
+    if (th != -30.0)
+    {
+        printf("strtof-1: FAILURE (strtof -> %f)\n", th);
+        return 1;
+    }
+
+    th = 0.0;
+    sscanf("-30", "%f", &th);
+    if (th != -30.0)
+    {
+        printf("strtof-1: FAILURE (sscanf -> %f)\n", th);
+        return 1;
+    }
+
+    printf("strtof-1: SUCCESS\n");
+    return 0;
+}
Index: trunk/src/libctests/libc/smoketests/sysctl-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/sysctl-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/sysctl-1.c	(revision 2055)
@@ -0,0 +1,76 @@
+#define sysctl _std_sysctl
+#include <string.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <time.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <errno.h>
+
+int main()
+{
+    int cErrors = 0;
+
+    {
+        char sz[80] = {0};
+        struct tm tm = {0};
+        time_t t;
+        int mib[] = {CTL_KERN, KERN_BOOTTIME};
+        struct timeval j, now;
+        size_t  cbOut = sizeof(j);
+        errno = 0; \
+        int     rc = sysctl(mib, 2, &j, &cbOut, NULL, 0);
+        if (rc || errno) cErrors++;
+        t= j.tv_sec;
+        gmtime_r(&t, &tm);
+        asctime_r(&tm, sz);
+        printf("KERN_BOOTTIME: rc=%d errno=%d cbOut=%d - %lu.%.6ld (%s)\n", rc, errno, cbOut, j.tv_sec, j.tv_usec, sz);
+        gettimeofday(&now, NULL);
+        if (now.tv_sec < j.tv_sec)
+        {
+            printf("error: KERN_BOOTTIME is in the future!\n");
+            cErrors++;
+        }
+        else if (j.tv_sec <= 0)
+        {
+            printf("error: KERN_BOOTTIME is before 1970!\n");
+            cErrors++;
+        }
+    }
+
+#define GETSTRING(a, b) \
+    { \
+    int mib[] = {a, b}; \
+    char sz[256] = {0}; \
+    size_t  cbOut = sizeof(sz); \
+    errno = 0; \
+    int     rc = sysctl(mib, 2, sz, &cbOut, NULL, 0); \
+    if (rc || errno) cErrors++; \
+    printf(#b ": rc=%d errno=%d cbOut=%d - %s\n", rc, errno, cbOut, sz); \
+    }
+
+#define GETINT(a, b, min, max) \
+    { \
+    int mib[] = {a, b}; \
+    int     j; \
+    size_t  cbOut = sizeof(j); \
+    errno = 0; \
+    int     rc = sysctl(mib, 2, &j, &cbOut, NULL, 0); \
+    if (rc || errno) cErrors++; \
+    printf(#b ": rc=%d errno=%d cbOut=%d - %d (%#x)\n", rc, errno, cbOut, j, j); \
+    if (j < (min)) { printf("error:" #b ": %d is too small, min=%d.\n", j, min); cErrors++;} \
+    if (j > (max)) { printf("error:" #b ": %d is too big, max=%d.\n", j, max); cErrors++;} \
+    }
+
+    GETSTRING(CTL_KERN, KERN_BOOTFILE)
+    GETSTRING(CTL_HW, HW_MACHINE_ARCH)
+    GETSTRING(CTL_HW, HW_MACHINE)
+    GETSTRING(CTL_HW, HW_MODEL)
+    GETINT(CTL_HW, HW_NCPU, 1, 127)
+
+    if (!cErrors)
+        printf("sysctl-1: SUCCESS\n");
+    else
+        printf("sysctl-1: FAILURE - %d errors\n", cErrors);
+    return !!cErrors;
+}
Index: trunk/src/libctests/libc/smoketests/tls-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/tls-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/tls-1.c	(revision 2055)
@@ -0,0 +1,312 @@
+/* $Id$ */
+/** @file
+ *
+ * LIBC tls tests.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+ *
+ *
+ * This file is part of LIBC.
+ *
+ * LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+/*******************************************************************************
+*   Defined Constants And Macros                                               *
+*******************************************************************************/
+#define TEST_THREADS 10
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <InnoTekLIBC/thread.h>
+#include <process.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <386/builtin.h>
+
+/*******************************************************************************
+*   Structures and Typedefs                                                    *
+*******************************************************************************/
+/** Generic argument structure for the thread functions. */
+typedef struct ThreadArg
+{
+    int     iTLS;
+    int     cErrors;
+    int     tid;
+    int     fDone;
+} THREADARG, *PTHREADARG;
+
+static void thread1(void *pvArg)
+{
+    PTHREADARG  pArg = (PTHREADARG)pvArg;
+    int         i;
+
+    if (__libc_TLSGet(pArg->iTLS) != NULL)
+    {
+        printf("tls: error: tid %d: initial get failed on index %d\n",
+               pArg->tid, pArg->iTLS);
+        pArg->cErrors++;
+    }
+
+    for (i = 0; i < 100; i++)
+    {
+        if (__libc_TLSSet(pArg->iTLS, pvArg))
+        {
+            printf("tls: error: tid %d: set failed on index %d, i=%d\n",
+                   pArg->tid, pArg->iTLS, i);
+            pArg->cErrors++;
+        }
+
+        if (__libc_TLSGet(pArg->iTLS) != pvArg)
+        {
+            printf("tls: error: tid %d: get failed on index %d, i=%d\n",
+                   pArg->tid, pArg->iTLS, i);
+            pArg->cErrors++;
+        }
+        usleep(1000);
+    }
+    pArg->fDone = 1;
+}
+
+
+/** allocations and deallocations thread function. */
+static void thread2(void *pvArg)
+{
+    PTHREADARG pArg = (PTHREADARG)pvArg;
+    int i;
+
+    for (i = 0; i < 20000; i++)
+    {
+        int iTLS1;
+        int iTLS2;
+        iTLS1 = __libc_TLSAlloc();
+        if (iTLS1 < 0)
+        {
+            printf("tls: error: tid %d: TLSAlloc (1) failed, i=%d\n", pArg->tid, i);
+            pArg->cErrors++;
+        }
+
+        iTLS2 = __libc_TLSAlloc();
+        if (iTLS2 < 0)
+        {
+            printf("tls: error: tid %d: TLSAlloc (2) failed, i=%d\n", pArg->tid, i);
+            pArg->cErrors++;
+        }
+
+        if (__libc_TLSFree(iTLS1))
+        {
+            printf("tls: error: tid %d: TLSFree (1) failed, i=%d, iTLS1=%d\n", pArg->tid, i, iTLS1);
+            pArg->cErrors++;
+        }
+
+        if (__libc_TLSFree(iTLS2))
+        {
+            printf("tls: error: tid %d: TLSFree (2) failed, i=%d, iTLS2=%d\n", pArg->tid, i, iTLS2);
+            pArg->cErrors++;
+        }
+    }
+    pArg->fDone = 1;
+}
+
+
+int main()
+{
+    int         cErrors = 0;
+    int         cTLSes = 0;
+    static int  aiTLSes[1024];
+    int         i;
+    static THREADARG    aThreadArgs[1024];
+    int         iTLS;
+
+    /*
+     * Allocate the maximum number of TLSes checking that
+     * the limit checking works.
+     */
+    do
+    {
+        aiTLSes[cTLSes] = __libc_TLSAlloc();
+        if (aiTLSes[cTLSes] < 0)
+            break;
+        cTLSes++;
+    } while (cTLSes < 1024);
+    printf("tls: info: max=%d\n", cTLSes);
+    if (cTLSes < __LIBC_TLS_MAX)
+    {
+        printf("tls: error: cTLSes != max (%d != %d)\n", cTLSes, __LIBC_TLS_MAX);
+        cErrors++;
+    }
+    /* check for duplicates */
+    for (i = 0; i <  cTLSes; i++)
+    {
+        int j;
+        for (j = 0; j < cTLSes; j++)
+        {
+            if (i != j && aiTLSes[i] == aiTLSes[j])
+            {
+                printf("tls: error: duplicate allocation. i=%d, j=%d, index=%d\n",
+                       i, j, aiTLSes[i]);
+                cErrors++;
+            }
+        }
+    }
+
+    /*
+     * Set,get,set all entries.
+     */
+    i = cTLSes;
+    while (i-- > 0)
+    {
+        if (__libc_TLSSet(aiTLSes[i], (void*)(0x80000000 | i)))
+        {
+            printf("tls: error: set failed on index %d (i=%d)\n",
+                   aiTLSes[i], i);
+            cErrors++;
+        }
+
+        if (__libc_TLSGet(aiTLSes[i]) != (void*)(0x80000000 | i))
+        {
+            printf("tls: error: get failed on index %d (i=%d)\n",
+                   aiTLSes[i], i);
+            cErrors++;
+        }
+
+        if (__libc_TLSSet(aiTLSes[i], (void*)(0x80004000 | i)))
+        {
+            printf("tls: error: set (2) failed on index %d (i=%d)\n",
+                   aiTLSes[i], i);
+            cErrors++;
+        }
+    }
+
+    /*
+     * Free the allocated TLSes.
+     */
+    for (i = 0; i < cTLSes; i++)
+    {
+        if (__libc_TLSGet(aiTLSes[i]) !=  (void*)(0x80004000 | i))
+        {
+            printf("tls: error: get (2) failed on index %d (i=%d)\n",
+                   aiTLSes[i], i);
+            cErrors++;
+        }
+
+        if (__libc_TLSFree(aiTLSes[i]))
+        {
+            printf("tls: error: failed to free index %d\n", aiTLSes[i]);
+            cErrors++;
+        }
+
+        if (__libc_TLSGet(aiTLSes[i]) != NULL)
+        {
+            printf("tls: error: access possible after freed, index %d\n", aiTLSes[i]);
+            cErrors++;
+        }
+
+    }
+
+
+    /*
+     * Set & Get threaded.
+     */
+    iTLS = __libc_TLSAlloc();
+    if (iTLS >= 0)
+    {
+        /* spawn threads. */
+        for (i = 0; i < TEST_THREADS; i++)
+        {
+            aThreadArgs[i].cErrors  = 0;
+            aThreadArgs[i].iTLS     = iTLS;
+            aThreadArgs[i].fDone    = 0;
+            aThreadArgs[i].tid      = _beginthread(thread1, NULL, 0x10000, &aThreadArgs[i]);
+            if (aThreadArgs[i].tid <= 0)
+            {
+                aThreadArgs[i].fDone    = 1;
+                printf("tls: error: failed to create thread! i=%d\n", i);
+                cErrors++;
+            }
+        }
+
+        /* wait for the threads */
+        i = 0;
+        do
+        {
+            usleep(64000 + i);
+            for (i = 0; i < TEST_THREADS; i++)
+                if (!aThreadArgs[i].fDone)
+                    break;
+        } while (i < TEST_THREADS);
+
+        for (i = 0; i < TEST_THREADS; i++)
+            cErrors += aThreadArgs[i].cErrors;
+
+        if (__libc_TLSFree(iTLS))
+        {
+            printf("tls: error: failed to free TLS entry %d (set/get)\n", iTLS);
+            cErrors++;
+        }
+    }
+    else
+    {
+        printf("tls: error: failed to allocated TLS entry for set/get threaded.\n");
+        cErrors++;
+    }
+
+    /*
+     * Threaded alloc + free.
+     */
+    /*
+     * Set & Get threaded.
+     */
+    for (i = 0; i < TEST_THREADS; i++)
+    {
+        aThreadArgs[i].cErrors  = 0;
+        aThreadArgs[i].iTLS     = iTLS;
+        aThreadArgs[i].fDone    = 0;
+        aThreadArgs[i].tid      = _beginthread(thread2, NULL, 0x10000, &aThreadArgs[i]);
+        if (aThreadArgs[i].tid <= 0)
+        {
+            aThreadArgs[i].fDone    = 1;
+            printf("tls: error: failed to create thread! i=%d\n", i);
+            cErrors++;
+        }
+    }
+
+    /* wait for the threads */
+    i = 0;
+    do
+    {
+        usleep(32000 + i);
+        for (i = 0; i < TEST_THREADS; i++)
+            if (!aThreadArgs[i].fDone)
+                break;
+    } while (i < TEST_THREADS);
+
+    for (i = 0; i < TEST_THREADS; i++)
+        cErrors += aThreadArgs[i].cErrors;
+
+
+    /*
+     * Test summary
+     */
+    if (cErrors)
+        printf("tls: testcase failed with %d errors\n", cErrors);
+    else
+        printf("tls: testcase executed successfully\n");
+    return cErrors;
+}
Index: trunk/src/libctests/libc/smoketests/tmpfile-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/tmpfile-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/tmpfile-1.c	(revision 2055)
@@ -0,0 +1,50 @@
+/* $Id$ */
+/** @file
+ *
+ * LIBC - tmpfile testcase.
+ *
+ * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <stdio.h>
+
+int main()
+{
+    int cErrors = 0;
+    for (int i = 0; i <= 11000; i++)
+    {
+        FILE *pFile = tmpfile();
+        if (pFile)
+        {
+            fclose(pFile);
+            if (!(i % 1000))
+                printf("tmpfile-1: i=%d\n", i);
+        }
+        else
+        {
+            printf("tmpfile-1: failure i=%d\n", i);
+            if (++cErrors > 10)
+                break;
+        }
+    }
+    return !!cErrors;
+}
+
Index: trunk/src/libctests/libc/smoketests/usleep-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/usleep-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/usleep-1.c	(revision 2055)
@@ -0,0 +1,116 @@
+#include <unistd.h>
+#include <PrfTiming.h>
+#include <stdio.h>
+#include <errno.h>
+
+
+#ifdef __EMX__
+/* guesses, will fail on high system load */
+#define MAXDIFF_BIG     32000
+#define MAXDIFF_SMALL   10000
+#else
+#define MAXDIFF_BIG     20000
+#define MAXDIFF_SMALL    2000
+#endif
+
+
+
+
+int main()
+{
+    struct __test
+    {
+        /** Number of seconds to sleep. */
+        useconds_t      useconds;
+        /** Accepted number variation (higher, not lower). */
+        useconds_t      udiff;
+        /** expected return code. */
+        int             rc;
+        /** expected errno. */
+        int             err;
+    }   aTests[] =
+    {
+        {        1, MAXDIFF_SMALL, 0, 0 },
+        {     2000, MAXDIFF_SMALL, 0, 0 },
+        {     4000, MAXDIFF_SMALL, 0, 0 },
+        {    10000, MAXDIFF_SMALL, 0, 0 },
+        {    20000, MAXDIFF_SMALL, 0, 0 },
+        {    25000, MAXDIFF_SMALL, 0, 0 },
+        {    30000, MAXDIFF_SMALL, 0, 0 },
+        {    33000, MAXDIFF_SMALL, 0, 0 },
+        {    32100, MAXDIFF_SMALL, 0, 0 },
+        {    32200, MAXDIFF_SMALL, 0, 0 },
+        {    32300, MAXDIFF_SMALL, 0, 0 },
+        {    33000, MAXDIFF_SMALL, 0, 0 },
+        {    32000, MAXDIFF_SMALL, 0, 0 },
+        {    29000, MAXDIFF_SMALL, 0, 0 },
+        {    29500, MAXDIFF_SMALL, 0, 0 },
+        {    30000, MAXDIFF_SMALL, 0, 0 },
+        {    30500, MAXDIFF_SMALL, 0, 0 },
+        {    31000, MAXDIFF_SMALL, 0, 0 },
+        {    31100, MAXDIFF_SMALL, 0, 0 },
+        {    31300, MAXDIFF_SMALL, 0, 0 },
+        {    31500, MAXDIFF_SMALL, 0, 0 },
+        {    31700, MAXDIFF_SMALL, 0, 0 },
+        {    31900, MAXDIFF_SMALL, 0, 0 },
+        {    33000, MAXDIFF_SMALL, 0, 0 },
+        {   200000, MAXDIFF_BIG,   0, 0 },
+    };
+    int         i;
+    int         rcRet = 0;
+
+    for (i = 0; i < sizeof(aTests)/sizeof(aTests[0]); i++)
+    {
+        int j;
+        for (j = 0; j < 10; j++)
+        {
+            long double lrdEnd, lrdStart, lrdDiff;
+            useconds_t  udiff;
+            int         err;
+            int         rc;
+
+            errno = 0;
+            lrdStart = gettime();
+            rc = usleep(aTests[i].useconds);
+            lrdEnd = gettime();
+            err = errno;
+
+            lrdDiff = lrdEnd - lrdStart;
+            udiff = lrdDiff * 1000000 / getHz();
+
+            /* check rc/errno */
+            if (    rc != aTests[i].rc
+                ||  err != aTests[i].err)
+            {
+                printf("usleep: %d: Invalid rc and/or errno. returned rc=%d expected %d, errno=%d, expected %d.\n",
+                       i, rc, aTests[i].rc, err, aTests[i].err);
+                rcRet++;
+            }
+            else if (!rc)
+            {   /* check time */
+                if (udiff < aTests[i].useconds)
+                {
+                    printf("usleep: %d: returned too early. sleept %d, requested %d\n",
+                           i, udiff, aTests[i].useconds);
+                    rcRet++;
+                    break;
+                }
+                else if (udiff > aTests[i].useconds + aTests[i].udiff)
+                {
+                    printf("usleep: %d: returned too late. sleept %d, requested %d. overslept %d max expected diff %d\n",
+                           i, udiff, aTests[i].useconds, udiff - aTests[i].useconds, aTests[i].udiff);
+                    rcRet++;
+                    break;
+                }
+            }
+        }
+    }
+
+    if (!rcRet)
+        printf("usleep: all tests succeeded.\n");
+    else
+        printf("usleep: %d failure%s\n", rcRet, rcRet > 1 ? "s" : "");
+
+    return rcRet;
+}
+
Index: trunk/src/libctests/libc/smoketests/waitpid-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/waitpid-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/waitpid-1.c	(revision 2055)
@@ -0,0 +1,158 @@
+/* $Id$ */
+/** @file
+ *
+ * LIBC - waitpid testcase no.1.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <sys/wait.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <process.h>
+#include <signal.h>
+
+
+/*******************************************************************************
+*   Global Variables                                                           *
+*******************************************************************************/
+volatile pid_t g_pid0 = -1;
+volatile pid_t g_pid1 = -1;
+volatile pid_t g_pid64 = -1;
+volatile pid_t g_pid128 = -1;
+volatile pid_t g_pidKill = -1;
+volatile int   g_cErrors = 0;
+volatile int   g_cReaped = 0;
+
+static void sigchild(int iSignal)
+{
+    int     rc;
+    pid_t   pid;
+    while ((pid = waitpid(-1, &rc, WNOHANG)) > 0)
+    {
+        g_cReaped++;
+        printf("waitpid-1: info - reaped %#x rc=%d\n", pid, rc);
+        int rcWanted = -1;
+        if (pid == g_pid0)
+            rcWanted = W_EXITCODE(0,0);
+        else if (pid == g_pid1)
+            rcWanted = W_EXITCODE(1, 0);
+        else if (pid == g_pid64)
+            rcWanted = W_EXITCODE(64, 0);
+        else if (pid == g_pid128)
+            rcWanted = W_EXITCODE(128, 0);
+        else if (pid == g_pidKill)
+            rcWanted = W_EXITCODE(0, SIGKILL);
+        else
+        {
+            printf("waitpid-1: WARNING - interrupted before spawn returned!?!\n");
+            continue;
+        }
+        if (rc != rcWanted)
+        {
+            printf("waitpid-1: ERROR - pid=%#x exitted with rc=%#x expected %#x\n", pid, rc, rcWanted);
+            g_cErrors++;
+        }
+    }
+}
+
+int main(int argc, char **argv)
+{
+    /*
+     * Child for child.
+     */
+    if (argc == 2)
+    {
+        usleep(1000);
+        if (!strcmp(argv[1], "child-1"))
+            return 1;
+        if (!strcmp(argv[1], "child-64"))
+            return 64;
+        if (!strcmp(argv[1], "child-128"))
+            return 128;
+        if (!strcmp(argv[1], "child-kill"))
+            sleep(24*60*60);
+        return 0;
+    }
+
+    struct sigaction sigact;
+    sigact.sa_handler = sigchild;
+    sigact.sa_flags = 0;
+    sigemptyset(&sigact.sa_mask);
+    if (sigaction(SIGCHLD, &sigact, NULL))
+    {
+        printf("waitpid-1: ERROR - sigaction failed. errno=%d\n", errno);
+        return 1;
+    }
+
+    /*
+     * spawn children.
+     */
+    sighold(SIGCHLD);
+    g_pid0 = spawnl(P_NOWAIT, argv[0], argv[0], "child", NULL);
+    g_pid1 = spawnl(P_NOWAIT, argv[0], argv[0], "child-1", NULL);
+    g_pid64 = spawnl(P_NOWAIT, argv[0], argv[0], "child-64", NULL);
+    g_pid128 = spawnl(P_NOWAIT, argv[0], argv[0], "child-128", NULL);
+    g_pidKill = spawnl(P_NOWAIT, argv[0], argv[0], "child-kill", NULL);
+    int cSpawned = (g_pid0 > 0)
+                 + (g_pid1 > 0)
+                 + (g_pid64 > 0)
+                 + (g_pid128 > 0)
+                 + (g_pidKill > 0);
+    printf("waitpid-1: info - pid0=%#x pid1=%#x pid64=%#x pid128=%#x pidKill=%#x\n", g_pid0, g_pid1, g_pid64, g_pid128, g_pidKill);
+    if (cSpawned != 5)
+    {
+        printf("waitpid-1: ERROR - one or more spawns failed. cSpawned=%d should be 5!\n", cSpawned);
+        g_cErrors++;
+    }
+    sigrelse(SIGCHLD);
+
+    int cWaits = 0;
+    while (g_cReaped < cSpawned && cWaits++ < 30)
+    {
+        if (cWaits == 1 && g_cReaped + 1 == cSpawned)
+            kill(g_pidKill, SIGKILL);
+        else
+        {
+            sleep(1);
+            kill(g_pidKill, SIGKILL);
+        }
+    }
+
+    if (g_cReaped != cSpawned)
+    {
+        printf("waitpid-1: ERROR - reaped %d spawned %d!\n", g_cReaped, cSpawned);
+        g_cErrors++;
+    }
+
+    if (!g_cErrors)
+        printf("waitpid-1: SUCCESS\n");
+    else
+        printf("waitpid-1: FAILED - %d errors\n", g_cErrors);
+
+    return !!g_cErrors;
+}
Index: trunk/src/libctests/libc/smoketests/wctype-1.c
===================================================================
--- trunk/src/libctests/libc/smoketests/wctype-1.c	(revision 2055)
+++ trunk/src/libctests/libc/smoketests/wctype-1.c	(revision 2055)
@@ -0,0 +1,46 @@
+/* $Id$ */
+/** @file
+ *
+ * LIBC - extremely incomplete wctype testcase.
+ *
+ * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <wctype.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <locale.h>
+
+int main()
+{
+    int rc = 0;
+    if (!setlocale(LC_ALL, "C"))
+    {
+        printf("setlocale failed!\n");
+        return 1;
+    }
+    printf("iscntrl(0x82) -> %d\n", iscntrl(0x82));
+    printf("iswcntrl(0x82) -> %d\n", iswcntrl(0x82));
+    if (!!iscntrl(0x82) != !!iswcntrl(0x82))
+        printf("!!iscntrl(0x82) != !!iswcntrl(0x82) - behaviour isn't specified afaik, just checking.\n");
+    return rc;
+}
+
