Skip to content

Commit cf07a86

Browse files
cjihrigMylesBorins
authored andcommittedNov 16, 2020
deps: upgrade to libuv 1.40.0
Notable changes: - The UV_UDP_MMSG_FREE flag has been added. - UV__EPROTO has been remapped from 4046 to -4046 for consistency with other error codes. - On Windows, UTF-16 surrogate pairs are no longer replaced with the Unicode replacement character. - uv_timer_get_due_in() has been added. PR-URL: #35333 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent b0e43c7 commit cf07a86

31 files changed

+390
-114
lines changed
 

Diff for: ‎deps/uv/AUTHORS

+5
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,8 @@ escherstair <ernestviga@gmail.com>
443443
Evan Lucas <evanlucas@me.com>
444444
tjarlama <59913901+tjarlama@users.noreply.github.com>
445445
司徒玟琅 <sanjusss@qq.com>
446+
YuMeiJie <yumeijie@huawei.com>
447+
Aleksej Lebedev <root@zta.lk>
448+
Nikolay Mitev <github@hmel.org>
449+
Ulrik Strid <ulrik.strid@outlook.com>
450+
Elad Lahav <elahav@qnx.com>

Diff for: ‎deps/uv/CMakeLists.txt

+27-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ if(WIN32)
146146
list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c)
147147
else()
148148
list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE)
149-
if(NOT CMAKE_SYSTEM_NAME MATCHES "Android|OS390")
149+
if(NOT CMAKE_SYSTEM_NAME MATCHES "Android|OS390|QNX")
150150
# TODO: This should be replaced with find_package(Threads) if possible
151151
# Android has pthread as part of its c library, not as a separate
152152
# libpthread.so.
@@ -298,6 +298,30 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
298298
list(APPEND uv_sources src/unix/no-proctitle.c src/unix/sunos.c)
299299
endif()
300300

301+
if(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
302+
list(APPEND uv_defines _BSD_SOURCE)
303+
list(APPEND uv_libraries bsd network)
304+
list(APPEND uv_sources
305+
src/unix/haiku.c
306+
src/unix/bsd-ifaddrs.c
307+
src/unix/no-fsevents.c
308+
src/unix/no-proctitle.c
309+
src/unix/posix-hrtime.c
310+
src/unix/posix-poll.c)
311+
endif()
312+
313+
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
314+
list(APPEND uv_sources
315+
src/unix/posix-hrtime.c
316+
src/unix/posix-poll.c
317+
src/unix/qnx.c
318+
src/unix/bsd-ifaddrs.c
319+
src/unix/no-proctitle.c
320+
src/unix/no-fsevents.c)
321+
list(APPEND uv_cflags -fno-strict-aliasing)
322+
list(APPEND uv_libraries socket)
323+
endif()
324+
301325
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD")
302326
list(APPEND uv_test_libraries util)
303327
endif()
@@ -568,10 +592,11 @@ if(UNIX OR MINGW)
568592
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
569593
set(prefix ${CMAKE_INSTALL_PREFIX})
570594
configure_file(libuv.pc.in libuv.pc @ONLY)
595+
configure_file(libuv-static.pc.in libuv-static.pc @ONLY)
571596

572597
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
573598
install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
574-
install(FILES ${PROJECT_BINARY_DIR}/libuv.pc
599+
install(FILES ${PROJECT_BINARY_DIR}/libuv.pc ${PROJECT_BINARY_DIR}/libuv-static.pc
575600
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
576601
install(TARGETS uv LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
577602
install(TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

Diff for: ‎deps/uv/ChangeLog

+35
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
2020.09.26, Version 1.40.0 (Stable), 4e69e333252693bd82d6338d6124f0416538dbfc
2+
3+
Changes since version 1.39.0:
4+
5+
* udp: add UV_UDP_MMSG_FREE recv_cb flag (Ryan Liptak)
6+
7+
* include: re-map UV__EPROTO from 4046 to -4046 (YuMeiJie)
8+
9+
* doc: correct UV_UDP_MMSG_FREE version added (cjihrig)
10+
11+
* doc: add uv_metrics_idle_time() version metadata (Ryan Liptak)
12+
13+
* win,tty: pass through utf-16 surrogate pairs (Mustafa M)
14+
15+
* unix: fix DragonFly BSD build (Aleksej Lebedev)
16+
17+
* win,udp: fix error code returned by connect() (Santiago Gimeno)
18+
19+
* src: suppress user_timeout maybe-uninitialized (Daniel Bevenius)
20+
21+
* test: fix compiler warning (Vladimír Čunát)
22+
23+
* build: fix the Haiku cmake build (David Carlier)
24+
25+
* linux: fix i386 sendmmsg/recvmmsg support (Ben Noordhuis)
26+
27+
* build: add libuv-static pkg-config file (Nikolay Mitev)
28+
29+
* unix,win: add uv_timer_get_due_in() (Ulrik Strid)
30+
31+
* build,unix: add QNX support (Elad Lahav)
32+
33+
* include: remove incorrect UV__ERR() for EPROTO (cjihrig)
34+
35+
136
2020.08.26, Version 1.39.0 (Stable), 25f4b8b8a3c0f934158cd37a37b0525d75ca488e
237

338
Changes since version 1.38.1:

Diff for: ‎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.39.0], [https://github.com/libuv/libuv/issues])
16+
AC_INIT([libuv], [1.40.0], [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])

Diff for: ‎deps/uv/docs/src/loop.rst

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ API
7373

7474
This option is necessary to use :c:func:`uv_metrics_idle_time`.
7575

76+
.. versionchanged:: 1.39.0 added the UV_METRICS_IDLE_TIME option.
77+
7678
.. c:function:: int uv_loop_close(uv_loop_t* loop)
7779
7880
Releases all internal loop resources. Call this function only when the loop

Diff for: ‎deps/uv/docs/src/metrics.rst

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ API
2323
The event loop will not begin accumulating the event provider's idle
2424
time until calling :c:type:`uv_loop_configure` with
2525
:c:type:`UV_METRICS_IDLE_TIME`.
26+
27+
.. versionadded:: 1.39.0

Diff for: ‎deps/uv/docs/src/timer.rst

+7
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,11 @@ API
7878
7979
Get the timer repeat value.
8080
81+
.. c:function:: uint64_t uv_timer_get_due_in(const uv_timer_t* handle)
82+
83+
Get the timer due value or 0 if it has expired. The time is relative to
84+
:c:func:`uv_now()`.
85+
86+
.. versionadded:: 1.40.0
87+
8188
.. seealso:: The :c:type:`uv_handle_t` API functions also apply.

Diff for: ‎deps/uv/docs/src/udp.rst

+11-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ Data types
4747
* must not be freed by the recv_cb callback.
4848
*/
4949
UV_UDP_MMSG_CHUNK = 8,
50+
/*
51+
* Indicates that the buffer provided has been fully utilized by recvmmsg and
52+
* that it should now be freed by the recv_cb callback. When this flag is set
53+
* in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL.
54+
*/
55+
UV_UDP_MMSG_FREE = 16,
5056
/*
5157
* Indicates that recvmmsg should be used, if available.
5258
*/
@@ -80,8 +86,10 @@ Data types
8086
When using :man:`recvmmsg(2)`, chunks will have the `UV_UDP_MMSG_CHUNK` flag set,
8187
those must not be freed. There will be a final callback with `nread` set to 0,
8288
`addr` set to NULL and the buffer pointing at the initially allocated data with
83-
the `UV_UDP_MMSG_CHUNK` flag cleared. This is a good chance for the callee to
84-
free the provided buffer.
89+
the `UV_UDP_MMSG_CHUNK` flag cleared and the `UV_UDP_MMSG_FREE` flag set.
90+
The callee can now safely free the provided buffer.
91+
92+
.. versionchanged:: 1.40.0 added the `UV_UDP_MMSG_FREE` flag.
8593

8694
.. note::
8795
The receive callback will be called with `nread` == 0 and `addr` == NULL when there is
@@ -392,7 +400,7 @@ API
392400
it must be explicitly requested by passing the `UV_UDP_RECVMMSG` flag to
393401
:c:func:`uv_udp_init_ex`.
394402
.. versionchanged:: 1.39.0 :c:func:`uv_udp_using_recvmmsg` can be used in `alloc_cb` to
395-
determine if a buffer sized for use with :man:`recvmmsg(2)` should be
403+
determine if a buffer sized for use with :man:`recvmmsg(2)` should be
396404
allocated for the current handle/platform.
397405
398406
.. c:function:: int uv_udp_using_recvmmsg(uv_udp_t* handle)

Diff for: ‎deps/uv/include/uv.h

+7
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,12 @@ enum uv_udp_flags {
614614
* must not be freed by the recv_cb callback.
615615
*/
616616
UV_UDP_MMSG_CHUNK = 8,
617+
/*
618+
* Indicates that the buffer provided has been fully utilized by recvmmsg and
619+
* that it should now be freed by the recv_cb callback. When this flag is set
620+
* in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL.
621+
*/
622+
UV_UDP_MMSG_FREE = 16,
617623

618624
/*
619625
* Indicates that recvmmsg should be used, if available.
@@ -865,6 +871,7 @@ UV_EXTERN int uv_timer_stop(uv_timer_t* handle);
865871
UV_EXTERN int uv_timer_again(uv_timer_t* handle);
866872
UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat);
867873
UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle);
874+
UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t* handle);
868875

869876

870877
/*

Diff for: ‎deps/uv/include/uv/errno.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
#if defined(EPROTO) && !defined(_WIN32)
318318
# define UV__EPROTO UV__ERR(EPROTO)
319319
#else
320-
# define UV__EPROTO UV__ERR(4046)
320+
# define UV__EPROTO (-4046)
321321
#endif
322322

323323
#if defined(EPROTONOSUPPORT) && !defined(_WIN32)

Diff for: ‎deps/uv/include/uv/unix.h

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
# include "uv/posix.h"
7070
#elif defined(__HAIKU__)
7171
# include "uv/posix.h"
72+
#elif defined(__QNX__)
73+
# include "uv/posix.h"
7274
#endif
7375

7476
#ifndef NI_MAXHOST

Diff for: ‎deps/uv/include/uv/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232

3333
#define UV_VERSION_MAJOR 1
34-
#define UV_VERSION_MINOR 39
34+
#define UV_VERSION_MINOR 40
3535
#define UV_VERSION_PATCH 0
3636
#define UV_VERSION_IS_RELEASE 1
3737
#define UV_VERSION_SUFFIX ""

Diff for: ‎deps/uv/libuv-static.pc.in

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prefix=@prefix@
2+
exec_prefix=${prefix}
3+
libdir=@libdir@
4+
includedir=@includedir@
5+
6+
Name: libuv-static
7+
Version: @PACKAGE_VERSION@
8+
Description: multi-platform support library with a focus on asynchronous I/O.
9+
URL: http://libuv.org/
10+
11+
Libs: -L${libdir} -luv_a @LIBS@
12+
Cflags: -I${includedir}

Diff for: ‎deps/uv/src/random.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int uv__random(void* buf, size_t buflen) {
3333

3434
#if defined(__PASE__)
3535
rc = uv__random_readpath("/dev/urandom", buf, buflen);
36-
#elif defined(_AIX)
36+
#elif defined(_AIX) || defined(__QNX__)
3737
rc = uv__random_readpath("/dev/random", buf, buflen);
3838
#elif defined(__APPLE__) || defined(__OpenBSD__) || \
3939
(defined(__ANDROID_API__) && __ANDROID_API__ >= 28)

Diff for: ‎deps/uv/src/timer.c

+8
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ uint64_t uv_timer_get_repeat(const uv_timer_t* handle) {
130130
}
131131

132132

133+
uint64_t uv_timer_get_due_in(const uv_timer_t* handle) {
134+
if (handle->loop->time >= handle->timeout)
135+
return 0;
136+
137+
return handle->timeout - handle->loop->time;
138+
}
139+
140+
133141
int uv__next_timeout(const uv_loop_t* loop) {
134142
const struct heap_node* heap_node;
135143
const uv_timer_t* handle;

Diff for: ‎deps/uv/src/unix/bsd-ifaddrs.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
113113
address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr);
114114
}
115115

116-
if (ent->ifa_netmask->sa_family == AF_INET6) {
116+
if (ent->ifa_netmask == NULL) {
117+
memset(&address->netmask, 0, sizeof(address->netmask));
118+
} else if (ent->ifa_netmask->sa_family == AF_INET6) {
117119
address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask);
118120
} else {
119121
address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask);

Diff for: ‎deps/uv/src/unix/freebsd.c

+4-37
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,6 @@ int uv__platform_loop_init(uv_loop_t* loop) {
5656
void uv__platform_loop_delete(uv_loop_t* loop) {
5757
}
5858

59-
60-
#ifdef __DragonFly__
61-
int uv_exepath(char* buffer, size_t* size) {
62-
char abspath[PATH_MAX * 2 + 1];
63-
ssize_t abspath_size;
64-
65-
if (buffer == NULL || size == NULL || *size == 0)
66-
return UV_EINVAL;
67-
68-
abspath_size = readlink("/proc/curproc/file", abspath, sizeof(abspath));
69-
if (abspath_size < 0)
70-
return UV__ERR(errno);
71-
72-
assert(abspath_size > 0);
73-
*size -= 1;
74-
75-
if (*size > abspath_size)
76-
*size = abspath_size;
77-
78-
memcpy(buffer, abspath, *size);
79-
buffer[*size] = '\0';
80-
81-
return 0;
82-
}
83-
#else
8459
int uv_exepath(char* buffer, size_t* size) {
8560
char abspath[PATH_MAX * 2 + 1];
8661
int mib[4];
@@ -110,7 +85,6 @@ int uv_exepath(char* buffer, size_t* size) {
11085

11186
return 0;
11287
}
113-
#endif
11488

11589
uint64_t uv_get_free_memory(void) {
11690
int freecount;
@@ -290,25 +264,18 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
290264
}
291265

292266

293-
int uv__sendmmsg(int fd,
294-
struct uv__mmsghdr* mmsg,
295-
unsigned int vlen,
296-
unsigned int flags) {
267+
int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) {
297268
#if __FreeBSD__ >= 11
298-
return sendmmsg(fd, mmsg, vlen, flags);
269+
return sendmmsg(fd, mmsg, vlen, /* flags */ 0);
299270
#else
300271
return errno = ENOSYS, -1;
301272
#endif
302273
}
303274

304275

305-
int uv__recvmmsg(int fd,
306-
struct uv__mmsghdr* mmsg,
307-
unsigned int vlen,
308-
unsigned int flags,
309-
struct timespec* timeout) {
276+
int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) {
310277
#if __FreeBSD__ >= 11
311-
return recvmmsg(fd, mmsg, vlen, flags, timeout);
278+
return recvmmsg(fd, mmsg, vlen, 0 /* flags */, NULL /* timeout */);
312279
#else
313280
return errno = ENOSYS, -1;
314281
#endif

Diff for: ‎deps/uv/src/unix/fs.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@
7979
defined(__NetBSD__)
8080
# include <sys/param.h>
8181
# include <sys/mount.h>
82-
#elif defined(__sun) || defined(__MVS__) || defined(__NetBSD__) || defined(__HAIKU__)
82+
#elif defined(__sun) || \
83+
defined(__MVS__) || \
84+
defined(__NetBSD__) || \
85+
defined(__HAIKU__) || \
86+
defined(__QNX__)
8387
# include <sys/statvfs.h>
8488
#else
8589
# include <sys/statfs.h>
@@ -629,7 +633,11 @@ static int uv__fs_closedir(uv_fs_t* req) {
629633

630634
static int uv__fs_statfs(uv_fs_t* req) {
631635
uv_statfs_t* stat_fs;
632-
#if defined(__sun) || defined(__MVS__) || defined(__NetBSD__) || defined(__HAIKU__)
636+
#if defined(__sun) || \
637+
defined(__MVS__) || \
638+
defined(__NetBSD__) || \
639+
defined(__HAIKU__) || \
640+
defined(__QNX__)
633641
struct statvfs buf;
634642

635643
if (0 != statvfs(req->path, &buf))
@@ -646,7 +654,12 @@ static int uv__fs_statfs(uv_fs_t* req) {
646654
return -1;
647655
}
648656

649-
#if defined(__sun) || defined(__MVS__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__)
657+
#if defined(__sun) || \
658+
defined(__MVS__) || \
659+
defined(__OpenBSD__) || \
660+
defined(__NetBSD__) || \
661+
defined(__HAIKU__) || \
662+
defined(__QNX__)
650663
stat_fs->f_type = 0; /* f_type is not supported. */
651664
#else
652665
stat_fs->f_type = buf.f_type;

Diff for: ‎deps/uv/src/unix/internal.h

+2-9
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,8 @@ struct uv__mmsghdr {
334334
unsigned int msg_len;
335335
};
336336

337-
int uv__recvmmsg(int fd,
338-
struct uv__mmsghdr* mmsg,
339-
unsigned int vlen,
340-
unsigned int flags,
341-
struct timespec* timeout);
342-
int uv__sendmmsg(int fd,
343-
struct uv__mmsghdr* mmsg,
344-
unsigned int vlen,
345-
unsigned int flags);
337+
int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen);
338+
int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen);
346339
#else
347340
#define HAVE_MMSG 0
348341
#endif

Diff for: ‎deps/uv/src/unix/linux-core.c

+1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
281281
timeout = 0;
282282
} else {
283283
reset_timeout = 0;
284+
user_timeout = 0;
284285
}
285286

286287
/* You could argue there is a dependency between these two but

Diff for: ‎deps/uv/src/unix/linux-syscalls.c

+39-17
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#ifndef __NR_recvmmsg
3838
# if defined(__x86_64__)
3939
# define __NR_recvmmsg 299
40-
# elif defined(__i386__)
41-
# define __NR_recvmmsg 337
4240
# elif defined(__arm__)
4341
# define __NR_recvmmsg (UV_SYSCALL_BASE + 365)
4442
# endif
@@ -47,8 +45,6 @@
4745
#ifndef __NR_sendmmsg
4846
# if defined(__x86_64__)
4947
# define __NR_sendmmsg 307
50-
# elif defined(__i386__)
51-
# define __NR_sendmmsg 345
5248
# elif defined(__arm__)
5349
# define __NR_sendmmsg (UV_SYSCALL_BASE + 374)
5450
# endif
@@ -146,25 +142,51 @@
146142

147143
struct uv__mmsghdr;
148144

149-
int uv__sendmmsg(int fd,
150-
struct uv__mmsghdr* mmsg,
151-
unsigned int vlen,
152-
unsigned int flags) {
153-
#if defined(__NR_sendmmsg)
154-
return syscall(__NR_sendmmsg, fd, mmsg, vlen, flags);
145+
int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) {
146+
#if defined(__i386__)
147+
unsigned long args[4];
148+
int rc;
149+
150+
args[0] = (unsigned long) fd;
151+
args[1] = (unsigned long) mmsg;
152+
args[2] = (unsigned long) vlen;
153+
args[3] = /* flags */ 0;
154+
155+
/* socketcall() raises EINVAL when SYS_SENDMMSG is not supported. */
156+
rc = syscall(/* __NR_socketcall */ 102, 20 /* SYS_SENDMMSG */, args);
157+
if (rc == -1)
158+
if (errno == EINVAL)
159+
errno = ENOSYS;
160+
161+
return rc;
162+
#elif defined(__NR_sendmmsg)
163+
return syscall(__NR_sendmmsg, fd, mmsg, vlen, /* flags */ 0);
155164
#else
156165
return errno = ENOSYS, -1;
157166
#endif
158167
}
159168

160169

161-
int uv__recvmmsg(int fd,
162-
struct uv__mmsghdr* mmsg,
163-
unsigned int vlen,
164-
unsigned int flags,
165-
struct timespec* timeout) {
166-
#if defined(__NR_recvmmsg)
167-
return syscall(__NR_recvmmsg, fd, mmsg, vlen, flags, timeout);
170+
int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) {
171+
#if defined(__i386__)
172+
unsigned long args[5];
173+
int rc;
174+
175+
args[0] = (unsigned long) fd;
176+
args[1] = (unsigned long) mmsg;
177+
args[2] = (unsigned long) vlen;
178+
args[3] = /* flags */ 0;
179+
args[4] = /* timeout */ 0;
180+
181+
/* socketcall() raises EINVAL when SYS_RECVMMSG is not supported. */
182+
rc = syscall(/* __NR_socketcall */ 102, 19 /* SYS_RECVMMSG */, args);
183+
if (rc == -1)
184+
if (errno == EINVAL)
185+
errno = ENOSYS;
186+
187+
return rc;
188+
#elif defined(__NR_recvmmsg)
189+
return syscall(__NR_recvmmsg, fd, mmsg, vlen, /* flags */ 0, /* timeout */ 0);
168190
#else
169191
return errno = ENOSYS, -1;
170192
#endif

Diff for: ‎deps/uv/src/unix/qnx.c

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/* Copyright libuv contributors. All rights reserved.
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to
5+
* deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
* sell copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
* IN THE SOFTWARE.
20+
*/
21+
22+
#include "uv.h"
23+
#include "internal.h"
24+
25+
#include <string.h>
26+
#include <sys/process.h>
27+
#include <sys/neutrino.h>
28+
#include <sys/memmsg.h>
29+
#include <sys/syspage.h>
30+
#include <sys/procfs.h>
31+
32+
static void
33+
get_mem_info(uint64_t* totalmem, uint64_t* freemem) {
34+
mem_info_t msg;
35+
36+
memset(&msg, 0, sizeof(msg));
37+
msg.i.type = _MEM_INFO;
38+
msg.i.fd = -1;
39+
40+
if (MsgSend(MEMMGR_COID, &msg.i, sizeof(msg.i), &msg.o, sizeof(msg.o))
41+
!= -1) {
42+
*totalmem = msg.o.info.__posix_tmi_total;
43+
*freemem = msg.o.info.posix_tmi_length;
44+
} else {
45+
*totalmem = 0;
46+
*freemem = 0;
47+
}
48+
}
49+
50+
51+
void uv_loadavg(double avg[3]) {
52+
avg[0] = 0.0;
53+
avg[1] = 0.0;
54+
avg[2] = 0.0;
55+
}
56+
57+
58+
int uv_exepath(char* buffer, size_t* size) {
59+
char path[PATH_MAX];
60+
if (buffer == NULL || size == NULL || *size == 0)
61+
return UV_EINVAL;
62+
63+
realpath(_cmdname(NULL), path);
64+
strlcpy(buffer, path, *size);
65+
*size = strlen(buffer);
66+
return 0;
67+
}
68+
69+
70+
uint64_t uv_get_free_memory(void) {
71+
uint64_t totalmem;
72+
uint64_t freemem;
73+
get_mem_info(&totalmem, &freemem);
74+
return freemem;
75+
}
76+
77+
78+
uint64_t uv_get_total_memory(void) {
79+
uint64_t totalmem;
80+
uint64_t freemem;
81+
get_mem_info(&totalmem, &freemem);
82+
return totalmem;
83+
}
84+
85+
86+
uint64_t uv_get_constrained_memory(void) {
87+
return 0;
88+
}
89+
90+
91+
int uv_resident_set_memory(size_t* rss) {
92+
int fd;
93+
procfs_asinfo asinfo;
94+
95+
fd = uv__open_cloexec("/proc/self/ctl", O_RDONLY);
96+
if (fd == -1)
97+
return UV__ERR(errno);
98+
99+
if (devctl(fd, DCMD_PROC_ASINFO, &asinfo, sizeof(asinfo), 0) == -1) {
100+
uv__close(fd);
101+
return UV__ERR(errno);
102+
}
103+
104+
uv__close(fd);
105+
*rss = asinfo.rss;
106+
return 0;
107+
}
108+
109+
110+
int uv_uptime(double* uptime) {
111+
struct qtime_entry* qtime = _SYSPAGE_ENTRY(_syspage_ptr, qtime);
112+
*uptime = (qtime->nsec / 1000000000.0);
113+
return 0;
114+
}
115+
116+
117+
int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
118+
struct cpuinfo_entry* cpuinfo =
119+
(struct cpuinfo_entry*)_SYSPAGE_ENTRY(_syspage_ptr, new_cpuinfo);
120+
size_t cpuinfo_size = _SYSPAGE_ELEMENT_SIZE(_syspage_ptr, cpuinfo);
121+
struct strings_entry* strings = _SYSPAGE_ENTRY(_syspage_ptr, strings);
122+
int num_cpus = _syspage_ptr->num_cpu;
123+
int i;
124+
125+
*count = num_cpus;
126+
*cpu_infos = uv__malloc(num_cpus * sizeof(**cpu_infos));
127+
if (*cpu_infos == NULL)
128+
return UV_ENOMEM;
129+
130+
for (i = 0; i < num_cpus; i++) {
131+
(*cpu_infos)[i].model = strdup(&strings->data[cpuinfo->name]);
132+
(*cpu_infos)[i].speed = cpuinfo->speed;
133+
SYSPAGE_ARRAY_ADJ_OFFSET(cpuinfo, cpuinfo, cpuinfo_size);
134+
}
135+
136+
return 0;
137+
}

Diff for: ‎deps/uv/src/unix/udp.c

+22-14
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ static void uv__udp_mmsg_init(void) {
7373
s = uv__socket(AF_INET, SOCK_DGRAM, 0);
7474
if (s < 0)
7575
return;
76-
ret = uv__sendmmsg(s, NULL, 0, 0);
76+
ret = uv__sendmmsg(s, NULL, 0);
7777
if (ret == 0 || errno != ENOSYS) {
7878
uv__sendmmsg_avail = 1;
7979
uv__recvmmsg_avail = 1;
8080
} else {
81-
ret = uv__recvmmsg(s, NULL, 0, 0, NULL);
81+
ret = uv__recvmmsg(s, NULL, 0);
8282
if (ret == 0 || errno != ENOSYS)
8383
uv__recvmmsg_avail = 1;
8484
}
@@ -213,7 +213,7 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) {
213213
}
214214

215215
do
216-
nread = uv__recvmmsg(handle->io_watcher.fd, msgs, chunks, 0, NULL);
216+
nread = uv__recvmmsg(handle->io_watcher.fd, msgs, chunks);
217217
while (nread == -1 && errno == EINTR);
218218

219219
if (nread < 1) {
@@ -238,7 +238,7 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) {
238238

239239
/* one last callback so the original buffer is freed */
240240
if (handle->recv_cb != NULL)
241-
handle->recv_cb(handle, 0, buf, NULL, 0);
241+
handle->recv_cb(handle, 0, buf, NULL, UV_UDP_MMSG_FREE);
242242
}
243243
return nread;
244244
}
@@ -356,7 +356,7 @@ static void uv__udp_sendmmsg(uv_udp_t* handle) {
356356
}
357357

358358
do
359-
npkts = uv__sendmmsg(handle->io_watcher.fd, h, pkts, 0);
359+
npkts = uv__sendmmsg(handle->io_watcher.fd, h, pkts);
360360
while (npkts == -1 && errno == EINTR);
361361

362362
if (npkts < 1) {
@@ -851,7 +851,11 @@ static int uv__udp_set_membership6(uv_udp_t* handle,
851851
}
852852

853853

854-
#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__ANDROID__)
854+
#if !defined(__OpenBSD__) && \
855+
!defined(__NetBSD__) && \
856+
!defined(__ANDROID__) && \
857+
!defined(__DragonFly__) & \
858+
!defined(__QNX__)
855859
static int uv__udp_set_source_membership4(uv_udp_t* handle,
856860
const struct sockaddr_in* multicast_addr,
857861
const char* interface_addr,
@@ -1039,7 +1043,11 @@ int uv_udp_set_source_membership(uv_udp_t* handle,
10391043
const char* interface_addr,
10401044
const char* source_addr,
10411045
uv_membership membership) {
1042-
#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__ANDROID__)
1046+
#if !defined(__OpenBSD__) && \
1047+
!defined(__NetBSD__) && \
1048+
!defined(__ANDROID__) && \
1049+
!defined(__DragonFly__) && \
1050+
!defined(__QNX__)
10431051
int err;
10441052
union uv__sockaddr mcast_addr;
10451053
union uv__sockaddr src_addr;
@@ -1146,7 +1154,7 @@ int uv_udp_set_ttl(uv_udp_t* handle, int ttl) {
11461154
* and use the general uv__setsockopt_maybe_char call on other platforms.
11471155
*/
11481156
#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
1149-
defined(__MVS__)
1157+
defined(__MVS__) || defined(__QNX__)
11501158

11511159
return uv__setsockopt(handle,
11521160
IP_TTL,
@@ -1155,15 +1163,15 @@ int uv_udp_set_ttl(uv_udp_t* handle, int ttl) {
11551163
sizeof(ttl));
11561164

11571165
#else /* !(defined(__sun) || defined(_AIX) || defined (__OpenBSD__) ||
1158-
defined(__MVS__)) */
1166+
defined(__MVS__) || defined(__QNX__)) */
11591167

11601168
return uv__setsockopt_maybe_char(handle,
11611169
IP_TTL,
11621170
IPV6_UNICAST_HOPS,
11631171
ttl);
11641172

11651173
#endif /* defined(__sun) || defined(_AIX) || defined (__OpenBSD__) ||
1166-
defined(__MVS__) */
1174+
defined(__MVS__) || defined(__QNX__) */
11671175
}
11681176

11691177

@@ -1175,15 +1183,15 @@ int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) {
11751183
* and use the general uv__setsockopt_maybe_char call otherwise.
11761184
*/
11771185
#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
1178-
defined(__MVS__)
1186+
defined(__MVS__) || defined(__QNX__)
11791187
if (handle->flags & UV_HANDLE_IPV6)
11801188
return uv__setsockopt(handle,
11811189
IP_MULTICAST_TTL,
11821190
IPV6_MULTICAST_HOPS,
11831191
&ttl,
11841192
sizeof(ttl));
11851193
#endif /* defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
1186-
defined(__MVS__) */
1194+
defined(__MVS__) || defined(__QNX__) */
11871195

11881196
return uv__setsockopt_maybe_char(handle,
11891197
IP_MULTICAST_TTL,
@@ -1200,15 +1208,15 @@ int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) {
12001208
* and use the general uv__setsockopt_maybe_char call otherwise.
12011209
*/
12021210
#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
1203-
defined(__MVS__)
1211+
defined(__MVS__) || defined(__QNX__)
12041212
if (handle->flags & UV_HANDLE_IPV6)
12051213
return uv__setsockopt(handle,
12061214
IP_MULTICAST_LOOP,
12071215
IPV6_MULTICAST_LOOP,
12081216
&on,
12091217
sizeof(on));
12101218
#endif /* defined(__sun) || defined(_AIX) ||defined(__OpenBSD__) ||
1211-
defined(__MVS__) */
1219+
defined(__MVS__) || defined(__QNX__) */
12121220

12131221
return uv__setsockopt_maybe_char(handle,
12141222
IP_MULTICAST_LOOP,

Diff for: ‎deps/uv/src/win/tty.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -2122,13 +2122,6 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
21222122
abort();
21232123
}
21242124

2125-
/* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the windows
2126-
* console doesn't really support UTF-16, so just emit the replacement
2127-
* character. */
2128-
if (utf8_codepoint > 0xffff) {
2129-
utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER;
2130-
}
2131-
21322125
if (utf8_codepoint == 0x0a || utf8_codepoint == 0x0d) {
21332126
/* EOL conversion - emit \r\n when we see \n. */
21342127

@@ -2155,6 +2148,12 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
21552148
ENSURE_BUFFER_SPACE(1);
21562149
utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint;
21572150
previous_eol = 0;
2151+
} else {
2152+
ENSURE_BUFFER_SPACE(2);
2153+
utf8_codepoint -= 0x10000;
2154+
utf16_buf[utf16_buf_used++] = (WCHAR) (utf8_codepoint / 0x400 + 0xD800);
2155+
utf16_buf[utf16_buf_used++] = (WCHAR) (utf8_codepoint % 0x400 + 0xDC00);
2156+
previous_eol = 0;
21582157
}
21592158
}
21602159
}

Diff for: ‎deps/uv/src/win/udp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ int uv__udp_connect(uv_udp_t* handle,
10731073

10741074
err = connect(handle->socket, addr, addrlen);
10751075
if (err)
1076-
return uv_translate_sys_error(err);
1076+
return uv_translate_sys_error(WSAGetLastError());
10771077

10781078
handle->flags |= UV_HANDLE_UDP_CONNECTED;
10791079

@@ -1089,7 +1089,7 @@ int uv__udp_disconnect(uv_udp_t* handle) {
10891089

10901090
err = connect(handle->socket, &addr, sizeof(addr));
10911091
if (err)
1092-
return uv_translate_sys_error(err);
1092+
return uv_translate_sys_error(WSAGetLastError());
10931093

10941094
handle->flags &= ~UV_HANDLE_UDP_CONNECTED;
10951095
return 0;

Diff for: ‎deps/uv/test/test-dlerror.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ TEST_IMPL(dlerror) {
4242

4343
msg = uv_dlerror(&lib);
4444
ASSERT(msg != NULL);
45-
#ifndef __OpenBSD__
45+
#if !defined(__OpenBSD__) && !defined(__QNX__)
4646
ASSERT(strstr(msg, path) != NULL);
4747
#endif
4848
ASSERT(strstr(msg, dlerror_no_error) == NULL);
4949

5050
/* Should return the same error twice in a row. */
5151
msg = uv_dlerror(&lib);
5252
ASSERT(msg != NULL);
53-
#ifndef __OpenBSD__
53+
#if !defined(__OpenBSD__) && !defined(__QNX__)
5454
ASSERT(strstr(msg, path) != NULL);
5555
#endif
5656
ASSERT(strstr(msg, dlerror_no_error) == NULL);

Diff for: ‎deps/uv/test/test-fs-copyfile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#if defined(__unix__) || defined(__POSIX__) || \
2626
defined(__APPLE__) || defined(__sun) || \
2727
defined(_AIX) || defined(__MVS__) || \
28-
defined(__HAIKU__)
28+
defined(__HAIKU__) || defined(__QNX__)
2929
#include <unistd.h> /* unlink, etc. */
3030
#else
3131
# include <direct.h>

Diff for: ‎deps/uv/test/test-tcp-connect-timeout.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ static void connect_local_cb(uv_connect_t* req, int status) {
100100
connect_cb_called++;
101101
}
102102

103-
static int is_supported_system() {
103+
static int is_supported_system(void) {
104104
int semver[3];
105105
int min_semver[3] = {10, 0, 16299};
106106
int cnt;
107107
uv_utsname_t uname;
108108
ASSERT_EQ(uv_os_uname(&uname), 0);
109-
if (strcmp(uname.sysname, "Windows_NT") == 0) {
109+
if (strcmp(uname.sysname, "Windows_NT") == 0) {
110110
cnt = sscanf(uname.release, "%d.%d.%d", &semver[0], &semver[1], &semver[2]);
111111
if (cnt != 3) {
112112
return 0;

Diff for: ‎deps/uv/test/test-timer.c

+4
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ TEST_IMPL(timer_init) {
161161

162162
ASSERT(0 == uv_timer_init(uv_default_loop(), &handle));
163163
ASSERT(0 == uv_timer_get_repeat(&handle));
164+
ASSERT_UINT64_LE(0, uv_timer_get_due_in(&handle));
164165
ASSERT(0 == uv_is_active((uv_handle_t*) &handle));
165166

166167
MAKE_VALGRIND_HAPPY();
@@ -232,6 +233,9 @@ TEST_IMPL(timer_huge_timeout) {
232233
ASSERT(0 == uv_timer_start(&tiny_timer, tiny_timer_cb, 1, 0));
233234
ASSERT(0 == uv_timer_start(&huge_timer1, tiny_timer_cb, 0xffffffffffffLL, 0));
234235
ASSERT(0 == uv_timer_start(&huge_timer2, tiny_timer_cb, (uint64_t) -1, 0));
236+
ASSERT_UINT64_EQ(1, uv_timer_get_due_in(&tiny_timer));
237+
ASSERT_UINT64_EQ(281474976710655, uv_timer_get_due_in(&huge_timer1));
238+
ASSERT_UINT64_LE(0, uv_timer_get_due_in(&huge_timer2));
235239
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
236240
MAKE_VALGRIND_HAPPY();
237241
return 0;

Diff for: ‎deps/uv/test/test-udp-connect.c

+11
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ TEST_IMPL(udp_connect) {
124124

125125
buf = uv_buf_init("EXIT", 4);
126126

127+
// connect() to INADDR_ANY fails on Windows wih WSAEADDRNOTAVAIL
128+
ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &tmp_addr));
129+
r = uv_udp_connect(&client, (const struct sockaddr*) &tmp_addr);
130+
#ifdef _WIN32
131+
ASSERT_EQ(r, UV_EADDRNOTAVAIL);
132+
#else
133+
ASSERT_EQ(r, 0);
134+
r = uv_udp_connect(&client, NULL);
135+
ASSERT_EQ(r, 0);
136+
#endif
137+
127138
ASSERT(0 == uv_ip4_addr("8.8.8.8", TEST_PORT, &ext_addr));
128139
ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &lo_addr));
129140

Diff for: ‎deps/uv/test/test-udp-mmsg.c

+16-10
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,22 @@ static void recv_cb(uv_udp_t* handle,
7474
unsigned flags) {
7575
ASSERT_GE(nread, 0);
7676

77-
if (nread > 0) {
78-
ASSERT_EQ(nread, 4);
79-
ASSERT(addr != NULL);
80-
ASSERT_MEM_EQ("PING", rcvbuf->base, nread);
81-
82-
recv_cb_called++;
83-
if (recv_cb_called == NUM_SENDS) {
84-
uv_close((uv_handle_t*)handle, close_cb);
85-
uv_close((uv_handle_t*)&sender, close_cb);
86-
}
77+
/* free and return if this is a mmsg free-only callback invocation */
78+
if (flags & UV_UDP_MMSG_FREE) {
79+
ASSERT_EQ(nread, 0);
80+
ASSERT(addr == NULL);
81+
free(rcvbuf->base);
82+
return;
83+
}
84+
85+
ASSERT_EQ(nread, 4);
86+
ASSERT(addr != NULL);
87+
ASSERT_MEM_EQ("PING", rcvbuf->base, nread);
88+
89+
recv_cb_called++;
90+
if (recv_cb_called == NUM_SENDS) {
91+
uv_close((uv_handle_t*)handle, close_cb);
92+
uv_close((uv_handle_t*)&sender, close_cb);
8793
}
8894

8995
/* Don't free if the buffer could be reused via mmsg */

0 commit comments

Comments
 (0)
Please sign in to comment.