Пример #1
0
int
main(
	int argc,
	char *argv[]
	)
{
	if (argc > 2)
	{
		fprintf(stderr, "Usage: %s [tick_value]\n", argv[0]);
		exit(-1);
	}
	else if (argc == 2)
	{
#ifdef ADJ_TIMETICK
		if ( (txc.time_tick = atoi(argv[1])) < 1 )
#else
		if ( (txc.tick = atoi(argv[1])) < 1 )
#endif
		{
			fprintf(stderr, "Silly value for tick: %s\n", argv[1]);
			exit(-1);
		}
#ifdef ADJ_TIMETICK
		txc.modes = ADJ_TIMETICK;
#else
#ifdef MOD_OFFSET
		txc.modes = ADJ_TICK;
#else
		txc.mode = ADJ_TICK;
#endif
#endif
	}
	else
	{
#ifdef ADJ_TIMETICK
		txc.modes = 0;
#else
#ifdef MOD_OFFSET
		txc.modes = 0;
#else
		txc.mode = 0;
#endif
#endif
	}
    
	if (__adjtimex(&txc) < 0)
	{
		perror("adjtimex");
	}
	else
	{
#ifdef ADJ_TIMETICK
		printf("tick     = %ld\ntick_adj = %ld\n", txc.time_tick, txc.tickadj);
#else
		printf("tick = %ld\n", txc.tick);
#endif
	}

	exit(0);
}
Пример #2
0
int
ntp_gettime (struct ntptimeval *ntv)
{
  struct timex tntx;
  int result;

  tntx.modes = 0;
  result = __adjtimex (&tntx);
  ntv->time = tntx.time;
  ntv->maxerror = tntx.maxerror;
  ntv->esterror = tntx.esterror;
  return result;
}
Пример #3
0
static int get_current_freq(void)
{
	/* OS dependent routine to get the current value of clock frequency.
	 */
#ifdef __linux__
	struct timex txc;
	txc.modes=0;
	if (__adjtimex(&txc) < 0) {
		perror("adjtimex"); exit(1);
	}
	return txc.freq;
#else
	return 0;
#endif
}
Пример #4
0
static int set_freq(int new_freq)
{
	/* OS dependent routine to set a new value of clock frequency.
	 */
#ifdef __linux__
	struct timex txc;
	txc.modes = ADJ_FREQUENCY;
	txc.freq = new_freq;
	if (__adjtimex(&txc) < 0) {
		perror("adjtimex"); exit(1);
	}
	return txc.freq;
#else
	return 0;
#endif
}
Пример #5
0
int
main(
	int argc,
	char *argv[]
	)
{
	int     c, i;
	int     quiet = 0;
	int     errflg = 0;
	char    *progname;
	extern int ntp_optind;
	extern char *ntp_optarg;

	progname = argv[0];
	if (argc==2 && argv[1][0] != '-') { /* old Linux format, for compatability */
	    if ((i = atoi(argv[1])) > 0) {
		    txc.time_tick = i;
		    txc.modes = ADJ_TIMETICK;
	    } else {
		    fprintf(stderr, "Silly value for tick: %s\n", argv[1]);
		    errflg++;
	    }
	} else {
	    while ((c = ntp_getopt(argc, argv, "a:qt:")) != EOF) {
		switch (c) {
		    case 'a':
			if ((i=atoi(ntp_optarg)) > 0) {
				txc.tickadj = i;
				txc.modes |= ADJ_TICKADJ;
			} else {
				(void) fprintf(stderr,
				       "%s: unlikely value for tickadj: %s\n",
				       progname, ntp_optarg);
				errflg++;
			}
			break;

		    case 'q':
			quiet = 1;
			break;

		    case 't':
			if ((i=atoi(ntp_optarg)) > 0) {
				txc.time_tick = i;
				txc.modes |= ADJ_TIMETICK;
			} else {
				(void) fprintf(stderr,
				       "%s: unlikely value for tick: %s\n",
				       progname, ntp_optarg);
				errflg++;
			}
			break;

		    default:
			fprintf(stderr,
			    "Usage: %s [tick_value]\n-or-   %s [ -q ] [ -t tick ] [ -a tickadj ]\n",
			    progname, progname);
			errflg++;
			break;
		}
	    }
	}

	if (!errflg) {
		if (__adjtimex(&txc) < 0)
			perror("adjtimex");
		else if (!quiet)
			printf("tick     = %ld\ntick_adj = %d\n",
			    txc.time_tick, txc.tickadj);
	}

	exit(errflg ? 1 : 0);
}