summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/ntpd/refclock_shm.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/ntpd/refclock_shm.c')
-rw-r--r--contrib/ntp/ntpd/refclock_shm.c44
1 files changed, 12 insertions, 32 deletions
diff --git a/contrib/ntp/ntpd/refclock_shm.c b/contrib/ntp/ntpd/refclock_shm.c
index a8094c8..3747ce0 100644
--- a/contrib/ntp/ntpd/refclock_shm.c
+++ b/contrib/ntp/ntpd/refclock_shm.c
@@ -13,12 +13,6 @@
#if defined(REFCLOCK) && defined(CLOCK_SHM)
-#undef fileno
-#include <ctype.h>
-#undef fileno
-#include <sys/time.h>
-#undef fileno
-
#include "ntpd.h"
#undef fileno
#include "ntp_io.h"
@@ -29,15 +23,16 @@
#undef fileno
#include "ntp_stdlib.h"
+#undef fileno
+#include <ctype.h>
+#undef fileno
+
#ifndef SYS_WINNT
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <assert.h>
-#include <time.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
+# include <sys/ipc.h>
+# include <sys/shm.h>
+# include <assert.h>
+# include <unistd.h>
+# include <stdio.h>
#endif
/*
@@ -94,35 +89,19 @@ struct shmTime {
};
struct shmTime *getShmTime (int unit) {
#ifndef SYS_WINNT
- extern char *sys_errlist[ ];
- extern int sys_nerr;
int shmid=0;
assert (unit<10); /* MAXUNIT is 4, so should never happen */
shmid=shmget (0x4e545030+unit, sizeof (struct shmTime),
IPC_CREAT|(unit<2?0700:0777));
if (shmid==-1) { /*error */
- char buf[20];
- char *pe=buf;
- if (errno<sys_nerr)
- pe=sys_errlist[errno];
- else {
- sprintf (buf,"errno=%d",errno);
- }
- msyslog(LOG_ERR,"SHM shmget (unit %d): %s",unit,pe);
+ msyslog(LOG_ERR,"SHM shmget (unit %d): %s",unit,strerror(errno));
return 0;
}
else { /* no error */
struct shmTime *p=(struct shmTime *)shmat (shmid, 0, 0);
if ((int)(long)p==-1) { /* error */
- char buf[20];
- char *pe=buf;
- if (errno<sys_nerr)
- pe=sys_errlist[errno];
- else {
- sprintf (buf,"errno=%d",errno);
- }
- msyslog(LOG_ERR,"SHM shmat (unit %d): %s",unit,pe);
+ msyslog(LOG_ERR,"SHM shmat (unit %d): %s",unit,strerror(errno));
return 0;
}
return p;
@@ -285,6 +264,7 @@ shm_poll(
up->valid=0;
if (ok) {
TVTOTS(&tvr,&pp->lastrec);
+ pp->lastrec.l_ui += JAN_1970;
/* pp->lasttime = current_time; */
pp->polls++;
t=gmtime (&tvt.tv_sec);
OpenPOWER on IntegriCloud