/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that advances the system wide
realtime clock approximately one hour and gets the 
resolution of the user profiling clock */
#include <stdio.h>
#include <time.h>
#include <errno.h>

int main() {
    struct timespec cur_time;
    struct timespec new_time;
    struct timespec resolution;

    if (clock_gettime(CLOCK_REALTIME, &cur_time)) {
        perror("clock_gettime(CLOCK_REALTIME) failed");
        exit(1);
    }
    new_time.tv_sec = cur_time.tv_sec + 3600;
    new_time.tv_nsec = cur_time.tv_nsec;
    if((getuid()) == 0) {
        if (clock_settime(CLOCK_REALTIME, &new_time)) {
            perror("clock_settime(CLOCK_REALTIME) failed");
            exit(2);
        }
    }
    if (clock_getres(CLOCK_REALTIME, &resolution)) {
        perror("clock_getres(CLOCK_REALTIME) failed");
        exit(1);
    }
    printf("Resolution of user profiling clock is:\n");
    printf("%d seconds and %d nanoseconds.\n",
                resolution.tv_sec, resolution.tv_nsec);
}


