This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gthr-win32.h patch


This patch looks like it will do the right thing but you need to supply
a ChangeLog, too.

I'll apply the patch once you supply the ChangeLog.  Send it to gcc-patches,
please.

cgf

On Wed, Jan 10, 2001 at 09:31:58AM +0100, Thomas Pfaff wrote:
>Hi,
>
>there is a problem with the -mthreads support for mingw32. If you compile
>with -mthreads and call a function that will throw an exception,
>__get_eh_context is called on function entry and the WIN32 LastError is
>cleared by TlsGetValue in gthread_getspecific. I have attached a patch that
>will preserve the WIN32 error.
>This patch will apply to gcc-current.
>
>Here is an example:
>
>#include <windows.h>
>
>#include <string>
>#include <iostream>
>
>using namespace std;
>
>static void FormatError( void );
>
>int main( void )
>{
>
> try {
>  SetLastError( ERROR_ACCESS_DENIED );
>  FormatError();
>  return 0;
> }
>
> catch( string &szError ) {
>  cerr << szError << endl;
> }
>
> catch( ... ) {
> }
>
> return 0;
>}
>
>static void FormatError( void )
>{
>
> int nLastError = GetLastError();
> char szLastError[2048];
> int nBufferSize = sizeof( szLastError );
>
> if( 0 == nLastError ) {
>  throw( string( "Last Error cleared by TlsGetValue" ) );
> }
>
> FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL,
>       nLastError, MAKELANGID( LANG_NEUTRAL, SUBLANG_SYS_DEFAULT ),
>       szLastError, nBufferSize, NULL );
>
> cerr << szLastError;
>}
>
>Without this patch you will see the "Last Error cleared" message, otherwise
>an "Access denied" as you would expect.
>
>Regards,
>
>Thomas Pfaff
>



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]