Previously, write() was somewhat soft - it only ever made one attempt to
wait for buffer space, so it would take as much data as would fit in the
buffer in one call.
This is not the intent of a POSIX filehandle write. It should try to
send everything if blocking, and only send less if interrupted by a
signal:
- If the O_NONBLOCK flag is clear, write() shall block the calling
thread until the data can be accepted.
- If the O_NONBLOCK flag is set, write() shall not block the thread.
If some data can be written without blocking the thread, write()
shall write what it can and return the number of bytes written.
Otherwise, it shall return -1 and set errno to [EAGAIN].
This "send all" behaviour is of slightly limited usefulness in POSIX, as
you still usually have to worry about the interruption possibility:
- If write() is interrupted by a signal before it writes any data, it
shall return -1 with errno set to [EINTR].
- If write() is interrupted by a signal after it successfully writes
some data, it shall return the number of bytes written.
But as mbed OS does not have the possibility of signal interruption, if we
strengthen write to write everything, we can make applications' lives
easier - they can just do "write(large amount)" confident that it will
all go in one call (if no errors).
So, rework to make multiple writes to the buffer, blocking as necessary,
until all data is written.
This change does not apply to read(), which is correct in only blocking until
some data is available:
- If O_NONBLOCK is set, read() shall return -1 and set errno to [EAGAIN].
- If O_NONBLOCK is clear, read() shall block the calling thread until some
data becomes available.
- The use of the O_NONBLOCK flag has no effect if there is some data
available.
Remove the condition code around the defines in mbed_retarget.h so
all toolchains use the defined values. Exclude a small subset of
values for GCC since these are in its standard header files.
errno (part of thread local storage) setting caused hardfault with IAR8.x
versions. TLS is not supported, hence using main thread TLS area for
all threads.
Turn the compile time error issued when a NonCopyable resource is copied
into a compile time and runtime warning.
If the application is compiled with the debug profile the compile time
error remains.
The compile time error can be enforced by setting the library option
force-non-copyable-error to true.
This patch deprecates the CallChain class since it is an
internal API (not in mbed.h) and is only being used by
InterruptManager which is also deprecated.
Add weak implementations of *_ticker_get_info which returns 1MHz and
a width of 32 bits. This allows the updated Ticker API to work with
existing devices.
Note - in the future when all targets have implemented
*_ticker_get_info these weak functions will be removed.
Spinning while polling is overly CPU intensive, and inconsistent with
the current blocking behaviour of UARTSerial.
Change to use Thread::wait(1) to match UARTSerial.
Add _lock_count to DeepSleepLock and use this to prevent deep sleep
from staying locked when the DeepSleepLock objected is destroyed after
an unbalanced number of calls to lock and unlock.
Update platform code to use the ticker common layer rather than using
HAL us ticker directly. This both ensures that the underlying ticker
is properly initialized and that the value read is in microseconds with
full 32-bit range.
GCC's newlib library depends on fstat to get in-flight information about
a file's type an size. A working fstat for regular files is needed for
seek and related functions to work correctly.
This change prevents inclusion of non throwing versions of the new operator from
the compiler standard library. On GCC, the non throwing version bring with it
some portion of the exception support code.