VirtualBox

Changeset 900 in kBuild for vendor/gnumake/current/job.c


Ignore:
Timestamp:
May 23, 2007 3:13:11 AM (17 years ago)
Author:
bird
Message:

Load /home/bird/src/Gnu/make/2007-05-23 into vendor/gnumake/current.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/gnumake/current/job.c

    r501 r900  
    9999# include <starlet.h>
    100100# include <lib$routines.h>
    101 static void vmsWaitForChildren PARAMS ((int *));
     101static void vmsWaitForChildren (int *);
    102102#endif
    103103
     
    131131
    132132#if !defined (wait) && !defined (POSIX)
    133 extern int wait ();
     133int wait ();
    134134#endif
    135135
     
    176176
    177177#ifndef HAVE_UNISTD_H
    178 extern int dup2 ();
    179 extern int execve ();
    180 extern void _exit ();
     178int dup2 ();
     179int execve ();
     180void _exit ();
    181181# ifndef VMS
    182 extern int geteuid ();
    183 extern int getegid ();
    184 extern int setgid ();
    185 extern int getgid ();
     182int geteuid ();
     183int getegid ();
     184int setgid ();
     185int getgid ();
    186186# endif
    187187#endif
    188188
    189 extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file));
    190 
    191 extern int getloadavg PARAMS ((double loadavg[], int nelem));
    192 extern int start_remote_job PARAMS ((char **argv, char **envp, int stdin_fd,
    193                 int *is_remote, int *id_ptr, int *used_stdin));
    194 extern int start_remote_job_p PARAMS ((int));
    195 extern int remote_status PARAMS ((int *exit_code_ptr, int *signal_ptr,
    196                 int *coredump_ptr, int block));
    197 
    198 RETSIGTYPE child_handler PARAMS ((int));
    199 static void free_child PARAMS ((struct child *));
    200 static void start_job_command PARAMS ((struct child *child));
    201 static int load_too_high PARAMS ((void));
    202 static int job_next_command PARAMS ((struct child *));
    203 static int start_waiting_job PARAMS ((struct child *));
     189int getloadavg (double loadavg[], int nelem);
     190int start_remote_job (char **argv, char **envp, int stdin_fd, int *is_remote,
     191                      int *id_ptr, int *used_stdin);
     192int start_remote_job_p (int);
     193int remote_status (int *exit_code_ptr, int *signal_ptr, int *coredump_ptr,
     194                   int block);
     195
     196RETSIGTYPE child_handler (int);
     197static void free_child (struct child *);
     198static void start_job_command (struct child *child);
     199static int load_too_high (void);
     200static int job_next_command (struct child *);
     201static int start_waiting_job (struct child *);
    204202
    205203
     
    304302        {
    305303          const unsigned final_size = path_size + size + 1;
    306           char *const path = (char *) xmalloc (final_size);
     304          char *const path = xmalloc (final_size);
    307305          memcpy (path, temp_path, final_size);
    308306          *fd = _open_osfhandle ((long)h, 0);
     
    363361  i = 0;
    364362  while (known_os2shells[i] != NULL) {
    365     if (stricmp (name, known_os2shells[i]) == 0) /* strcasecmp() */
     363    if (strcasecmp (name, known_os2shells[i]) == 0)
    366364      return 0; /* not a unix shell */
    367365    i++;
     
    380378
    381379static void
    382 child_error (char *target_name, int exit_code, int exit_sig, int coredump,
    383              int ignored)
     380child_error (const char *target_name,
     381             int exit_code, int exit_sig, int coredump, int ignored)
    384382{
    385383  if (ignored && silent_flag)
     
    501499
    502500         The test and decrement are not atomic; if it is compiled into:
    503                 register = dead_children - 1;
     501                register = dead_children - 1;
    504502                dead_children = register;
    505503         a SIGCHLD could come between the two instructions.
     
    881879      for (i = 0; i < child->file->cmds->ncommand_lines; ++i)
    882880        free (child->command_lines[i]);
    883       free ((char *) child->command_lines);
     881      free (child->command_lines);
    884882    }
    885883
     
    889887      while (*ep != 0)
    890888        free (*ep++);
    891       free ((char *) child->environment);
    892     }
    893 
    894   free ((char *) child);
     889      free (child->environment);
     890    }
     891
     892  free (child);
    895893}
    896894
     
    938936#endif
    939937
    940   bzero ((char *) &sa, sizeof sa);
     938  memset (&sa, '\0', sizeof sa);
    941939  sa.sa_handler = child_handler;
    942940  sa.sa_flags = set_handler ? 0 : SA_RESTART;
     
    10441042#ifndef VMS
    10451043      free (argv[0]);
    1046       free ((char *) argv);
     1044      free (argv);
    10471045#endif
    10481046      child->file->update_status = 1;
     
    10591057        {
    10601058          free (argv[0]);
    1061           free ((char *) argv);
     1059          free (argv);
    10621060        }
    10631061#endif
     
    11201118    {
    11211119      free (argv[0]);
    1122       free ((char *) argv);
     1120      free (argv);
    11231121      goto next_command;
    11241122    }
     
    11311129#ifndef VMS
    11321130      free (argv[0]);
    1133       free ((char *) argv);
     1131      free (argv);
    11341132#endif
    11351133      goto next_command;
     
    14091407#ifndef VMS
    14101408  free (argv[0]);
    1411   free ((char *) argv);
     1409  free (argv);
    14121410#endif
    14131411
     
    14911489new_job (struct file *file)
    14921490{
    1493   register struct commands *cmds = file->cmds;
    1494   register struct child *c;
     1491  struct commands *cmds = file->cmds;
     1492  struct child *c;
    14951493  char **lines;
    1496   register unsigned int i;
     1494  unsigned int i;
    14971495
    14981496  /* Let any previously decided-upon jobs that are waiting
     
    15071505
    15081506  /* Expand the command lines and store the results in LINES.  */
    1509   lines = (char **) xmalloc (cmds->ncommand_lines * sizeof (char *));
     1507  lines = xmalloc (cmds->ncommand_lines * sizeof (char *));
    15101508  for (i = 0; i < cmds->ncommand_lines; ++i)
    15111509    {
     
    15331531               we processed (where IN points) and the new chunk
    15341532               we are about to process (where REF points).  */
    1535             bcopy (in, out, ref - in);
     1533            memmove (out, in, ref - in);
    15361534
    15371535          /* Move both pointers past the boring stuff.  */
     
    16111609     `struct child', and add that to the chain.  */
    16121610
    1613   c = (struct child *) xmalloc (sizeof (struct child));
    1614   bzero ((char *)c, sizeof (struct child));
     1611  c = xmalloc (sizeof (struct child));
     1612  memset (c, '\0', sizeof (struct child));
    16151613  c->file = file;
    16161614  c->command_lines = lines;
     
    17321730  /* The job is now primed.  Start it running.
    17331731     (This will notice if there are in fact no commands.)  */
    1734   (void) start_waiting_job (c);
     1732  if (cmds->fileinfo.filenm)
     1733    DB (DB_BASIC, (_("Invoking commands from %s:%lu to update target `%s'.\n"),
     1734                   cmds->fileinfo.filenm, cmds->fileinfo.lineno,
     1735                   c->file->name));
     1736  else
     1737    DB (DB_BASIC, (_("Invoking builtin commands to update target `%s'.\n"),
     1738                   c->file->name));
     1739
     1740
     1741  start_waiting_job (c);
    17351742
    17361743  if (job_slots == 1 || not_parallel)
     
    21252132# endif
    21262133
    2127         new_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *));
     2134        new_argv = alloca ((1 + argc + 1) * sizeof (char *));
    21282135        new_argv[0] = shell;
    21292136
     
    23182325                             "shift", "switch", "test", "times", "trap",
    23192326                             "umask", "wait", "while", 0 };
    2320 #endif
    2321   register int i;
    2322   register char *p;
    2323   register char *ap;
     2327# ifdef HAVE_DOS_PATHS
     2328  /* This is required if the MSYS/Cygwin ports (which do not define
     2329     WINDOWS32) are compiled with HAVE_DOS_PATHS defined, which uses
     2330     sh_chars_sh[] directly (see below).  */
     2331  static char *sh_chars_sh = sh_chars;
     2332# endif  /* HAVE_DOS_PATHS */
     2333#endif
     2334  int i;
     2335  char *p;
     2336  char *ap;
    23242337  char *end;
    23252338  int instring, word_has_equals, seen_nonequals, last_argument_was_empty;
     
    23532366  else if (strcmp (shell, default_shell))
    23542367  {
    2355     char *s1 = _fullpath(NULL, shell, 0);
    2356     char *s2 = _fullpath(NULL, default_shell, 0);
    2357 
    2358     slow_flag = strcmp((s1 ? s1 : ""), (s2 ? s2 : ""));
     2368    char *s1 = _fullpath (NULL, shell, 0);
     2369    char *s2 = _fullpath (NULL, default_shell, 0);
     2370
     2371    slow_flag = strcmp ((s1 ? s1 : ""), (s2 ? s2 : ""));
    23592372
    23602373    if (s1)
     
    23672380#else  /* not WINDOWS32 */
    23682381#if defined (__MSDOS__) || defined (__EMX__)
    2369   else if (stricmp (shell, default_shell))
     2382  else if (strcasecmp (shell, default_shell))
    23702383    {
    23712384      extern int _is_unixy_shell (const char *_path);
     
    24092422
    24102423  /* More than 1 arg per character is impossible.  */
    2411   new_argv = (char **) xmalloc (i * sizeof (char *));
     2424  new_argv = xmalloc (i * sizeof (char *));
    24122425
    24132426  /* All the args can fit in a buffer as big as LINE is.   */
    2414   ap = new_argv[0] = argstr = (char *) xmalloc (i);
     2427  ap = new_argv[0] = argstr = xmalloc (i);
    24152428  end = ap + i;
    24162429
     
    24512464                  *(ap++) = *p;
    24522465                }
    2453               /* If there's a TAB here, skip it.  */
    2454               if (p[1] == '\t')
     2466              /* If there's a command prefix char here, skip it.  */
     2467              if (p[1] == cmd_prefix)
    24552468                ++p;
    24562469            }
     
    25012514                ++p;
    25022515
    2503                 /* If there is a tab after a backslash-newline, remove it.  */
    2504                 if (p[1] == '\t')
     2516                /* If there is a command prefix after a backslash-newline,
     2517                   remove it.  */
     2518                if (p[1] == cmd_prefix)
    25052519                  ++p;
    25062520
     
    26292643      /* Line was empty.  */
    26302644      free (argstr);
    2631       free ((char *)new_argv);
     2645      free (new_argv);
    26322646      return 0;
    26332647    }
     
    26422656      /* Free the old argument list we were working on.  */
    26432657      free (argstr);
    2644       free ((char *)new_argv);
     2658      free (new_argv);
    26452659    }
    26462660
     
    26552669    char *dptr;
    26562670
    2657     buffer = (char *)xmalloc (strlen (line)+1);
     2671    buffer = xmalloc (strlen (line)+1);
    26582672
    26592673    ptr = line;
     
    26722686    *dptr = 0;
    26732687
    2674     new_argv = (char **) xmalloc (2 * sizeof (char *));
     2688    new_argv = xmalloc (2 * sizeof (char *));
    26752689    new_argv[0] = buffer;
    26762690    new_argv[1] = 0;
     
    27082722    unsigned int line_len = strlen (line);
    27092723
    2710     char *new_line = (char *) alloca (shell_len + (sizeof (minus_c) - 1)
    2711                                       + (line_len * 2) + 1);
     2724    char *new_line = alloca (shell_len + (sizeof (minus_c)-1)
     2725                             + (line_len*2) + 1);
    27122726    char *command_ptr = NULL; /* used for batch_mode_shell mode */
    27132727
     
    27182732
    27192733    ap = new_line;
    2720     bcopy (shell, ap, shell_len);
     2734    memcpy (ap, shell, shell_len);
    27212735    ap += shell_len;
    2722     bcopy (minus_c, ap, sizeof (minus_c) - 1);
     2736    memcpy (ap, minus_c, sizeof (minus_c) - 1);
    27232737    ap += sizeof (minus_c) - 1;
    27242738    command_ptr = ap;
     
    27492763
    27502764            ++p;
    2751             if (p[1] == '\t')
     2765            if (p[1] == cmd_prefix)
    27522766              ++p;
    27532767
     
    27842798      /* Need to allocate new_argv, although it's unused, because
    27852799        start_job_command will want to free it and its 0'th element.  */
    2786       new_argv = (char **) xmalloc(2 * sizeof (char *));
     2800      new_argv = xmalloc(2 * sizeof (char *));
    27872801      new_argv[0] = xstrdup ("");
    27882802      new_argv[1] = NULL;
     
    28112825
    28122826      /* create argv */
    2813       new_argv = (char **) xmalloc(3 * sizeof (char *));
     2827      new_argv = xmalloc(3 * sizeof (char *));
    28142828      if (unixy_shell) {
    28152829        new_argv[0] = xstrdup (shell);
     
    28232837#endif /* WINDOWS32 */
    28242838    if (unixy_shell)
    2825       new_argv = construct_command_argv_internal (new_line, (char **) NULL,
    2826                                                   (char *) 0, (char *) 0,
    2827                                                   (char **) 0);
     2839      new_argv = construct_command_argv_internal (new_line, 0, 0, 0, 0);
    28282840#ifdef __EMX__
    28292841    else if (!unixy_shell)
     
    28422854              {
    28432855                q += 2; /* remove '\\' and '\n' */
    2844                 if (q[0] == '\t')
    2845                   q++; /* remove 1st tab in the next line */
     2856                /* Remove any command prefix in the next line */
     2857                if (q[0] == cmd_prefix)
     2858                  q++;
    28462859              }
    28472860            else
     
    28832896
    28842897          /* exactly 3 arguments + NULL */
    2885           new_argv = (char **) xmalloc (4 * sizeof (char *));
     2898          new_argv = xmalloc (4 * sizeof (char *));
    28862899          /* Exactly strlen(shell) + strlen("/c") + strlen(line) + 3 times
    28872900             the trailing '\0' */
    2888           new_argv[0] = (char *) malloc (sh_len + line_len + 5);
     2901          new_argv[0] = xmalloc (sh_len + line_len + 5);
    28892902          memcpy (new_argv[0], shell, sh_len + 1);
    28902903          new_argv[1] = new_argv[0] + sh_len + 1;
     
    29012914           instead of recursively calling ourselves, because we
    29022915           cannot backslash-escape the special characters (see above).  */
    2903         new_argv = (char **) xmalloc (sizeof (char *));
     2916        new_argv = xmalloc (sizeof (char *));
    29042917        line_len = strlen (new_line) - shell_len - sizeof (minus_c) + 1;
    29052918        new_argv[0] = xmalloc (line_len + 1);
     
    29592972    }
    29602973
    2961   argv = (char **)malloc (argc * sizeof (char *));
     2974  argv = xmalloc (argc * sizeof (char *));
    29622975  if (argv == 0)
    29632976    abort ();
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