diff options
author | Mathias Bauer <mba@openoffice.org> | 2009-11-01 14:45:53 +0100 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2009-11-01 14:45:53 +0100 |
commit | dedb5f15dbf5da58780a4febac0302d095b61a74 (patch) | |
tree | 47d3019ce5ab1dc9d885cdb011cc4d1f00267ff0 | |
parent | 94e088428a4d9ea74188f84982f24e601232a39d (diff) | |
parent | 40ab64211cc89ec112e5baf8c7ff78ad4680b7a3 (diff) |
merge commit for DEV300_m63
-rw-r--r-- | idlc/inc/idlc/options.hxx | 4 | ||||
-rw-r--r-- | idlc/source/idlcmain.cxx | 31 | ||||
-rw-r--r-- | idlc/source/options.cxx | 18 | ||||
-rw-r--r-- | offapi/util/makefile.mk | 12 | ||||
-rw-r--r-- | offapi/util/target.pmk | 4 | ||||
-rw-r--r-- | sal/osl/unx/file.cxx | 45 | ||||
-rw-r--r-- | sal/osl/w32/file.cxx | 43 | ||||
-rw-r--r-- | udkapi/util/target.pmk | 4 |
8 files changed, 136 insertions, 25 deletions
diff --git a/idlc/inc/idlc/options.hxx b/idlc/inc/idlc/options.hxx index e55dc961903b..11bc0fe4d657 100644 --- a/idlc/inc/idlc/options.hxx +++ b/idlc/inc/idlc/options.hxx @@ -69,11 +69,15 @@ public: const StringVector& getInputFiles() const { return m_inputFiles; } bool readStdin() const { return m_stdin; } + bool verbose() const { return m_verbose; } + bool quiet() const { return m_quiet; } protected: ::rtl::OString m_program; StringVector m_inputFiles; bool m_stdin; + bool m_verbose; + bool m_quiet; OptionMap m_options; }; diff --git a/idlc/source/idlcmain.cxx b/idlc/source/idlcmain.cxx index 1ce3a9fa05b0..68c1ae7cf5a5 100644 --- a/idlc/source/idlcmain.cxx +++ b/idlc/source/idlcmain.cxx @@ -56,11 +56,12 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) sal_Int32 nErrors = 0; if (options.readStdin()) { - fprintf( - stdout, "%s: compile stdin...\n", - options.getProgramName().getStr()); + if ( !options.quiet() ) + fprintf( + stdout, "%s: Compiling stdin\n", + options.getProgramName().getStr()); nErrors = compileFile(0); - if (idlc()->getWarningCount() > 0) { + if ( ( idlc()->getWarningCount() > 0 ) && !options.quiet() ) { fprintf( stdout, "%s: detected %lu warnings compiling stdin\n", options.getProgramName().getStr(), @@ -85,16 +86,23 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) idlc()->reset(); } StringVector const & files = options.getInputFiles(); + if ( options.verbose() ) + { + fprintf( stdout, "%s: compiling %i source files ... \n", + options.getProgramName().getStr(), (int)files.size() ); + fflush( stdout ); + } for (StringVector::const_iterator i(files.begin()); i != files.end() && nErrors == 0; ++i) { OString sysFileName( convertToAbsoluteSystemPath(*i) ); - fprintf(stdout, "%s: compile '%s' ... \n", - options.getProgramName().getStr(), (*i).getStr()); + if ( !options.quiet() ) + fprintf(stdout, "Compiling: %s\n", + (*i).getStr()); nErrors = compileFile(&sysFileName); - if ( idlc()->getWarningCount() ) + if ( idlc()->getWarningCount() && !options.quiet() ) fprintf(stdout, "%s: detected %lu warnings compiling file '%s'\n", options.getProgramName().getStr(), sal::static_int_cast< unsigned long >( @@ -128,15 +136,16 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) if ( nErrors > 0 ) { - fprintf(stdout, "%s: detected %ld errors%s", + fprintf(stderr, "%s: detected %ld errors%s", options.getProgramName().getStr(), sal::static_int_cast< long >(nErrors), options.prepareVersion().getStr()); } else { - fprintf(stdout, "%s: returned successful%s", - options.getProgramName().getStr(), - options.prepareVersion().getStr()); + if ( options.verbose() ) + fprintf(stdout, "%s: returned successful%s", + options.getProgramName().getStr(), + options.prepareVersion().getStr()); } return nErrors; } diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx index 6bfbcc9e443e..963ddafda8d0 100644 --- a/idlc/source/options.cxx +++ b/idlc/source/options.cxx @@ -37,7 +37,7 @@ using namespace rtl; -Options::Options(): m_stdin(false) +Options::Options(): m_stdin(false), m_verbose(false), m_quiet(false) { } @@ -190,6 +190,22 @@ sal_Bool Options::initOptions(int ac, char* av[], sal_Bool bCmdFile) } else throw IllegalArgument(OString(av[j]) + ", please check your input"); break; + case 'v': + if ( 0 == strcmp( &av[j][1], "verbose" ) ) + { + m_verbose = true; + } + else + throw IllegalArgument(OString(av[j]) + ", please check your input"); + break; + case 'q': + if ( 0 == strcmp( &av[j][1], "quiet" ) ) + { + m_quiet = true; + } + else + throw IllegalArgument(OString(av[j]) + ", please check your input"); + break; case 'w': if (av[j][2] == 'e' && av[j][3] == '\0') { if (m_options.count("-we") == 0) diff --git a/offapi/util/makefile.mk b/offapi/util/makefile.mk index b0fa7a30cf46..d3157dac31df 100644 --- a/offapi/util/makefile.mk +++ b/offapi/util/makefile.mk @@ -164,14 +164,14 @@ ALLTAR : $(UCR)$/types.db \ $(UNOTYPE_STATISTICS) $(UCR)$/types.db : $(UCR)$/offapi.db $(SOLARBINDIR)$/udkapi.rdb - -$(RM) $(REGISTRYCHECKFLAG) - $(GNUCOPY) -f $(UCR)$/offapi.db $@ - $(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi.rdb + @-$(RM) $(REGISTRYCHECKFLAG) + @$(GNUCOPY) -f $(UCR)$/offapi.db $@ + $(COMMAND_ECHO)$(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi.rdb $(OUT)$/ucrdoc$/types_doc.db : $(OUT)$/ucrdoc$/offapi_doc.db $(SOLARBINDIR)$/udkapi_doc.rdb - -$(RM) $(REGISTRYCHECKFLAG) - $(GNUCOPY) -f $(OUT)$/ucrdoc$/offapi_doc.db $@ - $(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi_doc.rdb + @-$(RM) $(REGISTRYCHECKFLAG) + @$(GNUCOPY) -f $(OUT)$/ucrdoc$/offapi_doc.db $@ + $(COMMAND_ECHO)$(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi_doc.rdb #JSC: The type library has changed, all temporary not checked types are removed # and will be check from now on. diff --git a/offapi/util/target.pmk b/offapi/util/target.pmk index 08912b011857..63804f3e554a 100644 --- a/offapi/util/target.pmk +++ b/offapi/util/target.pmk @@ -30,8 +30,8 @@ #************************************************************************* $(OUT)$/misc$/$(TARGET).idls: makefile.mk - -$(RM) $@ - $(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ + $(COMMAND_ECHO)-$(RM) $@ + $(COMMAND_ECHO)$(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ ALLTAR: $(OUT)$/misc$/$(TARGET).idls diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index b69849a08cdc..8e7d76cda614 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -44,6 +44,7 @@ #include <limits> #include <string.h> +#include <pthread.h> #include <sys/mman.h> #if defined(MACOSX) @@ -74,8 +75,9 @@ ******************************************************************/ struct FileHandle_Impl { - rtl_String * m_strFilePath; /* holds native file path */ - int m_fd; + pthread_mutex_t m_mutex; + rtl_String * m_strFilePath; /* holds native file path */ + int m_fd; /** State */ @@ -169,6 +171,17 @@ struct FileHandle_Impl Allocator(); ~Allocator(); }; + + /** Guard. + */ + class Guard + { + pthread_mutex_t * m_mutex; + + public: + explicit Guard(pthread_mutex_t * pMutex); + ~Guard(); + }; }; /******************************************************************* @@ -213,6 +226,18 @@ void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer) rtl_cache_free (m_cache, pBuffer); } +FileHandle_Impl::Guard::Guard(pthread_mutex_t * pMutex) + : m_mutex (pMutex) +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer."); + (void) pthread_mutex_lock (m_mutex); // ignoring EINVAL ... +} +FileHandle_Impl::Guard::~Guard() +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer."); + (void) pthread_mutex_unlock (m_mutex); +} + FileHandle_Impl::FileHandle_Impl (int fd, char const * path) : m_strFilePath (0), m_fd (fd), @@ -225,6 +250,7 @@ FileHandle_Impl::FileHandle_Impl (int fd, char const * path) m_bufsiz (0), m_buffer (0) { + (void) pthread_mutex_init(&m_mutex, 0); rtl_string_newFromStr (&m_strFilePath, path); Allocator::get().allocate (&m_buffer, &m_bufsiz); if (0 != m_buffer) @@ -234,6 +260,7 @@ FileHandle_Impl::~FileHandle_Impl() { Allocator::get().deallocate (m_buffer), m_buffer = 0; rtl_string_release (m_strFilePath), m_strFilePath = 0; + (void) pthread_mutex_destroy(&m_mutex); // ignoring EBUSY ... } void* FileHandle_Impl::operator new (size_t n) @@ -948,6 +975,8 @@ SAL_CALL osl_closeFile( oslFileHandle Handle ) if ((pImpl == 0) || (pImpl->m_fd < 0)) return osl_File_E_INVAL; + (void) pthread_mutex_lock (&(pImpl->m_mutex)); + /* close(2) implicitly (and unconditionally) unlocks */ OSL_TRACE("osl_closeFile(%d) => %s", pImpl->m_fd, rtl_string_getStr(pImpl->m_strFilePath)); oslFileError result = pImpl->syncFile(); @@ -962,6 +991,7 @@ SAL_CALL osl_closeFile( oslFileHandle Handle ) result = oslTranslateFileError (OSL_FET_ERROR, errno); } + (void) pthread_mutex_unlock (&(pImpl->m_mutex)); delete pImpl; return (result); } @@ -977,6 +1007,8 @@ SAL_CALL osl_syncFile(oslFileHandle Handle) if ((0 == pImpl) || (-1 == pImpl->m_fd)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + OSL_FILE_TRACE("osl_syncFile(%d)", pImpl->m_fd); oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) @@ -1086,6 +1118,7 @@ SAL_CALL osl_readLine ( sal_uInt64 uBytesRead = 0; // read at current fileptr; fileptr += uBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->readLineAt ( pImpl->m_fileptr, ppSequence, &uBytesRead); if (result == osl_File_E_None) @@ -1114,6 +1147,7 @@ SAL_CALL osl_readFile ( size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested); // read at current fileptr; fileptr += *pBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->readFileAt ( pImpl->m_fileptr, pBuffer, nBytesRequested, pBytesRead); if (result == osl_File_E_None) @@ -1144,6 +1178,7 @@ SAL_CALL osl_writeFile ( size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite); // write at current fileptr; fileptr += *pBytesWritten; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->writeFileAt ( pImpl->m_fileptr, pBuffer, nBytesToWrite, pBytesWritten); if (result == osl_File_E_None) @@ -1180,6 +1215,7 @@ SAL_CALL osl_readFileAt ( size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested); // read at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); return pImpl->readFileAt (nOffset, pBuffer, nBytesRequested, pBytesRead); } @@ -1214,6 +1250,7 @@ SAL_CALL osl_writeFileAt ( size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite); // write at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); return pImpl->writeFileAt (nOffset, pBuffer, nBytesToWrite, pBytesWritten); } @@ -1228,6 +1265,7 @@ SAL_CALL osl_isEndOfFile( oslFileHandle Handle, sal_Bool *pIsEOF ) if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pIsEOF)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pIsEOF = (pImpl->getPos() == pImpl->getSize()); return osl_File_E_None; } @@ -1243,6 +1281,7 @@ SAL_CALL osl_getFilePos( oslFileHandle Handle, sal_uInt64* pPos ) if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pPos)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pPos = pImpl->getPos(); return osl_File_E_None; } @@ -1263,6 +1302,7 @@ SAL_CALL osl_setFilePos (oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffse return osl_File_E_OVERFLOW; off_t nPos = 0, nOffset = sal::static_int_cast< off_t >(uOffset); + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); switch(uHow) { case osl_Pos_Absolut: @@ -1304,6 +1344,7 @@ SAL_CALL osl_getFileSize( oslFileHandle Handle, sal_uInt64* pSize ) if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pSize)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pSize = pImpl->getSize(); return osl_File_E_None; } diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index d2eb9e7a4523..34deba2293da 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -69,7 +69,8 @@ //################################################################## struct FileHandle_Impl { - HANDLE m_hFile; + CRITICAL_SECTION m_mutex; + HANDLE m_hFile; /** State */ @@ -162,6 +163,17 @@ struct FileHandle_Impl Allocator(); ~Allocator(); }; + + /** Guard. + */ + class Guard + { + LPCRITICAL_SECTION m_mutex; + + public: + explicit Guard(LPCRITICAL_SECTION pMutex); + ~Guard(); + }; }; FileHandle_Impl::Allocator & @@ -199,6 +211,18 @@ void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer) rtl_cache_free (m_cache, pBuffer); } +FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex) + : m_mutex (pMutex) +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer."); + ::EnterCriticalSection (m_mutex); +} +FileHandle_Impl::Guard::~Guard() +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer."); + ::LeaveCriticalSection (m_mutex); +} + FileHandle_Impl::FileHandle_Impl(HANDLE hFile) : m_hFile (hFile), m_state (STATE_READABLE | STATE_WRITEABLE), @@ -210,6 +234,7 @@ FileHandle_Impl::FileHandle_Impl(HANDLE hFile) m_bufsiz (0), m_buffer (0) { + ::InitializeCriticalSection (&m_mutex); Allocator::get().allocate (&m_buffer, &m_bufsiz); if (m_buffer != 0) memset (m_buffer, 0, m_bufsiz); @@ -218,6 +243,7 @@ FileHandle_Impl::FileHandle_Impl(HANDLE hFile) FileHandle_Impl::~FileHandle_Impl() { Allocator::get().deallocate (m_buffer), m_buffer = 0; + ::DeleteCriticalSection (&m_mutex); } void * FileHandle_Impl::operator new(size_t n) @@ -729,6 +755,8 @@ SAL_CALL osl_syncFile(oslFileHandle Handle) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) return result; @@ -747,6 +775,8 @@ SAL_CALL osl_closeFile(oslFileHandle Handle) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; + ::EnterCriticalSection (&(pImpl->m_mutex)); + oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) { @@ -759,6 +789,7 @@ SAL_CALL osl_closeFile(oslFileHandle Handle) result = oslTranslateFileError( GetLastError() ); } + ::LeaveCriticalSection (&(pImpl->m_mutex)); delete pImpl; return (result); } @@ -870,6 +901,7 @@ SAL_CALL osl_readLine( sal_uInt64 uBytesRead = 0; // read at current filepos; filepos += uBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->readLineAt ( pImpl->m_filepos, ppSequence, &uBytesRead); if (result == osl_File_E_None) @@ -890,6 +922,7 @@ SAL_CALL osl_readFile( return osl_File_E_INVAL; // read at current filepos; filepos += *pBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->readFileAt ( pImpl->m_filepos, pBuffer, uBytesRequested, pBytesRead); if (result == osl_File_E_None) @@ -911,6 +944,7 @@ SAL_CALL osl_writeFile( return osl_File_E_INVAL; // write at current filepos; filepos += *pBytesWritten; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->writeFileAt ( pImpl->m_filepos, pBuffer, uBytesToWrite, pBytesWritten); if (result == osl_File_E_None) @@ -940,6 +974,7 @@ SAL_CALL osl_readFileAt( LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset); // read at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); return pImpl->readFileAt (nOffset, pBuffer, uBytesRequested, pBytesRead); } @@ -965,6 +1000,7 @@ SAL_CALL osl_writeFileAt( LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset); // write at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); return pImpl->writeFileAt (nOffset, pBuffer, uBytesToWrite, pBytesWritten); } @@ -977,6 +1013,7 @@ SAL_CALL osl_isEndOfFile (oslFileHandle Handle, sal_Bool *pIsEOF) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pIsEOF)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pIsEOF = (pImpl->getPos() == pImpl->getSize()); return osl_File_E_None; } @@ -989,6 +1026,7 @@ SAL_CALL osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pPos)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pPos = pImpl->getPos(); return osl_File_E_None; } @@ -1006,6 +1044,7 @@ SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffset return osl_File_E_OVERFLOW; LONGLONG nPos = 0, nOffset = sal::static_int_cast< LONGLONG >(uOffset); + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); switch (uHow) { case osl_Pos_Absolut: @@ -1045,6 +1084,7 @@ SAL_CALL osl_getFileSize (oslFileHandle Handle, sal_uInt64 *pSize) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pSize)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pSize = pImpl->getSize(); return osl_File_E_None; } @@ -1064,6 +1104,7 @@ SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize) if (g_limit_longlong < uSize) return osl_File_E_OVERFLOW; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) return (result); diff --git a/udkapi/util/target.pmk b/udkapi/util/target.pmk index f6e7bc9beb3c..2a01738e7eb7 100644 --- a/udkapi/util/target.pmk +++ b/udkapi/util/target.pmk @@ -30,8 +30,8 @@ #************************************************************************* $(OUT)$/misc$/$(TARGET).idls: makefile.mk - -$(RM) $@ - $(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ + $(COMMAND_ECHO)-$(RM) $@ + $(COMMAND_ECHO)$(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ ALLTAR: $(OUT)$/misc$/$(TARGET).idls |