diff options
Diffstat (limited to 'nuttx/examples/poll')
-rw-r--r-- | nuttx/examples/poll/host.c | 4 | ||||
-rw-r--r-- | nuttx/examples/poll/net_listener.c | 43 | ||||
-rw-r--r-- | nuttx/examples/poll/net_reader.c | 5 | ||||
-rw-r--r-- | nuttx/examples/poll/poll_listener.c | 14 | ||||
-rw-r--r-- | nuttx/examples/poll/select_listener.c | 18 |
5 files changed, 42 insertions, 42 deletions
diff --git a/nuttx/examples/poll/host.c b/nuttx/examples/poll/host.c index a55c1843e..47f2c3e53 100644 --- a/nuttx/examples/poll/host.c +++ b/nuttx/examples/poll/host.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/poll/host.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -37,9 +37,7 @@ * Included Files ****************************************************************************/ -#include <sys/types.h> #include <sys/socket.h> - #include <stdio.h> #include <stdlib.h> #include <unistd.h> diff --git a/nuttx/examples/poll/net_listener.c b/nuttx/examples/poll/net_listener.c index fbb70f4bd..12621de9a 100644 --- a/nuttx/examples/poll/net_listener.c +++ b/nuttx/examples/poll/net_listener.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/poll/net_listener.c * - * Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -39,12 +39,13 @@ #include <nuttx/config.h> -#include <sys/types.h> #include <sys/stat.h> #include <sys/select.h> #include <sys/socket.h> #include <sys/ioctl.h> +#include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <unistd.h> #include <string.h> @@ -89,7 +90,7 @@ struct net_listener_s * Name: net_closeclient ****************************************************************************/ -static boolean net_closeclient(struct net_listener_s *nls, int sd) +static bool net_closeclient(struct net_listener_s *nls, int sd) { message("net_listener: Closing host side connection sd=%d\n", sd); close(sd); @@ -97,18 +98,18 @@ static boolean net_closeclient(struct net_listener_s *nls, int sd) /* If we just closed the max SD, then search downward for the next biggest SD. */ - while (FD_ISSET(nls->mxsd, &nls->master) == FALSE) + while (FD_ISSET(nls->mxsd, &nls->master) == false) { nls->mxsd -= 1; } - return TRUE; + return true; } /**************************************************************************** * Name: net_incomingdata ****************************************************************************/ -static inline boolean net_incomingdata(struct net_listener_s *nls, int sd) +static inline bool net_incomingdata(struct net_listener_s *nls, int sd) { char *ptr; int nbytes; @@ -130,7 +131,7 @@ static inline boolean net_incomingdata(struct net_listener_s *nls, int sd) if (errno != EAGAIN) { net_closeclient(nls, sd); - return FALSE; + return false; } } } @@ -138,7 +139,7 @@ static inline boolean net_incomingdata(struct net_listener_s *nls, int sd) { message("net_listener: Client connection lost sd=%d\n", sd); net_closeclient(nls, sd); - return FALSE; + return false; } else { @@ -156,7 +157,7 @@ static inline boolean net_incomingdata(struct net_listener_s *nls, int sd) { message("net_listener: Send failed sd=%d: \n", sd, errno); net_closeclient(nls, sd); - return FALSE; + return false; } } else @@ -174,7 +175,7 @@ static inline boolean net_incomingdata(struct net_listener_s *nls, int sd) * Name: net_connection ****************************************************************************/ -static inline boolean net_connection(struct net_listener_s *nls) +static inline bool net_connection(struct net_listener_s *nls) { int sd; @@ -193,7 +194,7 @@ static inline boolean net_connection(struct net_listener_s *nls) if (errno != EINTR) { - return FALSE; + return false; } } else @@ -207,17 +208,17 @@ static inline boolean net_connection(struct net_listener_s *nls) { nls->mxsd = sd; } - return TRUE; + return true; } } - return FALSE; + return false; } /**************************************************************************** * Name: net_mksocket ****************************************************************************/ -static inline boolean net_mksocket(struct net_listener_s *nls) +static inline bool net_mksocket(struct net_listener_s *nls) { int value; int ret; @@ -229,7 +230,7 @@ static inline boolean net_mksocket(struct net_listener_s *nls) if (nls->listensd < 0) { message("net_listener: socket failed: %d\n", errno); - return FALSE; + return false; } /* Configure the socket */ @@ -240,7 +241,7 @@ static inline boolean net_mksocket(struct net_listener_s *nls) { message("net_listener: setsockopt failed: %d\n", errno); close(nls->listensd); - return FALSE; + return false; } /* Set the socket to non-blocking */ @@ -251,7 +252,7 @@ static inline boolean net_mksocket(struct net_listener_s *nls) { message("net_listener: ioctl failed: %d\n", errno); close(nls->listensd); - return FALSE; + return false; } #endif @@ -266,7 +267,7 @@ static inline boolean net_mksocket(struct net_listener_s *nls) { message("net_listener: bind failed: %d\n", errno); close(nls->listensd); - return FALSE; + return false; } /* Mark the socket as a listener */ @@ -276,10 +277,10 @@ static inline boolean net_mksocket(struct net_listener_s *nls) { message("net_listener: bind failed: %d\n", errno); close(nls->listensd); - return FALSE; + return false; } - return TRUE; + return true; } /**************************************************************************** @@ -290,7 +291,7 @@ static void net_configure(void) { struct in_addr addr; #if defined(CONFIG_EXAMPLE_POLL_NOMAC) - ubyte mac[IFHWADDRLEN]; + uint8_t mac[IFHWADDRLEN]; #endif /* Configure uIP */ diff --git a/nuttx/examples/poll/net_reader.c b/nuttx/examples/poll/net_reader.c index ca1fa4bb0..1ea8dbe54 100644 --- a/nuttx/examples/poll/net_reader.c +++ b/nuttx/examples/poll/net_reader.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/poll/net_reader.c * - * Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,7 @@ #include <sys/select.h> #include <sys/socket.h> +#include <stdint.h> #include <stdio.h> #include <unistd.h> #include <string.h> @@ -83,7 +84,7 @@ static void net_configure(void) { struct in_addr addr; #if defined(CONFIG_EXAMPLE_POLL_NOMAC) - ubyte mac[IFHWADDRLEN]; + uint8_t mac[IFHWADDRLEN]; #endif /* Configure uIP */ diff --git a/nuttx/examples/poll/poll_listener.c b/nuttx/examples/poll/poll_listener.c index c798b6e88..816647e34 100644 --- a/nuttx/examples/poll/poll_listener.c +++ b/nuttx/examples/poll/poll_listener.c @@ -41,7 +41,7 @@ #include <sys/types.h> #include <sys/stat.h> - +#include <stdbool.h> #include <stdio.h> #include <unistd.h> #include <string.h> @@ -93,8 +93,8 @@ void *poll_listener(pthread_addr_t pvarg) struct pollfd fds[NPOLLFDS]; char buffer[64]; ssize_t nbytes; - boolean timeout; - boolean pollin; + bool timeout; + bool pollin; int nevents; int fd; int ret; @@ -128,8 +128,8 @@ void *poll_listener(pthread_addr_t pvarg) fds[FIFONDX].events = POLLIN; fds[FIFONDX].revents = 0; - timeout = FALSE; - pollin = FALSE; + timeout = false; + pollin = false; ret = poll(fds, NPOLLFDS, POLL_LISTENER_DELAY); @@ -141,7 +141,7 @@ void *poll_listener(pthread_addr_t pvarg) else if (ret == 0) { message("poll_listener: Timeout\n"); - timeout = TRUE; + timeout = true; } else if (ret > NPOLLFDS) { @@ -149,7 +149,7 @@ void *poll_listener(pthread_addr_t pvarg) } else { - pollin = TRUE; + pollin = true; } nevents = 0; diff --git a/nuttx/examples/poll/select_listener.c b/nuttx/examples/poll/select_listener.c index 85ff57a5e..80039ada3 100644 --- a/nuttx/examples/poll/select_listener.c +++ b/nuttx/examples/poll/select_listener.c @@ -42,7 +42,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/select.h> - +#include <stdbool.h> #include <stdio.h> #include <unistd.h> #include <string.h> @@ -83,8 +83,8 @@ void *select_listener(pthread_addr_t pvarg) struct timeval tv; char buffer[64]; ssize_t nbytes; - boolean timeout; - boolean ready; + bool timeout; + bool ready; int fd; int ret; @@ -112,8 +112,8 @@ void *select_listener(pthread_addr_t pvarg) tv.tv_sec = SELECT_LISTENER_DELAY; tv.tv_usec = 0; - timeout = FALSE; - ready = FALSE; + timeout = false; + ready = false; ret = select(fd+1, (FAR fd_set*)&rfds, (FAR fd_set*)NULL, (FAR fd_set*)NULL, &tv); message("\nselect_listener: select returned: %d\n", ret); @@ -125,7 +125,7 @@ void *select_listener(pthread_addr_t pvarg) else if (ret == 0) { message("select_listener: Timeout\n"); - timeout = TRUE; + timeout = true; } else { @@ -135,7 +135,7 @@ void *select_listener(pthread_addr_t pvarg) } else { - ready = TRUE; + ready = true; } if (!FD_ISSET(fd, rfds)) @@ -176,8 +176,8 @@ void *select_listener(pthread_addr_t pvarg) message("select_listener: Read '%s' (%d bytes)\n", buffer, nbytes); } - timeout = FALSE; - ready = FALSE; + timeout = false; + ready = false; } while (nbytes > 0); |