Author |
Message |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun Aug 01, 2004 12:55 pm Post maybe stupid 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:
#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:
#ifdef _MT
_lock_str(stream);
#endif
//etc |
Is there actually a reason for the way MS does it, or are they just stupid? _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sun Aug 01, 2004 1:43 pm Post maybe stupid Post subject: |
 |
|
|
|
They are just stupid. Don't look too hard at the run-time source if you just ate. _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun Aug 01, 2004 1:53 pm Post maybe stupid Post subject: |
 |
|
|
|
OK, thank goodness I posted this right before lunch.  |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Sun Aug 01, 2004 3:25 pm Post maybe stupid 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. |
|
Back to top |
|
 |
|