提交 0a6f4ae4 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Working on 3.6.10

* Update libuv to 1.38.1
* Update Catch to 2.12.4
* Update NPM deps
上级 20fa994c
# Changelog # Changelog
### 3.6.10 (WIP)
* Update `libuv` to 1.38.1.
* Update `Catch` to 2.12.4.
* Update NPM deps.
### 3.6.9 ### 3.6.9
* `Transport::ReceiveRtpPacket()`: Call `RecvStreamClosed(packet->GetSsrc())` if received RTP packet does not match any `Producer`. * `Transport::ReceiveRtpPacket()`: Call `RecvStreamClosed(packet->GetSsrc())` if received RTP packet does not match any `Producer`.
......
...@@ -67,7 +67,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -67,7 +67,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
// options // options
{ {
env: { env: {
MEDIASOUP_VERSION: '3.6.8' MEDIASOUP_VERSION: '3.6.9'
}, },
detached: false, detached: false,
// fd 0 (stdin) : Just ignore it. // fd 0 (stdin) : Just ignore it.
......
...@@ -10,7 +10,7 @@ exports.types = types; ...@@ -10,7 +10,7 @@ exports.types = types;
/** /**
* Expose mediasoup version. * Expose mediasoup version.
*/ */
exports.version = '3.6.8'; exports.version = '3.6.9';
/** /**
* Expose parseScalabilityMode() function. * Expose parseScalabilityMode() function.
*/ */
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
"testRegex": "test/test.*\\.js" "testRegex": "test/test.*\\.js"
}, },
"dependencies": { "dependencies": {
"@types/node": "^14.0.14", "@types/node": "^14.0.20",
"awaitqueue": "^2.2.1", "awaitqueue": "^2.2.3",
"debug": "^4.1.1", "debug": "^4.1.1",
"h264-profile-level-id": "^1.0.1", "h264-profile-level-id": "^1.0.1",
"netstring": "^0.3.0", "netstring": "^0.3.0",
...@@ -59,11 +59,11 @@ ...@@ -59,11 +59,11 @@
"@types/debug": "^4.1.5", "@types/debug": "^4.1.5",
"@types/random-number": "0.0.0", "@types/random-number": "0.0.0",
"@types/uuid": "^8.0.0", "@types/uuid": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^3.5.0", "@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.5.0", "@typescript-eslint/parser": "^3.6.0",
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"eslint": "^7.3.1", "eslint": "^7.4.0",
"eslint-plugin-jest": "^23.17.1", "eslint-plugin-jest": "^23.18.0",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-clang-format": "^1.0.27", "gulp-clang-format": "^1.0.27",
"jest": "^26.1.0", "jest": "^26.1.0",
......
patreon: horenmar custom: "https://www.paypal.me/horenmar"
...@@ -14,7 +14,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) ...@@ -14,7 +14,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif() endif()
project(Catch2 LANGUAGES CXX VERSION 2.12.3) project(Catch2 LANGUAGES CXX VERSION 2.12.4)
# Provide path for scripts # Provide path for scripts
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2) [![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2)
[![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2) [![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2)
[![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2) [![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/yfl7WhNJBY0IpgtF) [![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/wRuqI3INY7fTagL7)
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD) [![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD)
<a href="https://github.com/catchorg/Catch2/releases/download/v2.12.3/catch.hpp">The latest version of the single header can be downloaded directly using this link</a> <a href="https://github.com/catchorg/Catch2/releases/download/v2.12.4/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
## Catch2 is released! ## Catch2 is released!
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Release notes # Release notes
**Contents**<br> **Contents**<br>
[2.12.4](#2124)<br>
[2.12.3](#2123)<br> [2.12.3](#2123)<br>
[2.12.2](#2122)<br> [2.12.2](#2122)<br>
[2.12.1](#2121)<br> [2.12.1](#2121)<br>
...@@ -39,6 +40,12 @@ ...@@ -39,6 +40,12 @@
[Even Older versions](#even-older-versions)<br> [Even Older versions](#even-older-versions)<br>
## 2.12.4
### Improvements
* Added support for MacOS on ARM (#1971)
## 2.12.3 ## 2.12.3
### Fixes ### Fixes
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 12 #define CATCH_VERSION_MINOR 12
#define CATCH_VERSION_PATCH 3 #define CATCH_VERSION_PATCH 4
#ifdef __clang__ #ifdef __clang__
# pragma clang system_header # pragma clang system_header
......
...@@ -17,7 +17,11 @@ namespace Catch { ...@@ -17,7 +17,11 @@ namespace Catch {
#ifdef CATCH_PLATFORM_MAC #ifdef CATCH_PLATFORM_MAC
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ #if defined(__i386__) || defined(__x86_64__)
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#elif defined(__aarch64__)
#define CATCH_TRAP() __asm__(".inst 0xd4200000")
#endif
#elif defined(CATCH_PLATFORM_IPHONE) #elif defined(CATCH_PLATFORM_IPHONE)
......
...@@ -37,7 +37,7 @@ namespace Catch { ...@@ -37,7 +37,7 @@ namespace Catch {
} }
Version const& libraryVersion() { Version const& libraryVersion() {
static Version version( 2, 12, 3, "", 0 ); static Version version( 2, 12, 4, "", 0 );
return version; return version;
} }
......
/* /*
* Catch v2.12.3 * Catch v2.12.4
* Generated: 2020-06-29 20:47:52.374964 * Generated: 2020-07-05 11:47:18.451282
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 12 #define CATCH_VERSION_MINOR 12
#define CATCH_VERSION_PATCH 3 #define CATCH_VERSION_PATCH 4
#ifdef __clang__ #ifdef __clang__
# pragma clang system_header # pragma clang system_header
...@@ -7927,7 +7927,11 @@ namespace Catch { ...@@ -7927,7 +7927,11 @@ namespace Catch {
#ifdef CATCH_PLATFORM_MAC #ifdef CATCH_PLATFORM_MAC
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ #if defined(__i386__) || defined(__x86_64__)
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#elif defined(__aarch64__)
#define CATCH_TRAP() __asm__(".inst 0xd4200000")
#endif
#elif defined(CATCH_PLATFORM_IPHONE) #elif defined(CATCH_PLATFORM_IPHONE)
...@@ -15202,7 +15206,7 @@ namespace Catch { ...@@ -15202,7 +15206,7 @@ namespace Catch {
} }
Version const& libraryVersion() { Version const& libraryVersion() {
static Version version( 2, 12, 3, "", 0 ); static Version version( 2, 12, 4, "", 0 );
return version; return version;
} }
......
...@@ -3,6 +3,20 @@ name: CI ...@@ -3,6 +3,20 @@ name: CI
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
build-android:
runs-on: ubuntu-latest
container: reactnativecommunity/react-native-android:2020-5-20
steps:
- uses: actions/checkout@v2
- name: Envinfo
run: npx envinfo
- name: Build android arm64
# see build options you can use in https://developer.android.com/ndk/guides/cmake
run: |
mkdir build && cd build
$ANDROID_HOME/cmake/3.10.2.4988404/bin/cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk/20.0.5594570/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-21 ..
$ANDROID_HOME/cmake/3.10.2.4988404/bin/cmake --build .
build-cross-qemu: build-cross-qemu:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: build-cross-qemu-${{ matrix.config.target }} name: build-cross-qemu-${{ matrix.config.target }}
...@@ -37,7 +51,7 @@ jobs: ...@@ -37,7 +51,7 @@ jobs:
QEMU_SRC: "http://archive.ubuntu.com/ubuntu/pool/universe/q/qemu" QEMU_SRC: "http://archive.ubuntu.com/ubuntu/pool/universe/q/qemu"
QEMU_VER: "qemu-user-static_4\\.2-.*_amd64.deb$" QEMU_VER: "qemu-user-static_4\\.2-.*_amd64.deb$"
run: | run: |
DEB=`curl -s $QEMU_SRC/ | grep -o -E 'href="([^"#]+)"' | cut -d'"' -f2 | grep $QEMU_VER` DEB=`curl -s $QEMU_SRC/ | grep -o -E 'href="([^"#]+)"' | cut -d'"' -f2 | grep $QEMU_VER | tail -1`
wget $QEMU_SRC/$DEB wget $QEMU_SRC/$DEB
sudo dpkg -i $DEB sudo dpkg -i $DEB
- name: Install ${{ matrix.config.toolchain }} - name: Install ${{ matrix.config.toolchain }}
......
...@@ -432,3 +432,6 @@ Philip Chimento <philip.chimento@gmail.com> ...@@ -432,3 +432,6 @@ Philip Chimento <philip.chimento@gmail.com>
Michal Artazov <michal@artazov.cz> Michal Artazov <michal@artazov.cz>
Jeroen Roovers <jer@gentoo.org> Jeroen Roovers <jer@gentoo.org>
MasterDuke17 <MasterDuke17@users.noreply.github.com> MasterDuke17 <MasterDuke17@users.noreply.github.com>
Alexander Tokmakov <avtokmakov@yandex-team.ru>
Arenoros <arenoros@gmail.com>
lander0s <dh.landeros08@gmail.com>
...@@ -182,6 +182,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") ...@@ -182,6 +182,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Android") if(CMAKE_SYSTEM_NAME STREQUAL "Android")
list(APPEND uv_defines _GNU_SOURCE)
list(APPEND uv_libraries dl) list(APPEND uv_libraries dl)
list(APPEND uv_sources list(APPEND uv_sources
src/unix/android-ifaddrs.c src/unix/android-ifaddrs.c
...@@ -192,8 +193,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android") ...@@ -192,8 +193,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
src/unix/pthread-fixes.c src/unix/pthread-fixes.c
src/unix/random-getentropy.c src/unix/random-getentropy.c
src/unix/random-getrandom.c src/unix/random-getrandom.c
src/unix/random-sysctl-linux.c src/unix/random-sysctl-linux.c)
src/unix/sysinfo-loadavg.c)
endif() endif()
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Android|Linux|OS390") if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Android|Linux|OS390")
...@@ -206,7 +206,6 @@ endif() ...@@ -206,7 +206,6 @@ endif()
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD") if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
list(APPEND uv_sources src/unix/posix-hrtime.c src/unix/bsd-proctitle.c) list(APPEND uv_sources src/unix/posix-hrtime.c src/unix/bsd-proctitle.c)
list(APPEND uv_libraries kvm)
endif() endif()
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD") if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
...@@ -238,12 +237,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") ...@@ -238,12 +237,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
src/unix/linux-syscalls.c src/unix/linux-syscalls.c
src/unix/procfs-exepath.c src/unix/procfs-exepath.c
src/unix/random-getrandom.c src/unix/random-getrandom.c
src/unix/random-sysctl-linux.c src/unix/random-sysctl-linux.c)
src/unix/sysinfo-loadavg.c)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
list(APPEND uv_sources src/unix/netbsd.c) list(APPEND uv_sources src/unix/netbsd.c)
list(APPEND uv_libraries kvm)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
...@@ -510,6 +509,7 @@ if(LIBUV_BUILD_TESTS) ...@@ -510,6 +509,7 @@ if(LIBUV_BUILD_TESTS)
test/test-udp-send-and-recv.c test/test-udp-send-and-recv.c
test/test-udp-send-hang-loop.c test/test-udp-send-hang-loop.c
test/test-udp-send-immediate.c test/test-udp-send-immediate.c
test/test-udp-sendmmsg-error.c
test/test-udp-send-unreachable.c test/test-udp-send-unreachable.c
test/test-udp-try-send.c test/test-udp-try-send.c
test/test-uname.c test/test-uname.c
......
2020.05.18, Version 1.38.0 (Stable) 2020.07.04, Version 1.38.1 (Stable)
Changes since version 1.38.0:
* test: use last matching qemu version (cjihrig)
* win, util: rearrange uv_hrtime (Bartosz Sosnowski)
* test: skip signal_multiple_loops test on QEMU (gengjiawen)
* build: add android build to CI (gengjiawen)
* test: extend fs_event_error_reporting timeout (cjihrig)
* build: link libkvm on netbsd only (Alexander Tokmakov)
* linux: refactor /proc file reader logic (Ben Noordhuis)
* linux: read load average from /proc/loadavg (Ben Noordhuis)
* android: remove patch code for below 21 (gengjiawen)
* win: fix visual studio 2008 build (Arenoros)
* win,tty: fix deadlock caused by inconsistent state (lander0s)
* unix: use relaxed loads/stores for feature checks (Ben Noordhuis)
* build: don't .gitignore m4/ax_pthread.m4 (Ben Noordhuis)
* unix: fix gcc atomics feature check (Ben Noordhuis)
* darwin: work around clock jumping back in time (Ben Noordhuis)
* udp: fix write_queue cleanup on sendmmsg error (Santiago Gimeno)
* src: build fix for Android (David Carlier)
2020.05.18, Version 1.38.0 (Stable), 1ab9ea3790378f9f25c4e78e9e2b511c75f9c9ed
Changes since version 1.37.0: Changes since version 1.37.0:
......
...@@ -296,6 +296,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \ ...@@ -296,6 +296,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-udp-send-and-recv.c \ test/test-udp-send-and-recv.c \
test/test-udp-send-hang-loop.c \ test/test-udp-send-hang-loop.c \
test/test-udp-send-immediate.c \ test/test-udp-send-immediate.c \
test/test-udp-sendmmsg-error.c \
test/test-udp-send-unreachable.c \ test/test-udp-send-unreachable.c \
test/test-udp-try-send.c \ test/test-udp-try-send.c \
test/test-uname.c \ test/test-uname.c \
...@@ -379,6 +380,7 @@ endif ...@@ -379,6 +380,7 @@ endif
if ANDROID if ANDROID
uvinclude_HEADERS += include/uv/android-ifaddrs.h uvinclude_HEADERS += include/uv/android-ifaddrs.h
libuv_la_CFLAGS += -D_GNU_SOURCE
libuv_la_SOURCES += src/unix/android-ifaddrs.c \ libuv_la_SOURCES += src/unix/android-ifaddrs.c \
src/unix/linux-core.c \ src/unix/linux-core.c \
src/unix/linux-inotify.c \ src/unix/linux-inotify.c \
...@@ -386,8 +388,7 @@ libuv_la_SOURCES += src/unix/android-ifaddrs.c \ ...@@ -386,8 +388,7 @@ libuv_la_SOURCES += src/unix/android-ifaddrs.c \
src/unix/procfs-exepath.c \ src/unix/procfs-exepath.c \
src/unix/pthread-fixes.c \ src/unix/pthread-fixes.c \
src/unix/random-getrandom.c \ src/unix/random-getrandom.c \
src/unix/random-sysctl-linux.c \ src/unix/random-sysctl-linux.c
src/unix/sysinfo-loadavg.c
endif endif
if CYGWIN if CYGWIN
...@@ -468,8 +469,7 @@ libuv_la_SOURCES += src/unix/linux-core.c \ ...@@ -468,8 +469,7 @@ libuv_la_SOURCES += src/unix/linux-core.c \
src/unix/procfs-exepath.c \ src/unix/procfs-exepath.c \
src/unix/proctitle.c \ src/unix/proctitle.c \
src/unix/random-getrandom.c \ src/unix/random-getrandom.c \
src/unix/random-sysctl-linux.c \ src/unix/random-sysctl-linux.c
src/unix/sysinfo-loadavg.c
test_run_tests_LDFLAGS += -lutil test_run_tests_LDFLAGS += -lutil
endif endif
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT([libuv], [1.38.0], [https://github.com/libuv/libuv/issues]) AC_INIT([libuv], [1.38.1], [https://github.com/libuv/libuv/issues])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/libuv-extra-automake-flags.m4])
m4_include([m4/as_case.m4]) m4_include([m4/as_case.m4])
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define UV_VERSION_MAJOR 1 #define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 38 #define UV_VERSION_MINOR 38
#define UV_VERSION_PATCH 0 #define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX "" #define UV_VERSION_SUFFIX ""
......
# Ignore libtoolize-generated files. # Ignore libtoolize-generated files.
*.m4 *.m4
!as_case.m4 !as_case.m4
!ax_pthread.m4
!libuv-check-flags.m4 !libuv-check-flags.m4
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC to any special C compiler that is needed for
# multi-threaded programs (defaults to the value of CC otherwise). (This
# is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also to link with them as well. For example, you might link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threaded programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# PTHREAD_CFLAGS.
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# Updated for Autoconf 2.68 by Daniel Richard G.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 24
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_SED])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on Tru64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
ax_pthread_save_CC="$CC"
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok])
if test "x$ax_pthread_ok" = "xno"; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
CC="$ax_pthread_save_CC"
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
# (Note: HP C rejects this with "bad form for `-t' option")
# -pthreads: Solaris/gcc (Note: HP C also rejects)
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads and
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
# is present but should not be used directly; and before -mthreads,
# because the compiler interprets this as "-mt" + "-hreads")
# -mthreads: Mingw32/gcc, Lynx/gcc
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case $host_os in
freebsd*)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
;;
hpux*)
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
# multi-threading and also sets -lpthread."
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
;;
openedition*)
# IBM z/OS requires a feature-test macro to be defined in order to
# enable POSIX threads at all, so give the user a hint if this is
# not set. (We don't define these ourselves, as they can affect
# other portions of the system API in unpredictable ways.)
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
[
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
AX_PTHREAD_ZOS_MISSING
# endif
],
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
;;
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (N.B.: The stubs are missing
# pthread_cleanup_push, or rather a function called by this macro,
# so we could check for that, but who knows whether they'll stub
# that too in a future libc.) So we'll check first for the
# standard Solaris way of linking pthreads (-mt -lpthread).
ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
;;
esac
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
AS_IF([test "x$GCC" = "xyes"],
[ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
# The presence of a feature test macro requesting re-entrant function
# definitions is, on some systems, a strong hint that pthreads support is
# correctly enabled
case $host_os in
darwin* | hpux* | linux* | osf* | solaris*)
ax_pthread_check_macro="_REENTRANT"
;;
aix*)
ax_pthread_check_macro="_THREAD_SAFE"
;;
*)
ax_pthread_check_macro="--"
;;
esac
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
[ax_pthread_check_cond=0],
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
# Are we compiling with Clang?
AC_CACHE_CHECK([whether $CC is Clang],
[ax_cv_PTHREAD_CLANG],
[ax_cv_PTHREAD_CLANG=no
# Note that Autoconf sets GCC=yes for Clang as well as GCC
if test "x$GCC" = "xyes"; then
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
# if defined(__clang__) && defined(__llvm__)
AX_PTHREAD_CC_IS_CLANG
# endif
],
[ax_cv_PTHREAD_CLANG=yes])
fi
])
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
ax_pthread_clang_warning=no
# Clang needs special handling, because older versions handle the -pthread
# option in a rather... idiosyncratic way
if test "x$ax_pthread_clang" = "xyes"; then
# Clang takes -pthread; it has never supported any other flag
# (Note 1: This will need to be revisited if a system that Clang
# supports has POSIX threads in a separate library. This tends not
# to be the way of modern systems, but it's conceivable.)
# (Note 2: On some systems, notably Darwin, -pthread is not needed
# to get POSIX threads support; the API is always present and
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
# -pthread does define _REENTRANT, and while the Darwin headers
# ignore this macro, third-party headers might not.)
PTHREAD_CFLAGS="-pthread"
PTHREAD_LIBS=
ax_pthread_ok=yes
# However, older versions of Clang make a point of warning the user
# that, in an invocation where only linking and no compilation is
# taking place, the -pthread option has no effect ("argument unused
# during compilation"). They expect -pthread to be passed in only
# when source code is being compiled.
#
# Problem is, this is at odds with the way Automake and most other
# C build frameworks function, which is that the same flags used in
# compilation (CFLAGS) are also used in linking. Many systems
# supported by AX_PTHREAD require exactly this for POSIX threads
# support, and in fact it is often not straightforward to specify a
# flag that is used only in the compilation phase and not in
# linking. Such a scenario is extremely rare in practice.
#
# Even though use of the -pthread flag in linking would only print
# a warning, this can be a nuisance for well-run software projects
# that build with -Werror. So if the active version of Clang has
# this misfeature, we search for an option to squash it.
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
# Create an alternate version of $ac_link that compiles and
# links in two steps (.c -> .o, .o -> exe) instead of one
# (.c -> exe), because the warning occurs only in the second
# step
ax_pthread_save_ac_link="$ac_link"
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
ax_pthread_save_CFLAGS="$CFLAGS"
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
ac_link="$ax_pthread_save_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[ac_link="$ax_pthread_2step_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[break])
])
done
ac_link="$ax_pthread_save_ac_link"
CFLAGS="$ax_pthread_save_CFLAGS"
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
])
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
no | unknown) ;;
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
esac
fi # $ax_pthread_clang = yes
if test "x$ax_pthread_ok" = "xno"; then
for ax_pthread_try_flag in $ax_pthread_flags; do
case $ax_pthread_try_flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-mt,pthread)
AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
PTHREAD_CFLAGS="-mt"
PTHREAD_LIBS="-lpthread"
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
PTHREAD_CFLAGS="$ax_pthread_try_flag"
;;
pthread-config)
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
PTHREAD_LIBS="-l$ax_pthread_try_flag"
;;
esac
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
# if $ax_pthread_check_cond
# error "$ax_pthread_check_macro must be defined"
# endif
static void routine(void *a) { a = 0; }
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_join(th, 0);
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
[ax_pthread_ok=yes],
[])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
AC_MSG_RESULT([$ax_pthread_ok])
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$ax_pthread_ok" = "xyes"; then
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_CACHE_CHECK([for joinable pthread attribute],
[ax_cv_PTHREAD_JOINABLE_ATTR],
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $ax_pthread_attr; return attr /* ; */])],
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
[])
done
])
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
[$ax_cv_PTHREAD_JOINABLE_ATTR],
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
ax_pthread_joinable_attr_defined=yes
])
AC_CACHE_CHECK([whether more special flags are required for pthreads],
[ax_cv_PTHREAD_SPECIAL_FLAGS],
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
case $host_os in
solaris*)
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
;;
esac
])
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
test "x$ax_pthread_special_flags_added" != "xyes"],
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
ax_pthread_special_flags_added=yes])
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
test "x$ax_pthread_prio_inherit_defined" != "xyes"],
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
ax_pthread_prio_inherit_defined=yes
])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
# More AIX lossage: compile with *_r variant
if test "x$GCC" != "xyes"; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
;;
esac
fi
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
AC_SUBST([PTHREAD_LIBS])
AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CC])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "x$ax_pthread_ok" = "xyes"; then
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_POP
])dnl AX_PTHREAD
...@@ -79,10 +79,6 @@ extern char** environ; ...@@ -79,10 +79,6 @@ extern char** environ;
# endif # endif
#endif #endif
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
# include <dlfcn.h> /* for dlsym */
#endif
#if defined(__MVS__) #if defined(__MVS__)
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif
...@@ -220,15 +216,23 @@ int uv__getiovmax(void) { ...@@ -220,15 +216,23 @@ int uv__getiovmax(void) {
#if defined(IOV_MAX) #if defined(IOV_MAX)
return IOV_MAX; return IOV_MAX;
#elif defined(_SC_IOV_MAX) #elif defined(_SC_IOV_MAX)
static int iovmax = -1; static int iovmax_cached = -1;
if (iovmax == -1) { int iovmax;
iovmax = sysconf(_SC_IOV_MAX);
/* On some embedded devices (arm-linux-uclibc based ip camera), iovmax = uv__load_relaxed(&iovmax_cached);
* sysconf(_SC_IOV_MAX) can not get the correct value. The return if (iovmax != -1)
* value is -1 and the errno is EINPROGRESS. Degrade the value to 1. return iovmax;
*/
if (iovmax == -1) iovmax = 1; /* On some embedded devices (arm-linux-uclibc based ip camera),
} * sysconf(_SC_IOV_MAX) can not get the correct value. The return
* value is -1 and the errno is EINPROGRESS. Degrade the value to 1.
*/
iovmax = sysconf(_SC_IOV_MAX);
if (iovmax == -1)
iovmax = 1;
uv__store_relaxed(&iovmax_cached, iovmax);
return iovmax; return iovmax;
#else #else
return 1024; return 1024;
...@@ -662,7 +666,7 @@ ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) { ...@@ -662,7 +666,7 @@ ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) {
int* end; int* end;
#if defined(__linux__) #if defined(__linux__)
static int no_msg_cmsg_cloexec; static int no_msg_cmsg_cloexec;
if (no_msg_cmsg_cloexec == 0) { if (0 == uv__load_relaxed(&no_msg_cmsg_cloexec)) {
rc = recvmsg(fd, msg, flags | 0x40000000); /* MSG_CMSG_CLOEXEC */ rc = recvmsg(fd, msg, flags | 0x40000000); /* MSG_CMSG_CLOEXEC */
if (rc != -1) if (rc != -1)
return rc; return rc;
...@@ -671,7 +675,7 @@ ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) { ...@@ -671,7 +675,7 @@ ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) {
rc = recvmsg(fd, msg, flags); rc = recvmsg(fd, msg, flags);
if (rc == -1) if (rc == -1)
return UV__ERR(errno); return UV__ERR(errno);
no_msg_cmsg_cloexec = 1; uv__store_relaxed(&no_msg_cmsg_cloexec, 1);
} else { } else {
rc = recvmsg(fd, msg, flags); rc = recvmsg(fd, msg, flags);
} }
...@@ -1142,13 +1146,6 @@ int uv__getpwuid_r(uv_passwd_t* pwd) { ...@@ -1142,13 +1146,6 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
size_t shell_size; size_t shell_size;
long initsize; long initsize;
int r; int r;
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
int (*getpwuid_r)(uid_t, struct passwd*, char*, size_t, struct passwd**);
getpwuid_r = dlsym(RTLD_DEFAULT, "getpwuid_r");
if (getpwuid_r == NULL)
return UV_ENOSYS;
#endif
if (pwd == NULL) if (pwd == NULL)
return UV_EINVAL; return UV_EINVAL;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <stdint.h> #include <stdint.h>
#include <errno.h> #include <errno.h>
#include <dlfcn.h>
#include <mach/mach.h> #include <mach/mach.h>
#include <mach/mach_time.h> #include <mach/mach_time.h>
#include <mach-o/dyld.h> /* _NSGetExecutablePath */ #include <mach-o/dyld.h> /* _NSGetExecutablePath */
...@@ -32,6 +33,10 @@ ...@@ -32,6 +33,10 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <unistd.h> /* sysconf */ #include <unistd.h> /* sysconf */
static uv_once_t once = UV_ONCE_INIT;
static uint64_t (*time_func)(void);
static mach_timebase_info_data_t timebase;
int uv__platform_loop_init(uv_loop_t* loop) { int uv__platform_loop_init(uv_loop_t* loop) {
loop->cf_state = NULL; loop->cf_state = NULL;
...@@ -48,15 +53,19 @@ void uv__platform_loop_delete(uv_loop_t* loop) { ...@@ -48,15 +53,19 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
} }
uint64_t uv__hrtime(uv_clocktype_t type) { static void uv__hrtime_init_once(void) {
static mach_timebase_info_data_t info; if (KERN_SUCCESS != mach_timebase_info(&timebase))
if ((ACCESS_ONCE(uint32_t, info.numer) == 0 ||
ACCESS_ONCE(uint32_t, info.denom) == 0) &&
mach_timebase_info(&info) != KERN_SUCCESS)
abort(); abort();
return mach_absolute_time() * info.numer / info.denom; time_func = (uint64_t (*)(void)) dlsym(RTLD_DEFAULT, "mach_continuous_time");
if (time_func == NULL)
time_func = mach_absolute_time;
}
uint64_t uv__hrtime(uv_clocktype_t type) {
uv_once(&once, uv__hrtime_init_once);
return time_func() * timebase.numer / timebase.denom;
} }
......
...@@ -229,11 +229,7 @@ static ssize_t uv__fs_futime(uv_fs_t* req) { ...@@ -229,11 +229,7 @@ static ssize_t uv__fs_futime(uv_fs_t* req) {
struct timespec ts[2]; struct timespec ts[2];
ts[0] = uv__fs_to_timespec(req->atime); ts[0] = uv__fs_to_timespec(req->atime);
ts[1] = uv__fs_to_timespec(req->mtime); ts[1] = uv__fs_to_timespec(req->mtime);
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
return utimensat(req->file, NULL, ts, 0);
#else
return futimens(req->file, ts); return futimens(req->file, ts);
#endif
#elif defined(__APPLE__) \ #elif defined(__APPLE__) \
|| defined(__DragonFly__) \ || defined(__DragonFly__) \
|| defined(__FreeBSD__) \ || defined(__FreeBSD__) \
...@@ -316,7 +312,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) { ...@@ -316,7 +312,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) {
uv_once(&once, uv__mkostemp_initonce); uv_once(&once, uv__mkostemp_initonce);
#ifdef O_CLOEXEC #ifdef O_CLOEXEC
if (no_cloexec_support == 0 && uv__mkostemp != NULL) { if (uv__load_relaxed(&no_cloexec_support) == 0 && uv__mkostemp != NULL) {
r = uv__mkostemp(path, O_CLOEXEC); r = uv__mkostemp(path, O_CLOEXEC);
if (r >= 0) if (r >= 0)
...@@ -329,7 +325,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) { ...@@ -329,7 +325,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) {
/* We set the static variable so that next calls don't even /* We set the static variable so that next calls don't even
try to use mkostemp. */ try to use mkostemp. */
no_cloexec_support = 1; uv__store_relaxed(&no_cloexec_support, 1);
} }
#endif /* O_CLOEXEC */ #endif /* O_CLOEXEC */
...@@ -460,7 +456,7 @@ static ssize_t uv__fs_read(uv_fs_t* req) { ...@@ -460,7 +456,7 @@ static ssize_t uv__fs_read(uv_fs_t* req) {
result = preadv(req->file, (struct iovec*) req->bufs, req->nbufs, req->off); result = preadv(req->file, (struct iovec*) req->bufs, req->nbufs, req->off);
#else #else
# if defined(__linux__) # if defined(__linux__)
if (no_preadv) retry: if (uv__load_relaxed(&no_preadv)) retry:
# endif # endif
{ {
result = uv__fs_preadv(req->file, req->bufs, req->nbufs, req->off); result = uv__fs_preadv(req->file, req->bufs, req->nbufs, req->off);
...@@ -472,7 +468,7 @@ static ssize_t uv__fs_read(uv_fs_t* req) { ...@@ -472,7 +468,7 @@ static ssize_t uv__fs_read(uv_fs_t* req) {
req->nbufs, req->nbufs,
req->off); req->off);
if (result == -1 && errno == ENOSYS) { if (result == -1 && errno == ENOSYS) {
no_preadv = 1; uv__store_relaxed(&no_preadv, 1);
goto retry; goto retry;
} }
} }
...@@ -1355,7 +1351,7 @@ static int uv__fs_statx(int fd, ...@@ -1355,7 +1351,7 @@ static int uv__fs_statx(int fd,
int mode; int mode;
int rc; int rc;
if (no_statx) if (uv__load_relaxed(&no_statx))
return UV_ENOSYS; return UV_ENOSYS;
dirfd = AT_FDCWD; dirfd = AT_FDCWD;
...@@ -1388,7 +1384,7 @@ static int uv__fs_statx(int fd, ...@@ -1388,7 +1384,7 @@ static int uv__fs_statx(int fd,
* implemented, rc might return 1 with 0 set as the error code in which * implemented, rc might return 1 with 0 set as the error code in which
* case we return ENOSYS. * case we return ENOSYS.
*/ */
no_statx = 1; uv__store_relaxed(&no_statx, 1);
return UV_ENOSYS; return UV_ENOSYS;
} }
......
...@@ -82,7 +82,7 @@ int uv__io_fork(uv_loop_t* loop) { ...@@ -82,7 +82,7 @@ int uv__io_fork(uv_loop_t* loop) {
process. So we sidestep the issue by pretending like we never process. So we sidestep the issue by pretending like we never
started it in the first place. started it in the first place.
*/ */
uv__has_forked_with_cfrunloop = 1; uv__store_relaxed(&uv__has_forked_with_cfrunloop, 1);
uv__free(loop->cf_state); uv__free(loop->cf_state);
loop->cf_state = NULL; loop->cf_state = NULL;
} }
...@@ -487,7 +487,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, ...@@ -487,7 +487,7 @@ int uv_fs_event_start(uv_fs_event_t* handle,
if (!(statbuf.st_mode & S_IFDIR)) if (!(statbuf.st_mode & S_IFDIR))
goto fallback; goto fallback;
if (!uv__has_forked_with_cfrunloop) { if (0 == uv__load_relaxed(&uv__has_forked_with_cfrunloop)) {
int r; int r;
/* The fallback fd is no longer needed */ /* The fallback fd is no longer needed */
uv__close_nocheckstdio(fd); uv__close_nocheckstdio(fd);
...@@ -522,8 +522,9 @@ int uv_fs_event_stop(uv_fs_event_t* handle) { ...@@ -522,8 +522,9 @@ int uv_fs_event_stop(uv_fs_event_t* handle) {
uv__handle_stop(handle); uv__handle_stop(handle);
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 #if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (!uv__has_forked_with_cfrunloop && handle->cf_cb != NULL) if (0 == uv__load_relaxed(&uv__has_forked_with_cfrunloop))
r = uv__fsevents_close(handle); if (handle->cf_cb != NULL)
r = uv__fsevents_close(handle);
#endif #endif
if (handle->event_watcher.fd != -1) { if (handle->event_watcher.fd != -1) {
......
...@@ -85,17 +85,7 @@ static uint64_t read_cpufreq(unsigned int cpunum); ...@@ -85,17 +85,7 @@ static uint64_t read_cpufreq(unsigned int cpunum);
int uv__platform_loop_init(uv_loop_t* loop) { int uv__platform_loop_init(uv_loop_t* loop) {
int fd; int fd;
/* It was reported that EPOLL_CLOEXEC is not defined on Android API < 21,
* a.k.a. Lollipop. Since EPOLL_CLOEXEC is an alias for O_CLOEXEC on all
* architectures, we just use that instead.
*/
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
fd = -1;
errno = ENOSYS;
#else
fd = epoll_create1(O_CLOEXEC); fd = epoll_create1(O_CLOEXEC);
#endif
/* epoll_create1() can fail either because it's not implemented (old kernel) /* epoll_create1() can fail either because it's not implemented (old kernel)
* or because it doesn't understand the O_CLOEXEC flag. * or because it doesn't understand the O_CLOEXEC flag.
...@@ -208,8 +198,10 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { ...@@ -208,8 +198,10 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
* that being the largest value I have seen in the wild (and only once.) * that being the largest value I have seen in the wild (and only once.)
*/ */
static const int max_safe_timeout = 1789569; static const int max_safe_timeout = 1789569;
static int no_epoll_pwait; static int no_epoll_pwait_cached;
static int no_epoll_wait; static int no_epoll_wait_cached;
int no_epoll_pwait;
int no_epoll_wait;
struct epoll_event events[1024]; struct epoll_event events[1024];
struct epoll_event* pe; struct epoll_event* pe;
struct epoll_event e; struct epoll_event e;
...@@ -281,6 +273,15 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { ...@@ -281,6 +273,15 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
count = 48; /* Benchmarks suggest this gives the best throughput. */ count = 48; /* Benchmarks suggest this gives the best throughput. */
real_timeout = timeout; real_timeout = timeout;
/* You could argue there is a dependency between these two but
* ultimately we don't care about their ordering with respect
* to one another. Worst case, we make a few system calls that
* could have been avoided because another thread already knows
* they fail with ENOSYS. Hardly the end of the world.
*/
no_epoll_pwait = uv__load_relaxed(&no_epoll_pwait_cached);
no_epoll_wait = uv__load_relaxed(&no_epoll_wait_cached);
for (;;) { for (;;) {
/* See the comment for max_safe_timeout for an explanation of why /* See the comment for max_safe_timeout for an explanation of why
* this is necessary. Executive summary: kernel bug workaround. * this is necessary. Executive summary: kernel bug workaround.
...@@ -293,25 +294,24 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { ...@@ -293,25 +294,24 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
abort(); abort();
if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) { if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) {
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
nfds = -1;
errno = ENOSYS;
#else
nfds = epoll_pwait(loop->backend_fd, nfds = epoll_pwait(loop->backend_fd,
events, events,
ARRAY_SIZE(events), ARRAY_SIZE(events),
timeout, timeout,
&sigset); &sigset);
#endif if (nfds == -1 && errno == ENOSYS) {
if (nfds == -1 && errno == ENOSYS) uv__store_relaxed(&no_epoll_pwait_cached, 1);
no_epoll_pwait = 1; no_epoll_pwait = 1;
}
} else { } else {
nfds = epoll_wait(loop->backend_fd, nfds = epoll_wait(loop->backend_fd,
events, events,
ARRAY_SIZE(events), ARRAY_SIZE(events),
timeout); timeout);
if (nfds == -1 && errno == ENOSYS) if (nfds == -1 && errno == ENOSYS) {
uv__store_relaxed(&no_epoll_wait_cached, 1);
no_epoll_wait = 1; no_epoll_wait = 1;
}
} }
if (sigmask != 0 && no_epoll_pwait != 0) if (sigmask != 0 && no_epoll_pwait != 0)
...@@ -982,43 +982,51 @@ void uv__set_process_title(const char* title) { ...@@ -982,43 +982,51 @@ void uv__set_process_title(const char* title) {
} }
static uint64_t uv__read_proc_meminfo(const char* what) { static int uv__slurp(const char* filename, char* buf, size_t len) {
uint64_t rc;
ssize_t n; ssize_t n;
char* p;
int fd; int fd;
char buf[4096]; /* Large enough to hold all of /proc/meminfo. */
rc = 0; assert(len > 0);
fd = uv__open_cloexec("/proc/meminfo", O_RDONLY);
fd = uv__open_cloexec(filename, O_RDONLY);
if (fd < 0) if (fd < 0)
return 0; return fd;
do
n = read(fd, buf, len - 1);
while (n == -1 && errno == EINTR);
n = read(fd, buf, sizeof(buf) - 1); if (uv__close_nocheckstdio(fd))
abort();
if (n <= 0) if (n < 0)
goto out; return UV__ERR(errno);
buf[n] = '\0'; buf[n] = '\0';
p = strstr(buf, what);
if (p == NULL) return 0;
goto out; }
p += strlen(what);
if (1 != sscanf(p, "%" PRIu64 " kB", &rc)) static uint64_t uv__read_proc_meminfo(const char* what) {
goto out; uint64_t rc;
char* p;
char buf[4096]; /* Large enough to hold all of /proc/meminfo. */
rc *= 1024; if (uv__slurp("/proc/meminfo", buf, sizeof(buf)))
return 0;
out: p = strstr(buf, what);
if (uv__close_nocheckstdio(fd)) if (p == NULL)
abort(); return 0;
return rc; p += strlen(what);
rc = 0;
sscanf(p, "%" PRIu64 " kB", &rc);
return rc * 1024;
} }
...@@ -1056,28 +1064,13 @@ uint64_t uv_get_total_memory(void) { ...@@ -1056,28 +1064,13 @@ uint64_t uv_get_total_memory(void) {
static uint64_t uv__read_cgroups_uint64(const char* cgroup, const char* param) { static uint64_t uv__read_cgroups_uint64(const char* cgroup, const char* param) {
char filename[256]; char filename[256];
uint64_t rc;
int fd;
ssize_t n;
char buf[32]; /* Large enough to hold an encoded uint64_t. */ char buf[32]; /* Large enough to hold an encoded uint64_t. */
uint64_t rc;
snprintf(filename, 256, "/sys/fs/cgroup/%s/%s", cgroup, param);
rc = 0; rc = 0;
fd = uv__open_cloexec(filename, O_RDONLY); snprintf(filename, sizeof(filename), "/sys/fs/cgroup/%s/%s", cgroup, param);
if (0 == uv__slurp(filename, buf, sizeof(buf)))
if (fd < 0)
return 0;
n = read(fd, buf, sizeof(buf) - 1);
if (n > 0) {
buf[n] = '\0';
sscanf(buf, "%" PRIu64, &rc); sscanf(buf, "%" PRIu64, &rc);
}
if (uv__close_nocheckstdio(fd))
abort();
return rc; return rc;
} }
...@@ -1091,3 +1084,20 @@ uint64_t uv_get_constrained_memory(void) { ...@@ -1091,3 +1084,20 @@ uint64_t uv_get_constrained_memory(void) {
*/ */
return uv__read_cgroups_uint64("memory", "memory.limit_in_bytes"); return uv__read_cgroups_uint64("memory", "memory.limit_in_bytes");
} }
void uv_loadavg(double avg[3]) {
struct sysinfo info;
char buf[128]; /* Large enough to hold all of /proc/loadavg. */
if (0 == uv__slurp("/proc/loadavg", buf, sizeof(buf)))
if (3 == sscanf(buf, "%lf %lf %lf", &avg[0], &avg[1], &avg[2]))
return;
if (sysinfo(&info) < 0)
return;
avg[0] = (double) info.loads[0] / 65536.0;
avg[1] = (double) info.loads[1] / 65536.0;
avg[2] = (double) info.loads[2] / 65536.0;
}
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#pragma linkage(BPX4CTW, OS) #pragma linkage(BPX4CTW, OS)
#pragma linkage(BPX1CTW, OS) #pragma linkage(BPX1CTW, OS)
static int number_of_epolls;
static QUEUE global_epoll_queue; static QUEUE global_epoll_queue;
static uv_mutex_t global_epoll_lock; static uv_mutex_t global_epoll_lock;
static uv_once_t once = UV_ONCE_INIT; static uv_once_t once = UV_ONCE_INIT;
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
*/ */
/* Android versions < 4.1 have a broken pthread_sigmask. */ /* Android versions < 4.1 have a broken pthread_sigmask. */
#include "uv-common.h"
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <signal.h> #include <signal.h>
...@@ -38,13 +40,13 @@ int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset) { ...@@ -38,13 +40,13 @@ int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset) {
static int workaround; static int workaround;
int err; int err;
if (workaround) { if (uv__load_relaxed(&workaround)) {
return sigprocmask(how, set, oset); return sigprocmask(how, set, oset);
} else { } else {
err = pthread_sigmask(how, set, oset); err = pthread_sigmask(how, set, oset);
if (err) { if (err) {
if (err == EINVAL && sigprocmask(how, set, oset) == 0) { if (err == EINVAL && sigprocmask(how, set, oset) == 0) {
workaround = 1; uv__store_relaxed(&workaround, 1);
return 0; return 0;
} else { } else {
return -1; return -1;
......
...@@ -326,16 +326,19 @@ int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb) { ...@@ -326,16 +326,19 @@ int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb) {
int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) { int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
static int single_accept = -1; static int single_accept_cached = -1;
unsigned long flags; unsigned long flags;
int single_accept;
int err; int err;
if (tcp->delayed_error) if (tcp->delayed_error)
return tcp->delayed_error; return tcp->delayed_error;
single_accept = uv__load_relaxed(&single_accept_cached);
if (single_accept == -1) { if (single_accept == -1) {
const char* val = getenv("UV_TCP_SINGLE_ACCEPT"); const char* val = getenv("UV_TCP_SINGLE_ACCEPT");
single_accept = (val != NULL && atoi(val) != 0); /* Off by default. */ single_accept = (val != NULL && atoi(val) != 0); /* Off by default. */
uv__store_relaxed(&single_accept_cached, single_accept);
} }
if (single_accept) if (single_accept)
......
...@@ -709,11 +709,9 @@ int uv_cond_init(uv_cond_t* cond) { ...@@ -709,11 +709,9 @@ int uv_cond_init(uv_cond_t* cond) {
if (err) if (err)
return UV__ERR(err); return UV__ERR(err);
#if !(defined(__ANDROID_API__) && __ANDROID_API__ < 21)
err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
if (err) if (err)
goto error2; goto error2;
#endif
err = pthread_cond_init(cond, &attr); err = pthread_cond_init(cond, &attr);
if (err) if (err)
...@@ -805,16 +803,7 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { ...@@ -805,16 +803,7 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
#endif #endif
ts.tv_sec = timeout / NANOSEC; ts.tv_sec = timeout / NANOSEC;
ts.tv_nsec = timeout % NANOSEC; ts.tv_nsec = timeout % NANOSEC;
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
/*
* The bionic pthread implementation doesn't support CLOCK_MONOTONIC,
* but has this alternative function instead.
*/
r = pthread_cond_timedwait_monotonic_np(cond, mutex, &ts);
#else
r = pthread_cond_timedwait(cond, mutex, &ts); r = pthread_cond_timedwait(cond, mutex, &ts);
#endif /* __ANDROID_API__ */
#endif #endif
......
...@@ -367,7 +367,7 @@ write_queue_drain: ...@@ -367,7 +367,7 @@ write_queue_drain:
return; return;
for (i = 0, q = QUEUE_HEAD(&handle->write_queue); for (i = 0, q = QUEUE_HEAD(&handle->write_queue);
i < pkts && q != &handle->write_queue; i < pkts && q != &handle->write_queue;
++i, q = QUEUE_HEAD(q)) { ++i, q = QUEUE_HEAD(&handle->write_queue)) {
assert(q != NULL); assert(q != NULL);
req = QUEUE_DATA(q, uv_udp_send_t, queue); req = QUEUE_DATA(q, uv_udp_send_t, queue);
assert(req != NULL); assert(req != NULL);
......
...@@ -859,11 +859,11 @@ __attribute__((destructor)) ...@@ -859,11 +859,11 @@ __attribute__((destructor))
void uv_library_shutdown(void) { void uv_library_shutdown(void) {
static int was_shutdown; static int was_shutdown;
if (was_shutdown) if (uv__load_relaxed(&was_shutdown))
return; return;
uv__process_title_cleanup(); uv__process_title_cleanup();
uv__signal_cleanup(); uv__signal_cleanup();
uv__threadpool_cleanup(); uv__threadpool_cleanup();
was_shutdown = 1; uv__store_relaxed(&was_shutdown, 1);
} }
...@@ -60,6 +60,14 @@ extern int snprintf(char*, size_t, const char*, ...); ...@@ -60,6 +60,14 @@ extern int snprintf(char*, size_t, const char*, ...);
#define STATIC_ASSERT(expr) \ #define STATIC_ASSERT(expr) \
void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)]) void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)])
#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#define uv__load_relaxed(p) __atomic_load_n(p, __ATOMIC_RELAXED)
#define uv__store_relaxed(p, v) __atomic_store_n(p, v, __ATOMIC_RELAXED)
#else
#define uv__load_relaxed(p) (*p)
#define uv__store_relaxed(p, v) do *p = v; while (0)
#endif
/* Handle flags. Some flags are specific to Windows or UNIX. */ /* Handle flags. Some flags are specific to Windows or UNIX. */
enum { enum {
/* Used by all handles. */ /* Used by all handles. */
......
...@@ -266,7 +266,7 @@ void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle); ...@@ -266,7 +266,7 @@ void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle);
*/ */
void uv__util_init(void); void uv__util_init(void);
uint64_t uv__hrtime(double scale); uint64_t uv__hrtime(unsigned int scale);
__declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall); __declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall);
int uv__getpwuid_r(uv_passwd_t* pwd); int uv__getpwuid_r(uv_passwd_t* pwd);
int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8); int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8);
......
...@@ -517,6 +517,7 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) { ...@@ -517,6 +517,7 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) {
status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS); status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS);
if (status == TRAP_REQUESTED) { if (status == TRAP_REQUESTED) {
SET_REQ_SUCCESS(req); SET_REQ_SUCCESS(req);
InterlockedExchange(&uv__read_console_status, COMPLETED);
req->u.io.overlapped.InternalHigh = 0; req->u.io.overlapped.InternalHigh = 0;
POST_COMPLETION_FOR_REQ(loop, req); POST_COMPLETION_FOR_REQ(loop, req);
return 0; return 0;
......
...@@ -752,6 +752,9 @@ int uv__udp_set_source_membership6(uv_udp_t* handle, ...@@ -752,6 +752,9 @@ int uv__udp_set_source_membership6(uv_udp_t* handle,
int optname; int optname;
int err; int err;
STATIC_ASSERT(sizeof(mreq.gsr_group) >= sizeof(*multicast_addr));
STATIC_ASSERT(sizeof(mreq.gsr_source) >= sizeof(*source_addr));
if ((handle->flags & UV_HANDLE_BOUND) && !(handle->flags & UV_HANDLE_IPV6)) if ((handle->flags & UV_HANDLE_BOUND) && !(handle->flags & UV_HANDLE_IPV6))
return UV_EINVAL; return UV_EINVAL;
...@@ -774,8 +777,6 @@ int uv__udp_set_source_membership6(uv_udp_t* handle, ...@@ -774,8 +777,6 @@ int uv__udp_set_source_membership6(uv_udp_t* handle,
mreq.gsr_interface = 0; mreq.gsr_interface = 0;
} }
STATIC_ASSERT(sizeof(mreq.gsr_group) >= sizeof(*multicast_addr));
STATIC_ASSERT(sizeof(mreq.gsr_source) >= sizeof(*source_addr));
memcpy(&mreq.gsr_group, multicast_addr, sizeof(*multicast_addr)); memcpy(&mreq.gsr_group, multicast_addr, sizeof(*multicast_addr));
memcpy(&mreq.gsr_source, source_addr, sizeof(*source_addr)); memcpy(&mreq.gsr_source, source_addr, sizeof(*source_addr));
......
...@@ -67,8 +67,8 @@ extern BOOLEAN NTAPI SystemFunction036(PVOID Buffer, ULONG BufferLength); ...@@ -67,8 +67,8 @@ extern BOOLEAN NTAPI SystemFunction036(PVOID Buffer, ULONG BufferLength);
static char *process_title; static char *process_title;
static CRITICAL_SECTION process_title_lock; static CRITICAL_SECTION process_title_lock;
/* Interval (in seconds) of the high-resolution clock. */ /* Frequency of the high-resolution clock. */
static double hrtime_interval_ = 0; static uint64_t hrtime_frequency_ = 0;
/* /*
...@@ -84,9 +84,9 @@ void uv__util_init(void) { ...@@ -84,9 +84,9 @@ void uv__util_init(void) {
* and precompute its reciprocal. * and precompute its reciprocal.
*/ */
if (QueryPerformanceFrequency(&perf_frequency)) { if (QueryPerformanceFrequency(&perf_frequency)) {
hrtime_interval_ = 1.0 / perf_frequency.QuadPart; hrtime_frequency_ = perf_frequency.QuadPart;
} else { } else {
hrtime_interval_= 0; uv_fatal_error(GetLastError(), "QueryPerformanceFrequency");
} }
} }
...@@ -490,23 +490,25 @@ uint64_t uv_hrtime(void) { ...@@ -490,23 +490,25 @@ uint64_t uv_hrtime(void) {
return uv__hrtime(UV__NANOSEC); return uv__hrtime(UV__NANOSEC);
} }
uint64_t uv__hrtime(double scale) { uint64_t uv__hrtime(unsigned int scale) {
LARGE_INTEGER counter; LARGE_INTEGER counter;
double scaled_freq;
double result;
/* If the performance interval is zero, there's no support. */ assert(hrtime_frequency_ != 0);
if (hrtime_interval_ == 0) { assert(scale != 0);
return 0;
}
if (!QueryPerformanceCounter(&counter)) { if (!QueryPerformanceCounter(&counter)) {
return 0; uv_fatal_error(GetLastError(), "QueryPerformanceCounter");
} }
assert(counter.QuadPart != 0);
/* Because we have no guarantee about the order of magnitude of the /* Because we have no guarantee about the order of magnitude of the
* performance counter interval, integer math could cause this computation * performance counter interval, integer math could cause this computation
* to overflow. Therefore we resort to floating point math. * to overflow. Therefore we resort to floating point math.
*/ */
return (uint64_t) ((double) counter.QuadPart * hrtime_interval_ * scale); scaled_freq = (double) hrtime_frequency_ / scale;
result = (double) counter.QuadPart / scaled_freq;
return (uint64_t) result;
} }
......
...@@ -180,6 +180,7 @@ TEST_DECLARE (udp_open_connect) ...@@ -180,6 +180,7 @@ TEST_DECLARE (udp_open_connect)
#ifndef _WIN32 #ifndef _WIN32
TEST_DECLARE (udp_send_unix) TEST_DECLARE (udp_send_unix)
#endif #endif
TEST_DECLARE (udp_sendmmsg_error)
TEST_DECLARE (udp_try_send) TEST_DECLARE (udp_try_send)
TEST_DECLARE (pipe_bind_error_addrinuse) TEST_DECLARE (pipe_bind_error_addrinuse)
TEST_DECLARE (pipe_bind_error_addrnotavail) TEST_DECLARE (pipe_bind_error_addrnotavail)
...@@ -720,6 +721,7 @@ TASK_LIST_START ...@@ -720,6 +721,7 @@ TASK_LIST_START
TEST_ENTRY (udp_multicast_join) TEST_ENTRY (udp_multicast_join)
TEST_ENTRY (udp_multicast_join6) TEST_ENTRY (udp_multicast_join6)
TEST_ENTRY (udp_multicast_ttl) TEST_ENTRY (udp_multicast_ttl)
TEST_ENTRY (udp_sendmmsg_error)
TEST_ENTRY (udp_try_send) TEST_ENTRY (udp_try_send)
TEST_ENTRY (udp_open) TEST_ENTRY (udp_open)
...@@ -1010,7 +1012,7 @@ TASK_LIST_START ...@@ -1010,7 +1012,7 @@ TASK_LIST_START
TEST_ENTRY (fs_event_close_with_pending_event) TEST_ENTRY (fs_event_close_with_pending_event)
TEST_ENTRY (fs_event_close_in_callback) TEST_ENTRY (fs_event_close_in_callback)
TEST_ENTRY (fs_event_start_and_close) TEST_ENTRY (fs_event_start_and_close)
TEST_ENTRY (fs_event_error_reporting) TEST_ENTRY_CUSTOM (fs_event_error_reporting, 0, 0, 60000)
TEST_ENTRY (fs_event_getpath) TEST_ENTRY (fs_event_getpath)
TEST_ENTRY (fs_scandir_empty_dir) TEST_ENTRY (fs_scandir_empty_dir)
TEST_ENTRY (fs_scandir_non_existent_dir) TEST_ENTRY (fs_scandir_non_existent_dir)
......
...@@ -199,6 +199,11 @@ TEST_IMPL(signal_multiple_loops) { ...@@ -199,6 +199,11 @@ TEST_IMPL(signal_multiple_loops) {
though it is supposed to be blocking. Also the test hangs during though it is supposed to be blocking. Also the test hangs during
thread setup occasionally. */ thread setup occasionally. */
RETURN_SKIP("FIXME: This test needs more investigation on Cygwin"); RETURN_SKIP("FIXME: This test needs more investigation on Cygwin");
#endif
/* TODO(gengjiawen): Fix test on QEMU. */
#if defined(__QEMU__)
// See https://github.com/libuv/libuv/issues/2859
RETURN_SKIP("QEMU's signal emulation code is notoriously tricky");
#endif #endif
uv_thread_t loop_creating_threads[NUM_LOOP_CREATING_THREADS]; uv_thread_t loop_creating_threads[NUM_LOOP_CREATING_THREADS];
uv_thread_t signal_handling_threads[NUM_SIGNAL_HANDLING_THREADS]; uv_thread_t signal_handling_threads[NUM_SIGNAL_HANDLING_THREADS];
......
/* Copyright libuv project and contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
#include "task.h"
#include <stdio.h>
#include <stdlib.h>
#define DATAGRAMS 6
static uv_udp_t client;
static uv_udp_send_t req[DATAGRAMS];
static int send_cb_called;
static int close_cb_called;
static void close_cb(uv_handle_t* handle) {
ASSERT_PTR_EQ(handle, &client);
ASSERT(uv_is_closing(handle));
close_cb_called++;
}
static void send_cb(uv_udp_send_t* req, int status) {
if (status != 0)
ASSERT_EQ(status, UV_ECONNREFUSED);
if (++send_cb_called == DATAGRAMS)
uv_close((uv_handle_t*)&client, close_cb);
}
TEST_IMPL(udp_sendmmsg_error) {
struct sockaddr_in addr;
uv_buf_t buf;
int i;
ASSERT_EQ(0, uv_udp_init(uv_default_loop(), &client));
ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
ASSERT_EQ(0, uv_udp_connect(&client, (const struct sockaddr*)&addr));
buf = uv_buf_init("TEST", 4);
for (i = 0; i < DATAGRAMS; ++i)
ASSERT_EQ(0, uv_udp_send(&req[i], &client, &buf, 1, NULL, send_cb));
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT_EQ(1, close_cb_called);
ASSERT_EQ(DATAGRAMS, send_cb_called);
ASSERT_EQ(0, client.send_queue_size);
MAKE_VALGRIND_HAPPY();
return 0;
}
...@@ -80,7 +80,7 @@ function get_netstring() ...@@ -80,7 +80,7 @@ function get_netstring()
function get_libuv() function get_libuv()
{ {
GIT_REPO="https://github.com/libuv/libuv.git" GIT_REPO="https://github.com/libuv/libuv.git"
GIT_TAG="v1.38.0" GIT_TAG="v1.38.1"
DEST="deps/libuv/libuv" DEST="deps/libuv/libuv"
get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}" get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}"
...@@ -126,7 +126,7 @@ function get_abseil_cpp() ...@@ -126,7 +126,7 @@ function get_abseil_cpp()
function get_catch() function get_catch()
{ {
GIT_REPO="https://github.com/catchorg/Catch2.git" GIT_REPO="https://github.com/catchorg/Catch2.git"
GIT_TAG="v2.12.3" GIT_TAG="v2.12.4"
DEST="deps/catch" DEST="deps/catch"
get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}" get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}"
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论