[PATCH 3/3] Add minimal thread-safety to BFD

Tom Tromey tom@tromey.com
Wed Nov 1 20:08:47 GMT 2023


>>>>> "Nick" == Nick Clifton <nickc@redhat.com> writes:

>> +typedef void (*bfd_lock_unlock_fn_type) (void);

Nick> Given that we are dealing with client provided locking and unlocking
Nick> functions, I feel that the client might want to be able to reference
Nick> a data structure of their own performing these actions.  (I am not
Nick> hugely familiar with locking and unlocking functions, so maybe I am
Nick> mistaken here).  I also wonder if the functions might be interested
Nick> in the BFD being locked.  Thus I think that the typedef might be
Nick> better specified as:

Nick>  typedef void (* bfd_lock_unlock_fn_type) (bfd *, void *);

Seems reasonable.

Nick> I also wonder if the functions should be allowed to fail, in which
Nick> case the typedef would be:

Nick>  typedef bool (* bfd_lock_unlock_fn_type) (bfd *, void *);

I suppose the BFD callers can just return if these fail.

Nick> Also - should this function let the caller know if a previous set
Nick> of lock/unlock functions had been registered, or if there was a problem
Nick> registering them ?  (For example is it OK to have a lock function but
Nick> not an unlock function ?)  ie:

Yeah, I've changed it to fail if (1) it's ever been called before (I
don't think it's really necessary to support this right now) and (2) if
one of the functions is not specified.

Tom


More information about the Binutils mailing list