Changeset 2548


Ignore:
Timestamp:
Mar 2, 2006, 2:26:41 AM (19 years ago)
Author:
bird
Message:

#58: The standard file handles are always initialized as open.

Location:
branches/libc-0.6/src/emx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/ChangeLog.LIBC

    r2545 r2548  
    22
    33TODO: open replace on RAMFS fails with error 32!
     4
     52006-03-01: knut st. osmundsen <bird-gccos2-spam@anduin.net>
     6    - libc:
     7        o #58: The standard file handles are always initialized as open.
    48
    592006-02-06: knut st. osmundsen <bird-gccos2-spam@anduin.net>
  • branches/libc-0.6/src/emx/src/lib/app/stdio.c

    r2120 r2548  
    9292    {
    9393        PLIBCFH pFH = __libc_FH(i);
    94         if (pFH)
     94        if (!pFH)
     95            LIBCLOG_MSG("No open file for %d\n", i);
     96
     97        /*
     98         * Common init - recall everything is ZERO.
     99         */
     100        gPreStreamVec.cFree--;
     101        gaPreFiles[i].__uVersion = _FILE_STDIO_VERSION;
     102        gaPreFiles[i]._flags    |= _IOOPEN | _IONOCLOSEALL;
     103        gaPreFiles[i]._handle    = i;
     104        gaPreFiles[i]._flush     = _flushstream;
     105        if (_fmutex_create2(&gaPreFiles[i].__u.__fsem, 0, "LIBC stream") != 0)
    95106        {
    96             /*
    97              * Common init - recall everything is ZERO.
    98              */
    99             gPreStreamVec.cFree--;
    100             gaPreFiles[i].__uVersion = _FILE_STDIO_VERSION;
    101             gaPreFiles[i]._flags    |= _IOOPEN | _IONOCLOSEALL;
    102             gaPreFiles[i]._handle    = i;
    103             gaPreFiles[i]._flush     = _flushstream;
    104             if (_fmutex_create2(&gaPreFiles[i].__u.__fsem, 0, "LIBC stream") != 0)
    105             {
    106                 LIBC_ASSERTM_FAILED("_setmore failed for i=%d\n", i);
    107                 abort();
    108             }
     107            LIBC_ASSERTM_FAILED("_setmore failed for i=%d\n", i);
     108            abort();
     109        }
    109110
    110             /*
    111              * Specific init.
    112              */
    113             switch (i)
    114             {
    115                 case 0:
    116                     /* stdin is always buffered. */
    117                     gaPreFiles[0]._flags    |= _IOREAD | _IOFBF | _IOBUFUSER;
    118                     gaPreFiles[0]._ptr       = gachStdIn;
    119                     gaPreFiles[0]._buffer    = gachStdIn;
    120                     gaPreFiles[0]._buf_size  = BUFSIZ;
    121                     LIBCLOG_MSG("__stdinp=%p\n", (void *)__stdinp);
    122                     break;
     111        /*
     112         * Specific init.
     113         */
     114        switch (i)
     115        {
     116            case 0:
     117                /* stdin is always buffered. */
     118                gaPreFiles[0]._flags    |= _IOREAD | _IOFBF | _IOBUFUSER;
     119                gaPreFiles[0]._ptr       = gachStdIn;
     120                gaPreFiles[0]._buffer    = gachStdIn;
     121                gaPreFiles[0]._buf_size  = BUFSIZ;
     122                LIBCLOG_MSG("__stdinp=%p\n", (void *)__stdinp);
     123                break;
    123124
    124                 case 1:
    125                     /* stdout is buffered unless it's connected to a device. */
    126                     gaPreFiles[1]._flags |= _IOWRT | _IOBUFNONE
    127                         | ((pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV ? _IONBF : _IOFBF);
    128                     LIBCLOG_MSG("__stdoutp=%p flags=%#x (%s)\n", (void *)__stdoutp, gaPreFiles[1]._flags,
    129                                 (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV ? "dev" : "none-dev");
    130                     break;
     125            case 1:
     126                /* stdout is buffered unless it's connected to a device. */
     127                gaPreFiles[1]._flags |= _IOWRT | _IOBUFNONE
     128                    | (pFH && (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV ? _IONBF : _IOFBF);
     129                LIBCLOG_MSG("__stdoutp=%p flags=%#x (%s)\n", (void *)__stdoutp, gaPreFiles[1]._flags,
     130                            pFH && (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV ? "dev" : "none-dev");
     131                break;
    131132
    132                 case 2:
    133                     /* stderr is always unbuffered. */
    134                     gaPreFiles[2]._flags |= _IOWRT | _IOBUFNONE | _IONBF;
    135                     LIBCLOG_MSG("__stderrp=%p\n", (void *)__stderrp);
    136                     break;
    137             }
     133            case 2:
     134                /* stderr is always unbuffered. */
     135                gaPreFiles[2]._flags |= _IOWRT | _IOBUFNONE | _IONBF;
     136                LIBCLOG_MSG("__stderrp=%p\n", (void *)__stderrp);
     137                break;
    138138        }
    139         else
    140             LIBCLOG_MSG("No open file for %d\n", i);
    141139    } /* for standard handles. */
    142140    LIBCLOG_RETURN_VOID();
Note: See TracChangeset for help on using the changeset viewer.