Changeset 3628 for trunk/src/kmk


Ignore:
Timestamp:
Oct 23, 2024, 1:34:56 AM (9 months ago)
Author:
bird
Message:

kmk/incdep.c: Fixed the list corruption when there are actually no dependency files to be added (they don't exist according to kFsCacheLookupWithLengthA).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/incdep.c

    r3619 r3628  
    9191#if defined(__gnu_linux__) || defined(__linux__)
    9292# define PARSE_IN_WORKER
     93#endif
     94
     95
     96/*******************************************************************************
     97* Defined Constants And Macros                                                 *
     98********************************************************************************/
     99/* Custom assertion macro */
     100#if (!defined(NDEBUG) || 0) && defined(_MSC_VER)
     101# define MY_ASSERT(expr) do { \
     102    if (!!(expr)) { /* likely */ } \
     103    else { fprintf (stderr, "assertion failed on line %u in incdep.c: %s\n", __LINE__, #expr); __debugbreak(); } \
     104  } while (0)
     105# undef assert
     106# define assert(expr)     MY_ASSERT(expr)
     107#else
     108# define MY_ASSERT(expr)  ((void)0)
    93109#endif
    94110
     
    14291445      if (ch != '\\' && ch != '$')
    14301446        {
    1431           if (!STOP_SET (ch, stop_mask))
     1447          if (!STOP_SET (ch, stop_mask)
     1448#ifdef HAVE_DOS_PATHS
     1449              || (    ch == ':'
     1450                   && (uintptr_t)src < (uintptr_t)end
     1451                   && (*src == '/' || *src == '\\')
     1452                   && (dst - start) == 1
     1453                   && isalpha ((unsigned char)*start))
     1454#endif
     1455             )
    14321456            *dst++ = ch;
    14331457          else
     
    21272151                    else
    21282152                      filename = incdep_unescape_and_cache_filename (curdep, (char *)fnnext, fnend, 0, &fnnext, NULL);
    2129                     if (filename != filename_prev) /* clang optimization. */
     2153                    if (filename != filename_prev) /* clang optimization, it emit two targets for each dependency list. */
    21302154                      incdep_record_file (curdep, filename, incdep_dup_dep_list (curdep, deps), f);
    21312155                  }
     
    22352259  unsigned int name_len;
    22362260
     2261#if 0 /* sanity / debug */
     2262  {
     2263    struct incdep *check, *checktail;
     2264    unsigned items;
     2265    for (items = 0, check = checktail = incdep_head_todo; check; check = check->next)
     2266      checktail = check, items++;
     2267    MY_ASSERT (items == incdep_count_todo);
     2268    MY_ASSERT (checktail == incdep_tail_todo);
     2269  }
     2270#endif
     2271
    22372272  /* loop through NAMES, creating a todo list out of them. */
    22382273
     
    23002335  else
    23012336    {
    2302       struct incdep *tmp;
    2303 
    2304       /* initialize the worker threads and related stuff the first time around. */
    2305 
    2306       if (!incdep_initialized)
    2307         incdep_init (f);
    2308 
    2309       /* queue the files and notify the worker threads. */
    2310 
    2311       incdep_lock ();
    2312 
    2313       tmp = incdep_tail_todo;
    2314       if (tmp)
    2315         {
    2316           assert (incdep_count_todo > 0);
    2317           assert (incdep_head_todo != NULL);
    2318           tmp->next = head;
    2319         }
    2320       else
    2321         {
    2322           assert (incdep_count_todo == 0);
    2323           assert (incdep_head_todo == NULL);
    2324           incdep_head_todo = head;
    2325         }
    2326       incdep_tail_todo = tail;
    2327       incdep_count_todo += count;
    2328       thrd_data->todo_count += count;
    2329 
    2330       incdep_signal_todo ();
    2331       incdep_unlock ();
    2332 
    2333       /* flush the todo queue if we're requested to do so. */
    2334 
    2335       if (op == incdep_flush)
    2336         incdep_flush_it (f);
     2337      if (head)
     2338        {
     2339          struct incdep *tmp;
     2340
     2341          /* initialize the worker threads and related stuff the first time around. */
     2342
     2343          if (!incdep_initialized)
     2344            incdep_init (f);
     2345
     2346          /* queue the files and notify the worker threads. */
     2347
     2348          incdep_lock ();
     2349
     2350          tmp = incdep_tail_todo;
     2351          if (tmp)
     2352            {
     2353              assert (incdep_count_todo > 0);
     2354              assert (incdep_head_todo != NULL);
     2355              tmp->next = head;
     2356            }
     2357          else
     2358            {
     2359              assert (incdep_count_todo == 0);
     2360              assert (incdep_head_todo == NULL);
     2361              incdep_head_todo = head;
     2362            }
     2363          incdep_tail_todo = tail;
     2364          incdep_count_todo += count;
     2365          thrd_data->todo_count += count;
     2366
     2367#if 0 /* sanity / debug */
     2368          {
     2369            struct incdep *check, *checktail;
     2370            unsigned items;
     2371            for (items = 0, check = checktail = incdep_head_todo; check; check = check->next)
     2372              checktail = check, items++;
     2373            MY_ASSERT (items == incdep_count_todo);
     2374            MY_ASSERT (checktail == incdep_tail_todo);
     2375          }
     2376#endif
     2377
     2378          incdep_signal_todo ();
     2379          incdep_unlock ();
     2380        }
     2381
     2382        /* flush the todo queue if we're requested to do so. */
     2383
     2384        if (op == incdep_flush)
     2385          incdep_flush_it (f);
    23372386    }
    23382387}
Note: See TracChangeset for help on using the changeset viewer.