Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-misc/rdate/, net-misc/rdate/files/
Date: Thu, 03 Feb 2022 09:34:16
Message-Id: 1643880837.1588352a15a53c38ce3b00b5a8a0f9c243abc6a5.sam@gentoo
1 commit: 1588352a15a53c38ce3b00b5a8a0f9c243abc6a5
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Thu Feb 3 09:25:57 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Thu Feb 3 09:33:57 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1588352a
7
8 net-misc/rdate: fix build on musl
9
10 Closes: https://bugs.gentoo.org/832554
11 Signed-off-by: Sam James <sam <AT> gentoo.org>
12
13 .../rdate-1.10.2-fix-musl-compat-stdint.patch | 180 +++++++++++++++++++++
14 net-misc/rdate/rdate-1.10.2.ebuild | 8 +-
15 2 files changed, 186 insertions(+), 2 deletions(-)
16
17 diff --git a/net-misc/rdate/files/rdate-1.10.2-fix-musl-compat-stdint.patch b/net-misc/rdate/files/rdate-1.10.2-fix-musl-compat-stdint.patch
18 new file mode 100644
19 index 000000000000..a6ff70b353d5
20 --- /dev/null
21 +++ b/net-misc/rdate/files/rdate-1.10.2-fix-musl-compat-stdint.patch
22 @@ -0,0 +1,180 @@
23 +https://github.com/resurrecting-open-source-projects/openrdate/pull/3
24 +
25 +From: Sam James <sam@g.o>
26 +Date: Thu, 3 Feb 2022 09:23:35 +0000
27 +Subject: [PATCH] Use <stdint.h> to fix musl compatibility
28 +
29 +uint32_t and friends are provided by <stdint.h> and the types
30 +previously being relied on are non-standard, so let's swap.
31 +
32 +This fixes building rdate on e.g. musl rather than glibc.
33 +
34 +Bug: https://bugs.gentoo.org/832554
35 +Signed-off-by: Sam James <sam@g.o>
36 +--- a/src/ntp.c
37 ++++ b/src/ntp.c
38 +@@ -52,6 +52,7 @@
39 + #include <netdb.h>
40 + #include <stdio.h>
41 + #include <stdlib.h>
42 ++#include <stdint.h>
43 + #include <string.h>
44 + #include <time.h>
45 + #include <unistd.h>
46 +@@ -106,11 +107,11 @@ struct ntp_data {
47 + double receive;
48 + double transmit;
49 + double current;
50 +- u_int64_t recvck;
51 ++ uint64_t recvck;
52 +
53 + /* Local State */
54 + double originate;
55 +- u_int64_t xmitck;
56 ++ uint64_t xmitck;
57 + };
58 +
59 + void ntp_client(const char *, int, struct timeval *, struct timeval *, int, int, int);
60 +@@ -282,7 +283,7 @@ write_packet(int fd, struct ntp_data *data)
61 +
62 + packet[0] = (NTP_VERSION << 3) | (NTP_MODE_CLIENT);
63 +
64 +- data->xmitck = (u_int64_t)arc4random() << 32 | arc4random();
65 ++ data->xmitck = (uint64_t)arc4random() << 32 | arc4random();
66 +
67 + /*
68 + * Send out a random 64-bit number as our transmit time. The NTP
69 +@@ -300,7 +301,7 @@ write_packet(int fd, struct ntp_data *data)
70 + * the transmit field intelligible.
71 + */
72 +
73 +- *(u_int64_t *)(packet + NTP_TRANSMIT) = data->xmitck;
74 ++ *(uint64_t *)(packet + NTP_TRANSMIT) = data->xmitck;
75 +
76 + data->originate = current_time(JAN_1970);
77 +
78 +@@ -453,7 +454,7 @@ double
79 + current_time(double offset)
80 + {
81 + struct timeval current;
82 +- u_int64_t t;
83 ++ uint64_t t;
84 +
85 + if (gettimeofday(&current, NULL))
86 + err(1, "Could not get local time of day");
87 +--- a/src/ntpleaps.c
88 ++++ b/src/ntpleaps.c
89 +@@ -45,12 +45,13 @@
90 + #include <fcntl.h>
91 + #include <stdio.h>
92 + #include <stdlib.h>
93 ++#include <stdint.h>
94 + #include <string.h>
95 + #include <unistd.h>
96 +
97 + #include "ntpleaps.h"
98 +
99 +-static u_int64_t *leapsecs;
100 ++static uint64_t *leapsecs;
101 + static unsigned int leapsecs_num;
102 +
103 +
104 +@@ -81,10 +82,10 @@ ntpleaps_init(void)
105 + }
106 +
107 + int
108 +-ntpleaps_sub(u_int64_t *t)
109 ++ntpleaps_sub(uint64_t *t)
110 + {
111 + unsigned int i = 0;
112 +- u_int64_t u;
113 ++ uint64_t u;
114 + int r = 1;
115 +
116 + if (ntpleaps_init() == -1)
117 +@@ -105,10 +106,10 @@ ntpleaps_sub(u_int64_t *t)
118 + return (r);
119 + }
120 +
121 +-u_int32_t
122 +-read_be_dword(u_int8_t *ptr)
123 ++uint32_t
124 ++read_be_dword(uint8_t *ptr)
125 + {
126 +- u_int32_t res;
127 ++ uint32_t res;
128 +
129 + memcpy(&res, ptr, 4);
130 + return (ntohl(res));
131 +@@ -120,10 +121,10 @@ ntpleaps_read(void)
132 + {
133 + int fd;
134 + unsigned int r;
135 +- u_int8_t buf[32];
136 +- u_int32_t m1, m2, m3;
137 +- u_int64_t s;
138 +- u_int64_t *l;
139 ++ uint8_t buf[32];
140 ++ uint32_t m1, m2, m3;
141 ++ uint64_t s;
142 ++ uint64_t *l;
143 +
144 + fd = open("/usr/share/zoneinfo/right/UTC", O_RDONLY | O_NDELAY);
145 + if (fd == -1)
146 +@@ -153,7 +154,7 @@ ntpleaps_read(void)
147 + close(fd);
148 + return (-1);
149 + }
150 +- if ((l = (u_int64_t *)malloc(r << 3)) == NULL) {
151 ++ if ((l = (uint64_t *)malloc(r << 3)) == NULL) {
152 + close(fd);
153 + return (-1);
154 + }
155 +--- a/src/ntpleaps.h
156 ++++ b/src/ntpleaps.h
157 +@@ -46,11 +46,13 @@
158 + #ifndef _NTPLEAPS_H
159 + #define _NTPLEAPS_H
160 +
161 ++#include <stdint.h>
162 ++
163 + /* Offset between struct timeval.tv_sec and a tai64_t */
164 + #define NTPLEAPS_OFFSET (4611686018427387914ULL)
165 +
166 + /* Hide this ugly value from programmes */
167 +-#define SEC_TO_TAI64(s) (NTPLEAPS_OFFSET + (u_int64_t)(s))
168 ++#define SEC_TO_TAI64(s) (NTPLEAPS_OFFSET + (uint64_t)(s))
169 + #define TAI64_TO_SEC(t) ((t) - NTPLEAPS_OFFSET)
170 +
171 + /* Initializes the leap second table. Does not need to be called
172 +@@ -70,6 +72,6 @@ int ntpleaps_read(void);
173 + * to posix clock tick time.
174 + * returns 0 on success, -1 on error (time is unchanged), 1 on leap second
175 + */
176 +-int ntpleaps_sub(u_int64_t *);
177 ++int ntpleaps_sub(uint64_t *);
178 +
179 + #endif
180 +--- a/src/rfc868time.c
181 ++++ b/src/rfc868time.c
182 +@@ -50,6 +50,7 @@
183 + #include <stdio.h>
184 + #include <ctype.h>
185 + #include <err.h>
186 ++#include <stdint.h>
187 + #include <string.h>
188 + #include <netdb.h>
189 + #include <unistd.h>
190 +@@ -68,10 +69,10 @@ rfc868time_client (const char *hostname, int family, struct timeval *new,
191 + {
192 + struct addrinfo hints, *res0, *res;
193 + struct timeval old;
194 +- u_int32_t tim; /* RFC 868 states clearly this is an uint32 */
195 ++ uint32_t tim; /* RFC 868 states clearly this is an uint32 */
196 + int s;
197 + int error;
198 +- u_int64_t td;
199 ++ uint64_t td;
200 +
201 + memset(&hints, 0, sizeof(hints));
202 + hints.ai_family = family;
203
204 diff --git a/net-misc/rdate/rdate-1.10.2.ebuild b/net-misc/rdate/rdate-1.10.2.ebuild
205 index 85c5f91b3cf8..40191e638b49 100644
206 --- a/net-misc/rdate/rdate-1.10.2.ebuild
207 +++ b/net-misc/rdate/rdate-1.10.2.ebuild
208 @@ -1,4 +1,4 @@
209 -# Copyright 1999-2021 Gentoo Authors
210 +# Copyright 1999-2022 Gentoo Authors
211 # Distributed under the terms of the GNU General Public License v2
212
213 EAPI=8
214 @@ -17,7 +17,11 @@ SLOT="0"
215 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
216
217 DEPEND="dev-libs/libbsd"
218 -RDEPEND=${DEPEND}
219 +RDEPEND="${DEPEND}"
220 +
221 +PATCHES=(
222 + "${FILESDIR}"/${PN}-1.10.2-fix-musl-compat-stdint.patch
223 +)
224
225 src_prepare() {
226 default