__lock_try_acquire() and __lock_try_acquire_recursive() return value?

Freddie Chopin freddie_chopin@op.pl
Fri Apr 7 20:36:00 GMT 2017


Hi!

I'm wondering what's the exact meaning of __lock_try_acquire() and
__lock_try_acquire_recursive() return values? What should be returned
when the locking succeeds and what when it fails?

These functions are only used inside Linux port, and the only comment
that suggests the semantics is in lock.h for tirtos
(newlib/libc/sys/tirtos/include/sys/lock.h):

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

/* Returns 0 for success and non-zero for failure */
extern int __libc_lock_try_acquire(_LOCK_T *lock);
extern int __libc_lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock);
...
#define __lock_try_acquire(lock) \
    __libc_lock_try_acquire(&(lock))
#define __lock_try_acquire_recursive(lock) \
    __libc_lock_try_acquire_recursive(&(lock))

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

Anyone can confirm that this is the expected behaviour of these two
functions?

Regards,
FCh



More information about the Newlib mailing list