Lines Matching +full:- +full:h
2 util.h - utility functions
3 Copyright (C) 2016-2020, Przemyslaw Skibinski, Yann Collet
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 /*-****************************************
32 #include "platform.h" /* PLATFORM_POSIX_VERSION */
33 #include <stddef.h> /* size_t, ptrdiff_t */
34 #include <stdlib.h> /* malloc */
35 #include <string.h> /* strlen, strncpy */
36 #include <stdio.h> /* fprintf, fileno */
37 #include <assert.h>
38 #include <sys/types.h> /* stat, utime */
39 #include <sys/stat.h> /* stat */
41 # include <sys/utime.h> /* utime */
42 # include <io.h> /* _chmod */
44 # include <unistd.h> /* chown, stat */
46 # include <utime.h> /* utime */
48 # include <fcntl.h> /* AT_FDCWD */
49 # include <sys/stat.h> /* for utimensat */
52 #include <time.h> /* time */
53 #include <limits.h> /* INT_MAX */
54 #include <errno.h>
58 /*-**************************************************************
62 # include <stdint.h>
95 /*-****************************************
96 * Sleep functions: Windows - Posix - others
99 # include <windows.h>
103 #elif PLATFORM_POSIX_VERSION >= 0 /* Unix-like operating system */
104 # include <unistd.h>
105 # include <sys/resource.h> /* setpriority */
106 # include <time.h> /* clock_t, nanosleep, clock, CLOCKS_PER_SEC */
108 # define SET_REALTIME_PRIORITY setpriority(PRIO_PROCESS, 0, -20)
113 …_VERSION >= 199309L)) || (PLATFORM_POSIX_VERSION >= 200112L) /* nanosleep requires POSIX.1-2001 */
125 /*-****************************************
146 /*-****************************************
161 /*-****************************************
178 /*-****************************************
194 return 1000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart; in UTIL_getSpanTimeMicro()
205 return 1000000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart; in UTIL_getSpanTimeNano()
210 #include <mach/mach_time.h>
221 return (((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom)) / 1000ULL; in UTIL_getSpanTimeMicro()
231 return ((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom); in UTIL_getSpanTimeNano()
236 #include <time.h>
249 diff.tv_sec = (end.tv_sec - 1) - begin.tv_sec; in UTIL_getSpanTime()
250 diff.tv_nsec = (end.tv_nsec + 1000000000ULL) - begin.tv_nsec; in UTIL_getSpanTime()
252 diff.tv_sec = end.tv_sec - begin.tv_sec; in UTIL_getSpanTime()
253 diff.tv_nsec = end.tv_nsec - begin.tv_nsec; in UTIL_getSpanTime()
274 #else /* relies on standard C (note : clock_t measurements can be wrong when using multi-threadin…
278 …IL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000ULL * (clockEnd - clockStart) / CLOCKS… in UTIL_getSpanTimeMicro()
279 …time_t clockStart, UTIL_time_t clockEnd) { return 1000000000ULL * (clockEnd - clockStart) / CLOCKS… in UTIL_getSpanTimeNano()
308 /*-****************************************
327 return -1; in UTIL_setFileStat()
333 timebuf.modtime = statbuf->st_mtime; in UTIL_setFileStat()
339 timebuf[1].tv_sec = statbuf->st_mtime; in UTIL_setFileStat()
345 res += chown(filename, statbuf->st_uid, statbuf->st_gid); /* Copy ownership */ in UTIL_setFileStat()
348 res += chmod(filename, statbuf->st_mode & 07777); /* Copy file permissions */ in UTIL_setFileStat()
351 return -res; /* number of errors is returned */ in UTIL_setFileStat()
360 if (r || !(statbuf->st_mode & S_IFREG)) return 0; /* No good... */ in UTIL_getFileStat()
363 if (r || !S_ISREG(statbuf->st_mode)) return 0; /* No good... */ in UTIL_getFileStat()
487 ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE; in UTIL_prepareFileList()
493 strncpy(*bufStart + *pos, path, *bufEnd - (*bufStart + *pos)); in UTIL_prepareFileList()
506 …ined(__linux__) || (PLATFORM_POSIX_VERSION >= 200112L) /* opendir, readdir require POSIX.1-2001 */
508 # include <dirent.h> /* opendir, readdir */
509 # include <string.h> /* strerror, memcpy */
528 if (strcmp (entry->d_name, "..") == 0 || in UTIL_prepareFileList()
529 strcmp (entry->d_name, ".") == 0) continue; in UTIL_prepareFileList()
530 fnameLength = strlen(entry->d_name); in UTIL_prepareFileList()
535 memcpy(path+dirLength+1, entry->d_name, fnameLength); in UTIL_prepareFileList()
544 size_t const newListSize = (size_t)(*bufEnd - *bufStart) + LIST_SIZE_INCREASE; in UTIL_prepareFileList()
550 strncpy(*bufStart + *pos, path, *bufEnd - (*bufStart + *pos)); in UTIL_prepareFileList()
580 …* UTIL_createFileList - takes a list of files and directories (params: inputNames, inputNamesNb), …
614 bufSize = (size_t)(bufend - buf); in UTIL_createFileList()