Skip to content
Tcl Source Code History Of Ticket 219180
Login

History Of Ticket 219180

Artifacts Associated With Ticket 219180

  1. Ticket change [39fb677d72] (rid 112483) by hobbs on 2000-10-26 05:02:55:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 2113 RFE
      Version: 8.1
      SubmitDate: '1999-05-20'
      LastModified: '2000-04-03'
      Severity: MED
      Status: Assigned
      Submitter: pat
      ChangedBy: hobbs
      OS: Windows 95
      Machine: X86
      FixedDate: '2000-10-25'
      ClosedDate: '2000-10-25'
      
      
      Name:
      Jan Nijtmans
      
      Comments:
      This feature is already supplied by the plus-patches for Tcl7.6 and
          higher. It is duplicated in Img and Trf, in order to make those two
          extensions as independant as possible from the plus-patches. If
          those functions were provided in the stub table that would make
          the build process of Img and Trf a lot easier, a valuable
          addition to the TEA-summit.
      
          I have compatibility functions for AIX, ULTRIX, Macintosh, OSF
          HP-UX and the other UNIX variants which support dynamical loading
          as well. For now, I restrict this submission for Windows only,
          in order to simplify the evaluation process by Scriptics. All
          other functions can be found in Img 1.2 and in Trf 1.6, in the
          /compat/ directory. For UNIX, things are a little bit more
          complicated, because the configure script has the task to find
          out which one should be used.
      
          Because system libraries normally only use ASCII characters in
          their name, there is no need for extra precautions regarding
          UTF support. Therefore this patch should work for Tcl8.0.6
          as well.
      
      DesiredBehavior:
      Currently, extensions like Img, Trf, dllhelper and possibly
          others, which need to load other system dll's or shared
          libraries, only have access to the dlopen(), dlclose(), dlsym()
          and dlerror() functions in UNIX.
      
          It would be a lot easier if Tcl provided those functions,
          as compatibility functions in the stub table. Then extensions
          don't have to duplicate the trouble of finding out how
          dynamical loading should be done on each platform.
      
          tclLoadWin.c should be compiled with -DUSE_TCL_STUBS and
          -DSTATIC_BUILD (in order to prevent that the symbols are
          exported), and added to the stub library (as done in
          makefile.vc).
      
      Patch:
      *** win/makefile.vc.origThu May 20 20:13:48 1999
      --- win/makefile.vcThu May 20 20:16:44 1999
      ***************
      *** 206,211 ****
      --- 206,212 ----
        $(TMPDIR)\tclWinTime.obj 
      
        TCLSTUBOBJS = $(TMPDIR)\tclStubLib.obj  + $(TMPDIR)\tclLoadWin.obj
      
        cc32= "$(TOOLS32)\bin\cl.exe"
        link32= "$(TOOLS32)\bin\link.exe"
      ***************
      *** 531,536 ****
      --- 532,539 ----
        $(TMPDIR)\tclStubLib.obj : $(GENERICDIR)\tclStubLib.c
        $(cc32) $(TCL_CFLAGS) -DSTATIC_BUILD -Fo$@ $?
      
      + $(TMPDIR)\tclLoadWin.obj : $(WINDIR)\tclLoadWin.c
      + $(cc32) $(TCL_CFLAGS) -DSTATIC_BUILD -DUSE_TCL_STUBS -Fo$@ $?
      
        # Dedependency rules
      
      *** win/tclLoadWin.c.origThu May 20 20:03:36 1999
      --- win/tclLoadWin.cThu May 20 20:23:33 1999
      ***************
      *** 0 ****
      --- 1,195 ----
      + /* 
      +  * tclLoadWin.c --
      +  *
      +  *This procedure provides a version of dlopen() that
      +  *works with the Windows "LoadLibrary" and "GetProcAddress"
      +  *API for dynamic loading.
      +  *
      +  */
      + 
      + #include <windows.h>
      + #include "tclWinInt.h"
      + #include "compat/dlfcn.h"
      + 
      + typedef struct LibraryList {
      +     HINSTANCE handle;
      +     struct LibraryList *nextPtr;
      + } LibraryList;
      + 
      + static LibraryList *libraryList = NULL;/* List of currently loaded DLL's.  */
      + 
      + /*
      +  * Declarations for functions that are only used in this file.
      +  */
      + 
      + static void UnloadLibraries _ANSI_ARGS_((ClientData clientData));
      + 
      + 
      + /*
      +  *----------------------------------------------------------------------
      +  *
      +  * dlopen --
      +  *
      +  *This function is an alternative for the functions
      +  *TclWinLoadLibrary and TclWinGetTclInstance.  It is
      +  *responsible for adding library handles to the library list so
      +  *the libraries can be freed when tcl.dll is unloaded.
      +  *
      +  * Results:
      +  *Returns the handle of the newly loaded library, or NULL on
      +  *failure. If path is NULL, the global library instance handle
      +  *is returned.
      +  *
      +  * Side effects:
      +  *Loads the specified library into the process.
      +  *
      +  *----------------------------------------------------------------------
      +  */
      + 
      + VOID *dlopen(path, mode)
      +     CONST char *path;
      +     int mode;
      + {
      +     VOID *handle;
      +     LibraryList *ptr;
      +     static int initialized = 0;
      + 
      +     if (!initialized) {
      + initialized = 1;
      + Tcl_CreateExitHandler((Tcl_ExitProc *) UnloadLibraries,
      +     (ClientData) &libraryList);
      +     }
      +     handle = (VOID *) LoadLibrary(path);
      +     if (handle != NULL) {
      +     ptr = (LibraryList*) ckalloc(sizeof(LibraryList));
      +     ptr->handle = (HINSTANCE) handle;
      +     ptr->nextPtr = libraryList;
      +     libraryList = ptr;
      +     }
      +     return handle;
      + }
      + 
      + 
      + /*
      +  *----------------------------------------------------------------------
      +  *
      +  * dlclose --
      +  *
      +  *This function is an alternative for the function
      +  *FreeLibrary.  It is responsible for removing library
      +  *handles from the library list and remove the dll
      +  *from memory.
      +  *
      +  * Results:
      +  *-1 on error, 0 on success.
      +  *
      +  * Side effects:
      +  *Removes the specified library from the process.
      +  *
      +  *----------------------------------------------------------------------
      +  */
      + 
      + int
      + dlclose(handle)
      +     VOID *handle;
      + {
      +     LibraryList *ptr, *prevPtr;
      + 
      +     ptr = libraryList; prevPtr = NULL;
      +     while (ptr != NULL) {
      + if (ptr->handle == (HINSTANCE) handle) {
      +     FreeLibrary((HINSTANCE) handle);
      +     if (prevPtr) {
      + prevPtr->nextPtr = ptr->nextPtr;
      +     } else {
      + libraryList = ptr->nextPtr;
      +     }
      +     ckfree((char *) ptr);
      +     return 0;
      + }
      + prevPtr = ptr;
      + ptr = ptr->nextPtr;
      +     }
      +     return -1;
      + }
      + 
      + /*
      +  *----------------------------------------------------------------------
      +  *
      +  * dlsym --
      +  *
      +  *This function is an alternative for the system function
      +  *GetProcAddress. It returns the address of a
      +  *symbol, give the handle returned by dlopen().
      +  *
      +  * Results:
      +  *Returns the address of the symbol in the dll.
      +  *
      +  * Side effects:
      +  *None.
      +  *
      +  *----------------------------------------------------------------------
      +  */
      + 
      + VOID *dlsym(handle, symbol)
      +     VOID *handle;
      +     CONST char *symbol;
      + {
      +     return (VOID *) GetProcAddress((HINSTANCE) handle, symbol);
      + }
      + 
      + 
      + /*
      +  *----------------------------------------------------------------------
      +  *
      +  * dlerror --
      +  *
      +  *This function returns a string describing the error which
      +  *occurred in dlopen().
      +  *
      +  * Results:
      +  *Returns an error message.
      +  *
      +  * Side effects:
      +  *errno is set.
      +  *
      +  *----------------------------------------------------------------------
      +  */
      + 
      + char *
      + dlerror()
      + {
      +     TclWinConvertError(GetLastError());
      +     return Tcl_ErrnoMsg(Tcl_GetErrno());
      + }
      + 
      + /*
      +  *----------------------------------------------------------------------
      +  *
      +  * UnloadLibraries --
      +  *
      +  *Frees any dynamically allocated libraries loaded by Tcl.
      +  *
      +  * Results:
      +  *None.
      +  *
      +  * Side effects:
      +  *Frees the libraries on the library list as well as the list.
      +  *
      +  *----------------------------------------------------------------------
      +  */
      + 
      + static void
      + UnloadLibraries(clientData)
      +     ClientData clientData;
      + {
      +     LibraryList *ptr;
      +     LibraryList *list = *((LibraryList **) clientData);
      + 
      +     while (list != NULL) {
      + FreeLibrary(list->handle);
      + ptr = list->nextPtr;
      + ckfree((char *) list);
      + list = ptr;
      +     }
      + }
      
      PatchFiles:
      win/makefile.vc win/tclLoadWin.c (new file)
      
      
      
      I guess the purpose is to allow extensions that want to do their
      own dl'ing of libraries to just use dlopen... 
      -- 04/03/2000 hobbs
      
    4. foundin initialized to: "obsolete: 8.1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "hobbs"
    9. subsystem initialized to: "75. Tutorial"
    10. title initialized to:
      DL enhancement for extensions (dl* compat functions)
      
    11. type initialized to: "Patch"
  2. Ticket change [74b77819e5] (rid 105256) by dgp on 2001-04-05 06:52:46:

    1. subsystem changed to: "53. Configuration and Build Tools"
  3. Ticket change [101ade4a56] (rid 94913) by hobbs on 2001-08-02 08:46:30:

    1. foundin changed to: "None"
    2. subsystem changed to: "None"
  4. Ticket change [a95493ee7c] (rid 99134) by andreas_kupries on 2001-08-25 00:40:47:

    1. assignee changed to: "hobbs"
    2. icomment:
      Logged In: YES 
      user_id=75003
      
      Yes, in a portable way ...
      Something for 8.4, or 9.0 ?
      TIP required ?
      
      
      
    3. login: "andreas_kupries"
    4. mimetype: "text/plain"
    5. subsystem changed to: "40. Dynamic Loading"
    6. username: "andreas_kupries"
  5. Ticket change [c9a65cc61c] (rid 122325) by vincentdarley on 2001-08-29 23:08:54:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      This looks rather like something which could be 
      incorporated into the vfs overhaul.  Perhaps Jan would like 
      to see how it would fit in?  Certainly it would be a shame 
      if 'load' and Tcl_FSLoadFile work from a Vfs, but a 
      new 'dlopen' doesn't.
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. username: "vincentdarley"
  6. Ticket change [f0273948cb] (rid 109138) by dkf on 2007-03-19 01:28:39:

    1. is_private changed to: "1"
    2. priority changed to: "8"
  7. Ticket change [235f5b184b] (rid 130916) by hobbs on 2007-03-23 06:46:21:

    1. assignee changed to: "nobody"
    2. closedate changed to: "2007-03-22T23:46:21"
    3. closer changed to: "hobbs"
    4. priority changed to: "4"
    5. status changed to: "Deleted"
  8. Ticket change [2659ade6f7] (rid 88328) by nobody on 2007-03-23 06:47:31:

    1. icomment:
      Logged In: NO 
      
      test of non logged in user modifying this bug
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"