Move ROSKY to a separate SVN module.
[reactos.git] / rosky / lib / libsky / stubs.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: SkyOS library
5 * FILE: lib/libsky/stubs.c
6 * PURPOSE: libsky.dll stubs
7 * NOTES: If you implement a function, remove it from this file
8 *
9 * UPDATE HISTORY:
10 * 08/12/2004 Created
11 */
12 #include <windows.h>
13 /* #define NDEBUG */
14 #include "libsky.h"
15
16
17 typedef void (__cdecl *func_ptr) (void);
18
19 /*
20 * @unimplemented
21 */
22 void __cdecl
23 ctor_dtor_initialize(func_ptr *__CTOR_LIST__,
24 func_ptr *__DTOR_LIST__,
25 void *unknown)
26 {
27 STUB("ctor_dtor_initialize: __CTOR_LIST__=0x%x __DTOR_LIST__=0x%x unknown=0x%x\n", __CTOR_LIST__, __DTOR_LIST__, unknown);
28
29 /* unknown apparently is the virtual address of the .bss section, but what should
30 * we do with it?! Perhaps load a list of constructor/destructor addresses to this
31 * address before we call them?
32 */
33
34 /*
35 * Call constructors
36 */
37 if(__CTOR_LIST__ != NULL)
38 {
39 unsigned long nptrs;
40 /*
41 * If the first entry in the constructor list is -1 then the list
42 * is terminated with a null entry. Otherwise the first entry was
43 * the number of pointers in the list.
44 */
45 DBG("Calling constructors...\n");
46 nptrs = (unsigned long)__CTOR_LIST__[0];
47 if (nptrs == -1)
48 {
49 for(nptrs = 0; __CTOR_LIST__[nptrs + 1] != NULL; nptrs++);
50 }
51 DBG("There are %d constructors to call...\n", nptrs);
52
53 /*
54 * Go through the list backwards calling constructors.
55 * FIXME - backwards?! This is ripped off crtdll\misc\gccmain.c
56 */
57 for(; nptrs > 0; nptrs--)
58 {
59 DBG("call constructor 0x%x\n", __CTOR_LIST__[nptrs]);
60 __CTOR_LIST__[nptrs]();
61 }
62 DBG("Called all constructors\n");
63 }
64
65 /*
66 * Call destructors
67 */
68 if(__DTOR_LIST__ != NULL)
69 {
70 unsigned long nptrs;
71 /*
72 * If the first entry in the destructor list is -1 then the list
73 * is terminated with a null entry. Otherwise the first entry was
74 * the number of pointers in the list.
75 */
76 DBG("Calling destructors...\n");
77 nptrs = (unsigned long)__DTOR_LIST__[0];
78 if (nptrs == -1)
79 {
80 for(nptrs = 0; __DTOR_LIST__[nptrs + 1] != NULL; nptrs++);
81 }
82 DBG("There are %d destructors to call...\n", nptrs);
83
84 /*
85 * Go through the list backwards calling constructors.
86 * FIXME - backwards?! This is ripped off crtdll\misc\gccmain.c
87 */
88 for(; nptrs > 0; nptrs--)
89 {
90 DBG("call destructor 0x%x\n", __DTOR_LIST__[nptrs]);
91 __DTOR_LIST__[nptrs]();
92 }
93 DBG("Called all destructors\n");
94 }
95 }
96
97 /*
98 * @unimplemented
99 */
100 unsigned long long __cdecl
101 get_usec_counter(void)
102 {
103 /* FIXME - better implementation */
104 return (unsigned long long)GetTickCount() * 1000LL;
105 }
106
107 /* EOF */