diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2004-11-06 23:23:15 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:05:36 -0500 |
commit | 71db46ea665606384f2be1be708c74c97c9adfb2 (patch) | |
tree | 24c84e12f4fc925f3ec1e69348493d7222df1e44 /source4/build | |
parent | b012ab557b8f8a2f58dfbbe8b7818f3e6d8cf38f (diff) | |
download | samba-71db46ea665606384f2be1be708c74c97c9adfb2.tar.gz samba-71db46ea665606384f2be1be708c74c97c9adfb2.tar.bz2 samba-71db46ea665606384f2be1be708c74c97c9adfb2.zip |
r3586: Fix some of the issues with the module init functions.
Both subsystems and modules can now have init functions, which can be
specified in .mk files (INIT_FUNCTION = ...)
The build system will define :
- SUBSYSTEM_init_static_modules that calls the init functions of all statically compiled modules. Failing to load will generate an error which is not fatal
- BINARY_init_subsystems that calls the init functions (if defined) for the subsystems the binary depends on
This removes the hack with the "static bool Initialised = " and the
"lazy_init" functions
(This used to be commit 7a8244761bfdfdfb48f8264d76951ebdfbf7bd8a)
Diffstat (limited to 'source4/build')
-rw-r--r-- | source4/build/pidl/header.pm | 2 | ||||
-rw-r--r-- | source4/build/pidl/server.pm | 2 | ||||
-rw-r--r-- | source4/build/smb_build/depend.pl | 69 | ||||
-rw-r--r-- | source4/build/smb_build/public.m4 | 4 | ||||
-rw-r--r-- | source4/build/smb_build/smb_build_h.pl | 36 |
5 files changed, 64 insertions, 49 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm index 3f652bd4a1..d1eb1d1630 100644 --- a/source4/build/pidl/header.pm +++ b/source4/build/pidl/header.pm @@ -349,7 +349,7 @@ sub HeaderInterface($) $res .= "#define DCERPC_$name\_HELPSTRING $interface->{PROPERTIES}->{helpstring}\n"; $res .= "\nextern const struct dcerpc_interface_table dcerpc_table_$interface->{NAME};\n"; - $res .= "NTSTATUS dcerpc_$interface->{NAME}_init(void);\n\n"; + $res .= "NTSTATUS dcerpc_server_$interface->{NAME}_init(void);\n\n"; } foreach my $d (@{$data}) { diff --git a/source4/build/pidl/server.pm b/source4/build/pidl/server.pm index 2c590ea642..01c5adacb4 100644 --- a/source4/build/pidl/server.pm +++ b/source4/build/pidl/server.pm @@ -175,7 +175,7 @@ static BOOL $name\__op_interface_by_name(struct dcesrv_interface *iface, const c return False; } -NTSTATUS dcerpc_$name\_init(void) +NTSTATUS dcerpc_server_$name\_init(void) { NTSTATUS ret; struct dcesrv_endpoint_server ep_server; diff --git a/source4/build/smb_build/depend.pl b/source4/build/smb_build/depend.pl index a5a95eb547..a45fb725e1 100644 --- a/source4/build/smb_build/depend.pl +++ b/source4/build/smb_build/depend.pl @@ -147,6 +147,7 @@ sub _do_depend_subsystems($) foreach my $key (sort keys %{$CTX->{INPUT}{SUBSYSTEMS}}) { my $name = $CTX->{INPUT}{SUBSYSTEMS}{$key}{NAME}; my @STATIC_MODULES_LIST = (); + my @INIT_FUNCTIONS = (); # # skip when the subsystem was disabled @@ -159,28 +160,19 @@ sub _do_depend_subsystems($) # create the subsystems used OBJ_LIST # my @OBJ_LIST = (); - foreach my $elem (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{INIT_OBJ_FILES}}) { - push(@OBJ_LIST,$elem); - } - foreach my $elem (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{ADD_OBJ_FILES}}) { - push(@OBJ_LIST,$elem); - } + push (@OBJ_LIST, @{$CTX->{INPUT}{SUBSYSTEMS}{$key}{INIT_OBJ_FILES}}); + push (@OBJ_LIST, @{$CTX->{INPUT}{SUBSYSTEMS}{$key}{ADD_OBJ_FILES}}); # # create the subsystems used SUBSYSTEMS_LIST # my @SUBSYSTEMS_LIST = (); - foreach my $elem (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_SUBSYSTEMS}}) { - push(@SUBSYSTEMS_LIST,$elem); - } - + push (@SUBSYSTEMS_LIST, (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_SUBSYSTEMS}})); # # create the subsystems used LIBRARIES_LIST # my @LIBRARIES_LIST = (); - foreach my $elem (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_LIBRARIES}}) { - push(@LIBRARIES_LIST,$elem); - } + push (@LIBRARIES_LIST, @{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_LIBRARIES}}); # # now collect the info from the subsystems static modules @@ -204,35 +196,29 @@ sub _do_depend_subsystems($) # add it to the STATIC_MODULES_LIST # push(@STATIC_MODULES_LIST,$subkey); + push (@INIT_FUNCTIONS, $CTX->{INPUT}{MODULES}{$subkey}{INIT_FUNCTION}) if $CTX->{INPUT}{MODULES}{$subkey}{INIT_FUNCTION} ne ""; # # add OBJS of static modules to the subsystems used OBJ_LIST # - foreach my $elem (@{$CTX->{INPUT}{MODULES}{$subkey}{INIT_OBJ_FILES}}) { - push(@OBJ_LIST,$elem); - } - foreach my $elem (@{$CTX->{INPUT}{MODULES}{$subkey}{ADD_OBJ_FILES}}) { - push(@OBJ_LIST,$elem); - } + push (@OBJ_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{INIT_OBJ_FILES}})); + push (@OBJ_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{ADD_OBJ_FILES}})); # # add SUBSYSTEMS of static modules to the subsystems used SUBSYSTEMS_LIST # - foreach my $elem (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_SUBSYSTEMS}}) { - push(@SUBSYSTEMS_LIST,$elem); - } + push (@SUBSYSTEMS_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_SUBSYSTEMS}})); # # add LIBRARIES of static modules to the subsystems used LIBRARIES_LIST # - foreach my $elem (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_LIBRARIES}}) { - push(@LIBRARIES_LIST,$elem); - } + push (@LIBRARIES_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_LIBRARIES}})); } # # set the lists # + @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}} = @INIT_FUNCTIONS; @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{OBJ_LIST}} = @OBJ_LIST; @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{STATIC_MODULES_LIST}} = @STATIC_MODULES_LIST; @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; @@ -303,9 +289,7 @@ sub _do_depend_shared_modules($) # create the shared modules used SUBSYSTEMS_LIST # my @SUBSYSTEMS_LIST = (); - foreach my $elem (@{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_SUBSYSTEMS}}) { - push(@SUBSYSTEMS_LIST,$elem); - } + push (@SUBSYSTEMS_LIST, (@{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_SUBSYSTEMS}})); # # now try to resolve the dependencies for the shared module @@ -316,9 +300,7 @@ sub _do_depend_shared_modules($) # create the shared modules used LIBRARIES_LIST # my @LIBRARIES_LIST = (); - foreach my $elem (@{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_LIBRARIES}}) { - push(@LIBRARIES_LIST,$elem); - } + push (@LIBRARIES_LIST, @{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_LIBRARIES}}); # # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST @@ -361,9 +343,7 @@ sub _do_depend_libraries($) # create the libraries used SUBSYSTEMS_LIST # my @SUBSYSTEMS_LIST = (); - foreach my $elem (@{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_SUBSYSTEMS}}) { - push(@SUBSYSTEMS_LIST,$elem); - } + push (@SUBSYSTEMS_LIST, @{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_SUBSYSTEMS}}); # # now try to resolve the dependencies for the library @@ -374,9 +354,7 @@ sub _do_depend_libraries($) # create the libraries used LIBRARIES_LIST # my @LIBRARIES_LIST = (); - foreach my $elem (@{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_LIBRARIES}}) { - push(@LIBRARIES_LIST,$elem); - } + push (@LIBRARIES_LIST, @{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_LIBRARIES}}); # # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST @@ -419,22 +397,26 @@ sub _do_depend_binaries($) # create the binaries used SUBSYSTEMS_LIST # my @SUBSYSTEMS_LIST = (); - foreach my $elem (@{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_SUBSYSTEMS}}) { - push(@SUBSYSTEMS_LIST,$elem); - } + push (@SUBSYSTEMS_LIST, @{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_SUBSYSTEMS}}); # # now try to resolve the dependencies for the binary # @SUBSYSTEMS_LIST = _do_calc_subsystem_list($CTX, \@SUBSYSTEMS_LIST); + my @INIT_FUNCTIONS = (); + + foreach my $subkey (@SUBSYSTEMS_LIST) + { + push (@INIT_FUNCTIONS, $CTX->{INPUT}{SUBSYSTEMS}{$subkey}{INIT_FUNCTION}) if $CTX->{INPUT}{SUBSYSTEMS}{$subkey}{INIT_FUNCTION} ne ""; + + } + # # create the binaries used LIBRARIES_LIST # my @LIBRARIES_LIST = (); - foreach my $elem (@{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_LIBRARIES}}) { - push(@LIBRARIES_LIST,$elem); - } + push (@LIBRARIES_LIST, @{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_LIBRARIES}}); # # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST @@ -446,6 +428,7 @@ sub _do_depend_binaries($) # @{$CTX->{DEPEND}{BINARIES}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; @{$CTX->{DEPEND}{BINARIES}{$key}{LIBRARIES_LIST}} = @LIBRARIES_LIST; + @{$CTX->{DEPEND}{BINARIES}{$key}{INIT_FUNCTIONS}} = @INIT_FUNCTIONS; } return; diff --git a/source4/build/smb_build/public.m4 b/source4/build/smb_build/public.m4 index 479ca9685d..74e54b0a0e 100644 --- a/source4/build/smb_build/public.m4 +++ b/source4/build/smb_build/public.m4 @@ -217,6 +217,7 @@ SMB_INFO_MODULES="$SMB_INFO_MODULES @{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{ADD_OBJ_FILES}} = str2array(\"$5\"); @{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{REQUIRED_LIBRARIES}} = str2array(\"$6\"); @{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{REQUIRED_SUBSYSTEMS}} = str2array(\"$7\"); +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{INIT_FUNCTION} = \"\"; # \$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{CHOSEN_BUILD} = \"$[SMB_MODULE_][$1]\"; # End MODULE $1 @@ -255,6 +256,7 @@ SMB_INFO_MODULES="$SMB_INFO_MODULES @{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{ADD_OBJ_FILES}} = module_get_array(\"$4\", \"$1\", \"ADD_OBJ_FILES\"); @{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{REQUIRED_LIBRARIES}} = module_get_array(\"$4\", \"$1\", \"REQUIRED_LIBRARIES\"); @{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{REQUIRED_SUBSYSTEMS}} = module_get_array(\"$4\", \"$1\", \"REQUIRED_SUBSYSTEMS\"); +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{INIT_FUNCTION} = module_get_var(\"$4\", \"$1\", \"INIT_FUNCTION\"); # \$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{CHOSEN_BUILD} = \"$[SMB_MODULE_][$1]\"; # End MODULE $1 @@ -303,6 +305,7 @@ SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS \$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{NAME} = \"$1\"; @{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{INIT_OBJ_FILES}} = str2array(\"$2\"); @{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{ADD_OBJ_FILES}} = str2array(\"$3\"); +\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{INIT_FUNCTION} = \"\"; @{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{REQUIRED_LIBRARIES}} = str2array(\"$4\"); @{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{REQUIRED_SUBSYSTEMS}} = str2array(\"$5\"); # @@ -336,6 +339,7 @@ SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS @{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{ADD_OBJ_FILES}} = subsystem_get_array(\"$2\", \"$1\", \"ADD_OBJ_FILES\"); @{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{REQUIRED_LIBRARIES}} = subsystem_get_array(\"$2\", \"$1\", \"REQUIRED_LIBRARIES\"); @{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{REQUIRED_SUBSYSTEMS}} = subsystem_get_array(\"$2\", \"$1\", \"REQUIRED_SUBSYSTEMS\"); +\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{INIT_FUNCTION} = subsystem_get_var(\"$2\", \"$1\", \"INIT_FUNCTION\"); # \$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{ENABLE} = \"$[SMB_SUBSYSTEM_ENABLE_][$1]\"; \$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{NOPROTO} = \"$[SMB_SUBSYSTEM_NOPROTO_][$1]\"; diff --git a/source4/build/smb_build/smb_build_h.pl b/source4/build/smb_build/smb_build_h.pl index 59e96574bd..cd6cb29525 100644 --- a/source4/build/smb_build/smb_build_h.pl +++ b/source4/build/smb_build/smb_build_h.pl @@ -36,15 +36,40 @@ sub _prepare_smb_build_h($) # Static modules # $DEFINE->{COMMENT} = "SUBSYSTEM $NAME INIT"; - $DEFINE->{KEY} = "static_init_$name"; + $DEFINE->{KEY} = $name . "_init_static_modules"; $DEFINE->{VAL} = "do { \\\n"; - foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{STATIC_MODULES_LIST}}) { - $DEFINE->{VAL} .= "\t\t$subkey\_init(); \\\n"; + foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}}) { + $DEFINE->{VAL} .= "\t\textern NTSTATUS $subkey(void); \\\n"; + } + + foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}}) { + $DEFINE->{VAL} .= "\t\t$subkey(); \\\n"; } $DEFINE->{VAL} .= "\t} while(0)"; push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE); + } + # + # loop over all binaries + # + foreach my $key (sort keys %{$CTX->{DEPEND}{BINARIES}}) { + my $NAME = $CTX->{INPUT}{BINARIES}{$key}{NAME}; + my $DEFINE = (); + my $name = lc($NAME); + + # + # Static modules + # + $DEFINE->{COMMENT} = "BINARY $NAME INIT"; + $DEFINE->{KEY} = $name . "_init_subsystems"; + $DEFINE->{VAL} = "do { \\\n"; + foreach my $subkey (@{$CTX->{DEPEND}{BINARIES}{$key}{INIT_FUNCTIONS}}) { + $DEFINE->{VAL} .= "\t\tif (NT_STATUS_IS_ERR($subkey())) exit(1); \\\n"; + } + $DEFINE->{VAL} .= "\t} while(0)"; + + push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE); } # @@ -54,10 +79,13 @@ sub _prepare_smb_build_h($) next if ($CTX->{INPUT}{MODULES}{$key}{BUILD} ne "SHARED"); my $name = $CTX->{INPUT}{MODULES}{$key}{NAME}; + my $func = $CTX->{INPUT}{MODULES}{$key}{INIT_FUNCTION}; + next if $func eq ""; + my $DEFINE = (); $DEFINE->{COMMENT} = "$name is built shared"; - $DEFINE->{KEY} = "$name\_init"; + $DEFINE->{KEY} = $func; $DEFINE->{VAL} = "init_module"; push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE); |