VirtualBox

Changeset 2702 in kBuild for trunk/src/kmk/glob


Ignore:
Timestamp:
Nov 21, 2013 12:11:08 AM (11 years ago)
Author:
bird
Message:

kmk/WindowsNT: Avoiding unnecessary stat() calls. Reimplemented stat(), lstat(), fstat(), opendir(), readdir(), and closedir() using native NT APIs.

Location:
trunk/src/kmk/glob
Files:
2 edited

Legend:

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

    r2591 r2702  
    807807      /* Return the directory if we don't check for error or if it exists.  */
    808808      if ((flags & GLOB_NOCHECK)
     809#ifdef KMK
     810          || (flags & GLOB_ALTDIRFUNC
     811              ? (*pglob->gl_isdir) (dirname)
     812              : __stat (dirname, &st) == 0 && S_ISDIR (st.st_mode))
     813#else
    809814          || (((flags & GLOB_ALTDIRFUNC)
    810815               ? (*pglob->gl_stat) (dirname, &st)
    811816               : __stat (dirname, &st)) == 0
    812               && S_ISDIR (st.st_mode)))
     817              && S_ISDIR (st.st_mode))
     818#endif
     819          )
    813820        {
    814821          pglob->gl_pathv
     
    954961
    955962                  /* First check whether this really is a directory.  */
     963#ifdef KMK
     964                  if (flags & GLOB_ALTDIRFUNC
     965                      ? !pglob->gl_isdir (dir)
     966                      : __stat (dir, &st) != 0 || !S_ISDIR (st.st_mode))
     967#else
    956968                  if (((flags & GLOB_ALTDIRFUNC)
    957969                       ? (*pglob->gl_stat) (dir, &st) : __stat (dir, &st)) != 0
    958970                      || !S_ISDIR (st.st_mode))
     971#endif
    959972                    /* No directory, ignore this entry.  */
    960973                    continue;
     
    10291042      struct stat st;
    10301043      for (i = oldcount; i < pglob->gl_pathc; ++i)
     1044#ifdef KMK
     1045        if (flags & GLOB_ALTDIRFUNC
     1046            ? pglob->gl_isdir (pglob->gl_pathv[i])
     1047            : __stat (pglob->gl_pathv[i], &st) == 0 && S_ISDIR (st.st_mode) )
     1048#else
    10311049        if (((flags & GLOB_ALTDIRFUNC)
    10321050             ? (*pglob->gl_stat) (pglob->gl_pathv[i], &st)
    10331051             : __stat (pglob->gl_pathv[i], &st)) == 0
    10341052            && S_ISDIR (st.st_mode))
     1053#endif
    10351054          {
    10361055            size_t len = strlen (pglob->gl_pathv[i]) + 2;
     
    12621281          memcpy (&fullname[dirlen + 1], pattern, patlen + 1);
    12631282# endif
     1283# ifdef KMK
     1284          if (flags & GLOB_ALTDIRFUNC ? pglob->gl_exists (fullname) : __stat (fullname, &st) == 0)
     1285# else
    12641286          if (((flags & GLOB_ALTDIRFUNC)
    12651287               ? (*pglob->gl_stat) (fullname, &st)
    12661288               : __stat (fullname, &st)) == 0)
     1289# endif
    12671290            /* We found this file to be existing.  Now tell the rest
    12681291               of the function to copy this name into the result.  */
  • trunk/src/kmk/glob/glob.h

    r1993 r2702  
    137137    int (*gl_stat) __PMT ((__const char *, struct stat *));
    138138#endif
     139#ifdef KMK
     140    int (*gl_exists) __PMT ((__const char *));
     141    int (*gl_isdir) __PMT ((__const char *));
     142#endif
    139143  } glob_t;
    140144
Note: See TracChangeset for help on using the changeset viewer.

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