- Timestamp:
- Nov 24, 2003 2:15:56 AM (21 years ago)
- Location:
- trunk/src/gmake
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/job.c
r57 r58 579 579 vmsWaitForChildren (&status); 580 580 pid = c->pid; 581 #elif MAKE_DLLSHELL 582 pid = wait_jobs((int*)&status, block); 581 583 #else 582 584 #ifdef WAIT_NOHANG … … 2439 2441 2440 2442 #ifdef MAKE_DLLSHELL 2443 /* Globals for the currently loaded dllshell. */ 2444 char *dllshell_spec; 2445 void *dllshell_dl; 2446 void *dllshell_instance; 2447 void *(*dllshell_init) PARAMS ((const char *spec)); 2448 pid_t (*dllshell_spawn) PARAMS ((void *instance, char **argv, char **envp, int *status, char *done)); 2449 pid_t (*dllshell_wait) PARAMS ((void *instance, int *status, int block)); 2450 2441 2451 /* This is called when all pipes and such are configured for the 2442 2452 child process. The child argument may be null, see child_execute_job. */ … … 2447 2457 if (!strncmp(argv[0], "dllshell://", 11)) 2448 2458 { 2449 static void *cur_dll; /* current loaded dll. */ 2450 static char *cur_dllspec; /* dllshell without shell arg. */ 2451 /* pointer to the entrypoint. */ 2452 static pid_t (*cur_spawn) PARAMS ((char **argv, char **envp, int *status, char *done)); 2453 2454 /* dllshell://<dllname>!<exec>[!<realshell>] */ 2455 char *name, *name_end, *symbol, *symbol_end; 2456 int len_basespec; 2459 /* dllshell://<dllname>[!<realshell>[!whatever]] */ 2460 char *name, *name_end; 2457 2461 int insert_child = 0; 2458 2462 … … 2461 2465 name_end = strchr (name, '!'); 2462 2466 if (!name_end) 2467 name_end = strchr (name, '\0'); 2468 if (name_end == name) 2463 2469 fatal (NILF, _("%s : malformed specifier!\n"), argv[0]); 2464 symbol = name_end + 1;2465 symbol_end = strchr (symbol, '!');2466 if (symbol == symbol_end)2467 fatal (NILF, _("%s : malformed specifier!\n"), argv[0]);2468 if (symbol_end)2469 symbol_end = strchr (symbol, 0);2470 len_basespec = symbol_end - name;2471 2470 2472 2471 /* need loading? */ 2473 if ( !cur_dllspec 2474 || strncmp (name, cur_dllspec, len_basespec) 2475 || argv[len_basespec]) 2472 if (!dllshell_spec || strcmp (argv[0], dllshell_spec)) 2476 2473 { 2477 if (cur_dll) 2478 { 2479 dlclose (cur_dll); 2480 free (cur_dllspec); 2481 } 2482 cur_dllspec = strdup (name); 2483 cur_dllspec[len_basespec] = '\0'; 2484 cur_dllspec[name_end - name] = '\0'; 2485 cur_dll = dlopen (cur_dllspec, RTLD_LOCAL); 2486 if (!cur_dll) 2474 if (dllshell_spec) 2475 fatal (NILF, _("cannot change the dllshell!!!\n")); 2476 2477 dllshell_spec = strdup (argv[0]); 2478 dllshell_spec[name_end - argv[0]] = '\0'; 2479 dllshell_dl = dlopen (dllshell_spec + (name - argv[0]), RTLD_LOCAL); 2480 if (!dllshell_dl) 2487 2481 fatal (NILF, _("%s : failed to load! dlerror: '%s'\n"), argv[0], dlerror()); 2488 cur_dllspec[name_end - name] = '!'; 2489 cur_spawn = dlsym (cur_dll, cur_dllspec + (symbol - name)); 2490 if (!cur_spawn) 2491 fatal (NILF, _("%s : failed to find symbol! dlerror: %s\n"), argv[0], dlerror()); 2482 dllshell_spec[name_end - name] = '!'; 2483 2484 /* get symbols */ 2485 dllshell_init = dlsym (dllshell_dl, "dllshell_init"); 2486 if (!dllshell_init) 2487 fatal (NILF, _("%s : failed to find symbols 'dllshell_init' dlerror: %s\n"), argv[0], dlerror()); 2488 dllshell_spawn = dlsym (dllshell_dl, "dllshell_spawn"); 2489 if (!dllshell_spawn) 2490 fatal (NILF, _("%s : failed to find symbols 'dllshell_spawn' dlerror: %s\n"), argv[0], dlerror()); 2491 dllshell_wait = dlsym (dllshell_dl, "dllshell_wait"); 2492 if (!dllshell_wait) 2493 fatal (NILF, _("%s : failed to find symbols 'dllshell_wait' dlerror: %s\n"), argv[0], dlerror()); 2494 2495 /* init */ 2496 dllshell_instance = dllshell_init(dllshell_spec); 2497 if (!dllshell_instance) 2498 fatal (NILF, _("%s : init failed!!!\n"), argv[0]); 2492 2499 } 2493 2500 … … 2501 2508 2502 2509 /* call it. return value is 0 on succes, -1 on failure. */ 2503 c->pid = cur_spawn (argv, envp, &c->status, &c->dllshell_done);2504 DB (DB_JOBS, (_("dllshell pid=%x "), c->pid));2510 c->pid = dllshell_spawn (dllshell_instance, argv, envp, &c->status, &c->dllshell_done); 2511 DB (DB_JOBS, (_("dllshell pid=%x\n"), c->pid)); 2505 2512 2506 2513 if (insert_child && c->pid > 0) … … 2523 2530 # error MAKE_DLLSHELL is not ported to your platform yet. 2524 2531 #endif 2525 DB (DB_JOBS, (_("spawn pid=%x "), c->pid));2532 DB (DB_JOBS, (_("spawn pid=%x\n"), c->pid)); 2526 2533 } 2527 2534 2528 2535 return c->pid; 2529 2536 } 2537 2538 /* Waits or pools for a job to finish. 2539 If the block argument the the function will not return 2540 till a job is completed (if there are any jobs). 2541 Returns pid of completed job. 2542 Returns 0 if no jobs are finished. 2543 Returns -1 if no jobs are running. */ 2544 pid_t wait_jobs (int *status, int block) 2545 { 2546 pid_t pid; 2547 if (dllshell_wait) 2548 pid = dllshell_wait(dllshell_instance, status, block); 2549 else 2550 { 2551 if (block) 2552 pid = WAIT_NOHANG(status); 2553 else 2554 pid = wait(status); 2555 } 2556 return pid; 2557 } 2558 2530 2559 #endif /* MAKE_DLLSHELL */ 2531 2560 -
trunk/src/gmake/job.h
r57 r58 63 63 char dllshell_done; /* Nonzero if executed thru a dll shell. 64 64 Another thread might set this. */ 65 unsigned int dllshelled:1; /* Nonzero if executed thru dllshell. */ 65 66 #endif 66 67 unsigned int remote:1; /* Nonzero if executing remotely. */ … … 108 109 #endif 109 110 111 #ifdef MAKE_DLLSHELL 112 extern pid_t wait_jobs PARAMS ((int *status, int block)); 113 #endif 114 110 115 #endif /* SEEN_JOB_H */
Note:
See TracChangeset
for help on using the changeset viewer.