- Fix some bugs in Kernel Queue implementation:
[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 <debug.h>
15 #include "libsky.h"
16
17
18 typedef void (__cdecl *func_ptr) (void);
19
20 /*
21 * @unimplemented
22 */
23 void __cdecl
24 ctor_dtor_initialize(func_ptr *__CTOR_LIST__,
25 func_ptr *__DTOR_LIST__,
26 void *unknown)
27 {
28 STUB("ctor_dtor_initialize: __CTOR_LIST__=0x%x __DTOR_LIST__=0x%x unknown=0x%x\n", __CTOR_LIST__, __DTOR_LIST__, unknown);
29
30 /* unknown apparently is the virtual address of the .bss section, but what should
31 * we do with it?! Perhaps load a list of constructor/destructor addresses to this
32 * address before we call them?
33 */
34
35 /*
36 * Call constructors
37 */
38 if(__CTOR_LIST__ != NULL)
39 {
40 unsigned long nptrs;
41 /*
42 * If the first entry in the constructor list is -1 then the list
43 * is terminated with a null entry. Otherwise the first entry was
44 * the number of pointers in the list.
45 */
46 DBG("Calling constructors...\n");
47 nptrs = (unsigned long)__CTOR_LIST__[0];
48 if (nptrs == -1)
49 {
50 for(nptrs = 0; __CTOR_LIST__[nptrs + 1] != NULL; nptrs++);
51 }
52 DBG("There are %d constructors to call...\n", nptrs);
53
54 /*
55 * Go through the list backwards calling constructors.
56 * FIXME - backwards?! This is ripped off crtdll\misc\gccmain.c
57 */
58 for(; nptrs > 0; nptrs--)
59 {
60 DBG("call constructor 0x%x\n", __CTOR_LIST__[nptrs]);
61 __CTOR_LIST__[nptrs]();
62 }
63 DBG("Called all constructors\n");
64 }
65
66 /*
67 * Call destructors
68 */
69 if(__DTOR_LIST__ != NULL)
70 {
71 unsigned long nptrs;
72 /*
73 * If the first entry in the destructor list is -1 then the list
74 * is terminated with a null entry. Otherwise the first entry was
75 * the number of pointers in the list.
76 */
77 DBG("Calling destructors...\n");
78 nptrs = (unsigned long)__DTOR_LIST__[0];
79 if (nptrs == -1)
80 {
81 for(nptrs = 0; __DTOR_LIST__[nptrs + 1] != NULL; nptrs++);
82 }
83 DBG("There are %d destructors to call...\n", nptrs);
84
85 /*
86 * Go through the list backwards calling constructors.
87 * FIXME - backwards?! This is ripped off crtdll\misc\gccmain.c
88 */
89 for(; nptrs > 0; nptrs--)
90 {
91 DBG("call destructor 0x%x\n", __DTOR_LIST__[nptrs]);
92 __DTOR_LIST__[nptrs]();
93 }
94 DBG("Called all destructors\n");
95 }
96 }
97
98 /*
99 * @unimplemented
100 */
101 unsigned long long __cdecl
102 get_usec_counter(void)
103 {
104 /* FIXME - better implementation */
105 return (unsigned long long)GetTickCount() * 1000LL;
106 }
107
108 /* EOF */