VirtualBox

Changeset 58 in kBuild for trunk


Ignore:
Timestamp:
Nov 24, 2003 2:15:56 AM (21 years ago)
Author:
bird
Message:

Better interface...

Location:
trunk/src/gmake
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmake/job.c

    r57 r58  
    579579              vmsWaitForChildren (&status);
    580580              pid = c->pid;
     581#elif MAKE_DLLSHELL
     582              pid = wait_jobs((int*)&status, block);
    581583#else
    582584#ifdef WAIT_NOHANG
     
    24392441
    24402442#ifdef MAKE_DLLSHELL
     2443/* Globals for the currently loaded dllshell. */
     2444char   *dllshell_spec;
     2445void   *dllshell_dl;
     2446void   *dllshell_instance;
     2447void *(*dllshell_init) PARAMS ((const char *spec));
     2448pid_t (*dllshell_spawn) PARAMS ((void *instance, char **argv, char **envp, int *status, char *done));
     2449pid_t (*dllshell_wait) PARAMS ((void *instance, int *status, int block));
     2450
    24412451/* This is called when all pipes and such are configured for the
    24422452   child process. The child argument may be null, see child_execute_job. */
     
    24472457  if (!strncmp(argv[0], "dllshell://", 11))
    24482458    {
    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;
    24572461      int   insert_child = 0;
    24582462
     
    24612465      name_end = strchr (name, '!');
    24622466      if (!name_end)
     2467        name_end = strchr (name, '\0');
     2468      if (name_end == name)
    24632469        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;
    24712470
    24722471      /* 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))
    24762473        {
    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)
    24872481            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]);
    24922499        }
    24932500
     
    25012508
    25022509      /* 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));
    25052512
    25062513      if (insert_child && c->pid > 0)
     
    25232530# error MAKE_DLLSHELL is not ported to your platform yet.
    25242531#endif
    2525       DB (DB_JOBS, (_("spawn pid=%x"), c->pid));
     2532      DB (DB_JOBS, (_("spawn pid=%x\n"), c->pid));
    25262533    }
    25272534
    25282535  return c->pid;
    25292536}
     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. */
     2544pid_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
    25302559#endif /* MAKE_DLLSHELL */
    25312560
  • trunk/src/gmake/job.h

    r57 r58  
    6363    char dllshell_done;         /* Nonzero if executed thru a dll shell.
    6464                                   Another thread might set this. */
     65    unsigned int dllshelled:1;  /* Nonzero if executed thru dllshell. */
    6566#endif
    6667    unsigned int remote:1;      /* Nonzero if executing remotely.  */
     
    108109#endif
    109110
     111#ifdef MAKE_DLLSHELL
     112extern pid_t wait_jobs PARAMS ((int *status, int block));
     113#endif
     114
    110115#endif /* SEEN_JOB_H */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette