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
] 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
] 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.1 2002/02/19 08:25:11 sasu
101 Revision
1.1 2000/07/13 06:30:38 michael
104 Revision
1.6 2000/02/09 16:59:29 peter
107 Revision
1.5 2000/01/09 00:35:17 pierre
108 * initc now loads dpmiexcp unit to avoid linker problems
110 Revision
1.4 2000/01/07 16:41:32 daniel
113 Revision
1.3 2000/01/07 16:32:23 daniel
114 * copyright
2000 added