mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys: newlib: remove _read_r() race
This commit is contained in:
parent
4b1e1582af
commit
5549d0493d
@ -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)
|
||||
{
|
||||
#ifndef MODULE_UART0
|
||||
int res;
|
||||
mutex_lock(&uart_rx_mutex);
|
||||
|
||||
unsigned state = disableIRQ();
|
||||
count = count < rx_buf.avail ? count : rx_buf.avail;
|
||||
|
||||
return ringbuffer_get(&rx_buf, (char*)buffer, count);
|
||||
res = ringbuffer_get(&rx_buf, (char*)buffer, count);
|
||||
restoreIRQ(state);
|
||||
return res;
|
||||
#else
|
||||
char *res = (char*)buffer;
|
||||
res[0] = (char)uart0_readc();
|
||||
|
Loading…
Reference in New Issue
Block a user