Ignore:
Timestamp:
Mar 14, 2018, 10:28:10 PM (7 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

  • trunk/src/kmk/incdep.c

    r3100 r3140  
    3838#endif
    3939
    40 #include "make.h"
     40#include "makeint.h"
    4141
    4242#if !defined(WINDOWS32) && !defined(__OS2__)
     
    4848#include <glob.h>
    4949
     50#include "filedef.h"
    5051#include "dep.h"
    51 #include "filedef.h"
    5252#include "job.h"
    5353#include "commands.h"
     
    108108    int recursive;
    109109    struct variable_set *set;
    110     const struct floc *flocp;               /* NILF */
     110    const floc *flocp;                      /* NILF */
    111111};
    112112
     
    115115    struct incdep_variable_def *next;
    116116    /* the parameters */
    117     const struct floc *flocp;               /* NILF */
     117    const floc *flocp;                      /* NILF */
    118118    struct strcache2_entry *name_entry;     /* dep strcache - WRONG */
    119119    char *value;                            /* xmalloc'ed, free it */
     
    131131    struct strcache2_entry *filename_entry; /* dep strcache; converted to a nameseq record. */
    132132    struct dep *deps;                       /* All the names are dep strcache entries. */
    133     const struct floc *flocp;               /* NILF */
     133    const floc *flocp;                     /* NILF */
    134134};
    135135
     
    238238*   Internal Functions                                                         *
    239239*******************************************************************************/
    240 static void incdep_flush_it (struct floc *);
    241 static void eval_include_dep_file (struct incdep *, struct floc *);
     240static void incdep_flush_it (floc *);
     241static void eval_include_dep_file (struct incdep *, floc *);
    242242static void incdep_commit_recorded_file (const char *filename, struct dep *deps,
    243                                          const struct floc *flocp);
     243                                         const floc *flocp);
    244244
    245245
     
    496496/* Reads a dep file into memory. */
    497497static int
    498 incdep_read_file (struct incdep *cur, struct floc *f)
     498incdep_read_file (struct incdep *cur, floc *f)
    499499{
    500500#ifdef INCDEP_USE_KFSCACHE
     
    513513      incdep_xfree (cur, cur->file_base);
    514514    }
    515   error (f, "%s/%s: error reading file", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName);
     515  OSS (error, f, "%s/%s: error reading file", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName);
    516516
    517517#else /* !INCDEP_USE_KFSCACHE */
     
    520520
    521521  errno = 0;
    522 #ifdef O_BINARY
     522# ifdef O_BINARY
    523523  fd = open (cur->name, O_RDONLY | O_BINARY, 0);
    524 #else
     524# else
    525525  fd = open (cur->name, O_RDONLY, 0);
    526 #endif
     526# endif
    527527  if (fd < 0)
    528528    {
     
    531531      if (err == ENOENT || stat (cur->name, &st) != 0)
    532532        return 1;
    533       error (f, "%s: %s", cur->name, strerror (err));
     533      OSS (error, f, "%s: %s", cur->name, strerror (err));
    534534      return -1;
    535535    }
    536 #ifdef KBUILD_OS_WINDOWS /* fewer kernel calls */
     536# ifdef KBUILD_OS_WINDOWS /* fewer kernel calls */
    537537  if (!birdStatOnFdJustSize (fd, &st.st_size))
    538 #else
     538# else
    539539  if (!fstat (fd, &st))
    540 #endif
     540# endif
    541541    {
    542542      cur->file_base = incdep_xmalloc (cur, st.st_size + 1);
     
    673673  if (getenv ("KMK_THREADS_DISABLED"))
    674674    {
    675       message (1, "Threads disabled (environment)");
     675      O (message, 1, "Threads disabled (environment)");
    676676      return 0;
    677677    }
     
    694694   || getenv ("FAKEROOT_DB_SEARCH_PATHS"))
    695695    {
    696       message (1, "Threads disabled (fakeroot)");
     696      O (message, 1, "Threads disabled (fakeroot)");
    697697      return 0;
    698698    }
     
    702702  if (getenv ("LD_PRELOAD"))
    703703    {
    704       message (1, "Threads disabled (LD_PRELOAD)");
     704      O (message, 1, "Threads disabled (LD_PRELOAD)");
    705705      return 0;
    706706    }
     
    723723/* Creates the the worker threads. */
    724724static void
    725 incdep_init (struct floc *f)
     725incdep_init (floc *f)
    726726{
    727727  unsigned i;
     
    754754  rc = pthread_mutex_init (&incdep_mtx, NULL);
    755755  if (rc)
    756     fatal (f, _("pthread_mutex_init failed: err=%d"), rc);
     756    ON (fatal, f, _("pthread_mutex_init failed: err=%d"), rc);
    757757  rc = pthread_cond_init (&incdep_cond_todo, NULL);
    758758  if (rc)
    759     fatal (f, _("pthread_cond_init failed: err=%d"), rc);
     759    ON (fatal, f, _("pthread_cond_init failed: err=%d"), rc);
    760760  rc = pthread_cond_init (&incdep_cond_done, NULL);
    761761  if (rc)
    762     fatal (f, _("pthread_cond_init failed: err=%d"), rc);
     762    ON (fatal, f, _("pthread_cond_init failed: err=%d"), rc);
    763763
    764764#elif defined (WINDOWS32)
     
    766766  incdep_hev_todo = CreateEvent (NULL, TRUE /*bManualReset*/, FALSE /*bInitialState*/, NULL);
    767767  if (!incdep_hev_todo)
    768     fatal (f, _("CreateEvent failed: err=%d"), GetLastError());
     768    ON (fatal, f, _("CreateEvent failed: err=%d"), GetLastError());
    769769  incdep_hev_done = CreateEvent (NULL, TRUE /*bManualReset*/, FALSE /*bInitialState*/, NULL);
    770770  if (!incdep_hev_done)
    771     fatal (f, _("CreateEvent failed: err=%d"), GetLastError());
     771    ON (fatal, f, _("CreateEvent failed: err=%d"), GetLastError());
    772772  incdep_hev_todo_waiters = 0;
    773773  incdep_hev_done_waiters = 0;
     
    777777  rc = DosCreateEventSem (NULL, &incdep_hev_todo, 0, FALSE);
    778778  if (rc)
    779     fatal (f, _("DosCreateEventSem failed: rc=%d"), rc);
     779    ON (fatal, f, _("DosCreateEventSem failed: rc=%d"), rc);
    780780  rc = DosCreateEventSem (NULL, &incdep_hev_done, 0, FALSE);
    781781  if (rc)
    782     fatal (f, _("DosCreateEventSem failed: rc=%d"), rc);
     782    ON (fatal, f, _("DosCreateEventSem failed: rc=%d"), rc);
    783783  incdep_hev_todo_waiters = 0;
    784784  incdep_hev_done_waiters = 0;
     
    827827          rc = pthread_attr_init (&attr);
    828828          if (rc)
    829             fatal (f, _("pthread_attr_init failed: err=%d"), rc);
     829            ON (fatal, f, _("pthread_attr_init failed: err=%d"), rc);
    830830          /*rc = pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_JOINABLE); */
    831831          rc = pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
    832832          if (rc)
    833             fatal (f, _("pthread_attr_setdetachstate failed: err=%d"), rc);
     833            ON (fatal, f, _("pthread_attr_setdetachstate failed: err=%d"), rc);
    834834          rc = pthread_create (&incdep_threads[i], &attr,
    835835                               incdep_worker_pthread, (void *)(size_t)i);
    836836          if (rc)
    837             fatal (f, _("pthread_mutex_init failed: err=%d"), rc);
     837            ON (fatal, f, _("pthread_mutex_init failed: err=%d"), rc);
    838838          pthread_attr_destroy (&attr);
    839839
     
    843843                                    (void *)i, 0, &tid);
    844844          if (hThread == 0 || hThread == ~(uintptr_t)0)
    845             fatal (f, _("_beginthreadex failed: err=%d"), errno);
     845            ON (fatal, f, _("_beginthreadex failed: err=%d"), errno);
    846846          incdep_threads[i] = (HANDLE)hThread;
    847847
     
    849849          tid = _beginthread (incdep_worker_os2, NULL, 128*1024, (void *)i);
    850850          if (tid <= 0)
    851             fatal (f, _("_beginthread failed: err=%d"), errno);
     851            ON (fatal, f, _("_beginthread failed: err=%d"), errno);
    852852          incdep_threads[i] = tid;
    853853#endif
     
    927927  if (cur->err_msg)
    928928#ifdef INCDEP_USE_KFSCACHE
    929     error(NILF, "%s/%s(%d): %s", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName, cur->err_line_no, cur->err_msg);
     929    OSSNS (error, NILF, "%s/%s(%d): %s", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName,
     930           cur->err_line_no, cur->err_msg);
    930931#else
    931     error(NILF, "%s(%d): %s", cur->name, cur->err_line_no, cur->err_msg);
     932    OSNS (error,NILF, "%s(%d): %s", cur->name, cur->err_line_no, cur->err_msg);
    932933#endif
    933934
     
    10081009  if (cur->worker_tid == -1)
    10091010#ifdef INCDEP_USE_KFSCACHE
    1010     error (NILF, "%s/%s(%d): %s", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName, line_no, msg);
     1011    OSSNS (error,NILF, "%s/%s(%d): %s", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName, line_no, msg);
    10111012#else
    1012     error (NILF, "%s(%d): %s", cur->name, line_no, msg);
     1013    OSNS (error, NILF, "%s(%d): %s", cur->name, line_no, msg);
    10131014#endif
    10141015#ifdef PARSE_IN_WORKER
     
    10791080                               int recursive,
    10801081                               struct variable_set *set,
    1081                                const struct floc *flocp)
     1082                               const floc *flocp)
    10821083{
    10831084  assert (!duplicate_value);
     
    11121113static void
    11131114incdep_record_variable_def (struct incdep *cur,
    1114                             const struct floc *flocp,
     1115                            const floc *flocp,
    11151116                            const char *name,
    11161117                            unsigned int name_length,
     
    11521153static void
    11531154incdep_commit_recorded_file (const char *filename, struct dep *deps,
    1154                              const struct floc *flocp)
     1155                             const floc *flocp)
    11551156{
    11561157  struct file *f;
     
    11741175     )
    11751176    {
    1176       error (flocp, _("reserved filename '%s' used in dependency file, ignored"), filename);
     1177      OS (error, flocp, _("reserved filename '%s' used in dependency file, ignored"), filename);
    11771178      return;
    11781179    }
     
    11821183  if (f->double_colon)
    11831184    {
    1184       error (flocp, _("dependency file '%s' has a double colon entry already, ignoring"), filename);
     1185      OS (error, flocp, _("dependency file '%s' has a double colon entry already, ignoring"), filename);
    11851186      return;
    11861187    }
     
    12081209                    const char *filename,
    12091210                    struct dep *deps,
    1210                     const struct floc *flocp)
     1211                    const floc *flocp)
    12111212{
    12121213  if (cur->worker_tid == -1)
     
    12531254   */
    12541255static void
    1255 eval_include_dep_file (struct incdep *curdep, struct floc *f)
     1256eval_include_dep_file (struct incdep *curdep, floc *f)
    12561257{
    12571258  unsigned line_no = 1;
     
    12681269    {
    12691270      /* skip empty lines */
    1270       while (cur < file_end && isspace ((unsigned char)*cur) && *cur != '\n')
     1271      while (cur < file_end && ISSPACE (*cur) && *cur != '\n')
    12711272        ++cur;
    12721273      if (cur >= file_end)
     
    13121313          /* extract the variable name. */
    13131314          cur += 7;
    1314           while (isblank ((unsigned char)*cur))
     1315          while (ISBLANK (*cur))
    13151316            ++cur;
    13161317          value_start = endp = memchr (cur, '\n', file_end - cur);
    13171318          if (!endp)
    13181319              endp = cur;
    1319           while (endp > cur && isspace ((unsigned char)endp[-1]))
     1320          while (endp > cur && ISSPACE (endp[-1]))
    13201321            --endp;
    13211322          var_len = endp - cur;
     
    13371338                {
    13381339                  endp = cur + 5;
    1339                   while (endp < file_end && isspace ((unsigned char)*endp) && *endp != '\n')
     1340                  while (endp < file_end && ISSPACE (*endp) && *endp != '\n')
    13401341                    endp++;
    13411342                  if (endp >= file_end || *endp == '\n')
     
    14481449              /* extract the variable name. */
    14491450              endp = flavor == f_recursive ? equalp : equalp - 1;
    1450               while (endp > cur && isblank ((unsigned char)endp[-1]))
     1451              while (endp > cur && ISBLANK (endp[-1]))
    14511452                --endp;
    14521453              var_len = endp - cur;
     
    14671468              /* find the start of the value. */
    14681469              cur = equalp + 1;
    1469               while (cur < file_end && isblank ((unsigned char)*cur))
     1470              while (cur < file_end && ISBLANK (*cur))
    14701471                cur++;
    14711472              value_start = cur;
     
    16291630              /* Extract the first filename after trimming and basic checks. */
    16301631              fnend = colonp;
    1631               while ((uintptr_t)fnend > (uintptr_t)cur && isblank ((unsigned char)fnend[-1]))
     1632              while ((uintptr_t)fnend > (uintptr_t)cur && ISBLANK (fnend[-1]))
    16321633                --fnend;
    16331634              if (cur == fnend)
     
    16431644
    16441645              fnnext = cur;
    1645               while (fnnext != fnend && !isblank ((unsigned char)*fnnext))
     1646              while (fnnext != fnend && !ISBLANK (*fnnext))
    16461647                fnnext++;
    16471648              filename = incdep_dep_strcache (curdep, cur, fnnext - cur);
     
    16521653                {
    16531654                  /* skip blanks and count lines. */
    1654                   while (cur < file_end && isspace ((unsigned char)*cur) && *cur != '\n')
     1655                  while (cur < file_end && ISSPACE (*cur) && *cur != '\n')
    16551656                    ++cur;
    16561657                  if (cur >= file_end)
     
    16791680                  /* find the end of the filename */
    16801681                  endp = cur;
    1681                   while (endp < file_end && !isspace ((unsigned char)*endp))
     1682                  while (endp < file_end && !ISSPACE (*endp))
    16821683                    ++endp;
    16831684
     
    17001701                    const char *filename_prev = filename;
    17011702                    const char *fnstart;
    1702                     while (fnnext != fnend && isblank ((unsigned char)*fnnext))
     1703                    while (fnnext != fnend && ISBLANK (*fnnext))
    17031704                      fnnext++;
    17041705                    if (fnnext == fnend)
     
    17061707
    17071708                    fnstart = fnnext;
    1708                     while (fnnext != fnend && !isblank ((unsigned char)*fnnext))
     1709                    while (fnnext != fnend && !ISBLANK (*fnnext))
    17091710                      fnnext++;
    17101711
     
    17241725/* Flushes the incdep todo and done lists. */
    17251726static void
    1726 incdep_flush_it (struct floc *f)
     1727incdep_flush_it (floc *f)
    17271728{
    17281729  incdep_lock ();
     
    17851786   employing threads to try speed up the file reading. */
    17861787void
    1787 eval_include_dep (const char *names, struct floc *f, enum incdep_op op)
     1788eval_include_dep (const char *names, floc *f, enum incdep_op op)
    17881789{
    17891790  struct incdep *head = 0;
Note: See TracChangeset for help on using the changeset viewer.