[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/ilalink link_class.c,1.12,1.13 link_ini
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/ilalink link_class.c,1.12,1.13 link_init.c,1.1,1.2 |
Date: |
Thu, 26 Jun 2003 23:56:36 -0400 |
Update of /cvsroot/dotgnu-pnet/pnet/ilalink
In directory subversions:/tmp/cvs-serv29077/ilalink
Modified Files:
link_class.c link_init.c
Log Message:
Force the ".init" function to be called when a C library is used from a C#
application which doesn't use the crt0 process.
Index: link_class.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilalink/link_class.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** link_class.c 28 Feb 2003 00:04:20 -0000 1.12
--- link_class.c 27 Jun 2003 03:56:33 -0000 1.13
***************
*** 366,369 ****
--- 366,375 ----
const char *name = ILClass_Name(classInfo);
char *newName;
+ if(!strcmp(name, "init-on-demand"))
+ {
+ /* This class must not be renamed - there should be
+ only one instance of this name per link process */
+ return 0;
+ }
sprintf(buf, "-%lu-%lu", (unsigned long)(linker->imageNum),
(unsigned long)(ILClass_Token(classInfo) &
~IL_META_TOKEN_MASK));
Index: link_init.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilalink/link_init.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** link_init.c 25 Jun 2003 05:30:57 -0000 1.1
--- link_init.c 27 Jun 2003 03:56:33 -0000 1.2
***************
*** 461,464 ****
--- 461,502 ----
fputs("L6:\n", stream);
fputs("\tret\n", stream);
+ fputs("}\n\n", stream);
+
+ /* Generate the "init-on-demand" class, which is used to force
+ initialization of global variables when a C library is used
+ from C# code and the global initializer wasn't called by crt0 */
+ fputs(".class private sealed beforefieldinit 'init-on-demand' extends "
+ "[.library]System.Object\n", stream);
+ fputs("{\n", stream);
+ fputs("\t.method private static hidebysig specialname rtspecialname "
+ "void .cctor() cil managed\n", stream);
+ fputs("\t{\n", stream);
+ fputs("\t\t.maxstack 2\n", stream);
+ fputs("\t\t.locals (class [.library]System.Type)\n", stream);
+ fputs("\t\tldtoken 'init-count'\n", stream);
+ fputs("\t\tcall class [.library]System.Type [.library]System.Type::"
+ "GetTypeFromHandle(valuetype
[.library]System.RuntimeTypeHandle)\n",
+ stream);
+ fputs("\t\tdup\n", stream);
+ fputs("\t\tstloc.0\n", stream);
+ fputs("\t\tcall void [.library]System.Threading.Monitor::Enter"
+ "(class [.library]System.Object)\n", stream);
+ fputs("\t\t.try {\n", stream);
+ fputs("\t\t\tldsfld int32 'init-count'::'count'\n", stream);
+ fputs("\t\t\tbrtrue L7\n", stream);
+ fputs("\t\t\tleave L8\n", stream);
+ fputs("\t\tL7:\n", stream);
+ fputs("\t\t\tleave L9\n", stream);
+ fputs("\t\t} finally {\n", stream);
+ fputs("\t\t\tldloc.0\n", stream);
+ fputs("\t\t\tcall void [.library]System.Threading.Monitor::Exit"
+ "(class [.library]System.Object)\n", stream);
+ fputs("\t\t\tendfinally\n", stream);
+ fputs("\t\t}\n", stream);
+ fputs("\tL8:\n", stream);
+ fputs("\t\tcall void '.init'()\n", stream);
+ fputs("\tL9:\n", stream);
+ fputs("\t\tret\n", stream);
+ fputs("\t}\n", stream);
fputs("}\n", stream);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/ilalink link_class.c,1.12,1.13 link_init.c,1.1,1.2,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnet/cscc/c c_function.c,1.20,1.21 c_function.h,1.5,1.6 c_grammar.y,1.52,1.53
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnet ChangeLog,1.2474,1.2475
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnet/cscc/c c_function.c,1.20,1.21 c_function.h,1.5,1.6 c_grammar.y,1.52,1.53
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnet ChangeLog,1.2474,1.2475
- Index(es):