@Hans_
Apparently that's quite ok with a shared object, because each process that links to the shared object has it's own local var space. To me, it just looks like a thread unsafe time-bomb waiting to happen. It's bad coding practise. What happens if you use such code from multiple threads within the same process?
Depends. If you're on unixy system, it works out of the box. On MorphOS you can adjust the code or use relskeleton library model.
In many cases you're not writing the whole library from scratch. Quite a lot of lib code assumes that it is not shared between processes, that there is a separate memory space.
If you're writing your own code, you obviously can do the thing properly from the beginning, but often this is not the case. You can use the MorphOS relskeleton library model easier than actually rewriting tons of unfamiliar code.
I like the fact that I can decide what is global and what is local to a library opener.
This can be done easily with the relskeleton model. By default all static variables are local. To get "real" global variable just place it to section other than .sdata:
int reallyglobal __attribute__ ((section (".realsdata")));
Also, another neat feature of the thing is that you can have a "init-once" variables, that is that any local variable can be preset at LibInit, and it will be copied to all children-libraries. This is quite nice for library bases and such.
Really, I think that they created shared-object loading facilities so that you can just take some cross-platform source code, type make, and build the app
Well, you don't really get very well functioning stuff that way. And what happened to ixemul anyway? It actually works amazingly well on many such occasions (and you hardly ever really absolutely need shared-object stuff in quick compiles anyway).
without having to write library frameworks (a lot of extra work).
Actually the relskeleton framework is quite simple. Also, it doesn't involve changing millions places in the sourcecode (However, naturally some sources require more work than others). I'll much rather take proper library that doesn't gobble tons of memory and resources just because coders were lazy and/or incompetent.
It's also less of a problem if someone adds/removes functions to/from the shared-object (I think that removing functions from a library after release is a bad idea, you're breaking compatibility).
Huh. You never remove functions or insert new ones before the old. You only declare them obsolete, and wrap the old API so that it can use the services of the new, thus keeping binary compatibility. If the API changes completely, just create a new library (change the name) instead. This should be quite obvious.
Then there's the issue of some shared-objects wanting to link to external global variables. I can't think of any clean way of doing that with a library (I also don't think that a library should have external dependencies like that).
I'm not quite sure what you mean by that, but assuming it's just having some "really" global variable: the section trick does the job just fine, if you really must. If you just need some variable from other loadable component, you can do this quite easily too. There are various way to do this, for example fields in public library possize, or some function to return the variable pointer.
And finally: This relskeleton stuff is nothing magic, it's actually old news. Even SAS/C did it decades ago already.
I frankly don't understand why OS4 can't have the same.