Next: unctrl, Previous: ffs, Up: Misc [Contents][Index]

### 11.2 `__retarget_lock_init`, `__retarget_lock_init_recursive`, `__retarget_lock_close`, `__retarget_lock_close_recursive`, `__retarget_lock_acquire`, `__retarget_lock_acquire_recursive`, `__retarget_lock_try_acquire`, `__retarget_lock_try_acquire_recursive`, `__retarget_lock_release`, `__retarget_lock_release_recursive`—locking routines

Synopsis

    #include <lock.h>
    struct __lock __lock___sinit_recursive_mutex;
    struct __lock __lock___sfp_recursive_mutex;
    struct __lock __lock___atexit_recursive_mutex;
    struct __lock __lock___at_quick_exit_mutex;
    struct __lock __lock___malloc_recursive_mutex;
    struct __lock __lock___env_recursive_mutex;
    struct __lock __lock___tz_mutex;
    struct __lock __lock___dd_hash_mutex;
    struct __lock __lock___arc4random_mutex;

    void __retarget_lock_init (_LOCK_T * lock_ptr);
    void __retarget_lock_init_recursive (_LOCK_T * lock_ptr);
    void __retarget_lock_close (_LOCK_T lock);
    void __retarget_lock_close_recursive (_LOCK_T lock);
    void __retarget_lock_acquire (_LOCK_T lock);
    void __retarget_lock_acquire_recursive (_LOCK_T lock);
    int __retarget_lock_try_acquire (_LOCK_T lock);
    int __retarget_lock_try_acquire_recursive (_LOCK_T lock);
    void __retarget_lock_release (_LOCK_T lock);
    void __retarget_lock_release_recursive (_LOCK_T lock);

Description
Newlib was configured to allow the target platform to provide the locking routines and static locks at link time. As such, a dummy default implementation of these routines and static locks is provided for single-threaded application to link successfully out of the box on bare-metal systems.

For multi-threaded applications the target platform is required to provide an implementation for all these routines and static locks. If some routines or static locks are missing, the link will fail with doubly defined symbols.

Portability
These locking routines and static lock are newlib-specific. Supporting OS subroutines are required for linking multi-threaded applications.