Rev | Line | |
---|
[2] | 1 | #include <stdio.h>
|
---|
| 2 |
|
---|
| 3 | #ifdef _MSC_VER
|
---|
| 4 | void __cdecl _penter(void);
|
---|
| 5 | void __cdecl _pexit(void);
|
---|
| 6 | __declspec(naked) int naked(void)
|
---|
| 7 | {
|
---|
| 8 | __asm
|
---|
| 9 | {
|
---|
| 10 | call _penter
|
---|
| 11 | call _pexit
|
---|
| 12 | xor eax, eax
|
---|
| 13 | ret
|
---|
| 14 | }
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | #endif
|
---|
| 18 |
|
---|
| 19 | int bar(void)
|
---|
| 20 | {
|
---|
| 21 | unsigned i;
|
---|
| 22 | for (i = 0; i < 1000; i += 7)
|
---|
| 23 | i += i & 1;
|
---|
| 24 | return i;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | int foo(void)
|
---|
| 28 | {
|
---|
| 29 | unsigned i, rc = 0;
|
---|
| 30 | for (i = 0; i < 1000; i++)
|
---|
| 31 | rc += bar();
|
---|
| 32 | #ifdef _MSC_VER
|
---|
| 33 | for (; i < 2000; i++)
|
---|
| 34 | rc += naked();
|
---|
| 35 | #endif
|
---|
| 36 | return i;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | int main()
|
---|
| 40 | {
|
---|
| 41 | int rc;
|
---|
| 42 | printf("hello");
|
---|
| 43 | fflush(stdout);
|
---|
| 44 | rc = foo();
|
---|
| 45 | printf("world\n");
|
---|
| 46 | return rc;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.