Commit e1229484 authored by Aurelio Colosimo's avatar Aurelio Colosimo

pp_adj_freq implemented

virtualization of Linux adjtimex system clock time adjustment
parent df376863
...@@ -6,8 +6,11 @@ ...@@ -6,8 +6,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <sys/timex.h>
#include <pptp/pptp.h> #include <pptp/pptp.h>
#define POSIX_IO_ADJ_FREQ_MAX 512000
void pp_puts(const char *s) void pp_puts(const char *s)
{ {
fputs(s, stdout); fputs(s, stdout);
...@@ -55,3 +58,18 @@ void pp_set_tstamp(TimeInternal *t) ...@@ -55,3 +58,18 @@ void pp_set_tstamp(TimeInternal *t)
exit(0); exit(0);
} }
} }
int pp_adj_freq(Integer32 adj)
{
struct timex t;
if (adj > POSIX_IO_ADJ_FREQ_MAX)
adj = POSIX_IO_ADJ_FREQ_MAX;
else if (adj < -POSIX_IO_ADJ_FREQ_MAX)
adj = -POSIX_IO_ADJ_FREQ_MAX;
t.modes = MOD_FREQUENCY;
t.freq = adj * ((1 << 16) / 1000);
return !adjtimex(&t);
}
...@@ -275,6 +275,10 @@ extern void set_TimeInternal(TimeInternal *t, Integer32 s, Integer32 ns); ...@@ -275,6 +275,10 @@ extern void set_TimeInternal(TimeInternal *t, Integer32 s, Integer32 ns);
extern void pp_get_tstamp(TimeInternal *t); extern void pp_get_tstamp(TimeInternal *t);
extern void pp_set_tstamp(TimeInternal *t); extern void pp_set_tstamp(TimeInternal *t);
/* Virtualization of Linux adjtimex (or BSD adjtime) system clock time
* adjustment. Boolean: returns 1 in case of success and 0 if failure */
extern int pp_adj_freq(Integer32 adj);
/* /*
* The state machine itself is an array of these structures. * The state machine itself is an array of these structures.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment