zsh-workers
 help / color / mirror / code / Atom feed
* Re: Can't load module (when the module is static)
@ 1999-11-24  8:38 Sven Wischnowsky
  1999-11-24 10:33 ` Zefram
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 1999-11-24  8:38 UTC (permalink / raw)
  To: zsh-workers


Ollivier Robert wrote:

> Has anyone seen this in very recent zsh (taken from anoncvs):
> 
> 402 [17:23] roberto@sidhe:/build/zsh> Src/zsh
> compinit: failed to load module: parameter [109]
> 401 [17:23] roberto@sidhe:/build/zsh> echo $ZSH_VERSION 
> 3.1.6-pws-9
> 402 [17:24] roberto@sidhe:/build/zsh> cat Src/mymods.conf 
> rlimits
> zle
> complete
> compctl
> stat
> complist
> computil
> parameter
> zleparameter
> 403 [17:24] roberto@sidhe:/build/zsh> ldd Src/zsh
> Src/zsh:
>         libtermcap.so.2 => /usr/lib/libtermcap.so.2 (0x280e4000)
>         libm.so.2 => /usr/lib/libm.so.2 (0x280e9000)
>         libc.so.3 => /usr/lib/libc.so.3 (0x28104000)
> 
> FreeBSD sidhe 3.3-STABLE FreeBSD 3.3-STABLE #0: Thu Nov 11 16:32:24 CET 1999     roberto@sidhe:/src/src/sys/compile/SIDHE  i386
> 
> I also got another problem (when I leave out the two *parameter) modules: I 
> get a read-only variable with the same numer [109]...

Did you all know that it is possible to try to load a linked-in
module? That's what's causing these bugs.

The patch below changed load_module() to test if the requested module
is linked-in.

This is almost certainly not the final solution, though, and it
reminded me of Bart's request for handling linked-in modules a bit
more like loaded ones (at least that's how I understood it). Well,
here is one more reason to do that. I.e. we could build module structs
and hash table entries for the linked-in modules, too. Then we could
maybe get rid of the -e option to zmodload. Maybe? I mean that
zmodload without arguments would just report linked-in modules, too.

But the really hard question is how we should get at the delayed
initialization Bart asked for. Hm. Create all the autoload-structs for 
builtins/parameters/etc, not make the linked-in modules visible as
described above immediatly, but store them only in the bltin-list we
have now and make load_module() only call the init funcs. We would
then need to change the shell scripts to generate the autoload-stuff
for bltinmods.list even for linked-in modules.

And what happens to all this in a shell without dynamic loading?

Bye
 Sven

diff -u oldsrc/module.c Src/module.c
--- oldsrc/module.c	Wed Nov 24 09:03:37 1999
+++ Src/module.c	Wed Nov 24 09:24:40 1999
@@ -550,13 +550,16 @@
 #endif /* !AIXDYNAMIC */
 
 /**/
-Module
+int
 load_module(char const *name)
 {
     Module m;
     void *handle;
     LinkNode node, n;
 
+    if (module_linked(name))
+	return 1;
+
     if (!(node = find_module(name))) {
 	if (!(handle = do_load_module(name)))
 	    return NULL;
@@ -576,36 +579,36 @@
 	    return NULL;
 	}
 	m->flags &= ~MOD_SETUP;
-	return m;
+	return 1;
     } 
     m = (Module) getdata(node);
     if (m->flags & MOD_SETUP)
-	return m;
+	return 1;
     if (m->flags & MOD_UNLOAD)
 	m->flags &= ~MOD_UNLOAD;
     else if (m->handle)
-	return m;
+	return 1;
     if (m->flags & MOD_BUSY) {
 	zerr("circular dependencies for module %s", name, 0);
-	return NULL;
+	return 0;
     }
     m->flags |= MOD_BUSY;
     if (m->deps)
 	for (n = firstnode(m->deps); n; incnode(n))
 	    if (!load_module((char *) getdata(n))) {
 		m->flags &= ~MOD_BUSY;
-		return NULL;
+		return 0;
 	    }
     m->flags &= ~MOD_BUSY;
     if (!m->handle) {
 	if (!(m->handle = do_load_module(name)))
-	    return NULL;
+	    return 0;
 	m->flags |= MOD_SETUP;
 	if (setup_module(m)) {
 	    finish_module(m->handle);
 	    m->handle = NULL;
 	    m->flags &= ~MOD_SETUP;
-	    return NULL;
+	    return 0;
 	}
     }
     m->flags |= MOD_SETUP;
@@ -613,10 +616,10 @@
 	finish_module(m->handle);
 	m->handle = NULL;
 	m->flags &= ~MOD_SETUP;
-	return NULL;
+	return 0;
     }
     m->flags &= ~MOD_SETUP;
-    return m;
+    return 1;
 }
 
 /* This ensures that the module with the name given as the second argument
@@ -650,7 +653,7 @@
 	zwarnnam(nam, "%s: restricted", module, 0);
 	return 0;
     } else
-	return !!load_module(module);
+	return load_module(module);
 
     return 1;
 }

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can't load module (when the module is static)
  1999-11-24  8:38 Can't load module (when the module is static) Sven Wischnowsky
@ 1999-11-24 10:33 ` Zefram
  0 siblings, 0 replies; 4+ messages in thread
From: Zefram @ 1999-11-24 10:33 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-workers

Sven Wischnowsky wrote:
>This is almost certainly not the final solution, though, and it
>reminded me of Bart's request for handling linked-in modules a bit
>more like loaded ones (at least that's how I understood it). Well,
>here is one more reason to do that. I.e. we could build module structs
>and hash table entries for the linked-in modules, too. Then we could
>maybe get rid of the -e option to zmodload. Maybe? I mean that
>zmodload without arguments would just report linked-in modules, too.

Yes, this should be done.  Linked-in modules should appear exactly the
same as external modules, to the user.  The only differences are that
(1) libdl isn't used to load them and (2) they're automatically loaded
on startup.  That second thing could actually be separated out: we have an
arbitrary list of modules to load on startup, like the list of autoloaded
builtins/parameters/etc., and there's no requirement that the modules
so loaded be linked in.  Only the lowest level loading code needs to know.

Incidentally, this scheme would allow module use on systems that don't do
dynamic loading.  In this case modules *have* to be linked in, because
the dynamic loading method isn't available.

Thst's how I always wanted it to work.

-zefram


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can't load module (when the module is static)
  1999-11-23 16:29 Ollivier Robert
@ 1999-11-24 17:10 ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 1999-11-24 17:10 UTC (permalink / raw)
  To: Ollivier Robert, zsh-workers

On Nov 23,  5:29pm, Ollivier Robert wrote:
} Subject: Can't load module (when the module is static)
}
} Has anyone seen this in very recent zsh (taken from anoncvs):
} 
} 402 [17:23] roberto@sidhe:/build/zsh> Src/zsh
} compinit: failed to load module: parameter [109]

That was fixed by 8512, which Tanaka only recently added to his repository.
Of course, it's moot now that Sven's provided 8770.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Can't load module (when the module is static)
@ 1999-11-23 16:29 Ollivier Robert
  1999-11-24 17:10 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Ollivier Robert @ 1999-11-23 16:29 UTC (permalink / raw)
  To: zsh-workers

Has anyone seen this in very recent zsh (taken from anoncvs):

402 [17:23] roberto@sidhe:/build/zsh> Src/zsh
compinit: failed to load module: parameter [109]
401 [17:23] roberto@sidhe:/build/zsh> echo $ZSH_VERSION 
3.1.6-pws-9
402 [17:24] roberto@sidhe:/build/zsh> cat Src/mymods.conf 
rlimits
zle
complete
compctl
stat
complist
computil
parameter
zleparameter
403 [17:24] roberto@sidhe:/build/zsh> ldd Src/zsh
Src/zsh:
        libtermcap.so.2 => /usr/lib/libtermcap.so.2 (0x280e4000)
        libm.so.2 => /usr/lib/libm.so.2 (0x280e9000)
        libc.so.3 => /usr/lib/libc.so.3 (0x28104000)

FreeBSD sidhe 3.3-STABLE FreeBSD 3.3-STABLE #0: Thu Nov 11 16:32:24 CET 1999     roberto@sidhe:/src/src/sys/compile/SIDHE  i386

I also got another problem (when I leave out the two *parameter) modules: I 
get a read-only variable with the same numer [109]...
-- 
Ollivier ROBERT -=- Eurocontrol EEC/TEC -=- roberto@eurocontrol.fr
The Postman hits! The Postman hits! You have new mail.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-11-24 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-24  8:38 Can't load module (when the module is static) Sven Wischnowsky
1999-11-24 10:33 ` Zefram
  -- strict thread matches above, loose matches on Subject: below --
1999-11-23 16:29 Ollivier Robert
1999-11-24 17:10 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).