pftw.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. libpftw — parallel file tree walk library
  3. Copyright (C) 2015 Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #include <sys/types.h>
  16. #include <sys/stat.h>
  17. #include <unistd.h>
  18. #include <ftw.h>
  19. #define PFTW_MAX_THREADS_BITS 8
  20. #define PFTW_MAX_QUEUE_LENGTH_BITS 2
  21. #define PFTW_DIFFICULTY_THRESHOLD 4
  22. #define PFTW_MAX_THREADS (1 << PFTW_MAX_THREADS_BITS)
  23. #define PFTW_MAX_QUEUE_LENGTH (1 << (PFTW_MAX_THREADS_BITS + PFTW_MAX_QUEUE_LENGTH_BITS))
  24. #define PFTW_ALLOCPORTION (1<<4)
  25. //struct FTW;
  26. typedef int (*pftw_callback_t) (
  27. const char *fpath,
  28. const struct stat *sb,
  29. int typeflag,
  30. struct FTW *ftwbuf,
  31. void *arg);
  32. extern int pftw_init(int num_threads);
  33. extern int pftw(const char *dirpath, pftw_callback_t fn, int nopenfd, int flags, void *arg);
  34. extern int pftw_deinit();