mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-23 15:40:14 +08:00
bd54749095
At the moment when targeting bare-metal targets or systems without definition for the locking primitives newlib, uses dummy empty macros. This has the advantage of reduced size and faster implementation but does not allow the application to retarget the locking routines. Retargeting is useful for a single toolchain to support multiple systems since then it's only at link time that you know which system you are targeting. This patch adds a new configure option --enable-newlib-retargetable-locking to use dummy empty functions instead of dummy empty macros. The default is to keep the current behavior to not have any size or speed impact on targets not interested in this feature. To allow for any size of lock, the _LOCK_T type is changed into pointer to struct _lock and the _init function are tasked with allocating the locks. The platform being targeted must provide the static locks. A dummy implementation of the locking routines and static lock is provided for single-threaded applications to link successfully out of the box. To ensure that the behavior is consistent (either no locking whatsoever or working locking), the dummy implementation is strongly defined such that a partial retargeting will cause a doubly defined link error. Indeed, the linker will only pull in the file providing the dummy implementation if it cannot find an implementation for one of the routine or lock.
158 lines
3.8 KiB
C
158 lines
3.8 KiB
C
/*
|
|
FUNCTION
|
|
<<__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
|
|
|
|
INDEX
|
|
__lock___sinit_recursive_mutex
|
|
INDEX
|
|
__lock___sfp_recursive_mutex
|
|
INDEX
|
|
__lock___atexit_recursive_mutex
|
|
INDEX
|
|
__lock___at_quick_exit_mutex
|
|
INDEX
|
|
__lock___malloc_recursive_mutex
|
|
INDEX
|
|
__lock___env_recursive_mutex
|
|
INDEX
|
|
__lock___tz_mutex
|
|
INDEX
|
|
__lock___dd_hash_mutex
|
|
INDEX
|
|
__lock___arc4random_mutex
|
|
|
|
INDEX
|
|
__retarget_lock_init
|
|
INDEX
|
|
__retarget_lock_init_recursive
|
|
INDEX
|
|
__retarget_lock_close
|
|
INDEX
|
|
__retarget_lock_close_recursive
|
|
INDEX
|
|
__retarget_lock_acquire
|
|
INDEX
|
|
__retarget_lock_acquire_recursive
|
|
INDEX
|
|
__retarget_lock_try_acquire
|
|
INDEX
|
|
__retarget_lock_try_acquire_recursive
|
|
INDEX
|
|
__retarget_lock_release
|
|
INDEX
|
|
__retarget_lock_release_recursive
|
|
|
|
ANSI_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 @strong{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.
|
|
*/
|
|
|
|
/* dummy lock routines and static locks for single-threaded apps */
|
|
|
|
#ifndef __SINGLE_THREAD__
|
|
|
|
#include <sys/lock.h>
|
|
|
|
struct __lock {
|
|
char unused;
|
|
};
|
|
|
|
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)
|
|
{
|
|
}
|
|
|
|
void
|
|
__retarget_lock_init_recursive(_LOCK_T *lock)
|
|
{
|
|
}
|
|
|
|
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)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
int
|
|
__retarget_lock_try_acquire_recursive(_LOCK_T lock)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
void
|
|
__retarget_lock_release (_LOCK_T lock)
|
|
{
|
|
}
|
|
|
|
void
|
|
__retarget_lock_release_recursive (_LOCK_T lock)
|
|
{
|
|
}
|
|
|
|
#endif /* !defined(__SINGLE_THREAD__) */
|