diff options
author | Colin Watson <cjwatson@debian.org> | 2020-09-20 16:14:20 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2020-09-20 16:14:20 +0100 |
commit | 173bfbf7886608a4a7abbfac6a42ac4bf4a3432d (patch) | |
tree | b97833d8754f257f92d99dd2f5c9e9d557e3f689 /openbsd-compat | |
parent | 75073d0a8478441cc97a6efa10b566c5fb1dac81 (diff) |
New upstream version 1.5.0
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/clock_gettime.c | 32 | ||||
-rwxr-xr-x | openbsd-compat/diff.sh | 24 | ||||
-rw-r--r-- | openbsd-compat/openbsd-compat.h | 2 | ||||
-rw-r--r-- | openbsd-compat/time.h | 46 | ||||
-rw-r--r-- | openbsd-compat/types.h | 7 |
5 files changed, 80 insertions, 31 deletions
diff --git a/openbsd-compat/clock_gettime.c b/openbsd-compat/clock_gettime.c new file mode 100644 index 0000000..ca261a6 --- /dev/null +++ b/openbsd-compat/clock_gettime.c | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2020 Yubico AB. All rights reserved. | ||
3 | * Use of this source code is governed by a BSD-style | ||
4 | * license that can be found in the LICENSE file. | ||
5 | */ | ||
6 | |||
7 | #include "openbsd-compat.h" | ||
8 | |||
9 | #if !defined(HAVE_CLOCK_GETTIME) | ||
10 | |||
11 | #if _WIN32 | ||
12 | int | ||
13 | clock_gettime(clockid_t clock_id, struct timespec *tp) | ||
14 | { | ||
15 | ULONGLONG ms; | ||
16 | |||
17 | if (clock_id != CLOCK_MONOTONIC) { | ||
18 | errno = EINVAL; | ||
19 | return (-1); | ||
20 | } | ||
21 | |||
22 | ms = GetTickCount64(); | ||
23 | tp->tv_sec = ms / 1000L; | ||
24 | tp->tv_nsec = (ms % 1000L) * 1000000L; | ||
25 | |||
26 | return (0); | ||
27 | } | ||
28 | #else | ||
29 | #error "please provide an implementation of clock_gettime() for your platform" | ||
30 | #endif /* _WIN32 */ | ||
31 | |||
32 | #endif /* !defined(HAVE_CLOCK_GETTIME) */ | ||
diff --git a/openbsd-compat/diff.sh b/openbsd-compat/diff.sh deleted file mode 100755 index f21e7d8..0000000 --- a/openbsd-compat/diff.sh +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | #!/bin/bash -u | ||
2 | |||
3 | # Copyright (c) 2019 Yubico AB. All rights reserved. | ||
4 | # Use of this source code is governed by a BSD-style | ||
5 | # license that can be found in the LICENSE file. | ||
6 | |||
7 | OPENSSH=$(realpath ../../openssh) | ||
8 | LIBRESSL=$(realpath ../../libressl-2.8.3) | ||
9 | [[ ! -d "${OPENSSH}" || ! -d "${LIBRESSL}" ]] && exit 1 | ||
10 | |||
11 | diff -pu bsd-getpagesize.c ${OPENSSH}/openbsd-compat/bsd-getpagesize.c | ||
12 | diff -pu err.h ${LIBRESSL}/include/compat/err.h | ||
13 | diff -pu explicit_bzero.c ${OPENSSH}/openbsd-compat/explicit_bzero.c | ||
14 | diff -pu explicit_bzero_win32.c ${LIBRESSL}/crypto/compat/explicit_bzero_win.c | ||
15 | diff -pu getopt.h ${OPENSSH}/openbsd-compat/getopt.h | ||
16 | diff -pu getopt_long.c ${OPENSSH}/openbsd-compat/getopt_long.c | ||
17 | diff -pu posix_win.c ${LIBRESSL}/crypto/compat/posix_win.c | ||
18 | diff -pu readpassphrase.c ${OPENSSH}/openbsd-compat/readpassphrase.c | ||
19 | diff -pu readpassphrase.h ${OPENSSH}/openbsd-compat/readpassphrase.h | ||
20 | diff -pu recallocarray.c ${OPENSSH}/openbsd-compat/recallocarray.c | ||
21 | diff -pu strlcat.c ${OPENSSH}/openbsd-compat/strlcat.c | ||
22 | diff -pu strlcpy.c ${OPENSSH}/openbsd-compat/strlcpy.c | ||
23 | diff -pu timingsafe_bcmp.c ${OPENSSH}/openbsd-compat/timingsafe_bcmp.c | ||
24 | diff -pu types.h ${LIBRESSL}/include/compat/sys/types.h | ||
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index 30d80b3..4f847a5 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h | |||
@@ -90,4 +90,6 @@ int timingsafe_bcmp(const void *, const void *, size_t); | |||
90 | ssize_t getline(char **, size_t *, FILE *); | 90 | ssize_t getline(char **, size_t *, FILE *); |
91 | #endif | 91 | #endif |
92 | 92 | ||
93 | #include "time.h" | ||
94 | |||
93 | #endif /* !_OPENBSD_COMPAT_H */ | 95 | #endif /* !_OPENBSD_COMPAT_H */ |
diff --git a/openbsd-compat/time.h b/openbsd-compat/time.h new file mode 100644 index 0000000..23ac0fe --- /dev/null +++ b/openbsd-compat/time.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/time.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #if defined(_MSC_VER) && (_MSC_VER >= 1900) | ||
7 | #include <../ucrt/time.h> | ||
8 | #elif defined(_MSC_VER) && (_MSC_VER < 1900) | ||
9 | #include <../include/time.h> | ||
10 | #else | ||
11 | #include <time.h> | ||
12 | #endif | ||
13 | |||
14 | #ifndef _COMPAT_TIME_H | ||
15 | #define _COMPAT_TIME_H | ||
16 | |||
17 | #ifndef CLOCK_MONOTONIC | ||
18 | #define CLOCK_MONOTONIC CLOCK_REALTIME | ||
19 | #endif | ||
20 | |||
21 | #ifndef CLOCK_REALTIME | ||
22 | #define CLOCK_REALTIME 0 | ||
23 | #endif | ||
24 | |||
25 | #ifndef HAVE_CLOCK_GETTIME | ||
26 | typedef int clockid_t; | ||
27 | int clock_gettime(clockid_t, struct timespec *); | ||
28 | #endif | ||
29 | |||
30 | #ifdef HAVE_TIMESPECSUB | ||
31 | #include <sys/time.h> | ||
32 | #endif | ||
33 | |||
34 | #ifndef HAVE_TIMESPECSUB | ||
35 | #define timespecsub(tsp, usp, vsp) \ | ||
36 | do { \ | ||
37 | (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ | ||
38 | (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ | ||
39 | if ((vsp)->tv_nsec < 0) { \ | ||
40 | (vsp)->tv_sec--; \ | ||
41 | (vsp)->tv_nsec += 1000000000L; \ | ||
42 | } \ | ||
43 | } while (0) | ||
44 | #endif | ||
45 | |||
46 | #endif /* _COMPAT_TIME_H */ | ||
diff --git a/openbsd-compat/types.h b/openbsd-compat/types.h index cc1da66..e3aa6b5 100644 --- a/openbsd-compat/types.h +++ b/openbsd-compat/types.h | |||
@@ -23,13 +23,6 @@ typedef uint32_t uid_t; | |||
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | #ifdef _MSC_VER | 25 | #ifdef _MSC_VER |
26 | typedef unsigned char u_char; | ||
27 | typedef unsigned short u_short; | ||
28 | typedef unsigned int u_int; | ||
29 | typedef uint32_t in_addr_t; | ||
30 | typedef uint32_t mode_t; | ||
31 | typedef uint32_t uid_t; | ||
32 | |||
33 | #include <basetsd.h> | 26 | #include <basetsd.h> |
34 | typedef SSIZE_T ssize_t; | 27 | typedef SSIZE_T ssize_t; |
35 | 28 | ||