Changeset 2861 for trunk/src/kmk


Ignore:
Timestamp:
Sep 2, 2016, 12:42:55 AM (9 years ago)
Author:
bird
Message:

Updates

Location:
trunk/src/kmk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/dir-nt-bird.c

    r2857 r2861  
    235235{
    236236    KMKNTOPENDIR *pDir = (KMKNTOPENDIR *)pvDir;
    237     while (pDir->idxNext < pDir->pDir->cChildren)
     237    KU32 const    cChildren = pDir->pDir->cChildren;
     238    while (pDir->idxNext < cChildren)
    238239    {
    239240        PKFSOBJ pEntry = pDir->pDir->papChildren[pDir->idxNext++];
     
    267268        }
    268269    }
     270
     271    /*
     272     * Fake the '.' and '..' directories because they're not part of papChildren above.
     273     */
     274    if (pDir->idxNext < cChildren + 2)
     275    {
     276        pDir->idxNext++;
     277        pDir->DirEnt.d_type    = DT_DIR;
     278        pDir->DirEnt.d_namlen  = pDir->idxNext - cChildren;
     279        pDir->DirEnt.d_reclen  = offsetof(struct dirent, d_name) + pDir->DirEnt.d_namlen;
     280        pDir->DirEnt.d_name[0] = '.';
     281        pDir->DirEnt.d_name[1] = '.';
     282        pDir->DirEnt.d_name[pDir->DirEnt.d_namlen] = '\0';
     283        return &pDir->DirEnt;
     284    }
     285
    269286    return NULL;
    270287}
     
    457474int stat_only_mtime(const char *pszPath, struct stat *pStat)
    458475{
    459     if (commands_started == 0)
    460     {
    461         KFSLOOKUPERROR  enmError;
    462         PKFSOBJ         pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError);
    463         if (pPathObj)
    464         {
    465             if (pPathObj->bObjType != KFSOBJ_TYPE_MISSING)
    466             {
    467                 kHlpAssert(pPathObj->fHaveStats); /* currently always true. */
    468                 pStat->st_mtime = pPathObj->Stats.st_mtime;
    469                 kFsCacheObjRelease(g_pFsCache, pPathObj);
    470                 return 0;
    471             }
    472 
     476    KFSLOOKUPERROR  enmError;
     477    PKFSOBJ         pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError);
     478    if (pPathObj)
     479    {
     480        if (pPathObj->bObjType != KFSOBJ_TYPE_MISSING)
     481        {
     482            kHlpAssert(pPathObj->fHaveStats); /* currently always true. */
     483            pStat->st_mtime = pPathObj->Stats.st_mtime;
    473484            kFsCacheObjRelease(g_pFsCache, pPathObj);
    474             errno = ENOENT;
    475         }
    476         else
    477             errno =    enmError == KFSLOOKUPERROR_NOT_DIR
    478                     || enmError == KFSLOOKUPERROR_PATH_COMP_NOT_DIR
    479                   ? ENOTDIR : ENOENT;
    480         return -1;
    481     }
    482     /** @todo implement cache refreshing.   */
    483     return birdStatFollowLink(pszPath, pStat);
    484 }
    485 
     485            return 0;
     486        }
     487
     488        kFsCacheObjRelease(g_pFsCache, pPathObj);
     489        errno = ENOENT;
     490    }
     491    else
     492        errno =    enmError == KFSLOOKUPERROR_NOT_DIR
     493                || enmError == KFSLOOKUPERROR_PATH_COMP_NOT_DIR
     494              ? ENOTDIR : ENOENT;
     495    return -1;
     496}
     497
     498
     499/**
     500 * Invalidate missing bits of the directory cache.
     501 *
     502 * This is called each time a make job completes.
     503 */
     504void dir_cache_invalid_missing(void)
     505{
     506    kFsCacheInvalidateMissing(g_pFsCache);
     507}
     508
  • trunk/src/kmk/incdep.c

    r2850 r2861  
    3232# define INCL_ERRORS
    3333#endif
     34#ifdef KBUILD_OS_WINDOWS
     35# ifdef KMK
     36#  define INCDEP_USE_KFSCACHE
     37# endif
     38#endif
    3439
    3540#include "make.h"
     
    6368# include <Windows.h>
    6469# define PARSE_IN_WORKER
     70#endif
     71
     72#ifdef INCDEP_USE_KFSCACHE
     73# include "nt/kFsCache.h"
     74extern PKFSCACHE g_pFsCache; /* dir-nt-bird.c for now */
    6575#endif
    6676
     
    146156  struct incdep_recorded_file *recorded_file_tail;
    147157#endif
    148 
     158#ifdef INCDEP_USE_KFSCACHE
     159  /** Pointer to the fs cache object for this file (it exists and is a file). */
     160  PKFSOBJ pFileObj;
     161#else
    149162  char name[1];
     163#endif
    150164};
    151165
     
    484498incdep_read_file (struct incdep *cur, struct floc *f)
    485499{
     500#ifdef INCDEP_USE_KFSCACHE
     501  size_t const cbFile = (size_t)cur->pFileObj->Stats.st_size;
     502
     503  assert(cur->pFileObj->fFlags);
     504  cur->file_base = incdep_xmalloc (cur, cbFile + 1);
     505  if (cur->file_base)
     506    {
     507      if (kFsCacheFileSimpleOpenReadClose (g_pFsCache, cur->pFileObj, 0, cur->file_base, cbFile))
     508        {
     509          cur->file_end = cur->file_base + cbFile;
     510          cur->file_base[cbFile] = '\0';
     511          return 0;
     512        }
     513      incdep_xfree (cur, cur->file_base);
     514    }
     515  error (f, "%s/%s: error reading file", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName);
     516
     517#else /* !INCDEP_USE_KFSCACHE */
    486518  int fd;
    487519  struct stat st;
     
    526558
    527559  close (fd);
     560#endif /* !INCDEP_USE_KFSCACHE */
    528561  cur->file_base = cur->file_end = NULL;
    529562  return -1;
     
    541574
    542575  incdep_xfree (cur, cur->file_base);
     576#ifdef INCDEP_USE_KFSCACHE
     577  /** @todo release object ref some day... */
     578#endif
    543579  cur->next = NULL;
    544580  free (cur);
     
    890926
    891927  if (cur->err_msg)
     928#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);
     930#else
    892931    error(NILF, "%s(%d): %s", cur->name, cur->err_line_no, cur->err_msg);
     932#endif
    893933
    894934
     
    9671007{
    9681008  if (cur->worker_tid == -1)
     1009#ifdef INCDEP_USE_KFSCACHE
     1010    error (NILF, "%s/%s(%d): %s", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName, line_no, msg);
     1011#else
    9691012    error (NILF, "%s(%d): %s", cur->name, line_no, msg);
     1013#endif
    9701014#ifdef PARSE_IN_WORKER
    9711015  else
     
    17541798  while ((name = find_next_token (&names_iterator, &name_len)) != 0)
    17551799    {
     1800#ifdef INCDEP_USE_KFSCACHE
     1801       KFSLOOKUPERROR enmError;
     1802       PKFSOBJ pFileObj = kFsCacheLookupWithLengthA (g_pFsCache, name, name_len, &enmError);
     1803       if (!pFileObj)
     1804         continue;
     1805       if (pFileObj->bObjType != KFSOBJ_TYPE_FILE)
     1806         {
     1807           kFsCacheObjRelease (g_pFsCache, pFileObj);
     1808           continue;
     1809         }
     1810
     1811       cur = xmalloc (sizeof (*cur));            /* not incdep_xmalloc here */
     1812       cur->pFileObj = pFileObj;
     1813#else
    17561814       cur = xmalloc (sizeof (*cur) + name_len); /* not incdep_xmalloc here */
    1757        cur->file_base = cur->file_end = NULL;
    17581815       memcpy (cur->name, name, name_len);
    17591816       cur->name[name_len] = '\0';
     1817#endif
     1818
     1819       cur->file_base = cur->file_end = NULL;
    17601820       cur->worker_tid = -1;
    17611821#ifdef PARSE_IN_WORKER
  • trunk/src/kmk/job.c

    r2846 r2861  
    686686              if (job_counter)
    687687                --job_counter;
     688
     689# if defined(KMK) && defined(KBUILD_OS_WINDOWS)
     690              /* Invalidate negative directory cache entries now that a
     691                 job has completed and possibly created new files that
     692                 was missing earlier. */
     693              extern void dir_cache_invalid_missing(void);
     694              dir_cache_invalid_missing ();
     695# endif
    688696            }
    689697          else
  • trunk/src/kmk/kbuild.c

    r2837 r2861  
    2929*   Header Files                                                               *
    3030*******************************************************************************/
     31#define NO_MEMCOPY_HACK
    3132#include "make.h"
    3233#include "filedef.h"
Note: See TracChangeset for help on using the changeset viewer.