1
0
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:
Joakim Gebart 2015-06-01 22:08:53 +02:00
commit baf568f7e8

View File

@ -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();