Skip to content

Commit 604ce0a

Browse files
cjihrigcodebytere
authored andcommittedMar 17, 2020
deps: upgrade to libuv 1.34.2
Notable changes: - SetApplicationDaemon() is no longer called on macOS. - uv_interface_addresses() is implemented on IBMi. - The return value of uv__open_cloexec() is now handled properly. - A race condition in fsevents has been fixed. Fixes: #31328 Fixes: nodejs/help#2099 PR-URL: #31477 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent fb32043 commit 604ce0a

16 files changed

+491
-243
lines changed
 

‎deps/uv/ChangeLog

+23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
2020.01.24, Version 1.34.2 (Stable), f868c9ab0c307525a16fff99fd21e32a6ebc3837
2+
3+
Changes since version 1.34.1:
4+
5+
* misc: adjust stalebot deadlines (Jameson Nash)
6+
7+
* test: fix env-vars flakiness (cjihrig)
8+
9+
* test: avoid truncating output lines (Jameson Nash)
10+
11+
* darwin: stop calling SetApplicationIsDaemon() (Ben Noordhuis)
12+
13+
* ibmi: implement uv_interface_addresses() (Xu Meng)
14+
15+
* osx,fsevent: fix race during uv_loop_close (Jameson Nash)
16+
17+
* osx,fsevent: clear pointer when deleting it [NFCI] (Jameson Nash)
18+
19+
* Revert "aix: replace ECONNRESET with EOF if already closed" (Jameson Nash)
20+
21+
* unix: handle uv__open_cloexec return value correctly (Anna Henningsen)
22+
23+
124
2020.01.13, Version 1.34.1 (Stable), 8aa5636ec72990bb2856f81e14c95813024a5c2b
225

326
Changes since version 1.34.0:

‎deps/uv/configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

1515
AC_PREREQ(2.57)
16-
AC_INIT([libuv], [1.34.1], [https://github.com/libuv/libuv/issues])
16+
AC_INIT([libuv], [1.34.2], [https://github.com/libuv/libuv/issues])
1717
AC_CONFIG_MACRO_DIR([m4])
1818
m4_include([m4/libuv-extra-automake-flags.m4])
1919
m4_include([m4/as_case.m4])

‎deps/uv/include/uv/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#define UV_VERSION_MAJOR 1
3434
#define UV_VERSION_MINOR 34
35-
#define UV_VERSION_PATCH 1
35+
#define UV_VERSION_PATCH 2
3636
#define UV_VERSION_IS_RELEASE 1
3737
#define UV_VERSION_SUFFIX ""
3838

‎deps/uv/src/unix/aix-common.c

-180
Original file line numberDiff line numberDiff line change
@@ -155,183 +155,3 @@ int uv_exepath(char* buffer, size_t* size) {
155155
return UV_EINVAL;
156156
}
157157
}
158-
159-
160-
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
161-
uv_interface_address_t* address;
162-
int sockfd, sock6fd, inet6, i, r, size = 1;
163-
struct ifconf ifc;
164-
struct ifreq *ifr, *p, flg;
165-
struct in6_ifreq if6;
166-
struct sockaddr_dl* sa_addr;
167-
168-
ifc.ifc_req = NULL;
169-
sock6fd = -1;
170-
r = 0;
171-
*count = 0;
172-
*addresses = NULL;
173-
174-
if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
175-
r = UV__ERR(errno);
176-
goto cleanup;
177-
}
178-
179-
if (0 > (sock6fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP))) {
180-
r = UV__ERR(errno);
181-
goto cleanup;
182-
}
183-
184-
if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) {
185-
r = UV__ERR(errno);
186-
goto cleanup;
187-
}
188-
189-
ifc.ifc_req = (struct ifreq*)uv__malloc(size);
190-
if (ifc.ifc_req == NULL) {
191-
r = UV_ENOMEM;
192-
goto cleanup;
193-
}
194-
ifc.ifc_len = size;
195-
if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) {
196-
r = UV__ERR(errno);
197-
goto cleanup;
198-
}
199-
200-
#define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p))
201-
202-
/* Count all up and running ipv4/ipv6 addresses */
203-
ifr = ifc.ifc_req;
204-
while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
205-
p = ifr;
206-
ifr = (struct ifreq*)
207-
((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
208-
209-
if (!(p->ifr_addr.sa_family == AF_INET6 ||
210-
p->ifr_addr.sa_family == AF_INET))
211-
continue;
212-
213-
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
214-
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
215-
r = UV__ERR(errno);
216-
goto cleanup;
217-
}
218-
219-
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
220-
continue;
221-
222-
(*count)++;
223-
}
224-
225-
if (*count == 0)
226-
goto cleanup;
227-
228-
/* Alloc the return interface structs */
229-
*addresses = uv__calloc(*count, sizeof(**addresses));
230-
if (!(*addresses)) {
231-
r = UV_ENOMEM;
232-
goto cleanup;
233-
}
234-
address = *addresses;
235-
236-
ifr = ifc.ifc_req;
237-
while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
238-
p = ifr;
239-
ifr = (struct ifreq*)
240-
((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
241-
242-
if (!(p->ifr_addr.sa_family == AF_INET6 ||
243-
p->ifr_addr.sa_family == AF_INET))
244-
continue;
245-
246-
inet6 = (p->ifr_addr.sa_family == AF_INET6);
247-
248-
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
249-
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1)
250-
goto syserror;
251-
252-
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
253-
continue;
254-
255-
/* All conditions above must match count loop */
256-
257-
address->name = uv__strdup(p->ifr_name);
258-
259-
if (inet6)
260-
address->address.address6 = *((struct sockaddr_in6*) &p->ifr_addr);
261-
else
262-
address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr);
263-
264-
if (inet6) {
265-
memset(&if6, 0, sizeof(if6));
266-
r = uv__strscpy(if6.ifr_name, p->ifr_name, sizeof(if6.ifr_name));
267-
if (r == UV_E2BIG)
268-
goto cleanup;
269-
r = 0;
270-
memcpy(&if6.ifr_Addr, &p->ifr_addr, sizeof(if6.ifr_Addr));
271-
if (ioctl(sock6fd, SIOCGIFNETMASK6, &if6) == -1)
272-
goto syserror;
273-
address->netmask.netmask6 = *((struct sockaddr_in6*) &if6.ifr_Addr);
274-
/* Explicitly set family as the ioctl call appears to return it as 0. */
275-
address->netmask.netmask6.sin6_family = AF_INET6;
276-
} else {
277-
if (ioctl(sockfd, SIOCGIFNETMASK, p) == -1)
278-
goto syserror;
279-
address->netmask.netmask4 = *((struct sockaddr_in*) &p->ifr_addr);
280-
/* Explicitly set family as the ioctl call appears to return it as 0. */
281-
address->netmask.netmask4.sin_family = AF_INET;
282-
}
283-
284-
address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0;
285-
286-
address++;
287-
}
288-
289-
/* Fill in physical addresses. */
290-
ifr = ifc.ifc_req;
291-
while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
292-
p = ifr;
293-
ifr = (struct ifreq*)
294-
((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
295-
296-
if (p->ifr_addr.sa_family != AF_LINK)
297-
continue;
298-
299-
address = *addresses;
300-
for (i = 0; i < *count; i++) {
301-
if (strcmp(address->name, p->ifr_name) == 0) {
302-
sa_addr = (struct sockaddr_dl*) &p->ifr_addr;
303-
memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
304-
}
305-
address++;
306-
}
307-
}
308-
309-
#undef ADDR_SIZE
310-
goto cleanup;
311-
312-
syserror:
313-
uv_free_interface_addresses(*addresses, *count);
314-
*addresses = NULL;
315-
*count = 0;
316-
r = UV_ENOSYS;
317-
318-
cleanup:
319-
if (sockfd != -1)
320-
uv__close(sockfd);
321-
if (sock6fd != -1)
322-
uv__close(sock6fd);
323-
uv__free(ifc.ifc_req);
324-
return r;
325-
}
326-
327-
328-
void uv_free_interface_addresses(uv_interface_address_t* addresses,
329-
int count) {
330-
int i;
331-
332-
for (i = 0; i < count; ++i) {
333-
uv__free(addresses[i].name);
334-
}
335-
336-
uv__free(addresses);
337-
}

‎deps/uv/src/unix/aix.c

+180
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,186 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
10391039
}
10401040

10411041

1042+
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
1043+
uv_interface_address_t* address;
1044+
int sockfd, sock6fd, inet6, i, r, size = 1;
1045+
struct ifconf ifc;
1046+
struct ifreq *ifr, *p, flg;
1047+
struct in6_ifreq if6;
1048+
struct sockaddr_dl* sa_addr;
1049+
1050+
ifc.ifc_req = NULL;
1051+
sock6fd = -1;
1052+
r = 0;
1053+
*count = 0;
1054+
*addresses = NULL;
1055+
1056+
if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
1057+
r = UV__ERR(errno);
1058+
goto cleanup;
1059+
}
1060+
1061+
if (0 > (sock6fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP))) {
1062+
r = UV__ERR(errno);
1063+
goto cleanup;
1064+
}
1065+
1066+
if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) {
1067+
r = UV__ERR(errno);
1068+
goto cleanup;
1069+
}
1070+
1071+
ifc.ifc_req = (struct ifreq*)uv__malloc(size);
1072+
if (ifc.ifc_req == NULL) {
1073+
r = UV_ENOMEM;
1074+
goto cleanup;
1075+
}
1076+
ifc.ifc_len = size;
1077+
if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) {
1078+
r = UV__ERR(errno);
1079+
goto cleanup;
1080+
}
1081+
1082+
#define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p))
1083+
1084+
/* Count all up and running ipv4/ipv6 addresses */
1085+
ifr = ifc.ifc_req;
1086+
while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
1087+
p = ifr;
1088+
ifr = (struct ifreq*)
1089+
((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
1090+
1091+
if (!(p->ifr_addr.sa_family == AF_INET6 ||
1092+
p->ifr_addr.sa_family == AF_INET))
1093+
continue;
1094+
1095+
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
1096+
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
1097+
r = UV__ERR(errno);
1098+
goto cleanup;
1099+
}
1100+
1101+
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
1102+
continue;
1103+
1104+
(*count)++;
1105+
}
1106+
1107+
if (*count == 0)
1108+
goto cleanup;
1109+
1110+
/* Alloc the return interface structs */
1111+
*addresses = uv__calloc(*count, sizeof(**addresses));
1112+
if (!(*addresses)) {
1113+
r = UV_ENOMEM;
1114+
goto cleanup;
1115+
}
1116+
address = *addresses;
1117+
1118+
ifr = ifc.ifc_req;
1119+
while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
1120+
p = ifr;
1121+
ifr = (struct ifreq*)
1122+
((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
1123+
1124+
if (!(p->ifr_addr.sa_family == AF_INET6 ||
1125+
p->ifr_addr.sa_family == AF_INET))
1126+
continue;
1127+
1128+
inet6 = (p->ifr_addr.sa_family == AF_INET6);
1129+
1130+
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
1131+
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1)
1132+
goto syserror;
1133+
1134+
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
1135+
continue;
1136+
1137+
/* All conditions above must match count loop */
1138+
1139+
address->name = uv__strdup(p->ifr_name);
1140+
1141+
if (inet6)
1142+
address->address.address6 = *((struct sockaddr_in6*) &p->ifr_addr);
1143+
else
1144+
address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr);
1145+
1146+
if (inet6) {
1147+
memset(&if6, 0, sizeof(if6));
1148+
r = uv__strscpy(if6.ifr_name, p->ifr_name, sizeof(if6.ifr_name));
1149+
if (r == UV_E2BIG)
1150+
goto cleanup;
1151+
r = 0;
1152+
memcpy(&if6.ifr_Addr, &p->ifr_addr, sizeof(if6.ifr_Addr));
1153+
if (ioctl(sock6fd, SIOCGIFNETMASK6, &if6) == -1)
1154+
goto syserror;
1155+
address->netmask.netmask6 = *((struct sockaddr_in6*) &if6.ifr_Addr);
1156+
/* Explicitly set family as the ioctl call appears to return it as 0. */
1157+
address->netmask.netmask6.sin6_family = AF_INET6;
1158+
} else {
1159+
if (ioctl(sockfd, SIOCGIFNETMASK, p) == -1)
1160+
goto syserror;
1161+
address->netmask.netmask4 = *((struct sockaddr_in*) &p->ifr_addr);
1162+
/* Explicitly set family as the ioctl call appears to return it as 0. */
1163+
address->netmask.netmask4.sin_family = AF_INET;
1164+
}
1165+
1166+
address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0;
1167+
1168+
address++;
1169+
}
1170+
1171+
/* Fill in physical addresses. */
1172+
ifr = ifc.ifc_req;
1173+
while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
1174+
p = ifr;
1175+
ifr = (struct ifreq*)
1176+
((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
1177+
1178+
if (p->ifr_addr.sa_family != AF_LINK)
1179+
continue;
1180+
1181+
address = *addresses;
1182+
for (i = 0; i < *count; i++) {
1183+
if (strcmp(address->name, p->ifr_name) == 0) {
1184+
sa_addr = (struct sockaddr_dl*) &p->ifr_addr;
1185+
memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
1186+
}
1187+
address++;
1188+
}
1189+
}
1190+
1191+
#undef ADDR_SIZE
1192+
goto cleanup;
1193+
1194+
syserror:
1195+
uv_free_interface_addresses(*addresses, *count);
1196+
*addresses = NULL;
1197+
*count = 0;
1198+
r = UV_ENOSYS;
1199+
1200+
cleanup:
1201+
if (sockfd != -1)
1202+
uv__close(sockfd);
1203+
if (sock6fd != -1)
1204+
uv__close(sock6fd);
1205+
uv__free(ifc.ifc_req);
1206+
return r;
1207+
}
1208+
1209+
1210+
void uv_free_interface_addresses(uv_interface_address_t* addresses,
1211+
int count) {
1212+
int i;
1213+
1214+
for (i = 0; i < count; ++i) {
1215+
uv__free(addresses[i].name);
1216+
}
1217+
1218+
uv__free(addresses);
1219+
}
1220+
1221+
10421222
void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
10431223
struct pollfd* events;
10441224
uintptr_t i;

‎deps/uv/src/unix/darwin-proctitle.c

+9-18
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ int uv__set_process_title(const char* title) {
7272
CFStringRef* display_name_key;
7373
CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef);
7474
CFBundleRef (*pCFBundleGetMainBundle)(void);
75-
CFBundleRef hi_services_bundle;
76-
OSStatus (*pSetApplicationIsDaemon)(int);
7775
CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef);
7876
void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t,
7977
void*);
@@ -144,30 +142,19 @@ int uv__set_process_title(const char* title) {
144142
if (pCFBundleGetInfoDictionary == NULL || pCFBundleGetMainBundle == NULL)
145143
goto out;
146144

147-
/* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */
148-
hi_services_bundle =
149-
pCFBundleGetBundleWithIdentifier(S("com.apple.HIServices"));
150-
err = UV_ENOENT;
151-
if (hi_services_bundle == NULL)
152-
goto out;
153-
154-
*(void **)(&pSetApplicationIsDaemon) = pCFBundleGetFunctionPointerForName(
155-
hi_services_bundle,
156-
S("SetApplicationIsDaemon"));
157145
*(void **)(&pLSApplicationCheckIn) = pCFBundleGetFunctionPointerForName(
158146
launch_services_bundle,
159147
S("_LSApplicationCheckIn"));
148+
149+
if (pLSApplicationCheckIn == NULL)
150+
goto out;
151+
160152
*(void **)(&pLSSetApplicationLaunchServicesServerConnectionStatus) =
161153
pCFBundleGetFunctionPointerForName(
162154
launch_services_bundle,
163155
S("_LSSetApplicationLaunchServicesServerConnectionStatus"));
164-
if (pSetApplicationIsDaemon == NULL ||
165-
pLSApplicationCheckIn == NULL ||
166-
pLSSetApplicationLaunchServicesServerConnectionStatus == NULL) {
167-
goto out;
168-
}
169156

170-
if (pSetApplicationIsDaemon(1) != noErr)
157+
if (pLSSetApplicationLaunchServicesServerConnectionStatus == NULL)
171158
goto out;
172159

173160
pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL);
@@ -178,6 +165,10 @@ int uv__set_process_title(const char* title) {
178165

179166
asn = pLSGetCurrentApplicationASN();
180167

168+
err = UV_EBUSY;
169+
if (asn == NULL)
170+
goto out;
171+
181172
err = UV_EINVAL;
182173
if (pLSSetApplicationInformationItem(-2, /* Magic value. */
183174
asn,

‎deps/uv/src/unix/fsevents.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,8 @@ static void* uv__cf_loop_runner(void* arg) {
747747
state->signal_source,
748748
*pkCFRunLoopDefaultMode);
749749

750+
state->loop = NULL;
751+
750752
return NULL;
751753
}
752754

@@ -799,13 +801,14 @@ int uv__cf_loop_signal(uv_loop_t* loop,
799801

800802
uv_mutex_lock(&loop->cf_mutex);
801803
QUEUE_INSERT_TAIL(&loop->cf_signals, &item->member);
802-
uv_mutex_unlock(&loop->cf_mutex);
803804

804805
state = loop->cf_state;
805806
assert(state != NULL);
806807
pCFRunLoopSourceSignal(state->signal_source);
807808
pCFRunLoopWakeUp(state->loop);
808809

810+
uv_mutex_unlock(&loop->cf_mutex);
811+
809812
return 0;
810813
}
811814

‎deps/uv/src/unix/ibmi.c

+243-16
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include <sys/vnode.h>
5757

5858
#include <as400_protos.h>
59+
#include <as400_types.h>
5960

6061

6162
typedef struct {
@@ -98,24 +99,91 @@ typedef struct {
9899
} SSTS0200;
99100

100101

102+
typedef struct {
103+
char header[208];
104+
unsigned char loca_adapter_address[12];
105+
} LIND0500;
106+
107+
108+
typedef struct {
109+
int bytes_provided;
110+
int bytes_available;
111+
char msgid[7];
112+
} errcode_s;
113+
114+
115+
static const unsigned char e2a[256] = {
116+
0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, 12, 13, 14, 15,
117+
16, 17, 18, 19, 157, 133, 8, 135, 24, 25, 146, 143, 28, 29, 30, 31,
118+
128, 129, 130, 131, 132, 10, 23, 27, 136, 137, 138, 139, 140, 5, 6, 7,
119+
144, 145, 22, 147, 148, 149, 150, 4, 152, 153, 154, 155, 20, 21, 158, 26,
120+
32, 160, 161, 162, 163, 164, 165, 166, 167, 168, 91, 46, 60, 40, 43, 33,
121+
38, 169, 170, 171, 172, 173, 174, 175, 176, 177, 93, 36, 42, 41, 59, 94,
122+
45, 47, 178, 179, 180, 181, 182, 183, 184, 185, 124, 44, 37, 95, 62, 63,
123+
186, 187, 188, 189, 190, 191, 192, 193, 194, 96, 58, 35, 64, 39, 61, 34,
124+
195, 97, 98, 99, 100, 101, 102, 103, 104, 105, 196, 197, 198, 199, 200, 201,
125+
202, 106, 107, 108, 109, 110, 111, 112, 113, 114, 203, 204, 205, 206, 207, 208,
126+
209, 126, 115, 116, 117, 118, 119, 120, 121, 122, 210, 211, 212, 213, 214, 215,
127+
216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231,
128+
123, 65, 66, 67, 68, 69, 70, 71, 72, 73, 232, 233, 234, 235, 236, 237,
129+
125, 74, 75, 76, 77, 78, 79, 80, 81, 82, 238, 239, 240, 241, 242, 243,
130+
92, 159, 83, 84, 85, 86, 87, 88, 89, 90, 244, 245, 246, 247, 248, 249,
131+
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 250, 251, 252, 253, 254, 255};
132+
133+
134+
static const unsigned char a2e[256] = {
135+
0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15,
136+
16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31,
137+
64, 79, 127, 123, 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97,
138+
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 122, 94, 76, 126, 110, 111,
139+
124, 193, 194, 195, 196, 197, 198, 199, 200, 201, 209, 210, 211, 212, 213, 214,
140+
215, 216, 217, 226, 227, 228, 229, 230, 231, 232, 233, 74, 224, 90, 95, 109,
141+
121, 129, 130, 131, 132, 133, 134, 135, 136, 137, 145, 146, 147, 148, 149, 150,
142+
151, 152, 153, 162, 163, 164, 165, 166, 167, 168, 169, 192, 106, 208, 161, 7,
143+
32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27,
144+
48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62, 225,
145+
65, 66, 67, 68, 69, 70, 71, 72, 73, 81, 82, 83, 84, 85, 86, 87,
146+
88, 89, 98, 99, 100, 101, 102, 103, 104, 105, 112, 113, 114, 115, 116, 117,
147+
118, 119, 120, 128, 138, 139, 140, 141, 142, 143, 144, 154, 155, 156, 157, 158,
148+
159, 160, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
149+
184, 185, 186, 187, 188, 189, 190, 191, 202, 203, 204, 205, 206, 207, 218, 219,
150+
220, 221, 222, 223, 234, 235, 236, 237, 238, 239, 250, 251, 252, 253, 254, 255};
151+
152+
153+
static void iconv_e2a(unsigned char src[], unsigned char dst[], size_t length) {
154+
size_t i;
155+
for (i = 0; i < length; i++)
156+
dst[i] = e2a[src[i]];
157+
}
158+
159+
160+
static void iconv_a2e(const char* src, unsigned char dst[], size_t length) {
161+
size_t srclen;
162+
size_t i;
163+
164+
srclen = strlen(src);
165+
if (srclen > length)
166+
abort();
167+
for (i = 0; i < srclen; i++)
168+
dst[i] = a2e[src[i]];
169+
/* padding the remaining part with spaces */
170+
for (; i < length; i++)
171+
dst[i] = a2e[' '];
172+
}
173+
174+
101175
static int get_ibmi_system_status(SSTS0200* rcvr) {
102176
/* rcvrlen is input parameter 2 to QWCRSSTS */
103177
unsigned int rcvrlen = sizeof(*rcvr);
178+
unsigned char format[8], reset_status[10];
104179

105-
/* format is input parameter 3 to QWCRSSTS ("SSTS0200" in EBCDIC) */
106-
unsigned char format[] = {0xE2, 0xE2, 0xE3, 0xE2, 0xF0, 0xF2, 0xF0, 0xF0};
107-
108-
/* reset_status is input parameter 4 to QWCRSSTS ("*NO " in EBCDIC) */
109-
unsigned char reset_status[] = {
110-
0x5C, 0xD5, 0xD6, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40
111-
};
180+
/* format is input parameter 3 to QWCRSSTS */
181+
iconv_a2e("SSTS0200", format, sizeof(format));
182+
/* reset_status is input parameter 4 */
183+
iconv_a2e("*NO", reset_status, sizeof(reset_status));
112184

113185
/* errcode is input parameter 5 to QWCRSSTS */
114-
struct _errcode {
115-
int bytes_provided;
116-
int bytes_available;
117-
char msgid[7];
118-
} errcode;
186+
errcode_s errcode;
119187

120188
/* qwcrssts_pointer is the 16-byte tagged system pointer to QWCRSSTS */
121189
ILEpointer __attribute__((aligned(16))) qwcrssts_pointer;
@@ -145,7 +213,7 @@ static int get_ibmi_system_status(SSTS0200* rcvr) {
145213
qwcrssts_argv[5] = NULL;
146214

147215
/* Call the IBM i QWCRSSTS API from PASE */
148-
rc = _PGMCALL(&qwcrssts_pointer, (void**)&qwcrssts_argv, 0);
216+
rc = _PGMCALL(&qwcrssts_pointer, qwcrssts_argv, 0);
149217

150218
return rc;
151219
}
@@ -166,10 +234,13 @@ uint64_t uv_get_free_memory(void) {
166234
uint64_t current_unprotected_storage_used =
167235
rcvr.current_unprotected_storage_used * 1024ULL;
168236

169-
uint64_t free_storage_size =
170-
(main_storage_size - current_unprotected_storage_used) * 1024ULL;
237+
/* Current unprotected storage includes the storage used for memory
238+
* and disks so it is possible to exceed the amount of main storage.
239+
*/
240+
if (main_storage_size <= current_unprotected_storage_used)
241+
return 0ULL;
171242

172-
return free_storage_size < 0 ? 0 : free_storage_size;
243+
return (main_storage_size - current_unprotected_storage_used) * 1024ULL;
173244
}
174245

175246

@@ -247,3 +318,159 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
247318

248319
return 0;
249320
}
321+
322+
323+
static int get_ibmi_physical_address(const char* line, char (*phys_addr)[6]) {
324+
LIND0500 rcvr;
325+
/* rcvrlen is input parameter 2 to QDCRLIND */
326+
unsigned int rcvrlen = sizeof(rcvr);
327+
unsigned char format[8], line_name[10];
328+
unsigned char mac_addr[sizeof(rcvr.loca_adapter_address)];
329+
int c[6];
330+
331+
/* format is input parameter 3 to QDCRLIND */
332+
iconv_a2e("LIND0500", format, sizeof(format));
333+
334+
/* line_name is input parameter 4 to QDCRLIND */
335+
iconv_a2e(line, line_name, sizeof(line_name));
336+
337+
/* err is input parameter 5 to QDCRLIND */
338+
errcode_s err;
339+
340+
/* qwcrssts_pointer is the 16-byte tagged system pointer to QDCRLIND */
341+
ILEpointer __attribute__((aligned(16))) qdcrlind_pointer;
342+
343+
/* qwcrssts_argv is the array of argument pointers to QDCRLIND */
344+
void* qdcrlind_argv[6];
345+
346+
/* Set the IBM i pointer to the QSYS/QDCRLIND *PGM object */
347+
int rc = _RSLOBJ2(&qdcrlind_pointer, RSLOBJ_TS_PGM, "QDCRLIND", "QSYS");
348+
349+
if (rc != 0)
350+
return rc;
351+
352+
/* initialize the QDCRLIND returned info structure */
353+
memset(&rcvr, 0, sizeof(rcvr));
354+
355+
/* initialize the QDCRLIND error code structure */
356+
memset(&err, 0, sizeof(err));
357+
err.bytes_provided = sizeof(err);
358+
359+
/* initialize the array of argument pointers for the QDCRLIND API */
360+
qdcrlind_argv[0] = &rcvr;
361+
qdcrlind_argv[1] = &rcvrlen;
362+
qdcrlind_argv[2] = &format;
363+
qdcrlind_argv[3] = &line_name;
364+
qdcrlind_argv[4] = &err;
365+
qdcrlind_argv[5] = NULL;
366+
367+
/* Call the IBM i QDCRLIND API from PASE */
368+
rc = _PGMCALL(&qdcrlind_pointer, qdcrlind_argv, 0);
369+
if (rc != 0)
370+
return rc;
371+
372+
/* convert ebcdic loca_adapter_address to ascii first */
373+
iconv_e2a(rcvr.loca_adapter_address, mac_addr,
374+
sizeof(rcvr.loca_adapter_address));
375+
376+
/* convert loca_adapter_address(char[12]) to phys_addr(char[6]) */
377+
int r = sscanf(mac_addr, "%02x%02x%02x%02x%02x%02x",
378+
&c[0], &c[1], &c[2], &c[3], &c[4], &c[5]);
379+
380+
if (r == ARRAY_SIZE(c)) {
381+
(*phys_addr)[0] = c[0];
382+
(*phys_addr)[1] = c[1];
383+
(*phys_addr)[2] = c[2];
384+
(*phys_addr)[3] = c[3];
385+
(*phys_addr)[4] = c[4];
386+
(*phys_addr)[5] = c[5];
387+
} else {
388+
memset(*phys_addr, 0, sizeof(*phys_addr));
389+
rc = -1;
390+
}
391+
return rc;
392+
}
393+
394+
395+
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
396+
uv_interface_address_t* address;
397+
struct ifaddrs_pase *ifap = NULL, *cur;
398+
int inet6, r = 0;
399+
400+
*count = 0;
401+
*addresses = NULL;
402+
403+
if (Qp2getifaddrs(&ifap))
404+
return UV_ENOSYS;
405+
406+
/* The first loop to get the size of the array to be allocated */
407+
for (cur = ifap; cur; cur = cur->ifa_next) {
408+
if (!(cur->ifa_addr->sa_family == AF_INET6 ||
409+
cur->ifa_addr->sa_family == AF_INET))
410+
continue;
411+
412+
if (!(cur->ifa_flags & IFF_UP && cur->ifa_flags & IFF_RUNNING))
413+
continue;
414+
415+
(*count)++;
416+
}
417+
418+
if (*count == 0) {
419+
Qp2freeifaddrs(ifap);
420+
return 0;
421+
}
422+
423+
/* Alloc the return interface structs */
424+
*addresses = uv__calloc(*count, sizeof(**addresses));
425+
if (*addresses == NULL) {
426+
Qp2freeifaddrs(ifap);
427+
return UV_ENOMEM;
428+
}
429+
address = *addresses;
430+
431+
/* The second loop to fill in the array */
432+
for (cur = ifap; cur; cur = cur->ifa_next) {
433+
if (!(cur->ifa_addr->sa_family == AF_INET6 ||
434+
cur->ifa_addr->sa_family == AF_INET))
435+
continue;
436+
437+
if (!(cur->ifa_flags & IFF_UP && cur->ifa_flags & IFF_RUNNING))
438+
continue;
439+
440+
address->name = uv__strdup(cur->ifa_name);
441+
442+
inet6 = (cur->ifa_addr->sa_family == AF_INET6);
443+
444+
if (inet6) {
445+
address->address.address6 = *((struct sockaddr_in6*)cur->ifa_addr);
446+
address->netmask.netmask6 = *((struct sockaddr_in6*)cur->ifa_netmask);
447+
address->netmask.netmask6.sin6_family = AF_INET6;
448+
} else {
449+
address->address.address4 = *((struct sockaddr_in*)cur->ifa_addr);
450+
address->netmask.netmask4 = *((struct sockaddr_in*)cur->ifa_netmask);
451+
address->netmask.netmask4.sin_family = AF_INET;
452+
}
453+
address->is_internal = cur->ifa_flags & IFF_LOOPBACK ? 1 : 0;
454+
if (!address->is_internal) {
455+
int rc = get_ibmi_physical_address(address->name, &address->phys_addr);
456+
if (rc != 0)
457+
r = rc;
458+
}
459+
460+
address++;
461+
}
462+
463+
Qp2freeifaddrs(ifap);
464+
return r;
465+
}
466+
467+
468+
void uv_free_interface_addresses(uv_interface_address_t* addresses, int count) {
469+
int i;
470+
471+
for (i = 0; i < count; ++i) {
472+
uv__free(addresses[i].name);
473+
}
474+
475+
uv__free(addresses);
476+
}

‎deps/uv/src/unix/linux-core.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ static uint64_t uv__read_proc_meminfo(const char* what) {
990990
rc = 0;
991991
fd = uv__open_cloexec("/proc/meminfo", O_RDONLY);
992992

993-
if (fd == -1)
993+
if (fd < 0)
994994
return 0;
995995

996996
n = read(fd, buf, sizeof(buf) - 1);

‎deps/uv/src/unix/random-devurandom.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ int uv__random_readpath(const char* path, void* buf, size_t buflen) {
3737

3838
fd = uv__open_cloexec(path, O_RDONLY);
3939

40-
if (fd == -1)
41-
return UV__ERR(errno);
40+
if (fd < 0)
41+
return fd;
4242

4343
if (fstat(fd, &s)) {
4444
uv__close(fd);

‎deps/uv/src/unix/stream.c

-4
Original file line numberDiff line numberDiff line change
@@ -1185,10 +1185,6 @@ static void uv__read(uv_stream_t* stream) {
11851185
} else if (errno == ECONNRESET && stream->type == UV_NAMED_PIPE) {
11861186
uv__stream_eof(stream, &buf);
11871187
return;
1188-
#elif defined(_AIX)
1189-
} else if (errno == ECONNRESET && (stream->flags & UV_DISCONNECT)) {
1190-
uv__stream_eof(stream, &buf);
1191-
return;
11921188
#endif
11931189
} else {
11941190
/* Error. User should call uv_close(). */

‎deps/uv/test/runner-unix.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ int process_copy_output(process_info_t* p, FILE* stream) {
371371
}
372372

373373
/* TODO: what if the line is longer than buf */
374-
while (fgets(buf, sizeof(buf), p->stdout_file) != NULL)
375-
print_lines(buf, strlen(buf), stream);
374+
while ((r = fread(buf, 1, sizeof(buf), p->stdout_file)) != 0)
375+
print_lines(buf, r, stream);
376376

377377
if (ferror(p->stdout_file)) {
378378
perror("read");
@@ -398,7 +398,8 @@ int process_read_last_line(process_info_t *p,
398398
buffer[0] = '\0';
399399

400400
while (fgets(buffer, buffer_len, p->stdout_file) != NULL) {
401-
for (ptr = buffer; *ptr && *ptr != '\r' && *ptr != '\n'; ptr++);
401+
for (ptr = buffer; *ptr && *ptr != '\r' && *ptr != '\n'; ptr++)
402+
;
402403
*ptr = '\0';
403404
}
404405

‎deps/uv/test/runner-win.c

+4-13
Original file line numberDiff line numberDiff line change
@@ -222,28 +222,19 @@ long int process_output_size(process_info_t *p) {
222222
int process_copy_output(process_info_t* p, FILE* stream) {
223223
char buf[1024];
224224
int fd, r;
225-
FILE* f;
226225

227226
fd = _open_osfhandle((intptr_t)p->stdio_out, _O_RDONLY | _O_TEXT);
228227
if (fd == -1)
229228
return -1;
230-
f = _fdopen(fd, "rt");
231-
if (f == NULL) {
232-
_close(fd);
233-
return -1;
234-
}
235229

236-
r = fseek(f, 0, SEEK_SET);
230+
r = _lseek(fd, 0, SEEK_SET);
237231
if (r < 0)
238232
return -1;
239233

240-
while (fgets(buf, sizeof(buf), f) != NULL)
241-
print_lines(buf, strlen(buf), stream);
242-
243-
if (ferror(f))
244-
return -1;
234+
while ((r = _read(fd, buf, sizeof(buf))) != 0)
235+
print_lines(buf, r, stream);
245236

246-
fclose(f);
237+
_close(fd);
247238
return 0;
248239
}
249240

‎deps/uv/test/runner.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,18 @@ void print_lines(const char* buffer, size_t size, FILE* stream) {
419419

420420
start = buffer;
421421
while ((end = memchr(start, '\n', &buffer[size] - start))) {
422-
fprintf(stream, "# %.*s\n", (int) (end - start), start);
422+
fputs("# ", stream);
423+
fwrite(start, 1, (int)(end - start), stream);
424+
fputs("\n", stream);
423425
fflush(stream);
424426
start = end + 1;
425427
}
426428

427-
if (start < &buffer[size]) {
428-
fprintf(stream, "# %s\n", start);
429+
end = &buffer[size];
430+
if (start < end) {
431+
fputs("# ", stream);
432+
fwrite(start, 1, (int)(end - start), stream);
433+
fputs("\n", stream);
429434
fflush(stream);
430435
}
431436
}

‎deps/uv/test/test-env-vars.c

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ TEST_IMPL(env_vars) {
102102
ASSERT(r == 0);
103103
r = uv_os_setenv(name2, "");
104104
ASSERT(r == 0);
105+
#ifdef _WIN32
106+
/* Create a special environment variable on Windows in case there are no
107+
naturally occurring ones. */
108+
r = uv_os_setenv("=Z:", "\\");
109+
ASSERT(r == 0);
110+
#endif
105111

106112
r = uv_os_environ(&envitems, &envcount);
107113
ASSERT(r == 0);

‎deps/uv/test/test-get-memory.c

+5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ TEST_IMPL(get_memory) {
3232
(unsigned long long) total_mem,
3333
(unsigned long long) constrained_mem);
3434

35+
/* On IBMi PASE, the amount of memory in use includes storage used for
36+
* memory and disks so it is possible to exceed the amount of main storage.
37+
*/
38+
#ifndef __PASE__
3539
ASSERT(free_mem > 0);
40+
#endif
3641
ASSERT(total_mem > 0);
3742
ASSERT(total_mem > free_mem);
3843

0 commit comments

Comments
 (0)
Please sign in to comment.