pthread cleanup macros are broken

Bug #480857 reported by Donny Viszneki
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu
Invalid
Undecided
Unassigned

Bug Description

donny@pacemates:~/gpsee/src$ echo -e '#include <pthread.h>\npthread_cleanup_push(foo, bar)' | gcc -Wall -E - | tail -n 1
do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (foo); void *__cancel_arg = (bar); int not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect (not_first_call, 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {

Just look at the very end of the output there and you can see how wrong that is. There's no reason the result of that macro should *end* with "do{"!!!

donny@pacemates:~/gpsee/src$ gcc --version
gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Revision history for this message
Gabe Gorelick (gabegorelick) wrote :

Actually, the macro is written like this on purpose. pthread_cleanup_push starts a do while loop that is terminated by the pthread_cleanup_pop macro. In between the two macros, you can add your own code that will get executed in the body of the do-while. Check out http://www.devdaily.com/unix/man/man3/pthread_cleanup_pop.3thr.shtml for more info.

Changed in ubuntu:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.