Changeset 195
- Timestamp:
- Jan 17, 2007, 7:33:51 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl-c-skelimpl.c
r118 r195 1272 1272 g_free(chrTemp); 1273 1273 } 1274 fprintf(ski->of, "#include \"nomgc.h\"\n"); 1274 1275 fprintf(ski->of, "NOMClass* NOMLINK %sNewClass(gulong ulMajor, gulong ulMinor)\n{\n", id); 1275 1276 fprintf(ski->of, " NOMClass* result;\n\n"); 1276 //fprintf(ski->of, "%s* NOMLINK %sNewClass(gulong ulMajor, gulong ulMinor)\n{\n", id, id); 1277 // fprintf(ski->of, " %s* result;\n\n", id); 1277 1278 fprintf(ski->of, "#ifdef __OS2__\n"); 1279 fprintf(ski->of, " gulong ulObj, ulOffset;\n gchar thePath[CCHMAXPATH];\n HMODULE hModule;\n\n"); 1280 fprintf(ski->of, 1281 " g_assert(DosQueryModFromEIP( &hModule, &ulObj, CCHMAXPATH, thePath, &ulOffset, (ULONG)%sNewClass)==0);\n", id); 1282 fprintf(ski->of, " g_strlcat(thePath, \".DLL\", sizeof(thePath));\n"); 1283 fprintf(ski->of, " if(!nomQueryUsingNameIsDLLRegistered(thePath))\n {\n"); 1284 fprintf(ski->of, " HREGDLL hReg=nomBeginRegisterDLLWithGC();\n"); 1285 fprintf(ski->of, " g_assert(nomRegisterDLLByName(hReg, thePath));\n"); 1286 fprintf(ski->of, " nomEndRegisterDLLWithGC(hReg);\n }\n"); 1287 fprintf(ski->of, "#else\n#error DLL must be registered with the garbage collector!\n#endif\n\n"); 1278 1288 1279 1289 /* Make sure meta class is created if specified by the user */ -
trunk/nom/exports.def
r190 r195 15 15 nomEndRegisterDLLWithGC 16 16 nomRegisterDLLByName 17 nomQueryUsingNameIsDLLRegistered 17 18 18 19 nomPrintf -
trunk/nom/include/nomgc.h
r193 r195 49 49 #if 0 50 50 NOMEXTERN BOOL NOMLINK nomRegisterDLLByHandle(const HREGDLL hRegisterDLL, const gpointer pDLLHandle); 51 NOMEXTERN BOOL NOMLINK nomQueryIsDLLRegisteredUsingHandle(const gpointer pDLLHandle);52 51 #endif 52 53 NOMEXTERN BOOL NOMLINK nomQueryUsingNameIsDLLRegistered(const gchar *chrName); 54 53 55 #endif /* NOMGC_H_INCLUDED */ 54 56 -
trunk/nom/include/nomtk.h
r193 r195 48 48 ULONG cbSize; /* Size of this struct */ 49 49 PVOID pMemPool; /* Shared memory heap for sub alloc */ 50 HMTX hmtx ; /* Mutex sem to protect this structure*/50 HMTX hmtx_obsolete; /* Mutex sem to protect this structure -Will go away! */ 51 51 ULONG ulNumRegIds; /* Number of registered somIDs */ 52 52 NOMClassPriv *ncpNOMObject; /* This is for NOMObject*/ -
trunk/nom/src/nomgc.c
r193 r195 55 55 56 56 gboolean bUseGC=FALSE; /* Mark if we use the garbage collector */ 57 GTree* treeRegisteredDLL; 57 58 58 59 static gpointer gcMalloc(gulong ulBytes) … … 96 97 /* fprintf(stderr, " GC memory functions set for GLIB. (%s: %d)\n", __FILE__, __LINE__); */ 97 98 99 /* Cretea tree holding the already registered DLLs */ 100 treeRegisteredDLL=g_tree_new((GCompareFunc)stricmp); 101 98 102 bUseGC=TRUE; 103 } 104 105 106 void test() 107 { 108 gulong ulObj, ulOffset; 109 gchar thePath[CCHMAXPATH]; 110 HMODULE hModule; 111 112 if(DosQueryModFromEIP( &hModule, &ulObj, CCHMAXPATH, thePath, &ulOffset, (ULONG)test)!=0) { 113 hModule=0; 114 return NULLHANDLE; /* Error */ 115 } 116 99 117 } 100 118 … … 271 289 GSList* lTemp; 272 290 273 // printf("Trying to register DLL %s\n", chrDLLName);291 //g_message("Trying to register DLL %s\n", chrDLLName); 274 292 lTemp=hRegisterDLL->dllList; 275 293 while(lTemp) … … 279 297 pModRec=(qsLrec_t*)lTemp->data; 280 298 if(pModRec){ 281 // printf("DLL name: %s\n", pModRec->pName);299 //g_message("DLL name: %s\n", pModRec->pName); 282 300 if(pModRec->pName && (NULLHANDLE!=strstr( pModRec->pName, chrDLLName))) 283 301 { … … 297 315 nomRegisterDataAreaForGC((char*)pObjInfo[iObj].oaddr, 298 316 (char*)(pObjInfo[iObj].oaddr+pObjInfo[iObj].osize)); 317 g_tree_insert(treeRegisteredDLL, g_strdup(chrDLLName), GUINT_TO_POINTER((guint)pModRec->hmte)); 299 318 } 300 319 } … … 307 326 } 308 327 309 #if 0 310 #define BUFSIZE 1024*1024 311 NOMEXTERN HREGDLL NOMLINK nomBeginRegisterDLLWithGC(void) 312 { 313 ULONG rc; 314 HREGDLL hReg=NULLHANDLE; 315 PTIB ptib; 316 PPIB ppib; 317 char * buf; 318 319 rc = DosGetInfoBlocks(&ptib, &ppib); 320 if (rc!=NO_ERROR) 321 return NULLHANDLE; 322 323 buf = malloc(BUFSIZE); 324 if(!buf) 325 return NULLHANDLE; 326 327 memset(buf,0,BUFSIZE); 328 329 rc = DosQuerySysState(QS_PROCESS | QS_SEMAPHORE | QS_MTE | QS_FILESYS | QS_SHMEMORY , 330 QS_MTE, /*0x96*/ ppib->pib_ulpid , 1UL, (PCHAR)buf, BUFSIZE); 331 if (rc==NO_ERROR) { 332 hReg=(qsPtrRec_t*) buf; 333 } 334 else 335 free(buf); 336 337 return hReg; 338 } 339 /* 340 FIXME: 341 342 This function will not find every given DLL because it doesn't follow every import of 343 each DLL. 344 It's only meant for registering the GTK+, GLIB and friends DLLs. This works because GTK2.DLL 345 is directly loaded by the exe and all the friends DLLs are imported by it. 346 347 Feel free to make this function really useful... 348 349 Oh, and some refactoring would be nice, too. 350 351 */ 352 #define OBJREAD 0x0001L 353 #define OBJWRITE 0x0002L 354 #define OBJINVALID 0x0080L 355 NOMEXTERN BOOL NOMLINK nomRegisterDLLByName(const HREGDLL hRegisterDLL, const char* chrDLLName) 356 { 357 qsPrec_t * p; 358 int a=0; 359 360 //printf("Trying to register DLL %s\n", chrDLLName); 361 362 p=hRegisterDLL->pProcRec; 363 while(p && p->RecType == 1) 364 { 365 a++; 366 if (p->cLib) { 367 int i; 368 369 for (i=0; i<p->cLib; i++){ 370 qsLrec_t * pModRec; 371 372 //printf("%d %04X (p: %04x %04X, %04X) ",i, p->pLibRec[i], p, &p->pLibRec[i], &p->pLibRec); 373 374 pModRec=qsFindModuleRec(hRegisterDLL, p->pLibRec[i]); 375 if(pModRec){ 376 // printf("DLL name: %s\n", pModRec->pName); 377 if(NULLHANDLE!=strstr( pModRec->pName, chrDLLName)) 378 { 379 qsLObjrec_t *pObjInfo; 380 //printf(" --> Found DLL %s\n", pModRec->pName); 381 pObjInfo=pModRec->pObjInfo; 382 if(NULLHANDLE!=pObjInfo) 383 { 384 int iObj; 385 for(iObj=0; iObj<pModRec->ctObj ;iObj++) 386 { 387 if (!(pObjInfo[iObj].oflags & OBJWRITE)) continue; 388 if (!(pObjInfo[iObj].oflags & OBJREAD)) continue; 389 if ((pObjInfo[iObj].oflags & OBJINVALID)) continue; 390 printf(" #%d: %04lX, size: %04lX %04lX", 391 iObj, pObjInfo[iObj].oaddr, pObjInfo[iObj].osize, pObjInfo[iObj].oflags); 392 nomRegisterDataAreaForGC((char*)pObjInfo[iObj].oaddr, 393 (char*)(pObjInfo[iObj].oaddr+pObjInfo[iObj].osize)); 394 } 395 } 396 return TRUE; 397 } 398 /* Check the imports of this DLL if any */ 399 if(pModRec->ctImpMod >0) 400 { 401 int iImps; 402 PUSHORT pImpHmte; 403 404 pImpHmte=(PUSHORT)((void*)pModRec + sizeof(qsLrec_t)); 405 406 for(iImps=0; iImps < pModRec->ctImpMod; iImps++) 407 { 408 qsLrec_t * pModImp; 409 // printf(" Trying import #%d (%04X)\n", iImps, pImpHmte[iImps]); 410 pModImp=qsFindModuleRec(hRegisterDLL, pImpHmte[iImps]); 411 if(pModImp){ 412 //printf(" DLL name: %s\n", pModImp->pName); 413 if(NULLHANDLE!=strstr( pModImp->pName, chrDLLName)) 414 { 415 qsLObjrec_t *pObjInfo; 416 //printf(" --> Found DLL %s\n", pModImp->pName); 417 pObjInfo=pModImp->pObjInfo; 418 if(NULLHANDLE!=pObjInfo) 419 { 420 int iObj; 421 for(iObj=0; iObj<pModImp->ctObj ;iObj++) 422 { 423 if (!(pObjInfo[iObj].oflags & OBJWRITE)) continue; 424 if (!(pObjInfo[iObj].oflags & OBJREAD)) continue; 425 if ((pObjInfo[iObj].oflags & OBJINVALID)) continue; 426 427 //printf(" #%d: %04lX, size: %04lX %04lX\n", 428 // iObj, pObjInfo[iObj].oaddr, pObjInfo[iObj].osize, pObjInfo[iObj].oflags); 429 nomRegisterDataAreaForGC((char*)pObjInfo[iObj].oaddr, 430 (char*)(pObjInfo[iObj].oaddr+pObjInfo[iObj].osize)); 431 } 432 } 433 return TRUE; 434 } 435 }/* for() */ 436 }/* for()*/ 437 }/* if() */ 438 } 439 }/* For() */ 440 } 441 break; 442 } 328 329 NOMEXTERN BOOL NOMLINK nomQueryUsingNameIsDLLRegistered(const gchar *chrName) 330 { 331 if(NULLHANDLE!=g_tree_lookup(treeRegisteredDLL, chrName)) 332 return TRUE; 333 443 334 return FALSE; 444 335 } 445 #endif -
trunk/nom/src/nomtkinit.c
r193 r195 180 180 181 181 182 183 182 NOMEXTERN PNOM_ENV NOMLINK nomTkInit(void) 184 183 { … … 196 195 ((PNOM_ENV)memPtr)->cbSize=sizeof(NOM_ENV); 197 196 pGlobalNomEnv=(PNOM_ENV)memPtr; 197 198 #if 0 198 199 if(NO_ERROR!=DosCreateMutexSem(NULL, &((PNOM_ENV)memPtr)->hmtx, DC_SEM_SHARED, FALSE)) 199 200 { … … 201 202 return NULL; 202 203 } 204 #endif 203 205 204 206 return (PNOM_ENV)memPtr; 205 206 #if 0 207 nomPrintf("*************************************\n"); 208 nomPrintf("!! This function must be rewritten !!\n"); 209 nomPrintf("!! It's using OS/2 only memory !!\n"); 210 nomPrintf("!! functions. !!\n"); 211 nomPrintf("*************************************\n"); 212 213 /* Check if we already allocated our shared mem */ 214 if(NO_ERROR==DosGetNamedSharedMem(&memPtr,SOMTK_SHARED_MEM_NAME_ROOT , PAG_EXECUTE|PAG_READ|PAG_WRITE)) { 215 nomPrintf("%s: Found root shared mem: %x.\n", __FUNCTION__, memPtr); 216 /* Give process access to memory pool*/ 217 DosGetSharedMem( ((PNOM_ENV)memPtr)->pMemPool, PAG_READ|PAG_WRITE|PAG_EXECUTE); 218 if(NO_ERROR!=DosSubSetMem(((PNOM_ENV)memPtr)->pMemPool, DOSSUB_SPARSE_OBJ|DOSSUB_SERIALIZE, SOMTK_SHARED_MEM_SIZE_POOL)) { 219 DosFreeMem(memPool); 220 DosFreeMem(memPtr); 221 return NULL; 222 } 223 pGlobalNomEnv=(PNOM_ENV)memPtr; 224 return (PNOM_ENV)memPtr; 225 } 226 nomPrintf("%s: No root memory yet\n", __FUNCTION__); 227 228 /* Get the mem for the root structure in a shared memory area */ 229 if(NO_ERROR!=DosAllocSharedMem(&memPtr, SOMTK_SHARED_MEM_NAME_ROOT, SOMTK_SHARED_MEM_SIZE_ROOT, 230 PAG_COMMIT | PAG_EXECUTE | PAG_READ | PAG_WRITE)) 231 return NULL; 232 233 nomPrintf("%s: Got root memory: %x\n", __FUNCTION__, memPtr); 234 235 /* Get our shared memory pool */ 236 if(NO_ERROR!=DosAllocSharedMem(&memPool, NULL, SOMTK_SHARED_MEM_SIZE_POOL,OBJ_GETTABLE | PAG_EXECUTE|PAG_READ|PAG_WRITE)) { 237 DosFreeMem(memPtr); 238 return NULL; 239 } 240 nomPrintf("%s: Got shared memory pool: %x\n", __FUNCTION__, memPool); 241 242 /* Now init the structure */ 243 memset(memPtr, 0, 1 /*SOMTK_SHARED_MEM_SIZE_ROOT*/); 244 nomPrintf("%s: zeroed memory\n", __FUNCTION__); 245 246 ((PNOM_ENV)memPtr)->cbSize=sizeof(NOM_ENV); 247 /* Init memory pool */ 248 if(NO_ERROR!=DosSubSetMem(memPool, DOSSUB_INIT|DOSSUB_SPARSE_OBJ|DOSSUB_SERIALIZE, SOMTK_SHARED_MEM_SIZE_POOL)) { 249 DosFreeMem(memPool); 250 DosFreeMem(memPtr); 251 return NULL; 252 } 253 ((PNOM_ENV)memPtr)->pMemPool=memPool; 254 if(NO_ERROR!=DosCreateMutexSem(NULL, &((PNOM_ENV)memPtr)->hmtx, DC_SEM_SHARED, FALSE)) 255 { 256 DosFreeMem(memPool); 257 DosFreeMem(memPtr); 258 return NULL; 259 } 260 pGlobalNomEnv=(PNOM_ENV)memPtr; 261 262 return (PNOM_ENV)memPtr; 263 #endif 264 } 265 266 267 268 269 270 271 272 273 274 275 207 } 208 209 210 211 212 213 214 215 216 217 218
Note:
See TracChangeset
for help on using the changeset viewer.