Commit d501ef0b authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

add --thread option to enable multithreading support

2007-07-10  Juerg Billeter  <j@bitron.ch>

	* vala/valacodecontext.vala, gobject/valaccodecompiler.vala,
	  gobject/valacodegeneratormethod.vala, compiler/valacompiler.vala:
	  add --thread option to enable multithreading support

svn path=/trunk/; revision=340
parent 931e7625
2007-07-10 Jürg Billeter <j@bitron.ch>
* vala/valacodecontext.vala, gobject/valaccodecompiler.vala,
gobject/valacodegeneratormethod.vala, compiler/valacompiler.vala:
add --thread option to enable multithreading support
2007-07-10 Jürg Billeter <j@bitron.ch> 2007-07-10 Jürg Billeter <j@bitron.ch>
* gobject/valaccodecompiler.vala: always use gobject-2.0 * gobject/valaccodecompiler.vala: always use gobject-2.0
......
...@@ -38,6 +38,7 @@ class Vala.Compiler { ...@@ -38,6 +38,7 @@ class Vala.Compiler {
static bool compile_only; static bool compile_only;
static string output; static string output;
static bool debug; static bool debug;
static bool thread;
static int optlevel; static int optlevel;
static bool disable_assert; static bool disable_assert;
static bool enable_checking; static bool enable_checking;
...@@ -55,6 +56,7 @@ class Vala.Compiler { ...@@ -55,6 +56,7 @@ class Vala.Compiler {
{ "compile", 'c', 0, OptionArg.NONE, ref compile_only, "Compile but do not link", null }, { "compile", 'c', 0, OptionArg.NONE, ref compile_only, "Compile but do not link", null },
{ "output", 'o', 0, OptionArg.FILENAME, out output, "Place output in file FILE", "FILE" }, { "output", 'o', 0, OptionArg.FILENAME, out output, "Place output in file FILE", "FILE" },
{ "debug", 'g', 0, OptionArg.NONE, ref debug, "Produce debug information", null }, { "debug", 'g', 0, OptionArg.NONE, ref debug, "Produce debug information", null },
{ "thread", 0, 0, OptionArg.NONE, ref thread, "Enable multithreading support", null },
{ "optimize", 'O', 0, OptionArg.INT, ref optlevel, "Optimization level", "OPTLEVEL" }, { "optimize", 'O', 0, OptionArg.INT, ref optlevel, "Optimization level", "OPTLEVEL" },
{ "disable-assert", 0, 0, OptionArg.NONE, ref disable_assert, "Disable assertions", null }, { "disable-assert", 0, 0, OptionArg.NONE, ref disable_assert, "Disable assertions", null },
{ "enable-checking", 0, 0, OptionArg.NONE, ref enable_checking, "Enable run-time checks", null }, { "enable-checking", 0, 0, OptionArg.NONE, ref enable_checking, "Enable run-time checks", null },
...@@ -152,6 +154,7 @@ class Vala.Compiler { ...@@ -152,6 +154,7 @@ class Vala.Compiler {
context.compile_only = compile_only; context.compile_only = compile_only;
context.output = output; context.output = output;
context.debug = debug; context.debug = debug;
context.thread = thread;
context.optlevel = optlevel; context.optlevel = optlevel;
/* default package */ /* default package */
......
...@@ -41,6 +41,9 @@ public class Vala.CCodeCompiler { ...@@ -41,6 +41,9 @@ public class Vala.CCodeCompiler {
pc += " --libs"; pc += " --libs";
} }
pc += " gobject-2.0"; pc += " gobject-2.0";
if (context.thread) {
pc += " gthread-2.0";
}
foreach (string pkg in context.get_packages ()) { foreach (string pkg in context.get_packages ()) {
pc += " " + pkg; pc += " " + pkg;
} }
......
...@@ -311,6 +311,13 @@ public class Vala.CodeGenerator { ...@@ -311,6 +311,13 @@ public class Vala.CodeGenerator {
cmain.add_parameter (new CCodeFormalParameter ("argc", "int")); cmain.add_parameter (new CCodeFormalParameter ("argc", "int"));
cmain.add_parameter (new CCodeFormalParameter ("argv", "char **")); cmain.add_parameter (new CCodeFormalParameter ("argv", "char **"));
var main_block = new CCodeBlock (); var main_block = new CCodeBlock ();
if (context.thread) {
var thread_init_call = new CCodeFunctionCall (new CCodeIdentifier ("g_thread_init"));
thread_init_call.add_argument (new CCodeConstant ("NULL"));
main_block.add_statement (new CCodeExpressionStatement (thread_init_call));
}
main_block.add_statement (new CCodeExpressionStatement (new CCodeFunctionCall (new CCodeIdentifier ("g_type_init")))); main_block.add_statement (new CCodeExpressionStatement (new CCodeFunctionCall (new CCodeIdentifier ("g_type_init"))));
var main_call = new CCodeFunctionCall (new CCodeIdentifier (function.name)); var main_call = new CCodeFunctionCall (new CCodeIdentifier (function.name));
if (args_parameter) { if (args_parameter) {
......
...@@ -74,6 +74,11 @@ public class Vala.CodeContext { ...@@ -74,6 +74,11 @@ public class Vala.CodeContext {
*/ */
public int optlevel { get; set; } public int optlevel { get; set; }
/**
* Enable multithreading support.
*/
public bool thread { get; set; }
/** /**
* Specifies the optional module initialization method. * Specifies the optional module initialization method.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment