Merge pull request #266 from cetic/pr-native-updates
Various native platform updates
This commit is contained in:
commit
a6c45a7a1f
|
@ -67,9 +67,11 @@ typedef uint16_t u16_t;
|
||||||
typedef uint32_t u32_t;
|
typedef uint32_t u32_t;
|
||||||
typedef int32_t s32_t;
|
typedef int32_t s32_t;
|
||||||
|
|
||||||
typedef unsigned short uip_stats_t;
|
typedef unsigned int uip_stats_t;
|
||||||
|
|
||||||
|
#ifndef UIP_CONF_BYTE_ORDER
|
||||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||||
|
#endif
|
||||||
|
|
||||||
#if NETSTACK_CONF_WITH_IPV6
|
#if NETSTACK_CONF_WITH_IPV6
|
||||||
|
|
||||||
|
|
|
@ -70,12 +70,44 @@
|
||||||
#define LOG_MODULE "Native"
|
#define LOG_MODULE "Native"
|
||||||
#define LOG_LEVEL LOG_LEVEL_MAIN
|
#define LOG_LEVEL LOG_LEVEL_MAIN
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* \name Native Platform Configuration
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Defines the maximum number of file descriptors monitored by the platform
|
||||||
|
* main loop.
|
||||||
|
*/
|
||||||
#ifdef SELECT_CONF_MAX
|
#ifdef SELECT_CONF_MAX
|
||||||
#define SELECT_MAX SELECT_CONF_MAX
|
#define SELECT_MAX SELECT_CONF_MAX
|
||||||
#else
|
#else
|
||||||
#define SELECT_MAX 8
|
#define SELECT_MAX 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Defines the timeout (in msec) of the select operation if no monitored file
|
||||||
|
* descriptors becomes ready.
|
||||||
|
*/
|
||||||
|
#ifdef SELECT_CONF_TIMEOUT
|
||||||
|
#define SELECT_TIMEOUT SELECT_CONF_TIMEOUT
|
||||||
|
#else
|
||||||
|
#define SELECT_TIMEOUT 1000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adds the STDIN file descriptor to the list of monitored file descriptors.
|
||||||
|
*/
|
||||||
|
#ifdef SELECT_CONF_STDIN
|
||||||
|
#define SELECT_STDIN SELECT_CONF_STDIN
|
||||||
|
#else
|
||||||
|
#define SELECT_STDIN 1
|
||||||
|
#endif
|
||||||
|
/** @} */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static const struct select_callback *select_callback[SELECT_MAX];
|
static const struct select_callback *select_callback[SELECT_MAX];
|
||||||
static int select_max = 0;
|
static int select_max = 0;
|
||||||
|
|
||||||
|
@ -116,6 +148,7 @@ select_set_callback(int fd, const struct select_callback *callback)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#if SELECT_STDIN
|
||||||
static int
|
static int
|
||||||
stdin_set_fd(fd_set *rset, fd_set *wset)
|
stdin_set_fd(fd_set *rset, fd_set *wset)
|
||||||
{
|
{
|
||||||
|
@ -135,6 +168,7 @@ stdin_handle_fd(fd_set *rset, fd_set *wset)
|
||||||
const static struct select_callback stdin_fd = {
|
const static struct select_callback stdin_fd = {
|
||||||
stdin_set_fd, stdin_handle_fd
|
stdin_set_fd, stdin_handle_fd
|
||||||
};
|
};
|
||||||
|
#endif /* SELECT_STDIN */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
set_lladdr(void)
|
set_lladdr(void)
|
||||||
|
@ -240,7 +274,9 @@ platform_init_stage_three()
|
||||||
void
|
void
|
||||||
platform_main_loop()
|
platform_main_loop()
|
||||||
{
|
{
|
||||||
|
#if SELECT_STDIN
|
||||||
select_set_callback(STDIN_FILENO, &stdin_fd);
|
select_set_callback(STDIN_FILENO, &stdin_fd);
|
||||||
|
#endif /* SELECT_STDIN */
|
||||||
while(1) {
|
while(1) {
|
||||||
fd_set fdr;
|
fd_set fdr;
|
||||||
fd_set fdw;
|
fd_set fdw;
|
||||||
|
@ -252,7 +288,7 @@ platform_main_loop()
|
||||||
retval = process_run();
|
retval = process_run();
|
||||||
|
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = retval ? 1 : 1000;
|
tv.tv_usec = retval ? 1 : SELECT_TIMEOUT;
|
||||||
|
|
||||||
FD_ZERO(&fdr);
|
FD_ZERO(&fdr);
|
||||||
FD_ZERO(&fdw);
|
FD_ZERO(&fdw);
|
||||||
|
|
Loading…
Reference in New Issue