summaryrefslogtreecommitdiffstats
path: root/src/lib/kStuff/kProfiler2/tst.c
blob: f56204c21c2b8ab7d7d0b438ede0d0a48588b65e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>

#ifdef _MSC_VER
void __cdecl _penter(void);
void __cdecl _pexit(void);
__declspec(naked) int  naked(void)
{
    __asm
    {
        call    _penter
        call    _pexit
        xor     eax, eax
        ret
    }
}

#endif

int bar(void)
{
    unsigned i;
    for (i = 0; i < 1000; i += 7)
        i += i & 1;
    return i;
}

int foo(void)
{
    unsigned i, rc = 0;
    for (i = 0; i < 1000; i++)
        rc += bar();
#ifdef _MSC_VER
    for (; i < 2000; i++)
        rc += naked();
#endif
    return i;
}

int main()
{
    int rc;
    printf("hello");
    fflush(stdout);
    rc = foo();
    printf("world\n");
    return rc;
}