2
$Id: initc.pp,v 1.4 2002/09/07 16:01:18 peter Exp $
3
This file is part of the Free Pascal run time library.
4
Copyright (c) 1999-2000 by Pierre Muller
6
Code to generate execution of all c functions
7
with constructors attributes
9
Based on .ctor and .dtor sections of DJGPP gcc compiler
11
See the file COPYING.FPC, included in this distribution,
12
for details about the copyright.
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
**********************************************************************}
25
{ we need to include dpmiexcp unit
26
to avoid getting troubles with _exit found both
27
in libc and in v2prt0.as PM }
32
simple_proc = procedure;
34
first_ctor : longint;external name 'djgpp_first_ctor';
35
ctor : array [0..maxlongint div sizeof(simple_proc)] of simple_proc;external name 'djgpp_first_ctor';
36
last_ctor : longint;external name 'djgpp_last_ctor';
37
first_dtor : longint;external name 'djgpp_first_dtor';
38
dtor : array [0..maxlongint div sizeof(simple_proc)] of simple_proc;external name 'djgpp_first_dtor';
39
last_dtor : longint;external name 'djgpp_last_dtor';
40
bss_count : longint;external name '___bss_count';
42
save_exit : pointer = nil;
44
procedure run_c_constructors;
47
already_done : longint = -1;
52
if already_done=bss_count then
54
already_done:=bss_count;
56
nb:=((cardinal(@last_ctor)-cardinal(@first_ctor)) div sizeof(pointer));
64
procedure run_c_destructors;
66
already_done : longint = -1;
72
if already_done=bss_count then
74
already_done:=bss_count;
76
nb:=((cardinal(last_dtor)-cardinal(first_dtor)) div sizeof(pointer));
86
If cardinal(@first_dtor)<>cardinal(@last_dtor) then
88
{ can exitproc be allready non nil here ?
89
you have to make really weird things to achieve
90
that be lets suppose it is possible !! (PM) }
92
exitproc:=@run_c_destructors;
98
Revision 1.4 2002/09/07 16:01:18 peter
99
* old logs removed and tabs fixed
101
Revision 1.3 2002/04/26 13:19:56 peter
102
* fixed too large arrays