Changeset 2090 for trunk/src/emx/include


Ignore:
Timestamp:
Jun 27, 2005, 5:30:23 AM (20 years ago)
Author:
bird
Message:

o Rewrote the libcXXXX.dll install rule to not play with emxload since

emxload sticks around when first loaded.

o Made unsetenv() cause tzset reload just like putenv() and setenv().
o Changed putenv() behaviour for removal (no '=' in input) to be identical

to unsetenv(). This solves duplicate variable testcase.

o Changed filestreams opened for both reading and writing to switch

more willingly between read and write mode.

o Made sscan() return EOF on EOF.
o Made sscan() skip blanks in input for '%%'.
o Implemented the stdio_unlocked stuff with BSD and GLIBC extension.

TODO: Require a new locktype which support recursive usage! Currently

a hack using 8 free flag bits is used.

o Corrected realpath() behaviour to return the path up to the failure

point on error. _realrealpath() also does this now.
(This also saves us a temp buffer and a copy of the result.)

o Fixed a bug in the handling of ".." in the path resolver.
o Extended that path resolver to check the directoryness of the input

according to flags and any trailing slashes.

o Change the path resolver to be very strict about UNC - UNC have exactly

two slashes at the start of the path.

Location:
trunk/src/emx/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/emx/io.h

    • Property cvs2svn:cvs-rev changed from 1.15 to 1.16
    r2089 r2090  
    88#include <InnoTekLIBC/fork.h>
    99#include <alloca.h>
     10#include <stdio.h>
    1011
    1112__BEGIN_DECLS
     
    148149#define _IONOCLOSEALL   0x00020000
    149150
     151/** This bit is set when the stream is locked by flockfile() or ftrylockfile().
     152 * !!TEMPORARY HACK!!
     153 * @todo replace the fmutex on the stream with a recursive lock! */
     154#define _IOLOCKED       0xff000000
    150155
    151156#define _FLUSH_FLUSH  (-1)
     
    192197
    193198#if defined (_SYS_FMUTEX_H)
    194 
    195199/* This semaphore (defined in app/stdio.c) protects _streamv[].  Only
    196200   concurrent access by _newstream(), _setmore(), and freopen() in
     
    204208#define STREAMV_LOCK    _fmutex_checked_request(&_streamv_fmutex, _FMR_IGNINT)
    205209#define STREAMV_UNLOCK  _fmutex_checked_release(&_streamv_fmutex)
    206 
    207 #define STREAM_LOCK(f) \
    208   ((f)->__uVersion != _FILE_STDIO_VERSION ? __stream_abort (f, "version error") \
    209    : _fmutex_request(&(f)->__u.__fsem, _FMR_IGNINT) != 0 \
    210    ? __stream_abort (f, "fmutex request") : 0)
    211 
    212 #define STREAM_UNLOCK(f) \
    213   (_fmutex_release(&(f)->__u.__fsem) != 0 ? __stream_abort (f, "fmutex release") : (void)0)
    214 
    215 #define STREAM_LOCK_NOWAIT(f) \
    216   (((f)->__uVersion == _FILE_STDIO_VERSION || __stream_abort (f, "version error")) && _fmutex_request(&(f)->__u.__fsem, _FMR_NOWAIT) == 0)
    217 
    218 #define STREAM_UNLOCKED(f) ((f)->__uVersion == _FILE_STDIO_VERSION && _fmutex_available(&(f)->__u.__fsem))
     210#endif /* _SYS_FMUTEX_H */
     211
     212#if defined (__FILE_FSEM_DECLARED)
    219213
    220214int __stream_abort(struct _FILE *f, const char *pszMsg);
    221215
    222 #endif /* defined (_SYS_FMUTEX_H) */
     216static int __inline__ stream_validate(struct _FILE *stream)
     217{
     218    if (stream->__uVersion != _FILE_STDIO_VERSION)
     219    {
     220        __stream_abort(stream, "version error");
     221        return 0;
     222    }
     223    return 1;
     224}
     225
     226static int __inline__ stream_lock(struct _FILE *stream)
     227{
     228    if (!stream_validate(stream))
     229        return 0;
     230    if (   !(stream->_flags & _IOLOCKED)
     231        || !_fmutex_is_owner(&stream->__u.__fsem))
     232    {
     233        if (_fmutex_request(&stream->__u.__fsem, _FMR_IGNINT) != 0)
     234        {
     235            __stream_abort(stream, "fmutex_request failed");
     236            return 0;
     237        }
     238        stream->_flags = 0x01000000 | (stream->_flags & ~_IOLOCKED);
     239    }
     240    else
     241        stream->_flags = ((stream->_flags & _IOLOCKED) + 0x01000000) | (stream->_flags & ~_IOLOCKED);
     242    return 1;
     243}
     244
     245static int __inline__ stream_trylock(struct _FILE *stream)
     246{
     247    if (!stream_validate(stream))
     248        return 0;
     249    if (   !(stream->_flags & _IOLOCKED)
     250        || !_fmutex_is_owner(&stream->__u.__fsem))
     251    {
     252        if (_fmutex_request(&stream->__u.__fsem, _FMR_NOWAIT) != 0)
     253        {
     254            __stream_abort(stream, "fmutex_request failed");
     255            return 0;
     256        }
     257        stream->_flags = 0x01000000 | (stream->_flags & ~_IOLOCKED);
     258    }
     259    else
     260        stream->_flags = ((stream->_flags & _IOLOCKED) + 0x01000000) | (stream->_flags & ~_IOLOCKED);
     261    return 1;
     262}
     263
     264static int __inline__ stream_unlock(struct _FILE *stream)
     265{
     266    if (!stream_validate(stream))
     267        return 0;
     268    if (!(stream->_flags & _IOLOCKED))
     269    {
     270        __stream_abort(stream, "unlock, 0 count");
     271        return 0;
     272    }
     273#ifdef __LIBC_STRICT
     274    if (!_fmutex_is_owner(&stream->__u.__fsem))
     275    {
     276        __stream_abort(stream, "unlock, not owner");
     277        return 0;
     278    }
     279#endif
     280    stream->_flags = ((stream->_flags & _IOLOCKED) - 0x01000000) | (stream->_flags & ~_IOLOCKED);
     281    if (   !(stream->_flags & _IOLOCKED)
     282        && _fmutex_release(&stream->__u.__fsem) != 0)
     283    {
     284        __stream_abort(stream, "fmutex_release failed");
     285        return 0;
     286    }
     287    return 1;
     288}
     289
     290#define STREAM_LOCK(f)          stream_lock(f)
     291#define STREAM_UNLOCK(f)        stream_unlock(f)
     292#define STREAM_LOCK_NOWAIT(f)   stream_trylock(f)
     293#define STREAM_UNLOCKED(f)      ((f)->__uVersion == _FILE_STDIO_VERSION && _fmutex_available(&(f)->__u.__fsem))
     294
     295#endif /* __FILE_FSEM_DECLARED */
    223296
    224297struct __libc_FileHandle;
     
    434507int _flushstream (struct _FILE *, int);
    435508void _closestream (struct _FILE *);
    436 int _fflush_nolock (struct _FILE *);
    437 int _fseek_nolock (struct _FILE *, off_t, int);
    438 off_t _ftell_nolock (struct _FILE *);
    439 size_t _fwrite_nolock (const void *, size_t, size_t, struct _FILE *);
     509int _fseek_unlocked (struct _FILE *, off_t, int);
     510off_t _ftello_unlocked (struct _FILE *);
    440511int _input (struct _FILE *, __const__ char *, char *);
    441512struct _FILE *_newstream (void);
  • trunk/src/emx/include/stdio.h

    • Property cvs2svn:cvs-rev changed from 1.14 to 1.15
    r2089 r2090  
    200200    {
    201201#if defined (_SYS_FMUTEX_H)
     202#define __FILE_FSEM_DECLARED
     203        /** @todo replace this by a nested lock construct, see flockfile(). */
    202204        _fmutex   __fsem;
    203205#endif
     
    287289long     ftell(FILE *);
    288290size_t   fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
    289 #if 0                                   /* bird: emx */
    290291int      getc(FILE *);
    291 #else                                   /* bird: emx */
    292 /** @todo: Check the standard, if this is correct or not. declaration might be required. */
    293 #define getc(s)   fgetc(s)              /* bird: emx */
    294 #endif                                  /* bird: emx */
    295292int      getchar(void);
    296293char    *gets(char *);
    297294void     perror(const char *);
    298295int      printf(const char * __restrict, ...);
    299 #if 0                                   /* bird: emx */
    300296int      putc(int, FILE *);
    301 #else                                   /* bird: emx */
    302 /** @todo: Check the standard, if this is correct or not. declaration might be required. */
    303 #define putc(c,s) fputc(c,s)            /* bird: emx */
    304 #endif                                  /* bird: emx */
    305297int      putchar(int);
    306298int      puts(const char *);
     
    356348
    357349#if __POSIX_VISIBLE >= 199506
    358 /** @todo int    ftrylockfile(FILE *); */
    359 /** @todo void   flockfile(FILE *); */
    360 /** @todo void   funlockfile(FILE *); */
     350int      ftrylockfile(FILE *);
     351void     flockfile(FILE *);
     352void     funlockfile(FILE *);
    361353
    362354/*
     
    364356 * requires functions as well.
    365357 */
    366 /** @todo int    getc_unlocked(FILE *); */
    367 /** @todo int    getchar_unlocked(void); */
    368 /** @todo int    putc_unlocked(int, FILE *); */
    369 /** @todo int    putchar_unlocked(int); */
     358int      getc_unlocked(FILE *);
     359int      getchar_unlocked(void);
     360int      putc_unlocked(int, FILE *);
     361int      putchar_unlocked(int);
    370362#endif
    371363#if __BSD_VISIBLE
    372 /** @todo void  clearerr_unlocked(FILE *); */
    373 /** @todo int   feof_unlocked(FILE *); */
    374 /** @todo int   ferror_unlocked(FILE *); */
    375 /** @todo int   fileno_unlocked(FILE *); */
     364void    clearerr_unlocked(FILE *);
     365int     feof_unlocked(FILE *);
     366int     ferror_unlocked(FILE *);
     367int     fileno_unlocked(FILE *);
     368#endif
     369#ifdef __USE_MISC
     370int     fflush_unlocked(FILE *);
     371size_t  fwrite_unlocked(const void * __restrict, size_t, size_t, FILE * __restrict);
     372size_t  fread_unlocked(void * __restrict, size_t, size_t, FILE * __restrict);
     373int     fgetc_unlocked(FILE *);
     374int     fputc_unlocked(int, FILE *);
     375int     fputs_unlocked(const char * __restrict, FILE * __restrict);
     376int     puts_unlocked(const char *);
    376377#endif
    377378
  • trunk/src/emx/include/sys/fmutex.h

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r2089 r2090  
    104104}
    105105
     106
     107static __inline__ int _fmutex_is_owner (_fmutex *sem)
     108{
     109    return sem->fs > _FMS_AVAILABLE && sem->Owner == fibGetTidPid();
     110}
     111
    106112/**
    107113 * Release a semaphore in the child process after the
Note: See TracChangeset for help on using the changeset viewer.