home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / smalltal / 2788 < prev    next >
Encoding:
Text File  |  1993-01-22  |  3.4 KB  |  78 lines

  1. Newsgroups: comp.lang.smalltalk
  2. Path: sparky!uunet!psinntp!sunic!ericom!eua.ericsson.se!euas62c37!konnbt
  3. From: konnbt@eua.ericsson.se (Niklas Bjornerstedt)
  4. Subject: ExternalInterface in ST80 
  5. Message-ID: <1993Jan22.080626.9060@eua.ericsson.se>
  6. Sender: news@eua.ericsson.se
  7. Nntp-Posting-Host: euas62c37.eua.ericsson.se
  8. Reply-To: konnbt@eua.ericsson.se
  9. Organization: Enator Functional Systems, Stockholm, Sweden
  10. Date: Fri, 22 Jan 1993 08:06:26 GMT
  11. Lines: 65
  12.  
  13. In working with the C interface in Smalltalk-80 on a SUN I've stumbled on 
  14. a very subtle bug (feature?). This bug applies to Smalltalk on UNIX platforms.
  15.  
  16. When you create an interface to a C-library you have to supply the name
  17. of the library and a list of paths to where the library should be sought.
  18. This would not work if you ship an image to a site that has its libraries
  19. in a different place. To solve this ObjectMemory sends the update aspect #earlySystemInstallation to the ExternalInterface class on system startup.
  20.  
  21. The ExternalInterface in turn sends (among other things) 
  22. installLibraryDirectoriesOn: to itself. At this point it would be possible
  23. on a UNIX platform to get an environment variable from the CEnvironment class.
  24. On a SUN the environment variable LD_LIBRARY_PATH stores the path names to
  25. a number of library directories.
  26.  
  27. But this wouldn't work! 
  28.  
  29. The reason is that CEnvironment also updates itself on system startup. It 
  30. regenerates its dictionary of environment variables when it receives the
  31. update aspect #returnFromSnapshot. The problem is that ExternalInterface
  32. receives #earlySystemInstallation before CEnvironment receives 
  33. #returnFromSnapshot. 
  34.  
  35. The result of this is that ExternalInterface would end up getting an old
  36. value for LD_LIBRARY_PATH from CEnvironment. 
  37.  
  38. The following code fixes this problem. The reason I use Smalltalk at: is 
  39. that I don't want a dependancy between ExternalInterface and CEnvironment.
  40.  
  41. 'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992
  42. ENVY/Developer R1.40 of 21 August 1992 on 22 January 1993 at 8:59:54 am'!
  43.  
  44.  
  45.  
  46. !ExternalInterface class methodsFor: 'initialize-release'!
  47.  
  48. install
  49.         "Inform all dependent classes of a return from snapshot."
  50.         "ExternalInterface install"
  51.  
  52.         | platformString platformArray platformID cEnv |
  53.  
  54.         "21 January 1993 - Added initialization of CEnvironment since some of the receiver's subclasses need environment variables that might have changed since the last snapshot. Remove CEnvironment from ObjectMemory since we don't want CEnvironment to initialize itself a second time"
  55.         cEnv := Smalltalk at: #CEnvironment ifAbsent: [].
  56.         cEnv = nil
  57.                 ifFalse: 
  58.                         [cEnv install.
  59.                         cEnv checkEnvironment.
  60.                         (ObjectMemory dependents includes: cEnv)
  61.                                 ifTrue: [ObjectMemory removeDependent: cEnv]].
  62.  
  63.         platformString := OSHandle informVM.
  64.         platformID := (platformString copyUpTo: Character space) asSymbol.
  65.         platformArray := Array with: platformID with: platformString.
  66.         self dependentClasses do: [:dependentClass | dependentClass installOn: platformArray].
  67.         self installLibraryDirectoriesOn: platformArray.
  68.         self installSubclassesOn: platformArray.
  69.         CurrentPlatform := platformArray! !
  70.  
  71.  
  72. _____________________________
  73.  
  74. Niklas Bjornerstedt
  75. Enator Functional Systems
  76. Email: konnbt@eua.ericsson.se
  77.  
  78.