From a6daababe7cd0293f659c7cb86e024bd2ddb038b Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Thu, 24 Mar 2005 15:31:16 +0000 Subject: [PATCH] - The thread-safe system() call now blocks all standard I/O operations until the function has returned. Which is harsh, but there is no elegant solution to the issue of keeping the same dos.library file handles from concurrent use which SystemTagList() might just end up using. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14898 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/changes | 19 +++++++++++++++---- library/stdio_fprintf.c | 6 +----- library/stdio_fscanf.c | 6 +----- library/stdlib_system.c | 17 ++++++++++++++++- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/library/changes b/library/changes index c8e91a1..20bb0a4 100644 --- a/library/changes +++ b/library/changes @@ -106,7 +106,7 @@ - Removed some more redundant data from stdlib_main.c. -- Added the first real C99 function: _Exit(). +- Added the first "real" C99 function: _Exit() ;-) - assertion failures early on during program initialization should no longer spell big trouble on account of the stdio @@ -118,12 +118,23 @@ it *again*. Which probably means that the 68k library will need further changes... -- Moved stdlib_main.o into the regular lib.c, at least for +- Moved stdlib_main.o into the regular libc.a, at least for the 68k build. The PowerPC build may follow later, provided - I manage to get the specs file fixed. + I manage to get the specs file fixed. Actually, stdlib_main.o + is in the libc.a library already. Now about that specs file... - Moved the check for the presence of an FPU into the - math_init.c code. + math_init.c code. I am far from certain whether this will + have the desired effect, though. Due to how the GNU ld linker + works, libraries are scanned once only. And the FPU check will + be pulled in only if something references the HUGE_VAL + constant. + +- The thread-safe system() call now blocks all standard I/O operations + until the function has returned. Which is harsh, but there is no + elegant solution to the issue of keeping the same dos.library + file handles from concurrent use which SystemTagList() might just + end up using. c.lib 1.189 (5.3.2005) diff --git a/library/stdio_fprintf.c b/library/stdio_fprintf.c index 82bb4f4..6410472 100644 --- a/library/stdio_fprintf.c +++ b/library/stdio_fprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fprintf.c,v 1.4 2005-02-27 18:09:10 obarthel Exp $ + * $Id: stdio_fprintf.c,v 1.5 2005-03-24 15:31:16 obarthel Exp $ * * :ts=4 * @@ -59,8 +59,6 @@ fprintf(FILE *stream,const char *format,...) if(__check_abort_enabled) __check_abort(); - flockfile(stream); - #if defined(CHECK_FOR_NULL_POINTERS) { if(stream == NULL || format == NULL) @@ -77,8 +75,6 @@ fprintf(FILE *stream,const char *format,...) out: - funlockfile(stream); - RETURN(result); return(result); } diff --git a/library/stdio_fscanf.c b/library/stdio_fscanf.c index f07ba4d..022865c 100644 --- a/library/stdio_fscanf.c +++ b/library/stdio_fscanf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fscanf.c,v 1.4 2005-02-27 18:09:10 obarthel Exp $ + * $Id: stdio_fscanf.c,v 1.5 2005-03-24 15:31:16 obarthel Exp $ * * :ts=4 * @@ -59,8 +59,6 @@ fscanf(FILE *stream, const char *format, ...) if(__check_abort_enabled) __check_abort(); - flockfile(stream); - #if defined(CHECK_FOR_NULL_POINTERS) { if(stream == NULL || format == NULL) @@ -79,8 +77,6 @@ fscanf(FILE *stream, const char *format, ...) out: - funlockfile(stream); - RETURN(result); return(result); } diff --git a/library/stdlib_system.c b/library/stdlib_system.c index 631ae2f..a73ad05 100644 --- a/library/stdlib_system.c +++ b/library/stdlib_system.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_system.c,v 1.5 2005-03-18 12:38:25 obarthel Exp $ + * $Id: stdlib_system.c,v 1.6 2005-03-24 15:31:16 obarthel Exp $ * * :ts=4 * @@ -35,6 +35,10 @@ #include "stdlib_headers.h" #endif /* _STDLIB_HEADERS_H */ +#ifndef _STIO_HEADERS_H +#include "stdio_headers.h" +#endif /* _STDIO_HEADERS_H */ + /****************************************************************************/ #ifndef _STDLIB_MEMORY_H @@ -172,7 +176,18 @@ system(const char * command) SHOWSTRING(command); PROFILE_OFF(); + + /* In thread-safe mode, system() operation can interfere with + regular file I/O if the same dos.library file handles are + involved. Because we really cannot predict which file handles + will be associated with the current Output() and Input() + streams, we play it safe and just block everything. */ + __stdio_lock(); + result = SystemTagList((STRPTR)command, (struct TagItem *)system_tags); + + __stdio_unlock(); + PROFILE_ON(); }