Changeset 2741


Ignore:
Timestamp:
Jul 23, 2006, 7:54:53 AM (19 years ago)
Author:
bird
Message:

Started backend cleanup for portability. Stil work in progress.

Location:
trunk/libc
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/Config.kmk

    r2739 r2741  
    4949DEFS = \
    5050        IN_INNOTEK_LIBC \
    51         __IN_INNOTEK_LIBC__
     51        __IN_INNOTEK_LIBC__ \
     52        __IN_KLIBC__
     53
    5254DEFS.os2   = __OS2__
    5355DEFS.nt    = __NT__
  • trunk/libc/src/fbsdlibc/Makefile.kmk

    r2739 r2741  
    3535include $(wildcard $(PATH_LIBC_SRC)/fbsdlibc/*/Makefile.kmk)
    3636else
     37include $(PATH_LIBC_SRC)/fbsdlibc/gen/Makefile.kmk
    3738include $(PATH_LIBC_SRC)/fbsdlibc/locale/Makefile.kmk
    3839endif
  • trunk/libc/src/fbsdlibc/gen/arc4random.c

    r2029 r2741  
    3333#include <fcntl.h>
    3434#include <unistd.h>
    35 #ifdef __EMX__
     35#ifdef __IN_KLIBC__
    3636#include <sys/fmutex.h>
    3737#else
     
    4848};
    4949
    50 #ifdef __EMX__
     50#ifdef __IN_KLIBC__
    5151static _fmutex  arc4random_mtx = _FMUTEX_INITIALIZER;
    5252#else
     
    5555
    5656#define RANDOMDEV       "/dev/urandom"
    57 #ifdef __EMX__
     57#ifdef __IN_KLIBC__
    5858#define THREAD_LOCK()   _fmutex_request(&arc4random_mtx, 0)
    5959#define THREAD_UNLOCK() _fmutex_release(&arc4random_mtx)
    60 #else /* !__EMX__ */
     60#else /* !__IN_KLIBC__ */
    6161#define THREAD_LOCK()                                           \
    6262        do {                                                    \
  • trunk/libc/src/fbsdlibc/gen/fts.c

    r2672 r2741  
    3939#endif /* LIBC_SCCS and not lint */
    4040#endif
    41 #ifndef __EMX__
     41#ifndef __IN_KLIBC__
    4242# define HAVE_FCHDIR
    4343# define HAVE_DIRFD
     
    4747# define HAVE_FCHDIR
    4848# undef HAVE_DIRFD
    49 # define IS_SLASH(ch)   ( (ch) == '/' || (ch) == '\\' )
     49# if defined(__OS2__) || defined(__NT__) || defined(__WIN__)
     50#  define IS_SLASH(ch)   ( (ch) == '/' || (ch) == '\\' )
     51# else
     52#  define IS_SLASH(ch)   ( (ch) == '/' )
     53# endif
    5054#endif
    5155
     
    108112};
    109113
    110 #ifndef __EMX__
     114#ifndef __IN_KLIBC__
    111115/*
    112116 * The "FTS_NOSTAT" option can avoid a lot of calls to stat(2) if it
     
    125129        0
    126130};
    127 #endif /* !__EMX__ */
     131#endif /* !__IN_KLIBC__ */
    128132
    129133FTS *
     
    727731         * If being called from fts_read, set the fts_info field.
    728732         */
    729 #if defined(FTS_WHITEOUT) && !defined(__EMX__)
     733#if defined(FTS_WHITEOUT) && !defined(__IN_KLIBC__)
    730734        if (ISSET(FTS_WHITEOUT))
    731735                oflag = DTF_NODUP | DTF_REWIND;
     
    13041308
    13051309        priv = (struct _fts_private *)sp;
    1306 #ifdef __EMX__
     1310#ifdef __IN_KLIBC__
    13071311        /* we don't have reliable links */
    13081312        priv->ftsp_linksreliable = 0;
  • trunk/libc/src/fbsdlibc/gen/getgrent.c

    r2256 r2741  
    4848#include <grp.h>
    4949#include <nsswitch.h>
    50 #ifndef __EMX__
     50#ifndef __IN_KLIBC__
    5151#include <pthread.h>
    5252#include <pthread_np.h>
     
    146146
    147147/* XXX IEEE Std 1003.1, 2003 specifies `void setgrent(void)' */
    148 int                             
     148int
    149149setgrent(void)
    150150{
     
    484484        }
    485485        rv = NS_NOTFOUND;
    486 #ifndef __EMX__
     486#ifndef __IN_KLIBC__
    487487        while ((line = fgetln(st->fp, &linesize)) != NULL) {
    488488#else
     
    698698        enum nss_lookup_type how;
    699699        int             *errnop, keylen, resultlen, rv;
    700        
     700
    701701        name = NULL;
    702702        gid = (gid_t)-1;
     
    801801        if (rv == NS_SUCCESS && retval != NULL)
    802802                *(struct group **)retval = grp;
    803         return (rv);   
     803        return (rv);
    804804erange:
    805805        *errnop = ERANGE;
     
    10191019        }
    10201020        rv = NS_NOTFOUND;
    1021 #ifndef __EMX__
     1021#ifndef __IN_KLIBC__
    10221022        while ((line = fgetln(st->fp, &linesize)) != NULL) {
    10231023#else
     
    10351035                                st->name = malloc(p - line);
    10361036                                if (st->name == NULL) {
    1037 #ifndef __EMX__
     1037#ifndef __IN_KLIBC__
    10381038                                        syslog(LOG_ERR,
    10391039                                         "getgrent memory allocation failure");
  • trunk/libc/src/fbsdlibc/gen/getmntinfo.c

    r1694 r2741  
    4040
    4141#include <sys/param.h>
    42 #ifndef __EMX__
     42#ifndef __IN_KLIBC__
    4343#include <sys/ucred.h>
    4444#endif
  • trunk/libc/src/fbsdlibc/gen/getnetgrent.c

    r1697 r2741  
    341341#endif
    342342        /* Sanity check */
    343        
     343
    344344        if (group == NULL || !strlen(group))
    345345                return (0);
  • trunk/libc/src/fbsdlibc/gen/getprogname.c

    r927 r2741  
    99
    1010#ifdef __EMX__
    11 #define INCL_BASE
    12 #define INCL_FSMACROS
    13 #include <os2emx.h>
    14 #include <string.h>
     11# define INCL_BASE
     12# define INCL_FSMACROS
     13# include <os2emx.h>
     14# include <string.h>
     15const char *__progname = NULL;
     16#endif
     17#ifdef __NT__
     18# include <klibc/nt/nt.h>
    1519const char *__progname = NULL;
    1620#endif
     
    2226_getprogname(void)
    2327{
    24 #ifdef __EMX__
    2528    /*
    2629     * On demand initiation.
     
    3134    if (!__progname)
    3235    {
     36#ifdef __EMX__
    3337        char *psz, *psz2;
    3438        PTIB ptib;
     
    5155        /* This is in the volatile env. block - dupe it. */
    5256        __progname = strdup(psz2);
     57
     58#elif defined(__NT__)
     59        asm("int3\n");
     60#else
     61# error "Port me!"
     62#endif
    5363    }
    54 #endif
    55         return (__progname);
     64    return (__progname);
    5665}
     66
  • trunk/libc/src/fbsdlibc/gen/getpwent.c

    r2256 r2741  
    4949#include <netdb.h>
    5050#include <nsswitch.h>
    51 #ifndef __EMX__
     51#ifndef __IN_KLIBC__
    5252#include <pthread.h>
    5353#include <pthread_np.h>
     
    475475        if (*version < 3 ||
    476476            *version >= sizeof(pwdb_versions)/sizeof(pwdb_versions[0])) {
    477 #ifndef __EMX__
     477#ifndef __IN_KLIBC__
    478478                syslog(LOG_CRIT, "Unsupported password database version %d",
    479479                    *version);
     
    11951195        return (0);
    11961196enomem:
    1197 #ifndef __EMX__
     1197#ifndef __IN_KLIBC__
    11981198        syslog(LOG_ERR, "getpwent memory allocation failure");
    11991199#endif
     
    12241224        copy = malloc(n);
    12251225        if (copy == NULL) {
    1226 #ifndef __EMX__
     1226#ifndef __IN_KLIBC__
    12271227                syslog(LOG_ERR, "getpwent memory allocation failure");
    12281228#endif
     
    16051605                                st->name = strdup(&pw_name[1]);
    16061606                                if (st->name == NULL) {
    1607 #ifndef __EMX__
     1607#ifndef __IN_KLIBC__
    16081608                                        syslog(LOG_ERR,
    16091609                                         "getpwent memory allocation failure");
  • trunk/libc/src/fbsdlibc/gen/glob.c

    r1697 r2741  
    159159static int       glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, int *);
    160160static int       globextend(const Char *, glob_t *, int *);
    161 static const Char *     
     161static const Char *
    162162                 globtilde(const Char *, Char *, size_t, glob_t *);
    163163static int       globexp1(const Char *, glob_t *, int *);
     
    808808                        while (((c = *pat++) & M_MASK) != M_END)
    809809                                if ((*pat & M_MASK) == M_RNG) {
    810 #ifdef __EMX__ /* we don't include all the locale stuff, only standalone stuff like this. */
     810#ifdef __IN_KLIBC__ /* we don't include all the locale stuff, only standalone stuff like this. */
    811811                                        if (   __collate_range_cmp(CHAR(c), CHAR(k)) <= 0
    812812                                            && __collate_range_cmp(CHAR(k), CHAR(pat[1])) <= 0)
  • trunk/libc/src/fbsdlibc/gen/isinf.c

    r2139 r2741  
    4545
    4646        u.d = d;
    47 #ifdef __EMX__
     47#ifdef __IN_KLIBC__
    4848        return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0)
    4949            ? u.bits.sign ? -1 : 1 : 0;
     
    5959
    6060        u.f = f;
    61 #ifdef __EMX__
     61#ifdef __IN_KLIBC__
    6262        return (u.bits.exp == 255 && u.bits.man == 0)
    6363            ? u.bits.sign ? -1 : 1 : 0;
     
    7474        u.e = e;
    7575        mask_nbit_l(u);
    76 #ifdef __EMX__
     76#ifdef __IN_KLIBC__
    7777#ifndef __alpha__
    7878        return (u.bits.exp == 32767 && u.bits.manl == 0 && u.bits.manh == 0)
     
    8989#endif
    9090}
     91
  • trunk/libc/src/fbsdlibc/gen/setprogname.c

    r1694 r2741  
    1212{
    1313    const char *p;
    14 #ifdef __EMX__
     14#if defined(__EMX__) || defined(__NT__)
    1515    p = strlen(progname) + progname;
    1616    while (p >= progname)
  • trunk/libc/src/fbsdlibc/locale/mblocal.h

    r1705 r2741  
    3535 * Conversion function pointers for current encoding.
    3636 */
    37 #ifndef __INNOTEK_LIBC__
     37#ifndef __IN_KLIBC__
    3838extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
    3939    size_t, mbstate_t * __restrict);
     
    4444extern size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict,
    4545    size_t, size_t, mbstate_t * __restrict);
    46 #else /* !__INNOTEK_LIBC__ */
    47 #define __mbrtowc(a,b,c,d)      __libc_GLocaleCtype.CtypeFuncs.pfnmbrtowc(a,b,c,d)
    48 #define __mbsinit(a)            __libc_GLocaleCtype.CtypeFuncs.pfnmbsinit(a)
    49 #define __mbsnrtowcs(a,b,c,d,e) __libc_GLocaleCtype.CtypeFuncs.pfnmbsnrtowcs(a,b,c,d,e)
    50 #define __wcrtomb(a,b,c)        __libc_GLocaleCtype.CtypeFuncs.pfnwcrtomb(a,b,c)
    51 #define __wcsnrtombs(a,b,c,d,e) __libc_GLocaleCtype.CtypeFuncs.pfnwcsnrtombs(a,b,c,d,e)
     46#else /* !__IN_KLIBC__ */
     47# define __mbrtowc(a,b,c,d)      __libc_GLocaleCtype.CtypeFuncs.pfnmbrtowc(a,b,c,d)
     48# define __mbsinit(a)            __libc_GLocaleCtype.CtypeFuncs.pfnmbsinit(a)
     49# define __mbsnrtowcs(a,b,c,d,e) __libc_GLocaleCtype.CtypeFuncs.pfnmbsnrtowcs(a,b,c,d,e)
     50# define __wcrtomb(a,b,c)        __libc_GLocaleCtype.CtypeFuncs.pfnwcrtomb(a,b,c)
     51# define __wcsnrtombs(a,b,c,d,e) __libc_GLocaleCtype.CtypeFuncs.pfnwcsnrtombs(a,b,c,d,e)
    5252#endif
    5353
  • trunk/libc/src/fbsdlibc/locale/utf8.c

    r2739 r2741  
    3131#include <errno.h>
    3232#include <limits.h>
    33 #ifdef IN_INNOTEK_LIBC
    34 #include <InnotekLIBC/locale.h>
     33#ifdef __IN_KLIBC__
     34# include <InnotekLIBC/locale.h>
    3535#else
    3636#include <runetype.h>
     
    5656} _UTF8State;
    5757
    58 #ifndef IN_INNOTEK_LIBC
     58#ifndef __IN_KLIBC__
    5959int
    6060_UTF8_init(_RuneLocale *rl)
     
    7171        return (0);
    7272}
    73 #else
     73#else   /* __IN_KLIBC__ */
    7474void __libc_localeFuncsUTF8(__LIBC_PLOCALECTYPEFUNCS pFuncs)
    7575{
     
    8080    pFuncs->pfnwcsnrtombs = _UTF8_wcsnrtombs;
    8181}
    82 #endif /* IN_INNOTEK_LIBC */
     82#endif  /* __IN_KLIBC__ */
    8383
    8484int
  • trunk/libc/src/libc/malloc/Makefile.kmk

    r2739 r2741  
    9898    $(PATH_LIBC_SRC)/libc/malloc/_um_abort.c \
    9999
     100## @todo need some header for these CFG_LIBC defines.
     101$(PATH_LIBC_SRC)/libc/malloc/_hinitheap.c_DEFS.os2 = CFG_LIBC_HIGH_HEAP
     102
    100103# configure the variants. */
    101104$(call LIBC_CONFIG_VARIANT_LIBS,libc_libc_malloc)
  • trunk/libc/src/libc/malloc/_hinitheap.c

    r2254 r2741  
    22/** @file
    33 *
    4  * High Memory Heap - init.
     4 * LIBC - High Memory Heap - init.
    55 *
    6  * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net>
     6 * Copyright (c) 2003-2006 knut st. osmundsen <bird-srcspam@anduin.net>
    77 *
    88 *
     
    5757{
    5858    LIBCLOG_ENTER("\n");
    59     /* only one init at a time. */
    60     static _smutex  lock;
     59    static _smutex  lock;           /* only one init at a time. */
     60    Heap_t          Heap;
     61
     62#if CFG_LIBC_HIGH_HEAP
    6163    void *          pvInitial;
    6264    size_t          cbInitial;
    6365    int             fClean;
    64     Heap_t          Heap;
    65 
    6666
    6767    /*
     
    9595    {
    9696        _um_abort("_hinitheap: __libc_HimemDefaultAlloc failed!\n");
    97         LIBCLOG_RETURN_P(NULL);
     97        LIBCLOG_ERROR_RETURN_P(NULL);
    9898    }
    9999
     
    108108    {
    109109        _um_abort("_hinitheap: _ucreate2 failed!\n");
    110         LIBCLOG_RETURN_P(NULL);
     110        LIBCLOG_ERROR_RETURN_P(NULL);
    111111    }
    112112    if (_uopen(Heap) != 0)
    113113    {
    114114        _um_abort("_hinitheap: _uopen(%p) failed!\n", Heap);
    115         LIBCLOG_RETURN_P(NULL);
     115        LIBCLOG_ERROR_RETURN_P(NULL);
    116116    }
    117117
     
    123123
    124124    LIBCLOG_RETURN_P(Heap);
     125
     126#else   /* !CFG_LIBC_HIGH_HEAP */
     127
     128    /*
     129     * Return the low heap.
     130     */
     131    _smutex_request(&lock);
     132    Heap; Heap = _um_high_heap;
     133    if (!_um_high_heap)
     134        _um_high_heap = Heap = _linitheap();
     135    _smutex_release(&lock);
     136
     137    LIBCLOG_RETURN_P(Heap);
     138#endif  /* !CFG_LIBC_HIGH_HEAP */
    125139}
    126140
Note: See TracChangeset for help on using the changeset viewer.