summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2023-04-23 17:23:35 -1000
committerKinseyMoore <48726349+KinseyMoore@users.noreply.github.com>2023-04-25 21:45:23 -0500
commit067962b80bfd5d0fb170ffa1d38f0484ca909bb4 (patch)
tree2bd56704e397351a585262eebf12c20793edf003
parentbsd/ntp: Remove warning about errno_to_str (diff)
downloadrtems-net-services-067962b80bfd5d0fb170ffa1d38f0484ca909bb4.tar.bz2
bsd/ntp: Use msyslog support for %m
-rw-r--r--bsd/freebsd/contrib/ntp/ntpd/ntp_io.c47
-rw-r--r--net/legacy/ntp/config.h2
-rw-r--r--net/libbsd/ntp/config.h16
-rw-r--r--net/lwip/ntp/config.h16
4 files changed, 63 insertions, 18 deletions
diff --git a/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c b/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c
index eea40ed..2a19e9e 100644
--- a/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c
+++ b/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c
@@ -197,7 +197,27 @@ static struct refclockio *refio;
* File descriptor masks etc. for call to select
* Not needed for I/O Completion Ports or anything outside this file
*/
+#ifdef __rtems__
+#include <rtems/libio_.h>
+static int rtems_fd_set_alloc(fd_set **setp) {
+ static size_t _fds_size;
+ if (*setp == NULL) {
+ _fds_size = sizeof(fd_set) * (howmany(rtems_libio_number_iops, sizeof(fd_set) * 8));
+ *setp = malloc(_fds_size);
+ if (*setp == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ }
+ memset(*setp, 0, _fds_size);
+ return 0;
+}
+#define activefds (*activefds_prealloc)
+static fd_set *activefds_prealloc;
+#define rtems_activefds_alloc() rtems_fd_set_alloc(&activefds_prealloc)
+#else /* __rtems__ */
static fd_set activefds;
+#endif /* __rtems__ */
static int maxactivefd;
/*
@@ -361,7 +381,12 @@ maintain_activefds(
{
int i;
+#ifdef __rtems__
+ rtems_activefds_alloc();
+ if (fd < 0 || fd >= rtems_libio_number_iops) {
+#else
if (fd < 0 || fd >= FD_SETSIZE) {
+#endif /* __rtems__ */
msyslog(LOG_ERR,
"Too many sockets in use, FD_SETSIZE %d exceeded by fd %d",
FD_SETSIZE, fd);
@@ -2068,6 +2093,9 @@ create_sockets(
u_short port
)
{
+#ifdef __rtems__
+ rtems_activefds_alloc();
+#endif /* __rtems__ */
#ifndef HAVE_IO_COMPLETION_PORT
/*
* I/O Completion Ports don't care about the select and FD_SET
@@ -3615,9 +3643,22 @@ void
io_handler(void)
{
# ifndef HAVE_SIGNALED_IO
+#if __rtems__
+ #define rdfdes (*rdfdes_prealloc)
+ static fd_set *rdfdes_prealloc;
+#else
fd_set rdfdes;
+#endif
int nfound;
+#if __rtems__
+ if (rtems_fd_set_alloc(&rdfdes_prealloc) < 0) {
+ return;
+ }
+#else
+ FD_ZERO(&set);
+#endif
+
/*
* Use select() on all on all input fd's for unlimited
* time. select() will terminate on SIGALARM or on the
@@ -3730,6 +3771,11 @@ sanitize_fdset(
{
int j, b, maxscan;
+#ifdef __rtems__
+ if (rtems_activefds_alloc() < 0 ){
+ return - 1;
+ }
+#endif /* __rtems__ */
# ifndef HAVE_SIGNALED_IO
/*
* extended FAU debugging output
@@ -4875,4 +4921,3 @@ init_async_notifications(void)
{
}
#endif
-
diff --git a/net/legacy/ntp/config.h b/net/legacy/ntp/config.h
index e378912..2756aea 100644
--- a/net/legacy/ntp/config.h
+++ b/net/legacy/ntp/config.h
@@ -1682,7 +1682,7 @@ typedef unsigned int uintptr_t;
#define VERSION "4.2.8p12"
/* vsnprintf expands "%m" to strerror(errno) */
-#define VSNPRINTF_PERCENT_M 1
+/* #undef VSNPRINTF_PERCENT_M */
/* configure --enable-ipv6 */
#define WANT_IPV6 1
diff --git a/net/libbsd/ntp/config.h b/net/libbsd/ntp/config.h
index d0251a1..f48309f 100644
--- a/net/libbsd/ntp/config.h
+++ b/net/libbsd/ntp/config.h
@@ -1275,7 +1275,7 @@
#endif
#define ISC_PLATFORM_NORETURN_PRE
#define ISC_PLATFORM_NORETURN_POST __attribute__((__noreturn__))
-
+
/* Define to 1 if you have the `__ntp_gettime' function. */
@@ -1292,8 +1292,8 @@
#ifdef HAVE___SS_FAMILY_IN_SS
# define ss_family __ss_family
#endif /* HAVE___SS_FAMILY_IN_SS */
-
-
+
+
/* Define to provide `rpl_snprintf' function. */
/* #undef HW_WANT_RPL_SNPRINTF */
@@ -1682,7 +1682,7 @@ typedef unsigned int uintptr_t;
#define VERSION "4.2.8p12"
/* vsnprintf expands "%m" to strerror(errno) */
-#define VSNPRINTF_PERCENT_M 1
+/* #undef VSNPRINTF_PERCENT_M */
/* configure --enable-ipv6 */
#define WANT_IPV6 1
@@ -1791,15 +1791,15 @@ typedef unsigned int uintptr_t;
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
-
+
#if !defined(_KERNEL) && !defined(PARSESTREAM)
/*
* stdio.h must be included after _GNU_SOURCE is defined
* but before #define snprintf rpl_snprintf
*/
- # include <stdio.h>
+ # include <stdio.h>
#endif
-
+
/* Define to rpl_snprintf if the replacement function should be used. */
/* #undef snprintf */
@@ -1857,7 +1857,7 @@ typedef union mpinfou {
# endif
# endif
#endif /* !defined(_KERNEL) && !defined(PARSESTREAM) */
-
+
/*
* FreeBSD specific: Explicitly specify date/time for reproducible build.
*/
diff --git a/net/lwip/ntp/config.h b/net/lwip/ntp/config.h
index d0251a1..4e06452 100644
--- a/net/lwip/ntp/config.h
+++ b/net/lwip/ntp/config.h
@@ -1275,7 +1275,7 @@
#endif
#define ISC_PLATFORM_NORETURN_PRE
#define ISC_PLATFORM_NORETURN_POST __attribute__((__noreturn__))
-
+
/* Define to 1 if you have the `__ntp_gettime' function. */
@@ -1292,8 +1292,8 @@
#ifdef HAVE___SS_FAMILY_IN_SS
# define ss_family __ss_family
#endif /* HAVE___SS_FAMILY_IN_SS */
-
-
+
+
/* Define to provide `rpl_snprintf' function. */
/* #undef HW_WANT_RPL_SNPRINTF */
@@ -1682,7 +1682,7 @@ typedef unsigned int uintptr_t;
#define VERSION "4.2.8p12"
/* vsnprintf expands "%m" to strerror(errno) */
-#define VSNPRINTF_PERCENT_M 1
+/* #undef VSNPRINTF_PERCENT_M */
/* configure --enable-ipv6 */
#define WANT_IPV6 1
@@ -1791,15 +1791,15 @@ typedef unsigned int uintptr_t;
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
-
+
#if !defined(_KERNEL) && !defined(PARSESTREAM)
/*
* stdio.h must be included after _GNU_SOURCE is defined
* but before #define snprintf rpl_snprintf
*/
- # include <stdio.h>
+ # include <stdio.h>
#endif
-
+
/* Define to rpl_snprintf if the replacement function should be used. */
/* #undef snprintf */
@@ -1857,7 +1857,7 @@ typedef union mpinfou {
# endif
# endif
#endif /* !defined(_KERNEL) && !defined(PARSESTREAM) */
-
+
/*
* FreeBSD specific: Explicitly specify date/time for reproducible build.
*/