This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: Feature request, warnings for non safe calls within signal handlers


Hi Jon and Ian,

On Wed, 14 Mar 2012 19:54:48 -0700, Ian Lance Taylor wrote:
> Jonathan Andrews <jon@jonshouse.co.uk> writes:
> 
>> Would it be possible to add a warning to gcc C when code in an signal
>> handler (alarm) uses non thread safe calls.
> 
> Your request for a warning is reasonable, I just don't see a way to
> implement it such that it is useful.

I like that idea.
When compiling applications on Apple's Mac OS X, they have keywords to inform about "deprecated" functions at compile-time.
A similar solution might be possible, providing that the authors of the libraries and functions being called, mark those as "thread_safe" or "interrupt_safe".
Ofcourse, a compiler might be able to recursively go through functions and hunt for things that identifies whether or not a function is thread-safe, a'la the optimizer, however at present, this might be too complex.

It would, for instance be a bit difficult to see whether a function that writes to a shared memory location is thread-safe, because writing to this location *could* be a semaphore or behind a semaphore.

Note: Remember there's a difference between thread-safe and interrupt-safe. Whether or not I should mention 'reentry-safe' or not, I don't know.. Well, hereby done. ;)


Love,
Jens


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