public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Ross Johnson <rpj@ise.canberra.edu.au>
To: "Kevin D. Clark" <kclark@cabletron.com>
Cc: Fred Forester <fforest@eticomm.net>,
	Pthreads Developers List <pthreads-win32@sourceware.cygnus.com>
Subject: Re: C++ cleanup handler execution
Date: Thu, 06 Jan 2000 18:17:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.05.10001071014001.17238-100000@swan.ise.canberra.edu.au> (raw)
In-Reply-To: <14453.4956.759854.712859@cabletron.com>

On Thu, 6 Jan 2000, Kevin D. Clark wrote:

> Environment: VC++ 6.0 on a NT 4.x box with service pack 5.
>              Pthreads-win32 snapshot 1999-11-02
> 	     I am compiling a C++ program that uses C++ exceptions,
>              pthread_cancel(), pthread_cleanup_push(), and
>              pthread_cleanup_pop(). 
[snip]
> 	     
> So I went poking around in the code to see what was going on here.  I
> ran my code through the preprocessor and noticed that "__try" was
> being placed in my code.
> 
[snip]
> 
> Remember, I'm getting the SEH version of the cancel cleanup code.
> Now, it is my understanding that I shouldn't be using the SEH stuff in
> my C++ environment.
> 
> Assuming I'm right about this, I don't know if checking for _MSC_VER
> in the code is correct.  The Microsoft VC++ documentation that I have
> says that:
> 

Hi Kevin,

I agree that _MSC_VER needs to be changed to be more specific around
SEH related code.

Presumably something like the following should be used:

#if defined(_MSC_VER) && ! defined(__cplusplus)

or perhaps this might be tighter:

#if defined(_MSC_VER) && defined(_INC_EXCPT)

I'm also wondering if it's worth building the library only with C++
EH. That is, removing the SEH implementation, but not before
soliciting comments from the list. I've never actually built the
library using MSVC and C++ EH.

>         
> 2:  Are there any obvious caveats that I should look out for when
>     using the C++ cleanup code?  For example, while I was playing around
>     with this, I changed the definition of this:
> 
> #define pthread_cleanup_push( _rout, _arg ) \
>         { \
> 	    PThreadCleanup  cleanup((void (PT_STDCALL *)(void *))(_rout), \
> 				    (void *) (_arg) );
>     to be like this:
> 				    
> #define pthread_cleanup_push( _rout, _arg ) \
>         { \
> 	    PThreadCleanup  cleanup((void (*)(void *))(_rout), \
> 				    (void *) (_arg) );
> 				    
> because I was having a hard time compiling my code any other way.  Am
> I going to get bitten by any subtle calling convention bugs here?
> Should I have had to modify this code in the first place? (it compiles
> and runs fine on Solaris and Linux)
> 

PT_STDCALL is defined in the current version of pthread.h as:

#ifdef __MINGW32__
#define PT_STDCALL
#else
#define PT_STDCALL __stdcall
#endif

In the version that you have (snap-99-11-02) it's defined in
implement.h, which applications don't (must not) include. That was
an omission.

> 
> Thanks for any assistance you can provide!  And thanks for such a
> high-quality pthreads implementation!
> 

On behalf of all the contributors, thanks. And thank you for the
feedback and bug report. Your fix should be in the next snapshot.

I'm in the process of automating the build/test cycle so that I can
easily test both library and applications in all of the following
environments and cross-environments.

Eg.
	   Applications | SEH | C++ | G++ |  C  | GCC |
	Library		|     |     |     |     |     |
	----------------+-----+-----+-----+-----+-----+
	SEH		|  X  |  X  |  X  |  X  |  X  |
	----------------+-----+-----+-----+-----+-----+
	C++ (MSC)	|  X  |  X  |  X  |  X  |  X  |
	----------------+-----+-----+-----+-----+-----+
	G++ (GNU)	|  ?  |  ?  |  X  |  ?  |  X  |
	----------------+-----+-----+-----+-----+-----+

'?' indicates combinations that I'm not sure are doable.

Ross

+----------------------+---+
| Ross Johnson         |   | E-Mail: rpj@ise.canberra.edu.au
| Info Sciences and Eng|___|
| University of Canberra   | FAX:    +61 6 2015227
| PO Box 1                 |
| Belconnen  ACT    2616   | WWW:    http://willow.canberra.edu.au/~rpj/
| AUSTRALIA                |
+--------------------------+


  reply	other threads:[~2000-01-06 18:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <000601bf578e$3c89a750$208e08d0@fflaptop>
2000-01-05 17:35 ` Ross Johnson
2000-01-06 14:11   ` Kevin D. Clark
2000-01-06 18:17     ` Ross Johnson [this message]
2000-01-14  8:19       ` Kevin D. Clark
2000-01-14  8:27         ` Kevin D. Clark
2000-01-14  8:30           ` Kevin D. Clark
2000-01-14  8:36           ` Kevin D. Clark
2000-02-02 10:08             ` pthread_cancel() problems Kevin D. Clark
2000-06-14 18:06         ` Question about condition variable Taci Ãœlker
     [not found]           ` <3949054F.3127@surfnshop.com>
2000-06-16  7:33             ` Taci Ãœlker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.05.10001071014001.17238-100000@swan.ise.canberra.edu.au \
    --to=rpj@ise.canberra.edu.au \
    --cc=fforest@eticomm.net \
    --cc=kclark@cabletron.com \
    --cc=pthreads-win32@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).