Skip to content
Tcl Source Code Artifact [39fb677d72]
Login

Artifact [39fb677d72]

Artifact 39fb677d72037951dbbb84c96deaa116852d263a:

Ticket change [39fb677d72] - New ticket [219180ffffffffff|219180ffff] <i>DL enhancement for extensions (dl* compat functions)</i>. by hobbs on 2000-10-26 05:02:55.
D 2000-10-26T05:02:55
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s2113\sRFE\nVersion:\s8.1\nSubmitDate:\s'1999-05-20'\nLastModified:\s'2000-04-03'\nSeverity:\sMED\nStatus:\sAssigned\nSubmitter:\spat\nChangedBy:\shobbs\nOS:\sWindows\s95\nMachine:\sX86\nFixedDate:\s'2000-10-25'\nClosedDate:\s'2000-10-25'\n\n\nName:\nJan\sNijtmans\n\nComments:\nThis\sfeature\sis\salready\ssupplied\sby\sthe\splus-patches\sfor\sTcl7.6\sand\n\s\s\s\shigher.\sIt\sis\sduplicated\sin\sImg\sand\sTrf,\sin\sorder\sto\smake\sthose\stwo\n\s\s\s\sextensions\sas\sindependant\sas\spossible\sfrom\sthe\splus-patches.\sIf\n\s\s\s\sthose\sfunctions\swere\sprovided\sin\sthe\sstub\stable\sthat\swould\smake\n\s\s\s\sthe\sbuild\sprocess\sof\sImg\sand\sTrf\sa\slot\seasier,\sa\svaluable\n\s\s\s\saddition\sto\sthe\sTEA-summit.\n\n\s\s\s\sI\shave\scompatibility\sfunctions\sfor\sAIX,\sULTRIX,\sMacintosh,\sOSF\n\s\s\s\sHP-UX\sand\sthe\sother\sUNIX\svariants\swhich\ssupport\sdynamical\sloading\n\s\s\s\sas\swell.\sFor\snow,\sI\srestrict\sthis\ssubmission\sfor\sWindows\sonly,\n\s\s\s\sin\sorder\sto\ssimplify\sthe\sevaluation\sprocess\sby\sScriptics.\sAll\n\s\s\s\sother\sfunctions\scan\sbe\sfound\sin\sImg\s1.2\sand\sin\sTrf\s1.6,\sin\sthe\n\s\s\s\s/compat/\sdirectory.\sFor\sUNIX,\sthings\sare\sa\slittle\sbit\smore\n\s\s\s\scomplicated,\sbecause\sthe\sconfigure\sscript\shas\sthe\stask\sto\sfind\n\s\s\s\sout\swhich\sone\sshould\sbe\sused.\n\n\s\s\s\sBecause\ssystem\slibraries\snormally\sonly\suse\sASCII\scharacters\sin\n\s\s\s\stheir\sname,\sthere\sis\sno\sneed\sfor\sextra\sprecautions\sregarding\n\s\s\s\sUTF\ssupport.\sTherefore\sthis\spatch\sshould\swork\sfor\sTcl8.0.6\n\s\s\s\sas\swell.\n\nDesiredBehavior:\nCurrently,\sextensions\slike\sImg,\sTrf,\sdllhelper\sand\spossibly\n\s\s\s\sothers,\swhich\sneed\sto\sload\sother\ssystem\sdll's\sor\sshared\n\s\s\s\slibraries,\sonly\shave\saccess\sto\sthe\sdlopen(),\sdlclose(),\sdlsym()\n\s\s\s\sand\sdlerror()\sfunctions\sin\sUNIX.\n\n\s\s\s\sIt\swould\sbe\sa\slot\seasier\sif\sTcl\sprovided\sthose\sfunctions,\n\s\s\s\sas\scompatibility\sfunctions\sin\sthe\sstub\stable.\sThen\sextensions\n\s\s\s\sdon't\shave\sto\sduplicate\sthe\strouble\sof\sfinding\sout\show\n\s\s\s\sdynamical\sloading\sshould\sbe\sdone\son\seach\splatform.\n\n\s\s\s\stclLoadWin.c\sshould\sbe\scompiled\swith\s-DUSE_TCL_STUBS\sand\n\s\s\s\s-DSTATIC_BUILD\s(in\sorder\sto\sprevent\sthat\sthe\ssymbols\sare\n\s\s\s\sexported),\sand\sadded\sto\sthe\sstub\slibrary\s(as\sdone\sin\n\s\s\s\smakefile.vc).\n\nPatch:\n***\swin/makefile.vc.origThu\sMay\s20\s20:13:48\s1999\n---\swin/makefile.vcThu\sMay\s20\s20:16:44\s1999\n***************\n***\s206,211\s****\n---\s206,212\s----\n\s\s$(TMPDIR)\\tclWinTime.obj\s\n\n\s\sTCLSTUBOBJS\s=\s$(TMPDIR)\\tclStubLib.obj\s\s+\s$(TMPDIR)\\tclLoadWin.obj\n\n\s\scc32=\s"$(TOOLS32)\\bin\\cl.exe"\n\s\slink32=\s"$(TOOLS32)\\bin\\link.exe"\n***************\n***\s531,536\s****\n---\s532,539\s----\n\s\s$(TMPDIR)\\tclStubLib.obj\s:\s$(GENERICDIR)\\tclStubLib.c\n\s\s$(cc32)\s$(TCL_CFLAGS)\s-DSTATIC_BUILD\s-Fo$@\s$?\n\n+\s$(TMPDIR)\\tclLoadWin.obj\s:\s$(WINDIR)\\tclLoadWin.c\n+\s$(cc32)\s$(TCL_CFLAGS)\s-DSTATIC_BUILD\s-DUSE_TCL_STUBS\s-Fo$@\s$?\n\n\s\s#\sDedependency\srules\n\n***\swin/tclLoadWin.c.origThu\sMay\s20\s20:03:36\s1999\n---\swin/tclLoadWin.cThu\sMay\s20\s20:23:33\s1999\n***************\n***\s0\s****\n---\s1,195\s----\n+\s/*\s\n+\s\s*\stclLoadWin.c\s--\n+\s\s*\n+\s\s*This\sprocedure\sprovides\sa\sversion\sof\sdlopen()\sthat\n+\s\s*works\swith\sthe\sWindows\s"LoadLibrary"\sand\s"GetProcAddress"\n+\s\s*API\sfor\sdynamic\sloading.\n+\s\s*\n+\s\s*/\n+\s\n+\s#include\s<windows.h>\n+\s#include\s"tclWinInt.h"\n+\s#include\s"compat/dlfcn.h"\n+\s\n+\stypedef\sstruct\sLibraryList\s{\n+\s\s\s\s\sHINSTANCE\shandle;\n+\s\s\s\s\sstruct\sLibraryList\s*nextPtr;\n+\s}\sLibraryList;\n+\s\n+\sstatic\sLibraryList\s*libraryList\s=\sNULL;/*\sList\sof\scurrently\sloaded\sDLL's.\s\s*/\n+\s\n+\s/*\n+\s\s*\sDeclarations\sfor\sfunctions\sthat\sare\sonly\sused\sin\sthis\sfile.\n+\s\s*/\n+\s\n+\sstatic\svoid\sUnloadLibraries\s_ANSI_ARGS_((ClientData\sclientData));\n+\s\n+\s\n+\s/*\n+\s\s*----------------------------------------------------------------------\n+\s\s*\n+\s\s*\sdlopen\s--\n+\s\s*\n+\s\s*This\sfunction\sis\san\salternative\sfor\sthe\sfunctions\n+\s\s*TclWinLoadLibrary\sand\sTclWinGetTclInstance.\s\sIt\sis\n+\s\s*responsible\sfor\sadding\slibrary\shandles\sto\sthe\slibrary\slist\sso\n+\s\s*the\slibraries\scan\sbe\sfreed\swhen\stcl.dll\sis\sunloaded.\n+\s\s*\n+\s\s*\sResults:\n+\s\s*Returns\sthe\shandle\sof\sthe\snewly\sloaded\slibrary,\sor\sNULL\son\n+\s\s*failure.\sIf\spath\sis\sNULL,\sthe\sglobal\slibrary\sinstance\shandle\n+\s\s*is\sreturned.\n+\s\s*\n+\s\s*\sSide\seffects:\n+\s\s*Loads\sthe\sspecified\slibrary\sinto\sthe\sprocess.\n+\s\s*\n+\s\s*----------------------------------------------------------------------\n+\s\s*/\n+\s\n+\sVOID\s*dlopen(path,\smode)\n+\s\s\s\s\sCONST\schar\s*path;\n+\s\s\s\s\sint\smode;\n+\s{\n+\s\s\s\s\sVOID\s*handle;\n+\s\s\s\s\sLibraryList\s*ptr;\n+\s\s\s\s\sstatic\sint\sinitialized\s=\s0;\n+\s\n+\s\s\s\s\sif\s(!initialized)\s{\n+\sinitialized\s=\s1;\n+\sTcl_CreateExitHandler((Tcl_ExitProc\s*)\sUnloadLibraries,\n+\s\s\s\s\s(ClientData)\s&libraryList);\n+\s\s\s\s\s}\n+\s\s\s\s\shandle\s=\s(VOID\s*)\sLoadLibrary(path);\n+\s\s\s\s\sif\s(handle\s!=\sNULL)\s{\n+\s\s\s\s\sptr\s=\s(LibraryList*)\sckalloc(sizeof(LibraryList));\n+\s\s\s\s\sptr->handle\s=\s(HINSTANCE)\shandle;\n+\s\s\s\s\sptr->nextPtr\s=\slibraryList;\n+\s\s\s\s\slibraryList\s=\sptr;\n+\s\s\s\s\s}\n+\s\s\s\s\sreturn\shandle;\n+\s}\n+\s\n+\s\n+\s/*\n+\s\s*----------------------------------------------------------------------\n+\s\s*\n+\s\s*\sdlclose\s--\n+\s\s*\n+\s\s*This\sfunction\sis\san\salternative\sfor\sthe\sfunction\n+\s\s*FreeLibrary.\s\sIt\sis\sresponsible\sfor\sremoving\slibrary\n+\s\s*handles\sfrom\sthe\slibrary\slist\sand\sremove\sthe\sdll\n+\s\s*from\smemory.\n+\s\s*\n+\s\s*\sResults:\n+\s\s*-1\son\serror,\s0\son\ssuccess.\n+\s\s*\n+\s\s*\sSide\seffects:\n+\s\s*Removes\sthe\sspecified\slibrary\sfrom\sthe\sprocess.\n+\s\s*\n+\s\s*----------------------------------------------------------------------\n+\s\s*/\n+\s\n+\sint\n+\sdlclose(handle)\n+\s\s\s\s\sVOID\s*handle;\n+\s{\n+\s\s\s\s\sLibraryList\s*ptr,\s*prevPtr;\n+\s\n+\s\s\s\s\sptr\s=\slibraryList;\sprevPtr\s=\sNULL;\n+\s\s\s\s\swhile\s(ptr\s!=\sNULL)\s{\n+\sif\s(ptr->handle\s==\s(HINSTANCE)\shandle)\s{\n+\s\s\s\s\sFreeLibrary((HINSTANCE)\shandle);\n+\s\s\s\s\sif\s(prevPtr)\s{\n+\sprevPtr->nextPtr\s=\sptr->nextPtr;\n+\s\s\s\s\s}\selse\s{\n+\slibraryList\s=\sptr->nextPtr;\n+\s\s\s\s\s}\n+\s\s\s\s\sckfree((char\s*)\sptr);\n+\s\s\s\s\sreturn\s0;\n+\s}\n+\sprevPtr\s=\sptr;\n+\sptr\s=\sptr->nextPtr;\n+\s\s\s\s\s}\n+\s\s\s\s\sreturn\s-1;\n+\s}\n+\s\n+\s/*\n+\s\s*----------------------------------------------------------------------\n+\s\s*\n+\s\s*\sdlsym\s--\n+\s\s*\n+\s\s*This\sfunction\sis\san\salternative\sfor\sthe\ssystem\sfunction\n+\s\s*GetProcAddress.\sIt\sreturns\sthe\saddress\sof\sa\n+\s\s*symbol,\sgive\sthe\shandle\sreturned\sby\sdlopen().\n+\s\s*\n+\s\s*\sResults:\n+\s\s*Returns\sthe\saddress\sof\sthe\ssymbol\sin\sthe\sdll.\n+\s\s*\n+\s\s*\sSide\seffects:\n+\s\s*None.\n+\s\s*\n+\s\s*----------------------------------------------------------------------\n+\s\s*/\n+\s\n+\sVOID\s*dlsym(handle,\ssymbol)\n+\s\s\s\s\sVOID\s*handle;\n+\s\s\s\s\sCONST\schar\s*symbol;\n+\s{\n+\s\s\s\s\sreturn\s(VOID\s*)\sGetProcAddress((HINSTANCE)\shandle,\ssymbol);\n+\s}\n+\s\n+\s\n+\s/*\n+\s\s*----------------------------------------------------------------------\n+\s\s*\n+\s\s*\sdlerror\s--\n+\s\s*\n+\s\s*This\sfunction\sreturns\sa\sstring\sdescribing\sthe\serror\swhich\n+\s\s*occurred\sin\sdlopen().\n+\s\s*\n+\s\s*\sResults:\n+\s\s*Returns\san\serror\smessage.\n+\s\s*\n+\s\s*\sSide\seffects:\n+\s\s*errno\sis\sset.\n+\s\s*\n+\s\s*----------------------------------------------------------------------\n+\s\s*/\n+\s\n+\schar\s*\n+\sdlerror()\n+\s{\n+\s\s\s\s\sTclWinConvertError(GetLastError());\n+\s\s\s\s\sreturn\sTcl_ErrnoMsg(Tcl_GetErrno());\n+\s}\n+\s\n+\s/*\n+\s\s*----------------------------------------------------------------------\n+\s\s*\n+\s\s*\sUnloadLibraries\s--\n+\s\s*\n+\s\s*Frees\sany\sdynamically\sallocated\slibraries\sloaded\sby\sTcl.\n+\s\s*\n+\s\s*\sResults:\n+\s\s*None.\n+\s\s*\n+\s\s*\sSide\seffects:\n+\s\s*Frees\sthe\slibraries\son\sthe\slibrary\slist\sas\swell\sas\sthe\slist.\n+\s\s*\n+\s\s*----------------------------------------------------------------------\n+\s\s*/\n+\s\n+\sstatic\svoid\n+\sUnloadLibraries(clientData)\n+\s\s\s\s\sClientData\sclientData;\n+\s{\n+\s\s\s\s\sLibraryList\s*ptr;\n+\s\s\s\s\sLibraryList\s*list\s=\s*((LibraryList\s**)\sclientData);\n+\s\n+\s\s\s\s\swhile\s(list\s!=\sNULL)\s{\n+\sFreeLibrary(list->handle);\n+\sptr\s=\slist->nextPtr;\n+\sckfree((char\s*)\slist);\n+\slist\s=\sptr;\n+\s\s\s\s\s}\n+\s}\n\nPatchFiles:\nwin/makefile.vc\swin/tclLoadWin.c\s(new\sfile)\n\n\n\nI\sguess\sthe\spurpose\sis\sto\sallow\sextensions\sthat\swant\sto\sdo\stheir\nown\sdl'ing\sof\slibraries\sto\sjust\suse\sdlopen...\s\n--\s04/03/2000\shobbs
J foundin obsolete:\s8.1
J priority 5\sMedium
J resolution None
J status Open
J submitter hobbs
J subsystem 75.\sTutorial
J title DL\senhancement\sfor\sextensions\s(dl*\scompat\sfunctions)
J type Patch
K 219180ffffffffffffffffffffffffffffffffff
U hobbs
Z 6b1ff90c96775f71bdf5816eb6476839