Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/winecrt0/gcc_ctors.c
12343 views
1
/*
2
* Copyright 2026 Yuxuan Shui for CodeWeavers
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17
*/
18
19
#ifdef __WINE_PE_BUILD
20
21
#include <stdarg.h>
22
#include <process.h>
23
#include "windef.h"
24
#include "winbase.h"
25
#include "wine/asm.h"
26
27
extern _PVFV __CTOR_LIST__[];
28
extern _PVFV __DTOR_LIST__[];
29
30
void __cdecl __wine_call_gcc_ctors(void)
31
{
32
ULONG_PTR n = (ULONG_PTR)__CTOR_LIST__[0], i;
33
if (n == (ULONG_PTR)-1) for (n = 0; __CTOR_LIST__[n + 1]; n++);
34
for (i = n; i >= 1; i--) __CTOR_LIST__[i]();
35
}
36
37
__ASM_SECTION_POINTER( ".section .CRT$XCB", __wine_call_gcc_ctors )
38
39
void __cdecl __wine_call_gcc_dtors(void)
40
{
41
size_t i;
42
for (i = 1; __DTOR_LIST__[i]; i++) __DTOR_LIST__[i]();
43
}
44
45
__ASM_SECTION_POINTER( ".section .CRT$XTB", __wine_call_gcc_dtors )
46
47
#endif
48
49