void _native_lpm_sleep() { #ifdef MODULE_UART0 int retval; retval = select(1, &_native_uart_rfds, NULL, NULL, NULL); DEBUG("_native_lpm_sleep: retval: %i\n", retval); if (retval != -1) { /* uart ready, handle input */ /* TODO: switch to ISR context */ _native_handle_uart0_input(); } else if (errno != EINTR) { /* select failed for reason other than signal */ err(1, "lpm_set(): select()"); } /* otherwise select was interrupted because of a signal, continue below */ #else pause(); #endif if (_native_sigpend > 0) { DEBUG("\n\n\t\treturn from syscall, calling native_irq_handler\n\n"); _native_in_syscall = 0; _native_in_isr = 1; swapcontext(_native_cur_ctx, _native_isr_ctx); } }
void _native_lpm_sleep() { #ifdef MODULE_UART0 int nfds; /* set fds */ FD_ZERO(&_native_rfds); nfds = _native_set_uart_fds(); nfds++; _native_in_syscall++; // no switching here nfds = select(nfds, &_native_rfds, NULL, NULL, NULL); _native_in_syscall--; DEBUG("_native_lpm_sleep: returned: %i\n", nfds); if (nfds != -1) { /* uart ready, handle input */ /* TODO: switch to ISR context */ _native_handle_uart0_input(); } else if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { /* would block / resource unavailable .. it appears a * contended socket can show this behavior sometimes */ _native_in_syscall++; warn("_native_lpm_sleep: select()"); _native_in_syscall--; return; } else if (errno != EINTR) { /* select failed for reason other than signal */ err(EXIT_FAILURE, "lpm_set(): select()"); } /* otherwise select was interrupted because of a signal, continue below */ #else _native_in_syscall++; // no switching here pause(); _native_in_syscall--; #endif if (_native_sigpend > 0) { DEBUG("\n\n\t\treturn from syscall, calling native_irq_handler\n\n"); _native_in_syscall++; _native_syscall_leave(); } }
void _native_lpm_sleep() { #ifdef MODULE_UART0 int nfds; /* set fds */ FD_ZERO(&_native_rfds); nfds = _native_set_uart_fds(); nfds++; _native_in_syscall++; // no switching here nfds = select(nfds, &_native_rfds, NULL, NULL, NULL); _native_in_syscall--; DEBUG("_native_lpm_sleep: returned: %i\n", nfds); if (nfds != -1) { /* uart ready, handle input */ /* TODO: switch to ISR context */ _native_handle_uart0_input(); } else if (errno != EINTR) { /* select failed for reason other than signal */ err(1, "lpm_set(): select()"); } /* otherwise select was interrupted because of a signal, continue below */ #else _native_in_syscall++; // no switching here pause(); _native_in_syscall--; #endif if (_native_sigpend > 0) { DEBUG("\n\n\t\treturn from syscall, calling native_irq_handler\n\n"); _native_in_syscall++; _native_syscall_leave(); } }