Server Help

Trash Talk - MT in MSVCRT

Cyan~Fire - Sun Aug 01, 2004 12:55 pm
Post subject: MT in MSVCRT
Just curious about this. In MS' CRT code, they always put MT-safe code in a separate function, like this:
Code: Show/Hide
#ifdef _MT
/* define locking/unlocking version */
size_t __cdecl fwrite (
        const void *buffer,
        size_t size,
        size_t count,
        FILE *stream
        )
{
        size_t retval;

        _lock_str(stream);                      /* lock stream */
        retval = _fwrite_lk(buffer, size, count, stream);  /* do the read */
        _unlock_str(stream);                    /* unlock stream */
        return retval;
}
#endif  /* _MT */

/* define the normal version */
#ifdef _MT
size_t __cdecl _fwrite_lk (
#else  /* _MT */
size_t __cdecl fwrite (
#endif  /* _MT */
//blah blah blah


I'd just put something like:
Code: Show/Hide
#ifdef _MT
_lock_str(stream);
#endif
//etc


Is there actually a reason for the way MS does it, or are they just stupid?
Mr Ekted - Sun Aug 01, 2004 1:43 pm
Post subject:
They are just stupid. Don't look too hard at the run-time source if you just ate.
Cyan~Fire - Sun Aug 01, 2004 1:53 pm
Post subject:
OK, thank goodness I posted this right before lunch. icon_biggrin.gif
Mine GO BOOM - Sun Aug 01, 2004 3:25 pm
Post subject:
They REALLY try to keep all the code inside the same area, so their method of making it work with 50 different compiling options really screw around with readablity. It works, but it takes more time to figure out how it works than it would to simple remake the code in a nicer manner.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group