Subversion Repositories shark

Rev

Rev 3 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/* Project:     OSLib
2
 * Description: The OS Construction Kit
3
 * Date:                1.6.2000
4
 * Idea by:             Luca Abeni & Gerardo Lamastra
5
 *
6
 * OSLib is an SO project aimed at developing a common, easy-to-use
7
 * low-level infrastructure for developing OS kernels and Embedded
8
 * Applications; it partially derives from the HARTIK project but it
9
 * currently is independently developed.
10
 *
11
 * OSLib is distributed under GPL License, and some of its code has
12
 * been derived from the Linux kernel source; also some important
13
 * ideas come from studying the DJGPP go32 extender.
14
 *
15
 * We acknowledge the Linux Community, Free Software Foundation,
16
 * D.J. Delorie and all the other developers who believe in the
17
 * freedom of software and ideas.
18
 *
19
 * For legalese, check out the included GPL license.
20
 */
21
 
22
/*      gettime() test file                     */
23
 
24
#include <ll/i386/stdlib.h>
25
#include <ll/i386/error.h>
26
#include <ll/sys/ll/ll-func.h>
27
#include <ll/sys/ll/event.h>
28
#include <ll/sys/ll/time.h>
29
 
30
DWORD smain;
31
DWORD sp;
32
 
33
int sys_abort(int code)
34
{
35
    cli();
36
    ll_abort(code);
37
 
38
    /* Never reach this! Just to shut up compiler warning...    */
39
    /* In the general case, a sys_abort can resume...           */
40
    return(1);
41
}
42
 
43
int main (int argc, char *argv[])
44
{
45
        DWORD t, t1, oldt, secs;
46
        struct ll_initparms parms;
47
        struct timespec ts;
48
 
49
        cli();
50
        message("Init Stack : %lu\n", get_SP());
51
 
52
        parms.mode = LL_PERIODIC;
53
        parms.tick = 1000;
54
        ll_init();
55
        event_init(&parms);             /* It's here, but must be changed...*/
56
 
57
        smain = get_SP();
58
        message("Smain --> %lx\n",smain);
59
 
60
        sti();
61
        secs = 0; oldt = 0;
62
        while (secs <= 120) {
63
                cli();
64
                t1 = ll_gettime(TIME_NEW, &ts);
65
                t = ll_gettime(TIME_EXACT, NULL);
66
                sti();
67
                if (t < oldt) {
68
                        error("Time goes back??\n");
69
                        message("ARGGGGG! %lu %lu\n", t, oldt);
70
                        ll_abort(100);
71
                }
72
                oldt = t;
73
                if ((t  / 1000000) > secs) {
74
                        secs++;
75
                        message("%lu                     %lu     %lu/%lu\n",
76
                                        TIMESPEC2USEC(&ts), secs, t, t1);
77
                }
78
        }
79
        message("\n DONE: Secs = %lu\n", secs);
80
        cli();
81
        ll_end();
82
        sp = get_SP();
83
        message("End reached!\n");
84
        message("Actual stack : %lx - ",sp);
85
        message("Main stack : %lx\n",smain);
86
        message("Check if same : %s\n",smain == sp ? "Ok :-)" : "No :-(");
87
        return 1;
88
}