Changeset 326 for trunk/nom/src/nomgc.c


Ignore:
Timestamp:
Apr 9, 2008, 10:22:08 PM (17 years ago)
Author:
cinc
Message:

Portability patches for Windows, Linux, Darwin by Bird.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/nom/src/nomgc.c

    r286 r326  
    3737 */
    3838
    39 #define INCL_DOS
    40 #define INCL_DOSERRORS
    41 #define INCL_DOSMEMMGR
    42 #include <os2.h>
     39#ifdef __OS2__
     40# define INCL_DOS
     41# define INCL_DOSERRORS
     42# define INCL_DOSMEMMGR
     43# include <os2.h>
     44#endif /* __OS2__ */
    4345
    4446#include <stdio.h>
     
    8385  memory functions as the GLIB default allocation function.
    8486 */
     87#ifdef __OS2__
    8588void _System  nomInitGarbageCollection(void* pMemInExe)
     89#else
     90void nomInitGarbageCollection(void* pMemInExe)
     91#endif
    8692{
    8793 GMemVTable vtbl={0};
     
    98104
    99105 /* Cretea tree holding the already registered DLLs */
     106#ifdef _MSC_VER
    100107 treeRegisteredDLL=g_tree_new((GCompareFunc)stricmp);
     108#else
     109 treeRegisteredDLL=g_tree_new((GCompareFunc)strcasecmp);
     110#endif
    101111
    102112 bUseGC=TRUE;
     
    104114
    105115
     116#ifdef __OS2__
    106117void test()
    107118{
     
    110121  HMODULE hModule;
    111122
    112   if(DosQueryModFromEIP( &hModule, &ulObj, CCHMAXPATH, thePath, &ulOffset, (ULONG)test)!=0) {
     123  if(DosQueryModFromEIP( &hModule, &ulObj, CCHMAXPATH, thePath, &ulOffset, (gulong)test)!=0) {
    113124    hModule=0;
    114125    return ; /* Error */
     
    116127
    117128}
     129#endif /* __OS2__ */
    118130
    119131NOMEXTERN void NOMLINK  nomRegisterDataAreaForGC(char* pStart, char* pEnd)
     
    122134}
    123135
     136#ifdef __OS2__
     137
    124138static void qsAddDLLToList(HREGDLL hReg, qsLrec_t* rec)
    125139{
    126   if(NULLHANDLE==g_slist_find(hReg->dllList, rec))
     140  if(NULL==g_slist_find(hReg->dllList, rec))
    127141    hReg->dllList=g_slist_append(hReg->dllList, rec);
    128142}
     
    160174      /* g_message("%d Checking: %x -> %04X (%s)", a, pModRec, pModRec->hmte, pModRec->pName); */
    161175
    162       if (NULLHANDLE==pModRec->pObjInfo   && pModRec->ctObj > 0)
     176      if (NULL==pModRec->pObjInfo   && pModRec->ctObj > 0)
    163177        {
    164178          pModRec->pObjInfo = (qsLObjrec_t*)((char*)pModRec
     
    179193}
    180194
     195
    181196/**
    182197   Get the info about the current DLLs from OS/2. Go over all found
     
    187202NOMEXTERN HREGDLL NOMLINK nomBeginRegisterDLLWithGC(void)
    188203{
    189   ULONG rc;
    190   HREGDLL hReg=NULLHANDLE;
     204  gulong rc;
     205  HREGDLL hReg=NULL;
    191206  PTIB     ptib;
    192207  PPIB     ppib;
    193208  char *  buf;
    194   HREGDLL  pRegDLL=NULLHANDLE;
     209  HREGDLL  pRegDLL=NULL;
    195210
    196211  rc = DosGetInfoBlocks(&ptib, &ppib);
    197212  if (rc!=NO_ERROR)
    198     return NULLHANDLE;
     213    return NULL;
    199214
    200215  buf = malloc(BUFSIZE);
    201216  if(!buf)
    202     return NULLHANDLE;
     217    return NULL;
    203218
    204219  pRegDLL =(HREGDLL) malloc(sizeof(REGDLL));
    205220  if(!pRegDLL){
    206221    free(buf);
    207     return NULLHANDLE;
     222    return NULL;
    208223  }
    209   pRegDLL->dllList=NULLHANDLE;
     224  pRegDLL->dllList=NULL;
    210225
    211226  memset(buf,0,BUFSIZE);
     
    303318#define OBJWRITE        0x0002L
    304319#define OBJINVALID      0x0080L
    305 NOMEXTERN BOOL NOMLINK nomRegisterDLLByName(const HREGDLL hRegisterDLL, const char* chrDLLName)
     320NOMEXTERN gboolean NOMLINK nomRegisterDLLByName(const HREGDLL hRegisterDLL, const char* chrDLLName)
    306321{
    307322  GSList* lTemp;
     
    316331      if(pModRec){
    317332        //  g_message("DLL name: %s", pModRec->pName);
    318         if(pModRec->pName && (NULLHANDLE!=strstr( pModRec->pName, chrDLLName)))
     333        if(pModRec->pName && (NULL!=strstr( pModRec->pName, chrDLLName)))
    319334          {
    320335            qsLObjrec_t  *pObjInfo;
    321336            //g_message("    --> Found DLL %s", pModRec->pName);
    322337            pObjInfo=pModRec->pObjInfo;
    323             if(NULLHANDLE!=pObjInfo)
     338            if(NULL!=pObjInfo)
    324339              {
    325340                int iObj;
     
    344359}
    345360
    346 
    347 NOMEXTERN BOOL NOMLINK nomQueryUsingNameIsDLLRegistered(const gchar *chrName)
    348 {
    349   if(NULLHANDLE!=g_tree_lookup(treeRegisteredDLL, chrName))
     361//#elif defined(_WIN32)
     362#else /* PORTME */
     363
     364NOMEXTERN HREGDLL NOMLINK nomBeginRegisterDLLWithGC(void)
     365{
     366    HREGDLL pRegDLL;
     367
     368    pRegDLL =(HREGDLL) malloc(sizeof(REGDLL));
     369    if(pRegDLL)
     370      pRegDLL->dllList=NULL;
     371    return pRegDLL;
     372}
     373
     374NOMEXTERN void NOMLINK nomEndRegisterDLLWithGC(const HREGDLL hRegisterDLL )
     375{
     376}
     377
     378NOMEXTERN gboolean NOMLINK nomRegisterDLLByName(const HREGDLL hRegisterDLL, const char* chrDLLName)
     379{
    350380    return TRUE;
     381}
     382
     383#endif
     384
     385NOMEXTERN gboolean NOMLINK nomQueryUsingNameIsDLLRegistered(const gchar *chrName)
     386{
     387  if(NULL!=g_tree_lookup(treeRegisteredDLL, chrName))
     388    return TRUE;
    351389
    352390  return FALSE;
Note: See TracChangeset for help on using the changeset viewer.