mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #3136 from kaspar030/make_newlib__read_r_thread_safe
sys: newlib: make _read_r thread safe
This commit is contained in:
commit
baf568f7e8
@ -203,11 +203,13 @@ int _open_r(struct _reent *r, const char *name, int mode)
|
|||||||
int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count)
|
int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count)
|
||||||
{
|
{
|
||||||
#ifndef MODULE_UART0
|
#ifndef MODULE_UART0
|
||||||
|
int res;
|
||||||
mutex_lock(&uart_rx_mutex);
|
mutex_lock(&uart_rx_mutex);
|
||||||
|
unsigned state = disableIRQ();
|
||||||
count = count < rx_buf.avail ? count : rx_buf.avail;
|
count = count < rx_buf.avail ? count : rx_buf.avail;
|
||||||
|
res = ringbuffer_get(&rx_buf, (char*)buffer, count);
|
||||||
return ringbuffer_get(&rx_buf, (char*)buffer, count);
|
restoreIRQ(state);
|
||||||
|
return res;
|
||||||
#else
|
#else
|
||||||
char *res = (char*)buffer;
|
char *res = (char*)buffer;
|
||||||
res[0] = (char)uart0_readc();
|
res[0] = (char)uart0_readc();
|
||||||
|
Loading…
Reference in New Issue
Block a user