1 /* machines.c - provide special support for peculiar architectures
11 #include "ntp_machine.h"
12 #include "ntp_syslog.h"
13 #include "ntp_stdlib.h"
14 #include "ntp_unixtime.h"
28 #include "ntp_syslog.h"
30 /* some translations to the world of vxWorkings -casey */
31 /* first some netdb type things */
36 struct hostent *gethostbyname(char *name)
38 struct hostent *host1;
39 h_errno = 0; /* we are always successful!!! */
40 host1 = (struct hostent *) malloc (sizeof(struct hostent));
42 host1->h_addrtype = AF_INET;
43 host1->h_aliases = name;
45 host1->h_addr_list[0] = (char *)hostGetByName (name);
46 host1->h_addr_list[1] = NULL;
50 struct hostent *gethostbyaddr(char *name, int size, int addr_type)
52 struct hostent *host1;
53 h_errno = 0; /* we are always successful!!! */
54 host1 = (struct hostent *) malloc (sizeof(struct hostent));
56 host1->h_addrtype = AF_INET;
57 host1->h_aliases = name;
59 host1->h_addr_list = NULL;
63 struct servent *getservbyname (char *name, char *type)
65 struct servent *serv1;
66 serv1 = (struct servent *) malloc (sizeof(struct servent));
67 serv1->s_name = "ntp"; /* official service name */
68 serv1->s_aliases = NULL; /* alias list */
69 serv1->s_port = 123; /* port # */
70 serv1->s_proto = "udp"; /* protocol to use */
75 * vxworks thinks it has insomnia
76 * we have to sleep for number of seconds
79 #define CLKRATE sysClkRateGet()
81 /* I am not sure how valid the granularity is - it is from G. Eger's port */
82 #define CLK_GRANULARITY 1 /* Granularity of system clock in usec */
83 /* Used to round down # usecs/tick */
84 /* On a VCOM-100, PIT gets 8 MHz clk, */
85 /* & it prescales by 32, thus 4 usec */
86 /* on mv167, granularity is 1usec anyway*/
87 /* To defeat rounding, set to 1 */
88 #define USECS_PER_SEC MILLION /* Microseconds per second */
89 #define TICK (((USECS_PER_SEC / CLKRATE) / CLK_GRANULARITY) * CLK_GRANULARITY)
94 void sleep(int seconds)
96 taskDelay(seconds*TICK);
99 * that pauses and calls SIGALRM after the seconds are up...
100 * so ... taskDelay() fudged for seconds should amount to the same thing.
103 void alarm (int seconds)
108 #endif /* SYS_VXWORKS */
110 #ifdef SYS_PTX /* Does PTX still need this? */
111 /*#include <sys/types.h> */
112 #include <sys/procstats.h>
120 * hi, this is Sequents sneak path to get to a clock
121 * this is also the most logical syscall for such a function
123 return (get_process_stats(tvp, PS_SELF, (struct procstats *) 0,
124 (struct procstats *) 0));
128 const char *set_tod_using = "UNKNOWN";
138 #ifdef HAVE_CLOCK_SETTIME
142 /* Convert timeval to timespec */
143 ts.tv_sec = tvp->tv_sec;
144 ts.tv_nsec = 1000 * tvp->tv_usec;
146 rc = clock_settime(CLOCK_REALTIME, &ts);
149 set_tod_using = "clock_settime";
153 #endif /* HAVE_CLOCK_SETTIME */
154 #ifdef HAVE_SETTIMEOFDAY
156 rc = SETTIMEOFDAY(tvp, tzp);
159 set_tod_using = "settimeofday";
163 #endif /* HAVE_SETTIMEOFDAY */
166 long tp = tvp->tv_sec;
168 rc = stime(&tp); /* lie as bad as SysVR4 */
171 set_tod_using = "stime";
175 #endif /* HAVE_STIME */
176 set_tod_using = "Failed!";
180 #endif /* not SYS_WINNT */
182 #if defined (SYS_WINNT) || defined (SYS_VXWORKS)
183 /* getpass is used in ntpq.c and ntpdc.c */
186 getpass(const char * prompt)
189 static char password[32];
191 fprintf(stderr, "%s", prompt);
194 for (i=0; i<sizeof(password)-1 && ((c=_getch())!='\n' && c!='\r'); i++) {
195 password[i] = (char) c;
201 #endif /* SYS_WINNT */
203 #if !defined(HAVE_MEMSET)