[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/cscc/c c_function.c,1.20,1.21 c_functio
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[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 |
Date: |
Thu, 26 Jun 2003 23:56:36 -0400 |
Update of /cvsroot/dotgnu-pnet/pnet/cscc/c
In directory subversions:/tmp/cvs-serv29077/cscc/c
Modified Files:
c_function.c c_function.h c_grammar.y
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: c_function.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_function.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** c_function.c 25 Jun 2003 01:27:16 -0000 1.20
--- c_function.c 27 Jun 2003 03:56:33 -0000 1.21
***************
*** 380,384 ****
}
! void CFunctionOutput(ILGenInfo *info, ILMethod *method, ILNode *body)
{
FILE *stream = info->asmOutput;
--- 380,385 ----
}
! void CFunctionOutput(ILGenInfo *info, ILMethod *method, ILNode *body,
! int initGlobalVars)
{
FILE *stream = info->asmOutput;
***************
*** 434,437 ****
--- 435,448 ----
returnMachineType = ILTypeToMachineType(info->returnType);
+ /* Force initialization of global variables if we were
+ called from C# code and ".init" hasn't been run yet */
+ if(initGlobalVars)
+ {
+ fputs("\tldtoken 'init-on-demand'\n", stream);
+ fputs("\tcall\tvoid [.library]System.Runtime.CompilerServices"
+ ".RuntimeHelpers::RunClassConstructor"
+ "(valuetype
[.library]System.RuntimeTypeHandle)\n", stream);
+ }
+
/* Create the "setjmp" header if necessary */
if(numSetJmpRefs > 0)
***************
*** 627,631 ****
/* Output the initializer */
! CFunctionOutput(info, method, list);
}
--- 638,642 ----
/* Output the initializer */
! CFunctionOutput(info, method, list, 0);
}
Index: c_function.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_function.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** c_function.h 19 Aug 2002 23:56:28 -0000 1.5
--- c_function.h 27 Jun 2003 03:56:33 -0000 1.6
***************
*** 41,45 ****
* Output a function that has been fully parsed.
*/
! void CFunctionOutput(ILGenInfo *info, ILMethod *method, ILNode *body);
/*
--- 41,46 ----
* Output a function that has been fully parsed.
*/
! void CFunctionOutput(ILGenInfo *info, ILMethod *method, ILNode *body,
! int initGlobalVars);
/*
Index: c_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_grammar.y,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -r1.52 -r1.53
*** c_grammar.y 27 Jun 2003 02:04:47 -0000 1.52
--- c_grammar.y 27 Jun 2003 03:56:33 -0000 1.53
***************
*** 37,40 ****
--- 37,41 ----
static ILInt32 currentEnumValue = 0;
static ILNode *initializers = 0;
+ static int usedGlobalVar = 0;
/*
***************
*** 1170,1173 ****
--- 1171,1175 ----
$$ =
ILNode_CGlobalVar_create
($1, type,
decayedType);
+ usedGlobalVar = 1;
}
break;
***************
*** 2725,2728 ****
--- 2727,2733 ----
/* Set the new function name */
functionName = $1.name;
+
+ /* No global variables in use yet */
+ usedGlobalVar = 0;
}
FunctionBody '}' {
***************
*** 2740,2744 ****
/* Output the finished function */
! CFunctionOutput(&CCCodeGen, $<methodInfo>4,
body);
/* Reset the function name */
--- 2745,2750 ----
/* Output the finished function */
! CFunctionOutput(&CCCodeGen, $<methodInfo>4,
body,
! usedGlobalVar);
/* Reset the function name */
***************
*** 2780,2783 ****
--- 2786,2792 ----
/* Set the new function name */
functionName = $2.name;
+
+ /* No global variables in use yet */
+ usedGlobalVar = 0;
}
FunctionBody '}' {
***************
*** 2795,2799 ****
/* Output the finished function */
! CFunctionOutput(&CCCodeGen, $<methodInfo>5,
body);
/* Reset the function name */
--- 2804,2809 ----
/* Output the finished function */
! CFunctionOutput(&CCCodeGen, $<methodInfo>5,
body,
! usedGlobalVar);
/* Reset the function name */
[Prev in Thread] |
Current Thread |
[Next in 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,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnet/cscc/c c_ainit.tc,1.2,1.3 c_defs.tc,1.21,1.22 c_grammar.y,1.51,1.52 c_oper.tc,1.29,1.30
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnet/ilalink link_class.c,1.12,1.13 link_init.c,1.1,1.2
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnet/cscc/c c_ainit.tc,1.2,1.3 c_defs.tc,1.21,1.22 c_grammar.y,1.51,1.52 c_oper.tc,1.29,1.30
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnet/ilalink link_class.c,1.12,1.13 link_init.c,1.1,1.2
- Index(es):