mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Fix issues for latest GCC toolchain
This commit is contained in:
parent
5cb9b2658c
commit
3b086af91b
22 changed files with 148 additions and 166 deletions
|
@ -24,20 +24,13 @@
|
|||
#include "libc/str/str.h"
|
||||
|
||||
static textwindows bool SubpathExistsThatsNotDirectory(char16_t *path) {
|
||||
int e;
|
||||
char16_t *p;
|
||||
uint32_t attrs;
|
||||
e = errno;
|
||||
while ((p = strrchr16(path, '\\'))) {
|
||||
*p = u'\0';
|
||||
if ((attrs = GetFileAttributes(path)) != -1u) {
|
||||
if (attrs & kNtFileAttributeDirectory) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
errno = e;
|
||||
if ((attrs = GetFileAttributes(path)) != -1u &&
|
||||
!(attrs & kNtFileAttributeDirectory)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -21,31 +21,40 @@
|
|||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/stat.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/nt/createfile.h"
|
||||
#include "libc/nt/enum/accessmask.h"
|
||||
#include "libc/nt/enum/creationdisposition.h"
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/nt/enum/filesharemode.h"
|
||||
#include "libc/nt/errors.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
|
||||
textwindows int sys_fstatat_nt(int dirfd, const char *path, struct stat *st,
|
||||
int flags) {
|
||||
int rc;
|
||||
int rc, e;
|
||||
int64_t fh;
|
||||
uint32_t dwDesiredAccess;
|
||||
uint16_t path16[PATH_MAX];
|
||||
if (__mkntpathat(dirfd, path, 0, path16) == -1) return -1;
|
||||
BLOCK_SIGNALS;
|
||||
e = errno;
|
||||
dwDesiredAccess = kNtFileGenericRead;
|
||||
TryAgain:
|
||||
if ((fh = CreateFile(
|
||||
path16, kNtFileGenericRead,
|
||||
kNtFileShareRead | kNtFileShareWrite | kNtFileShareDelete, 0,
|
||||
kNtOpenExisting,
|
||||
path16, dwDesiredAccess, 0, 0, kNtOpenExisting,
|
||||
kNtFileAttributeNormal | kNtFileFlagBackupSemantics |
|
||||
((flags & AT_SYMLINK_NOFOLLOW) ? kNtFileFlagOpenReparsePoint
|
||||
: 0),
|
||||
0)) != -1) {
|
||||
rc = st ? sys_fstat_nt(fh, st) : 0;
|
||||
CloseHandle(fh);
|
||||
} else if (dwDesiredAccess == kNtFileGenericRead &&
|
||||
GetLastError() == kNtErrorSharingViolation) {
|
||||
dwDesiredAccess = kNtFileReadAttributes;
|
||||
errno = e;
|
||||
goto TryAgain;
|
||||
} else {
|
||||
rc = __winerr();
|
||||
}
|
||||
|
|
|
@ -26,15 +26,12 @@
|
|||
* Returns true if file exists and is a directory on Windows NT.
|
||||
*/
|
||||
bool isdirectory_nt(const char *path) {
|
||||
int e;
|
||||
uint32_t x;
|
||||
char16_t path16[PATH_MAX];
|
||||
e = errno;
|
||||
if (__mkntpath(path, path16) == -1) return -1;
|
||||
if ((x = GetFileAttributes(path16)) != -1u) {
|
||||
return !!(x & kNtFileAttributeDirectory);
|
||||
} else {
|
||||
errno = e;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,15 +26,12 @@
|
|||
* Returns true if file exists and is a regular file on Windows NT.
|
||||
*/
|
||||
bool isregularfile_nt(const char *path) {
|
||||
int e;
|
||||
uint32_t x;
|
||||
char16_t path16[PATH_MAX];
|
||||
e = errno;
|
||||
if (__mkntpath(path, path16) == -1) return -1;
|
||||
if ((x = GetFileAttributes(path16)) != -1u) {
|
||||
return !(x & (kNtFileAttributeDirectory | kNtFileAttributeReparsePoint));
|
||||
} else {
|
||||
errno = e;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/nt/files.h"
|
||||
|
||||
|
@ -26,15 +24,12 @@
|
|||
* Returns true if file exists and is a symbolic link on Windows NT.
|
||||
*/
|
||||
bool issymlink_nt(const char *path) {
|
||||
int e;
|
||||
uint32_t x;
|
||||
char16_t path16[PATH_MAX];
|
||||
e = errno;
|
||||
if (__mkntpath(path, path16) == -1) return -1;
|
||||
if ((x = GetFileAttributes(path16)) != -1u) {
|
||||
return !!(x & kNtFileAttributeReparsePoint);
|
||||
} else {
|
||||
errno = e;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
__msabi extern typeof(GetFileAttributes) *const __imp_GetFileAttributesW;
|
||||
|
||||
static int __mkntpathat_impl(int dirfd, const char *path, int flags,
|
||||
char16_t file[hasatleast PATH_MAX]) {
|
||||
char16_t dir[PATH_MAX];
|
||||
|
@ -71,7 +69,7 @@ int __mkntpathat(int dirfd, const char *path, int flags,
|
|||
if (len > 1 && !(len == 3 && file[1] == ':')) {
|
||||
file[--len] = 0;
|
||||
}
|
||||
if ((fattr = __imp_GetFileAttributesW(file)) != -1u &&
|
||||
if ((fattr = GetFileAttributes(file)) != -1u &&
|
||||
!(fattr & kNtFileAttributeReparsePoint) &&
|
||||
!(fattr & kNtFileAttributeDirectory)) {
|
||||
return enotdir();
|
||||
|
|
|
@ -57,7 +57,7 @@ static textwindows int64_t sys_open_nt_impl(int dirfd, const char *path,
|
|||
// you can't open symlinks; use readlink
|
||||
// this flag only applies to the final path component
|
||||
// if O_NOFOLLOW_ANY is passed (-1 on NT) it'll be rejected later
|
||||
uint32_t fattr = __imp_GetFileAttributesW(path16);
|
||||
uint32_t fattr = GetFileAttributes(path16);
|
||||
if (flags & O_NOFOLLOW) {
|
||||
if (fattr != -1u && (fattr & kNtFileAttributeReparsePoint)) {
|
||||
return eloop();
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/vga/vga.internal.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
ssize_t sys_readv_metal(int fd, const struct iovec *iov, int iovlen) {
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
textwindows ssize_t sys_readv_nt(int fd, const struct iovec *iov, int iovlen) {
|
||||
|
|
|
@ -50,4 +50,4 @@ ssize_t sys_readv_serial(int fd, const struct iovec *iov, int iovlen) {
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
__msabi extern typeof(GetFileAttributes) *const __imp_GetFileAttributesW;
|
||||
__msabi extern typeof(RemoveDirectory) *const __imp_RemoveDirectoryW;
|
||||
|
||||
static textwindows bool StripTrailingSlash(char16_t *path) {
|
||||
size_t n = strlen16(path);
|
||||
bool had_trailing_slash = false;
|
||||
|
@ -67,8 +64,8 @@ textwindows int sys_renameat_nt(int olddirfd, const char *oldpath, int newdirfd,
|
|||
// test for some known error conditions ahead of time
|
||||
// the enotdir check can't be done reactively
|
||||
// ideally we should resolve symlinks first
|
||||
uint32_t oldattr = __imp_GetFileAttributesW(M.oldpath16);
|
||||
uint32_t newattr = __imp_GetFileAttributesW(M.newpath16);
|
||||
uint32_t oldattr = GetFileAttributes(M.oldpath16);
|
||||
uint32_t newattr = GetFileAttributes(M.newpath16);
|
||||
if ((old_must_be_dir && oldattr != -1u &&
|
||||
!(oldattr & kNtFileAttributeDirectory)) ||
|
||||
(new_must_be_dir && newattr != -1u &&
|
||||
|
@ -85,7 +82,7 @@ textwindows int sys_renameat_nt(int olddirfd, const char *oldpath, int newdirfd,
|
|||
} else if ((oldattr & kNtFileAttributeDirectory) &&
|
||||
(newattr & kNtFileAttributeDirectory)) {
|
||||
// both old and new are directories
|
||||
if (!__imp_RemoveDirectoryW(M.newpath16) &&
|
||||
if (!RemoveDirectory(M.newpath16) &&
|
||||
GetLastError() == kNtErrorDirNotEmpty) {
|
||||
return enotempty();
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include "libc/runtime/stack.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
__msabi extern typeof(GetFileAttributes) *const __imp_GetFileAttributesW;
|
||||
|
||||
static struct {
|
||||
_Atomic(uint32_t) once;
|
||||
_Bool allowed;
|
||||
|
@ -72,7 +70,7 @@ textwindows int sys_symlinkat_nt(const char *target, int newdirfd,
|
|||
if ((targetlen = __mkntpath(target, M.target16)) == -1) return -1;
|
||||
|
||||
// determine if we need directory flag
|
||||
if ((attrs = __imp_GetFileAttributesW(M.target16)) != -1u) {
|
||||
if ((attrs = GetFileAttributes(M.target16)) != -1u) {
|
||||
if (attrs & kNtFileAttributeDirectory) {
|
||||
flags = kNtSymbolicLinkFlagDirectory;
|
||||
} else {
|
||||
|
|
|
@ -55,8 +55,7 @@ static textwindows bool IsDirectorySymlink(const char16_t *path) {
|
|||
}
|
||||
|
||||
static textwindows int sys_rmdir_nt(const char16_t *path) {
|
||||
int e, ms;
|
||||
e = errno;
|
||||
int ms;
|
||||
for (ms = 1;; ms *= 2) {
|
||||
if (RemoveDirectory(path)) {
|
||||
return 0;
|
||||
|
@ -67,14 +66,13 @@ static textwindows int sys_rmdir_nt(const char16_t *path) {
|
|||
// Alternative is use Microsoft internal APIs.
|
||||
// Never could have imagined it'd be this bad.
|
||||
if (GetLastError() == kNtErrorDirNotEmpty && ms <= 2048) {
|
||||
errno = e;
|
||||
Sleep(ms);
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return __winerr();
|
||||
}
|
||||
|
||||
static textwindows int sys_unlink_nt(const char16_t *path) {
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
|
||||
|
@ -27,15 +25,12 @@ __msabi extern typeof(GetFileAttributes) *const __imp_GetFileAttributesW;
|
|||
|
||||
/**
|
||||
* Gets file info on the New Technology.
|
||||
*
|
||||
* @return handle, or -1u on failure
|
||||
* @note this wrapper takes care of ABI, STRACE(), and __winerr()
|
||||
*/
|
||||
textwindows uint32_t GetFileAttributes(const char16_t *lpPathName) {
|
||||
uint32_t flags;
|
||||
flags = __imp_GetFileAttributesW(lpPathName);
|
||||
if (flags == -1u) __winerr();
|
||||
NTTRACE("GetFileAttributes(%#hs) → %s% m", lpPathName,
|
||||
NTTRACE("GetFileAttributes(%#hs) → %s", lpPathName,
|
||||
DescribeNtFileFlagAttr(flags));
|
||||
return flags;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
|
@ -25,12 +24,10 @@ __msabi extern typeof(RemoveDirectory) *const __imp_RemoveDirectoryW;
|
|||
|
||||
/**
|
||||
* Deletes existing empty directory on the New Technology.
|
||||
* @note this wrapper takes care of ABI, STRACE(), and __winerr()
|
||||
*/
|
||||
textwindows bool32 RemoveDirectory(const char16_t *lpPathName) {
|
||||
bool32 ok;
|
||||
ok = __imp_RemoveDirectoryW(lpPathName);
|
||||
if (!ok) __winerr();
|
||||
NTTRACE("RemoveDirectory(%#hs) → %hhhd% m", lpPathName, ok);
|
||||
NTTRACE("RemoveDirectory(%#hs) → %hhhd", lpPathName, ok);
|
||||
return ok;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,20 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define __PRIPTR "ll"
|
||||
#endif
|
||||
|
||||
#if __INT_FAST16_WIDTH__ == 16
|
||||
#define __PRIFAST16 "h"
|
||||
#elif __INT_FAST16_WIDTH__ == 32
|
||||
#define __PRIFAST16 ""
|
||||
#else
|
||||
#define __PRIFAST16 "l"
|
||||
#endif
|
||||
|
||||
#if __INT_FAST32_WIDTH__ == 32
|
||||
#define __PRIFAST32 ""
|
||||
#else
|
||||
#define __PRIFAST32 "l"
|
||||
#endif
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § dismal format notation » printf » decimal ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
@ -86,8 +100,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define PRIdLEAST128 __PRI128 "d"
|
||||
|
||||
#define PRIdFAST8 __PRI8 "d"
|
||||
#define PRIdFAST16 __PRI32 "d"
|
||||
#define PRIdFAST32 __PRI32 "d"
|
||||
#define PRIdFAST16 __PRIFAST16 "d"
|
||||
#define PRIdFAST32 __PRIFAST32 "d"
|
||||
#define PRIdFAST64 __PRI64 "d"
|
||||
#define PRIdFAST128 __PRI128 "d"
|
||||
|
||||
|
@ -108,8 +122,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define PRIuLEAST128 __PRI128 "u"
|
||||
|
||||
#define PRIuFAST8 __PRI8 "u"
|
||||
#define PRIuFAST16 __PRI32 "u"
|
||||
#define PRIuFAST32 __PRI32 "u"
|
||||
#define PRIuFAST16 __PRIFAST16 "u"
|
||||
#define PRIuFAST32 __PRIFAST32 "u"
|
||||
#define PRIuFAST64 __PRI64 "u"
|
||||
#define PRIuFAST128 __PRI128 "u"
|
||||
|
||||
|
@ -130,8 +144,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define PRIiLEAST128 __PRI128 "i"
|
||||
|
||||
#define PRIiFAST8 __PRI8 "i"
|
||||
#define PRIiFAST16 __PRI32 "i"
|
||||
#define PRIiFAST32 __PRI32 "i"
|
||||
#define PRIiFAST16 __PRIFAST16 "i"
|
||||
#define PRIiFAST32 __PRIFAST32 "i"
|
||||
#define PRIiFAST64 __PRI64 "i"
|
||||
#define PRIiFAST128 __PRI128 "i"
|
||||
|
||||
|
@ -152,8 +166,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define PRIoLEAST128 __PRI128 "o"
|
||||
|
||||
#define PRIoFAST8 __PRI8 "o"
|
||||
#define PRIoFAST16 __PRI32 "o"
|
||||
#define PRIoFAST32 __PRI32 "o"
|
||||
#define PRIoFAST16 __PRIFAST16 "o"
|
||||
#define PRIoFAST32 __PRIFAST32 "o"
|
||||
#define PRIoFAST64 __PRI64 "o"
|
||||
#define PRIoFAST128 __PRI128 "o"
|
||||
|
||||
|
@ -174,8 +188,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define PRIxLEAST128 __PRI128 "x"
|
||||
|
||||
#define PRIxFAST8 __PRI8 "x"
|
||||
#define PRIxFAST16 __PRI32 "x"
|
||||
#define PRIxFAST32 __PRI32 "x"
|
||||
#define PRIxFAST16 __PRIFAST16 "x"
|
||||
#define PRIxFAST32 __PRIFAST32 "x"
|
||||
#define PRIxFAST64 __PRI64 "x"
|
||||
#define PRIxFAST128 __PRI128 "x"
|
||||
|
||||
|
@ -192,8 +206,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define PRIXLEAST128 __PRI128 "X"
|
||||
|
||||
#define PRIXFAST8 __PRI8 "X"
|
||||
#define PRIXFAST16 __PRI32 "X"
|
||||
#define PRIXFAST32 __PRI32 "X"
|
||||
#define PRIXFAST16 __PRIFAST16 "X"
|
||||
#define PRIXFAST32 __PRIFAST32 "X"
|
||||
#define PRIXFAST64 __PRI64 "X"
|
||||
#define PRIXFAST128 __PRI128 "X"
|
||||
|
||||
|
@ -214,8 +228,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define PRIbLEAST128 __PRI128 "b"
|
||||
|
||||
#define PRIbFAST8 __PRI8 "b"
|
||||
#define PRIbFAST16 __PRI32 "b"
|
||||
#define PRIbFAST32 __PRI32 "b"
|
||||
#define PRIbFAST16 __PRIFAST16 "b"
|
||||
#define PRIbFAST32 __PRIFAST32 "b"
|
||||
#define PRIbFAST64 __PRI64 "b"
|
||||
#define PRIbFAST128 __PRI128 "b"
|
||||
|
||||
|
@ -232,8 +246,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define PRIBLEAST128 __PRI128 "B"
|
||||
|
||||
#define PRIBFAST8 __PRI8 "B"
|
||||
#define PRIBFAST16 __PRI32 "B"
|
||||
#define PRIBFAST32 __PRI32 "B"
|
||||
#define PRIBFAST16 __PRIFAST16 "B"
|
||||
#define PRIBFAST32 __PRIFAST32 "B"
|
||||
#define PRIBFAST64 __PRI64 "B"
|
||||
#define PRIBFAST128 __PRI128 "B"
|
||||
|
||||
|
@ -272,8 +286,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define SCNdLEAST128 __PRI128 "d"
|
||||
|
||||
#define SCNdFAST8 __PRI8 "d"
|
||||
#define SCNdFAST16 __PRI32 "d"
|
||||
#define SCNdFAST32 __PRI32 "d"
|
||||
#define SCNdFAST16 __PRIFAST16 "d"
|
||||
#define SCNdFAST32 __PRIFAST32 "d"
|
||||
#define SCNdFAST64 __PRI64 "d"
|
||||
#define SCNdFAST128 __PRI128 "d"
|
||||
|
||||
|
@ -294,8 +308,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define SCNiLEAST128 __PRI128 "i"
|
||||
|
||||
#define SCNiFAST8 __PRI8 "i"
|
||||
#define SCNiFAST16 __PRI32 "i"
|
||||
#define SCNiFAST32 __PRI32 "i"
|
||||
#define SCNiFAST16 __PRIFAST16 "i"
|
||||
#define SCNiFAST32 __PRIFAST32 "i"
|
||||
#define SCNiFAST64 __PRI64 "i"
|
||||
#define SCNiFAST128 __PRI128 "i"
|
||||
|
||||
|
@ -316,8 +330,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define SCNuLEAST128 __PRI128 "u"
|
||||
|
||||
#define SCNuFAST8 __PRI8 "u"
|
||||
#define SCNuFAST16 __PRI32 "u"
|
||||
#define SCNuFAST32 __PRI32 "u"
|
||||
#define SCNuFAST16 __PRIFAST16 "u"
|
||||
#define SCNuFAST32 __PRIFAST32 "u"
|
||||
#define SCNuFAST64 __PRI64 "u"
|
||||
#define SCNuFAST128 __PRI128 "u"
|
||||
|
||||
|
@ -338,8 +352,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define SCNoLEAST128 __PRI128 "o"
|
||||
|
||||
#define SCNoFAST8 __PRI8 "o"
|
||||
#define SCNoFAST16 __PRI32 "o"
|
||||
#define SCNoFAST32 __PRI32 "o"
|
||||
#define SCNoFAST16 __PRIFAST16 "o"
|
||||
#define SCNoFAST32 __PRIFAST32 "o"
|
||||
#define SCNoFAST64 __PRI64 "o"
|
||||
#define SCNoFAST128 __PRI128 "o"
|
||||
|
||||
|
@ -360,8 +374,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define SCNxLEAST128 __PRI128 "x"
|
||||
|
||||
#define SCNxFAST8 __PRI8 "x"
|
||||
#define SCNxFAST16 __PRI32 "x"
|
||||
#define SCNxFAST32 __PRI32 "x"
|
||||
#define SCNxFAST16 __PRIFAST16 "x"
|
||||
#define SCNxFAST32 __PRIFAST32 "x"
|
||||
#define SCNxFAST64 __PRI64 "x"
|
||||
#define SCNxFAST128 __PRI128 "x"
|
||||
|
||||
|
@ -382,8 +396,8 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
|||
#define SCNbLEAST128 __PRI128 "b"
|
||||
|
||||
#define SCNbFAST8 __PRI8 "b"
|
||||
#define SCNbFAST16 __PRI32 "b"
|
||||
#define SCNbFAST32 __PRI32 "b"
|
||||
#define SCNbFAST16 __PRIFAST16 "b"
|
||||
#define SCNbFAST32 __PRIFAST32 "b"
|
||||
#define SCNbFAST64 __PRI64 "b"
|
||||
#define SCNbFAST128 __PRI128 "b"
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ struct NtWin32FindData {
|
|||
uint32_t dwReserved1;
|
||||
char16_t cFileName[260];
|
||||
char16_t cAlternateFileName[14];
|
||||
uint32_t dwFileType;
|
||||
uint32_t dwCreatorType;
|
||||
uint16_t wFinderFlags;
|
||||
uint32_t dwFileType; /* obsolete */
|
||||
uint32_t dwCreatorType; /* obsolete */
|
||||
uint16_t wFinderFlags; /* obsolete */
|
||||
};
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -16,18 +16,11 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/stdio/sysparam.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/utf16.h"
|
||||
|
||||
__msabi extern typeof(GetFileAttributes) *const __imp_GetFileAttributesW;
|
||||
|
||||
struct DosArgv {
|
||||
const char16_t *s;
|
||||
char *p;
|
||||
|
@ -143,7 +136,7 @@ textwindows int GetDosArgv(const char16_t *cmdline, char *buf, size_t size,
|
|||
AppendDosArgv('\0', st);
|
||||
}
|
||||
AppendDosArgv('\0', st);
|
||||
if (size) buf[min(st->p - buf, size - 1)] = '\0';
|
||||
if (max) argv[min(argc, max - 1)] = NULL;
|
||||
if (size) buf[MIN(st->p - buf, size - 1)] = '\0';
|
||||
if (max) argv[MIN(argc, max - 1)] = NULL;
|
||||
return argc;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sock/internal.h"
|
||||
|
|
|
@ -185,6 +185,10 @@ static textwindows uint8_t GetNtDirentType(struct NtWin32FindData *w) {
|
|||
|
||||
static textwindows dontinline struct dirent *readdir_nt(DIR *dir) {
|
||||
TryAgain:
|
||||
while (!dir->isdone &&
|
||||
(dir->windata.dwFileAttributes & kNtFileAttributeSystem)) {
|
||||
dir->isdone = !FindNextFile(dir->hand, &dir->windata);
|
||||
}
|
||||
if (dir->isdone) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ static const char gmt[] = "GMT";
|
|||
#endif
|
||||
|
||||
struct ttinfo { /* time type information */
|
||||
int_fast32_t tt_utoff; /* UT offset in seconds */
|
||||
int32_t tt_utoff; /* UT offset in seconds */
|
||||
bool tt_isdst; /* used to set tm_isdst */
|
||||
int tt_desigidx; /* abbreviation list index */
|
||||
bool tt_ttisstd; /* transition is std time */
|
||||
|
@ -126,7 +126,7 @@ struct ttinfo { /* time type information */
|
|||
|
||||
struct lsinfo { /* leap second information */
|
||||
time_t ls_trans; /* transition time */
|
||||
int_fast32_t ls_corr; /* correction to apply */
|
||||
int32_t ls_corr; /* correction to apply */
|
||||
};
|
||||
|
||||
#define SMALLEST(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
@ -180,16 +180,16 @@ struct rule {
|
|||
int r_day; /* day number of rule */
|
||||
int r_week; /* week number of rule */
|
||||
int r_mon; /* month number of rule */
|
||||
int_fast32_t r_time; /* transition time of rule */
|
||||
int32_t r_time; /* transition time of rule */
|
||||
};
|
||||
|
||||
static struct tm *gmtsub(struct state const *, time_t const *, int_fast32_t,
|
||||
static struct tm *gmtsub(struct state const *, time_t const *, int32_t,
|
||||
struct tm *);
|
||||
static bool increment_overflow(int *, int);
|
||||
static bool increment_overflow_time(time_t *, int_fast32_t);
|
||||
static int_fast32_t leapcorr(struct state const *, time_t);
|
||||
static bool normalize_overflow32(int_fast32_t *, int *, int);
|
||||
static struct tm *localtime_timesub(time_t const *, int_fast32_t,
|
||||
static bool increment_overflow_time(time_t *, int32_t);
|
||||
static int32_t leapcorr(struct state const *, time_t);
|
||||
static bool normalize_overflow32(int32_t *, int *, int);
|
||||
static struct tm *localtime_timesub(time_t const *, int32_t,
|
||||
struct state const *, struct tm *);
|
||||
static bool localtime_typesequiv(struct state const *, int, int);
|
||||
static bool localtime_tzparse(char const *, struct state *, struct state *);
|
||||
|
@ -230,7 +230,7 @@ long altzone;
|
|||
|
||||
/* Initialize *S to a value based on UTOFF, ISDST, and DESIGIDX. */
|
||||
static void
|
||||
init_ttinfo(struct ttinfo *s, int_fast32_t utoff, bool isdst, int desigidx)
|
||||
init_ttinfo(struct ttinfo *s, int32_t utoff, bool isdst, int desigidx)
|
||||
{
|
||||
s->tt_utoff = utoff;
|
||||
s->tt_isdst = isdst;
|
||||
|
@ -248,11 +248,11 @@ ttunspecified(struct state const *sp, int i)
|
|||
return memcmp(abbr, UNSPEC, sizeof UNSPEC) == 0;
|
||||
}
|
||||
|
||||
forceinline int_fast32_t detzcode(const char *const codep) {
|
||||
forceinline int32_t detzcode(const char *const codep) {
|
||||
return READ32BE(codep);
|
||||
}
|
||||
|
||||
forceinline int_fast64_t detzcode64(const char *const codep) {
|
||||
forceinline int64_t detzcode64(const char *const codep) {
|
||||
return READ64BE(codep);
|
||||
}
|
||||
|
||||
|
@ -429,15 +429,15 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend,
|
|||
for (stored = 4; stored <= 8; stored *= 2) {
|
||||
char version = up->tzhead.tzh_version[0];
|
||||
bool skip_datablock = stored == 4 && version;
|
||||
int_fast32_t datablock_size;
|
||||
int_fast32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt);
|
||||
int_fast32_t ttisutcnt = detzcode(up->tzhead.tzh_ttisutcnt);
|
||||
int_fast64_t prevtr = -1;
|
||||
int_fast32_t prevcorr = 0;
|
||||
int_fast32_t leapcnt = detzcode(up->tzhead.tzh_leapcnt);
|
||||
int_fast32_t timecnt = detzcode(up->tzhead.tzh_timecnt);
|
||||
int_fast32_t typecnt = detzcode(up->tzhead.tzh_typecnt);
|
||||
int_fast32_t charcnt = detzcode(up->tzhead.tzh_charcnt);
|
||||
int32_t datablock_size;
|
||||
int32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt);
|
||||
int32_t ttisutcnt = detzcode(up->tzhead.tzh_ttisutcnt);
|
||||
int64_t prevtr = -1;
|
||||
int32_t prevcorr = 0;
|
||||
int32_t leapcnt = detzcode(up->tzhead.tzh_leapcnt);
|
||||
int32_t timecnt = detzcode(up->tzhead.tzh_timecnt);
|
||||
int32_t typecnt = detzcode(up->tzhead.tzh_typecnt);
|
||||
int32_t charcnt = detzcode(up->tzhead.tzh_charcnt);
|
||||
char const *p = up->buf + tzheadsize;
|
||||
/* Although tzfile(5) currently requires typecnt to be nonzero,
|
||||
support future formats that may allow zero typecnt
|
||||
|
@ -476,7 +476,7 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend,
|
|||
occurred at TIME_T_MIN. */
|
||||
timecnt = 0;
|
||||
for (i = 0; i < sp->timecnt; ++i) {
|
||||
int_fast64_t at
|
||||
int64_t at
|
||||
= stored == 4 ? detzcode(p) : detzcode64(p);
|
||||
sp->types[i] = at <= TIME_T_MAX;
|
||||
if (sp->types[i]) {
|
||||
|
@ -528,8 +528,8 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend,
|
|||
/* Read leap seconds, discarding those out of time_t range. */
|
||||
leapcnt = 0;
|
||||
for (i = 0; i < sp->leapcnt; ++i) {
|
||||
int_fast64_t tr = stored == 4 ? detzcode(p) : detzcode64(p);
|
||||
int_fast32_t corr = detzcode(p + stored);
|
||||
int64_t tr = stored == 4 ? detzcode(p) : detzcode64(p);
|
||||
int32_t corr = detzcode(p + stored);
|
||||
p += stored + 4;
|
||||
|
||||
/* Leap seconds cannot occur before the Epoch,
|
||||
|
@ -876,10 +876,10 @@ getnum(register const char *strp, int *const nump, const int min, const int max)
|
|||
*/
|
||||
|
||||
static const char *
|
||||
getsecs(register const char *strp, int_fast32_t *const secsp)
|
||||
getsecs(register const char *strp, int32_t *const secsp)
|
||||
{
|
||||
int num;
|
||||
int_fast32_t secsperhour = SECSPERHOUR;
|
||||
int32_t secsperhour = SECSPERHOUR;
|
||||
|
||||
/*
|
||||
** 'HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like
|
||||
|
@ -917,7 +917,7 @@ getsecs(register const char *strp, int_fast32_t *const secsp)
|
|||
*/
|
||||
|
||||
static const char *
|
||||
getoffset(register const char *strp, int_fast32_t *const offsetp)
|
||||
getoffset(register const char *strp, int32_t *const offsetp)
|
||||
{
|
||||
register bool neg = false;
|
||||
|
||||
|
@ -992,12 +992,12 @@ getrule(const char *strp, register struct rule *const rulep)
|
|||
** effect, calculate the year-relative time that rule takes effect.
|
||||
*/
|
||||
|
||||
static int_fast32_t
|
||||
static int32_t
|
||||
transtime(const int year, register const struct rule *const rulep,
|
||||
const int_fast32_t offset)
|
||||
const int32_t offset)
|
||||
{
|
||||
register bool leapyear;
|
||||
register int_fast32_t value;
|
||||
register int32_t value;
|
||||
register int i;
|
||||
int d, m1, yy0, yy1, yy2, dow;
|
||||
|
||||
|
@ -1092,8 +1092,8 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep)
|
|||
size_t stdlen;
|
||||
size_t dstlen;
|
||||
size_t charcnt;
|
||||
int_fast32_t stdoffset;
|
||||
int_fast32_t dstoffset;
|
||||
int32_t stdoffset;
|
||||
int32_t dstoffset;
|
||||
register char * cp;
|
||||
register bool load_ok;
|
||||
time_t atlo = TIME_T_MIN, leaplo = TIME_T_MIN;
|
||||
|
@ -1163,7 +1163,7 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep)
|
|||
register int year;
|
||||
register int timecnt;
|
||||
time_t janfirst;
|
||||
int_fast32_t janoffset = 0;
|
||||
int32_t janoffset = 0;
|
||||
int yearbeg, yearlim;
|
||||
|
||||
++name;
|
||||
|
@ -1187,7 +1187,7 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep)
|
|||
yearbeg = EPOCH_YEAR;
|
||||
|
||||
do {
|
||||
int_fast32_t yearsecs
|
||||
int32_t yearsecs
|
||||
= year_lengths[isleap(yearbeg - 1)] * SECSPERDAY;
|
||||
yearbeg--;
|
||||
if (increment_overflow_time(&janfirst, -yearsecs)) {
|
||||
|
@ -1198,7 +1198,7 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep)
|
|||
&& EPOCH_YEAR - YEARSPERREPEAT / 2 < yearbeg);
|
||||
|
||||
while (true) {
|
||||
int_fast32_t yearsecs
|
||||
int32_t yearsecs
|
||||
= year_lengths[isleap(yearbeg)] * SECSPERDAY;
|
||||
int yearbeg1 = yearbeg;
|
||||
time_t janfirst1 = janfirst;
|
||||
|
@ -1214,15 +1214,15 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep)
|
|||
if (increment_overflow(&yearlim, YEARSPERREPEAT + 1))
|
||||
yearlim = INT_MAX;
|
||||
for (year = yearbeg; year < yearlim; year++) {
|
||||
int_fast32_t
|
||||
int32_t
|
||||
starttime = transtime(year, &start, stdoffset),
|
||||
endtime = transtime(year, &end, dstoffset);
|
||||
int_fast32_t
|
||||
int32_t
|
||||
yearsecs = (year_lengths[isleap(year)]
|
||||
* SECSPERDAY);
|
||||
bool reversed = endtime < starttime;
|
||||
if (reversed) {
|
||||
int_fast32_t swap = starttime;
|
||||
int32_t swap = starttime;
|
||||
starttime = endtime;
|
||||
endtime = swap;
|
||||
}
|
||||
|
@ -1263,9 +1263,9 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep)
|
|||
} else if (YEARSPERREPEAT < year - yearbeg)
|
||||
sp->goback = sp->goahead = true;
|
||||
} else {
|
||||
register int_fast32_t theirstdoffset;
|
||||
register int_fast32_t theirdstoffset;
|
||||
register int_fast32_t theiroffset;
|
||||
register int32_t theirstdoffset;
|
||||
register int32_t theirdstoffset;
|
||||
register int32_t theiroffset;
|
||||
register bool isdst;
|
||||
register int i;
|
||||
register int j;
|
||||
|
@ -1479,13 +1479,13 @@ localtime_gmtcheck(void)
|
|||
** set the applicable parts of tzname, timezone and altzone;
|
||||
** however, it's OK to omit this step if the timezone is POSIX-compatible,
|
||||
** since in that case tzset should have already done this step correctly.
|
||||
** SETNAME's type is int_fast32_t for compatibility with gmtsub,
|
||||
** SETNAME's type is int32_t for compatibility with gmtsub,
|
||||
** but it is actually a boolean and its value should be 0 or 1.
|
||||
*/
|
||||
|
||||
/*ARGSUSED*/
|
||||
static struct tm *
|
||||
localsub(struct state const *sp, time_t const *timep, int_fast32_t setname,
|
||||
localsub(struct state const *sp, time_t const *timep, int32_t setname,
|
||||
struct tm *const tmp)
|
||||
{
|
||||
register const struct ttinfo * ttisp;
|
||||
|
@ -1523,7 +1523,7 @@ localsub(struct state const *sp, time_t const *timep, int_fast32_t setname,
|
|||
return NULL; /* "cannot happen" */
|
||||
result = localsub(sp, &newt, setname, tmp);
|
||||
if (result) {
|
||||
register int_fast64_t newy;
|
||||
register int64_t newy;
|
||||
|
||||
newy = result->tm_year;
|
||||
if (t < sp->ats[0])
|
||||
|
@ -1595,7 +1595,7 @@ localtime_r(const time_t *timep, struct tm *tmp)
|
|||
*/
|
||||
|
||||
static struct tm *
|
||||
gmtsub(struct state const *sp, time_t const *timep, int_fast32_t offset,
|
||||
gmtsub(struct state const *sp, time_t const *timep, int32_t offset,
|
||||
struct tm *tmp)
|
||||
{
|
||||
register struct tm * result;
|
||||
|
@ -1655,15 +1655,15 @@ leaps_thru_end_of(time_t y)
|
|||
}
|
||||
|
||||
static struct tm *
|
||||
localtime_timesub(const time_t *timep, int_fast32_t offset,
|
||||
localtime_timesub(const time_t *timep, int32_t offset,
|
||||
const struct state *sp, struct tm *tmp)
|
||||
{
|
||||
register const struct lsinfo * lp;
|
||||
register time_t tdays;
|
||||
register const int * ip;
|
||||
register int_fast32_t corr;
|
||||
register int32_t corr;
|
||||
register int i;
|
||||
int_fast32_t idays, rem, dayoff, dayrem;
|
||||
int32_t idays, rem, dayoff, dayrem;
|
||||
time_t y;
|
||||
|
||||
/* If less than SECSPERMIN, the number of seconds since the
|
||||
|
@ -1709,7 +1709,7 @@ localtime_timesub(const time_t *timep, int_fast32_t offset,
|
|||
/* Increase Y and decrease IDAYS until IDAYS is in range for Y. */
|
||||
while (year_lengths[isleap(y)] <= idays) {
|
||||
int tdelta = idays / DAYSPERLYEAR;
|
||||
int_fast32_t ydelta = tdelta + !tdelta;
|
||||
int32_t ydelta = tdelta + !tdelta;
|
||||
time_t newy = y + ydelta;
|
||||
register int leapdays;
|
||||
leapdays = leaps_thru_end_of(newy - 1) -
|
||||
|
@ -1801,16 +1801,16 @@ increment_overflow(int *ip, int j)
|
|||
}
|
||||
|
||||
forceinline bool
|
||||
increment_overflow32(int_fast32_t *const lp, int const m)
|
||||
increment_overflow32(int32_t *const lp, int const m)
|
||||
{
|
||||
#if defined(__GNUC__) && __GNUC__ >= 6
|
||||
int_fast32_t i = *lp;
|
||||
int32_t i = *lp;
|
||||
if (__builtin_add_overflow(i, m, &i)) return true;
|
||||
*lp = i;
|
||||
return false;
|
||||
#else
|
||||
register int_fast32_t const l = *lp;
|
||||
if ((l >= 0) ? (m > INT_FAST32_MAX - l) : (m < INT_FAST32_MIN - l))
|
||||
register int32_t const l = *lp;
|
||||
if ((l >= 0) ? (m > INT32_MAX - l) : (m < INT32_MIN - l))
|
||||
return true;
|
||||
*lp += m;
|
||||
return false;
|
||||
|
@ -1818,7 +1818,7 @@ increment_overflow32(int_fast32_t *const lp, int const m)
|
|||
}
|
||||
|
||||
forceinline bool
|
||||
increment_overflow_time(time_t *tp, int_fast32_t j)
|
||||
increment_overflow_time(time_t *tp, int32_t j)
|
||||
{
|
||||
#if defined(__GNUC__) && __GNUC__ >= 6
|
||||
time_t i = *tp;
|
||||
|
@ -1853,7 +1853,7 @@ normalize_overflow(int *const tensptr, int *const unitsptr, const int base)
|
|||
}
|
||||
|
||||
static bool
|
||||
normalize_overflow32(int_fast32_t *tensptr, int *unitsptr, int base)
|
||||
normalize_overflow32(int32_t *tensptr, int *unitsptr, int base)
|
||||
{
|
||||
register int tensdelta;
|
||||
|
||||
|
@ -1884,19 +1884,19 @@ static time_t
|
|||
localtime_time2sub(
|
||||
struct tm *const tmp,
|
||||
struct tm *(*funcp)(struct state const *, time_t const *,
|
||||
int_fast32_t, struct tm *),
|
||||
int32_t, struct tm *),
|
||||
struct state const *sp,
|
||||
const int_fast32_t offset,
|
||||
const int32_t offset,
|
||||
bool *okayp,
|
||||
bool do_norm_secs)
|
||||
{
|
||||
register int dir;
|
||||
register int i, j;
|
||||
register int saved_seconds;
|
||||
register int_fast32_t li;
|
||||
register int32_t li;
|
||||
register time_t lo;
|
||||
register time_t hi;
|
||||
int_fast32_t y;
|
||||
int32_t y;
|
||||
time_t newt;
|
||||
time_t t;
|
||||
struct tm yourtm, mytm;
|
||||
|
@ -2011,10 +2011,10 @@ localtime_time2sub(
|
|||
&& (yourtm.TM_GMTOFF < 0
|
||||
? (-SECSPERDAY <= yourtm.TM_GMTOFF
|
||||
&& (mytm.TM_GMTOFF <=
|
||||
(SMALLEST(INT_FAST32_MAX, LONG_MAX)
|
||||
(SMALLEST(INT32_MAX, LONG_MAX)
|
||||
+ yourtm.TM_GMTOFF)))
|
||||
: (yourtm.TM_GMTOFF <= SECSPERDAY
|
||||
&& ((BIGGEST(INT_FAST32_MIN, LONG_MIN)
|
||||
&& ((BIGGEST(INT32_MIN, LONG_MIN)
|
||||
+ yourtm.TM_GMTOFF)
|
||||
<= mytm.TM_GMTOFF)))) {
|
||||
/* MYTM matches YOURTM except with the wrong UT offset.
|
||||
|
@ -2022,7 +2022,7 @@ localtime_time2sub(
|
|||
It's OK if YOURTM.TM_GMTOFF contains uninitialized data,
|
||||
since the guess gets checked. */
|
||||
time_t altt = t;
|
||||
int_fast32_t diff = mytm.TM_GMTOFF - yourtm.TM_GMTOFF;
|
||||
int32_t diff = mytm.TM_GMTOFF - yourtm.TM_GMTOFF;
|
||||
if (!increment_overflow_time(&altt, diff)) {
|
||||
struct tm alttm;
|
||||
if (funcp(sp, &altt, offset, &alttm)
|
||||
|
@ -2084,9 +2084,9 @@ static time_t
|
|||
localtime_time2(
|
||||
struct tm * const tmp,
|
||||
struct tm *(*funcp)(struct state const *, time_t const *,
|
||||
int_fast32_t, struct tm *),
|
||||
int32_t, struct tm *),
|
||||
struct state const *sp,
|
||||
const int_fast32_t offset,
|
||||
const int32_t offset,
|
||||
bool *okayp)
|
||||
{
|
||||
time_t t;
|
||||
|
@ -2104,9 +2104,9 @@ static time_t
|
|||
localtime_time1(
|
||||
struct tm *const tmp,
|
||||
struct tm *(*funcp)(struct state const *, time_t const *,
|
||||
int_fast32_t, struct tm *),
|
||||
int32_t, struct tm *),
|
||||
struct state const *sp,
|
||||
const int_fast32_t offset)
|
||||
const int32_t offset)
|
||||
{
|
||||
register time_t t;
|
||||
register int samei, otheri;
|
||||
|
@ -2218,7 +2218,7 @@ timeoff(struct tm *tmp, long offset)
|
|||
return localtime_time1(tmp, gmtsub, gmtptr, offset);
|
||||
}
|
||||
|
||||
static int_fast32_t
|
||||
static int32_t
|
||||
leapcorr(struct state const *sp, time_t t)
|
||||
{
|
||||
register struct lsinfo const * lp;
|
||||
|
|
|
@ -487,12 +487,12 @@ char *ctime_r(int64_t const *, char *);
|
|||
#define DAYSPERNYEAR 365
|
||||
#define DAYSPERLYEAR 366
|
||||
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
|
||||
#define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
|
||||
#define SECSPERDAY ((int32_t) SECSPERHOUR * HOURSPERDAY)
|
||||
#define MONSPERYEAR 12
|
||||
|
||||
#define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
|
||||
#define DAYSPERREPEAT ((int_fast32_t) 400 * 365 + 100 - 4 + 1)
|
||||
#define SECSPERREPEAT ((int_fast64_t) DAYSPERREPEAT * SECSPERDAY)
|
||||
#define DAYSPERREPEAT ((int32_t) 400 * 365 + 100 - 4 + 1)
|
||||
#define SECSPERREPEAT ((int64_t) DAYSPERREPEAT * SECSPERDAY)
|
||||
#define AVGSECSPERYEAR (SECSPERREPEAT / YEARSPERREPEAT)
|
||||
|
||||
#define TM_SUNDAY 0
|
||||
|
|
Loading…
Reference in a new issue