diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-10-07 15:49:08 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-10-07 15:49:08 +0000 |
commit | 6e4a5b7ec90b12f50ed6af6bb3bbd214d4aaaa35 (patch) | |
tree | 7bd4c53a7df4f129e96c095353cc73944f6f5971 | |
parent | a91cf35875165a1e7b20cb79925892e304c7b911 (diff) | |
parent | 1c145de846055758e1cf1a78a53d9b06ecf4e697 (diff) | |
download | ydb-6e4a5b7ec90b12f50ed6af6bb3bbd214d4aaaa35.tar.gz |
Merge branch 'rightlib' into mergelibs-241007-1548
197 files changed, 6898 insertions, 8679 deletions
diff --git a/build/conf/compilers/msvc_compiler.conf b/build/conf/compilers/msvc_compiler.conf index c6cf77de2f..9c4888497f 100644 --- a/build/conf/compilers/msvc_compiler.conf +++ b/build/conf/compilers/msvc_compiler.conf @@ -1,7 +1,6 @@ _STD_CXX=/std:$_STD_CXX_VERSION C_COMPILER=${_WINE_C_PREFIX} ${C_COMPILER_UNQUOTED} -C_COMPILER_OLD=${_WINE_C_PREFIX} ${quo:C_COMPILER_OLD_UNQUOTED} CXX_COMPILER=${_WINE_CXX_PREFIX} ${CXX_COMPILER_UNQUOTED} CXX_COMPILER_OLD=${_WINE_CXX_PREFIX} ${quo:CXX_COMPILER_OLD_UNQUOTED} MASM_COMPILER=${_WINE_MASM_PREFIX} ${MASM_COMPILER_UNQUOTED} diff --git a/build/conf/go.conf b/build/conf/go.conf index de2f207cb0..88f7f28b8e 100644 --- a/build/conf/go.conf +++ b/build/conf/go.conf @@ -216,7 +216,7 @@ macro _GO_COMPILE_CGO1(NAME, FLAGS[], FILES...) { # tag:go-specific macro _GO_COMPILE_CGO2(NAME, C_FILES[], S_FILES[], OBJ_FILES[], FILES...) { - .CMD=${hide:_CGO_FAKEID} $C_COMPILER_OLD $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} $CGO_CFLAGS_VALUE ${input;tobindir:"_cgo_main.c"} -c -o ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_main.c"} && $C_COMPILER $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} -o ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_"} $LDFLAGS $LDFLAGS_GLOBAL $CGO2_LDFLAGS_VALUE ${input;hide:"_cgo_export.h"} ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_main.c"} ${input;suf=${OBJECT_SUF}:"_cgo_export.c"} ${input;nopath;noext;suf=.cgo2.c${OBJECT_SUF}:FILES} ${input;suf=${OBJECT_SUF}:C_FILES} ${input;suf=.o:S_FILES} ${input:OBJ_FILES} $CGO_LDFLAGS_VALUE && ${GO_TOOLS_ROOT}/pkg/tool/$_GO_TC_PATH/cgo -dynpackage $NAME -dynimport ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_"} -dynout ${output:"_cgo_import.go"} -dynlinker $GO_CGO2_FLAGS_VALUE $GO_TOOLCHAIN_ENV ${kv;hide:"p go"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} + .CMD=${hide:_CGO_FAKEID} $C_COMPILER $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} $CGO_CFLAGS_VALUE ${input;tobindir:"_cgo_main.c"} -c -o ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_main.c"} && $C_COMPILER $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} -o ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_"} $LDFLAGS $LDFLAGS_GLOBAL $CGO2_LDFLAGS_VALUE ${input;hide:"_cgo_export.h"} ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_main.c"} ${input;suf=${OBJECT_SUF}:"_cgo_export.c"} ${input;nopath;noext;suf=.cgo2.c${OBJECT_SUF}:FILES} ${input;suf=${OBJECT_SUF}:C_FILES} ${input;suf=.o:S_FILES} ${input:OBJ_FILES} $CGO_LDFLAGS_VALUE && ${GO_TOOLS_ROOT}/pkg/tool/$_GO_TC_PATH/cgo -dynpackage $NAME -dynimport ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_"} -dynout ${output:"_cgo_import.go"} -dynlinker $GO_CGO2_FLAGS_VALUE $GO_TOOLCHAIN_ENV ${kv;hide:"p go"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} _USE_LINKER() } diff --git a/build/conf/linkers/msvc_linker.conf b/build/conf/linkers/msvc_linker.conf index 7bba3060ad..2e9bfe7081 100644 --- a/build/conf/linkers/msvc_linker.conf +++ b/build/conf/linkers/msvc_linker.conf @@ -51,6 +51,13 @@ when ($IDE_MSVS != "yes") { /LIBPATH:\""${_MSVC_TC_VC_ROOT}/lib/$_MSVC_ARCH"\" } +when ($WINDOWS_MANIFEST != "") { + _FLAGS_MANIFEST=/MANIFEST:EMBED /MANIFESTINPUT:${input:WINDOWS_MANIFEST} +} +otherwise { + _FLAGS_MANIFEST= +} + _FLAGS_COMMON =/NOLOGO /ERRORREPORT:PROMPT /SUBSYSTEM:CONSOLE /TLBID:1 $MSVC_DYNAMICBASE /NXCOMPAT _FLAGS_COMMON+=$_FLAGS_IGNORE _FLAGS_COMMON+=$_FLAGS_MACHINE @@ -100,7 +107,7 @@ LINK_STDLIBS=\ ws2_32.lib LDFLAGS_GLOBAL= -LDFLAGS= +LDFLAGS=$_FLAGS_MANIFEST OBJADDE= OBJADDE_LIB= OBJADDE_LIB_GLOBAL= diff --git a/build/export_generators/ide-gradle/build.gradle.kts.jinja b/build/export_generators/ide-gradle/build.gradle.kts.jinja index ee68d1729f..3f7755b94e 100644 --- a/build/export_generators/ide-gradle/build.gradle.kts.jinja +++ b/build/export_generators/ide-gradle/build.gradle.kts.jinja @@ -44,7 +44,7 @@ plugins { {%- endif %} } {# language level #} -{%- if target.required_jdk != "" %} +{%- if target.required_jdk is defined and target.required_jdk|length %} java { toolchain { languageVersion = JavaLanguageVersion.of("{{ target.required_jdk }}") @@ -55,6 +55,11 @@ java { allOpen { annotation("org.springframework.stereotype.Component") + annotation("org.springframework.transaction.annotation.Transactional") + annotation("org.springframework.scheduling.annotation.Async") + annotation("org.springframework.cache.annotation.Cacheable") + annotation("org.springframework.boot.test.context.SpringBootTest") + annotation("org.springframework.validation.annotation.Validated") } {% endif -%} {%- if with_kotlin %} diff --git a/build/external_resources/ymake/public.resources.json b/build/external_resources/ymake/public.resources.json index 9491a51b6b..a3147f2414 100644 --- a/build/external_resources/ymake/public.resources.json +++ b/build/external_resources/ymake/public.resources.json @@ -1,19 +1,19 @@ { "by_platform": { "darwin": { - "uri": "sbr:7167514017" + "uri": "sbr:7211385890" }, "darwin-arm64": { - "uri": "sbr:7167513539" + "uri": "sbr:7211384971" }, "linux": { - "uri": "sbr:7167514830" + "uri": "sbr:7211387031" }, "linux-aarch64": { - "uri": "sbr:7167513152" + "uri": "sbr:7211384106" }, "win32-clang-cl": { - "uri": "sbr:7167514469" + "uri": "sbr:7211386552" } } } diff --git a/build/external_resources/ymake/resources.json b/build/external_resources/ymake/resources.json index 5480381f38..a78ff39f53 100644 --- a/build/external_resources/ymake/resources.json +++ b/build/external_resources/ymake/resources.json @@ -1,19 +1,19 @@ { "by_platform": { "darwin": { - "uri": "sbr:7167510579" + "uri": "sbr:7211379592" }, "darwin-arm64": { - "uri": "sbr:7167510004" + "uri": "sbr:7211379140" }, "linux": { - "uri": "sbr:7167511734" + "uri": "sbr:7211380545" }, "linux-aarch64": { - "uri": "sbr:7167509437" + "uri": "sbr:7211378513" }, "win32-clang-cl": { - "uri": "sbr:7167511239" + "uri": "sbr:7211379980" } } } diff --git a/build/mapping.conf.json b/build/mapping.conf.json index 5242a8d948..33eb41b162 100644 --- a/build/mapping.conf.json +++ b/build/mapping.conf.json @@ -407,6 +407,8 @@ "7120353733": "https://devtools-registry.s3.yandex.net/7120353733", "7203766556": "https://devtools-registry.s3.yandex.net/7203766556", "7203793573": "https://devtools-registry.s3.yandex.net/7203793573", + "7214825617": "https://devtools-registry.s3.yandex.net/7214825617", + "7214836038": "https://devtools-registry.s3.yandex.net/7214836038", "5486731632": "https://devtools-registry.s3.yandex.net/5486731632", "5514350352": "https://devtools-registry.s3.yandex.net/5514350352", "5514360398": "https://devtools-registry.s3.yandex.net/5514360398", @@ -562,6 +564,7 @@ "7129654082": "https://devtools-registry.s3.yandex.net/7129654082", "7157619813": "https://devtools-registry.s3.yandex.net/7157619813", "7167514017": "https://devtools-registry.s3.yandex.net/7167514017", + "7211385890": "https://devtools-registry.s3.yandex.net/7211385890", "5766171800": "https://devtools-registry.s3.yandex.net/5766171800", "5805430761": "https://devtools-registry.s3.yandex.net/5805430761", "5829025456": "https://devtools-registry.s3.yandex.net/5829025456", @@ -604,6 +607,7 @@ "7129653224": "https://devtools-registry.s3.yandex.net/7129653224", "7157617132": "https://devtools-registry.s3.yandex.net/7157617132", "7167513539": "https://devtools-registry.s3.yandex.net/7167513539", + "7211384971": "https://devtools-registry.s3.yandex.net/7211384971", "5766173070": "https://devtools-registry.s3.yandex.net/5766173070", "5805432830": "https://devtools-registry.s3.yandex.net/5805432830", "5829031598": "https://devtools-registry.s3.yandex.net/5829031598", @@ -646,6 +650,7 @@ "7129655749": "https://devtools-registry.s3.yandex.net/7129655749", "7157625186": "https://devtools-registry.s3.yandex.net/7157625186", "7167514830": "https://devtools-registry.s3.yandex.net/7167514830", + "7211387031": "https://devtools-registry.s3.yandex.net/7211387031", "5766171341": "https://devtools-registry.s3.yandex.net/5766171341", "5805430188": "https://devtools-registry.s3.yandex.net/5805430188", "5829023352": "https://devtools-registry.s3.yandex.net/5829023352", @@ -688,6 +693,7 @@ "7129652122": "https://devtools-registry.s3.yandex.net/7129652122", "7157614512": "https://devtools-registry.s3.yandex.net/7157614512", "7167513152": "https://devtools-registry.s3.yandex.net/7167513152", + "7211384106": "https://devtools-registry.s3.yandex.net/7211384106", "5766172695": "https://devtools-registry.s3.yandex.net/5766172695", "5805432230": "https://devtools-registry.s3.yandex.net/5805432230", "5829029743": "https://devtools-registry.s3.yandex.net/5829029743", @@ -730,6 +736,7 @@ "7129654809": "https://devtools-registry.s3.yandex.net/7129654809", "7157622599": "https://devtools-registry.s3.yandex.net/7157622599", "7167514469": "https://devtools-registry.s3.yandex.net/7167514469", + "7211386552": "https://devtools-registry.s3.yandex.net/7211386552", "4307890075": "https://devtools-registry.s3.yandex.net/4307890075", "5517245192": "https://devtools-registry.s3.yandex.net/5517245192", "4307901240": "https://devtools-registry.s3.yandex.net/4307901240", @@ -1321,6 +1328,8 @@ "7120353733": "devtools/ya/test/programs/test_tool/bin/test_tool for linux", "7203766556": "devtools/ya/test/programs/test_tool/bin/test_tool for linux", "7203793573": "devtools/ya/test/programs/test_tool/bin/test_tool for linux", + "7214825617": "devtools/ya/test/programs/test_tool/bin/test_tool for linux", + "7214836038": "devtools/ya/test/programs/test_tool/bin/test_tool for linux", "5486731632": "devtools/ya/test/programs/test_tool/bin3/test_tool3 for linux", "5514350352": "devtools/ya/test/programs/test_tool/bin3/test_tool3 for linux", "5514360398": "devtools/ya/test/programs/test_tool/bin3/test_tool3 for linux", @@ -1476,6 +1485,7 @@ "7129654082": "devtools/ymake/bin/ymake for darwin", "7157619813": "devtools/ymake/bin/ymake for darwin", "7167514017": "devtools/ymake/bin/ymake for darwin", + "7211385890": "devtools/ymake/bin/ymake for darwin", "5766171800": "devtools/ymake/bin/ymake for darwin-arm64", "5805430761": "devtools/ymake/bin/ymake for darwin-arm64", "5829025456": "devtools/ymake/bin/ymake for darwin-arm64", @@ -1518,6 +1528,7 @@ "7129653224": "devtools/ymake/bin/ymake for darwin-arm64", "7157617132": "devtools/ymake/bin/ymake for darwin-arm64", "7167513539": "devtools/ymake/bin/ymake for darwin-arm64", + "7211384971": "devtools/ymake/bin/ymake for darwin-arm64", "5766173070": "devtools/ymake/bin/ymake for linux", "5805432830": "devtools/ymake/bin/ymake for linux", "5829031598": "devtools/ymake/bin/ymake for linux", @@ -1560,6 +1571,7 @@ "7129655749": "devtools/ymake/bin/ymake for linux", "7157625186": "devtools/ymake/bin/ymake for linux", "7167514830": "devtools/ymake/bin/ymake for linux", + "7211387031": "devtools/ymake/bin/ymake for linux", "5766171341": "devtools/ymake/bin/ymake for linux-aarch64", "5805430188": "devtools/ymake/bin/ymake for linux-aarch64", "5829023352": "devtools/ymake/bin/ymake for linux-aarch64", @@ -1602,6 +1614,7 @@ "7129652122": "devtools/ymake/bin/ymake for linux-aarch64", "7157614512": "devtools/ymake/bin/ymake for linux-aarch64", "7167513152": "devtools/ymake/bin/ymake for linux-aarch64", + "7211384106": "devtools/ymake/bin/ymake for linux-aarch64", "5766172695": "devtools/ymake/bin/ymake for win32-clang-cl", "5805432230": "devtools/ymake/bin/ymake for win32-clang-cl", "5829029743": "devtools/ymake/bin/ymake for win32-clang-cl", @@ -1644,6 +1657,7 @@ "7129654809": "devtools/ymake/bin/ymake for win32-clang-cl", "7157622599": "devtools/ymake/bin/ymake for win32-clang-cl", "7167514469": "devtools/ymake/bin/ymake for win32-clang-cl", + "7211386552": "devtools/ymake/bin/ymake for win32-clang-cl", "4307890075": "flake8_linter for linux", "5517245192": "flake8_linter for linux", "4307901240": "flake8_linter for linux-aarch64", diff --git a/build/platform/python/ymake_python3/ya.make b/build/platform/python/ymake_python3/ya.make index a9f77f93ae..86b39d3ebc 100644 --- a/build/platform/python/ymake_python3/ya.make +++ b/build/platform/python/ymake_python3/ya.make @@ -1,7 +1,7 @@ RESOURCES_LIBRARY() TOOLCHAIN(python3) -VERSION(3.12.5) +VERSION(3.12.6) NO_YMAKE_PYTHON3() SET(RESOURCES_LIBRARY_LINK $TOUCH_UNIT) diff --git a/build/platform/test_tool/host.ya.make.inc b/build/platform/test_tool/host.ya.make.inc index d06b61fec2..5b321b291d 100644 --- a/build/platform/test_tool/host.ya.make.inc +++ b/build/platform/test_tool/host.ya.make.inc @@ -1,12 +1,12 @@ IF (HOST_OS_DARWIN AND HOST_ARCH_X86_64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203790694) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214835716) ELSEIF (HOST_OS_DARWIN AND HOST_ARCH_ARM64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203789329) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214835475) ELSEIF (HOST_OS_LINUX AND HOST_ARCH_X86_64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203793573) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214836038) ELSEIF (HOST_OS_LINUX AND HOST_ARCH_AARCH64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203788076) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214835148) ELSEIF (HOST_OS_WINDOWS AND HOST_ARCH_X86_64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203792081) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214835884) ENDIF() diff --git a/build/platform/test_tool/host_os.ya.make.inc b/build/platform/test_tool/host_os.ya.make.inc index 03ef6b09e4..48c2363588 100644 --- a/build/platform/test_tool/host_os.ya.make.inc +++ b/build/platform/test_tool/host_os.ya.make.inc @@ -1,12 +1,12 @@ IF (HOST_OS_DARWIN AND HOST_ARCH_X86_64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203764126) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214824944) ELSEIF (HOST_OS_DARWIN AND HOST_ARCH_ARM64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203762905) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214824429) ELSEIF (HOST_OS_LINUX AND HOST_ARCH_X86_64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203766556) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214825617) ELSEIF (HOST_OS_LINUX AND HOST_ARCH_AARCH64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203761608) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214823934) ELSEIF (HOST_OS_WINDOWS AND HOST_ARCH_X86_64) - DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7203765438) + DECLARE_EXTERNAL_RESOURCE(TEST_TOOL_HOST sbr:7214825382) ENDIF() diff --git a/build/sysincl/misc-win.yml b/build/sysincl/misc-win.yml index 4410b37521..b643cd734e 100644 --- a/build/sysincl/misc-win.yml +++ b/build/sysincl/misc-win.yml @@ -99,11 +99,9 @@ - fcntl.h: contrib/tools/m4/lib/platform/win64/fcntl.h - langinfo.h: contrib/tools/m4/lib/platform/win64/langinfo.h - locale.h: contrib/tools/m4/lib/platform/win64/locale.h - - math.h: contrib/tools/m4/lib/platform/win64/math.h - sched.h: contrib/tools/m4/lib/platform/win64/sched.h - signal.h: contrib/tools/m4/lib/platform/win64/signal.h - spawn.h: contrib/tools/m4/lib/platform/win64/spawn.h - - stdbool.h: contrib/tools/m4/lib/platform/win64/stdbool.h - sys/stat.h: contrib/tools/m4/lib/platform/win64/sys/stat.h - sys/time.h: contrib/tools/m4/lib/platform/win64/sys/time.h - sys/wait.h: contrib/tools/m4/lib/platform/win64/sys/wait.h diff --git a/build/sysincl/misc.yml b/build/sysincl/misc.yml index e79e373ab6..19eef55002 100644 --- a/build/sysincl/misc.yml +++ b/build/sysincl/misc.yml @@ -59,8 +59,7 @@ - source_filter: "^contrib/tools/m4/" includes: - error.h: contrib/tools/m4/lib/error.h - - fcntl.h: contrib/tools/m4/lib/platform/posix/fcntl.h - - getopt.h: contrib/tools/m4/lib/platform/posix/getopt.h + - fcntl.h: contrib/tools/m4/lib/fcntl.h - obstack.h: contrib/tools/m4/lib/obstack.h - regex.h: contrib/tools/m4/lib/regex.h - system.h diff --git a/build/sysincl/nvidia.yml b/build/sysincl/nvidia.yml index d65b6806b6..75e0474388 100644 --- a/build/sysincl/nvidia.yml +++ b/build/sysincl/nvidia.yml @@ -57,6 +57,7 @@ - nvperf_host.h - nvperf_target.h - nvrtc.h + - nvtx3/nvToolsExt.h - surface_types.h - texture_types.h - vector_types.h @@ -67,3 +68,7 @@ includes: - NvInfer.h - NvInferPlugin.h + +- source_filter: "^contrib/libs/nvidia/nccl/.*" + includes: + - nvtx3/nvToolsExt.h: "contrib/libs/nvidia/nccl/src/include/nvtx3/nvToolsExt.h" diff --git a/build/sysincl/unsorted.yml b/build/sysincl/unsorted.yml index 64df9c2f1c..dcac806fa6 100644 --- a/build/sysincl/unsorted.yml +++ b/build/sysincl/unsorted.yml @@ -115,7 +115,6 @@ - pth.h - rtl.h - shlib-compat.h - - sigsegv.h - socket.h - socketshr.h - socklib.h diff --git a/build/ymake.core.conf b/build/ymake.core.conf index 73550a1a1d..6fcb0e14f6 100644 --- a/build/ymake.core.conf +++ b/build/ymake.core.conf @@ -3059,7 +3059,8 @@ macro _SRC("s79", SRC, SRCFLAGS...) { # tag:src-processing macro _SRC("mm", SRC, SRCFLAGS...) { - .CMD=$C_COMPILER_OLD $C_FLAGS_PLATFORM -x objective-c++ -fobjc-arc -fobjc-abi-version=2 -c -o ${output:SRC.o} ${input:SRC} $CXXFLAGS ${pre=-I:_C__INCLUDE} ${SRCFLAGS} ${hide;kv:"p CC"} ${hide;kv:"pc light-green"} $TOOLCHAIN_ENV + .CMD=$C_COMPILER $C_FLAGS_PLATFORM -x objective-c++ -fobjc-arc -fobjc-abi-version=2 -c -o ${output;suf=.o:SRC} ${input:SRC} $CXXFLAGS ${pre=-I:_C__INCLUDE} ${SRCFLAGS} ${hide;kv:"p CC"} ${hide;kv:"pc light-green"} $TOOLCHAIN_ENV + .STRUCT_CMD=yes } # tag:src-processing @@ -5696,19 +5697,20 @@ when (!$TENSORRT_VERSION) { ANDROID_APK_TEST_ACTIVITY_VALUE=com.yandex.test.unittests/.RunTestsActivity # tag:windows-specific -WINDOWS_MANIFEST= +WINDOWS_MANIFEST=${ARCADIA_ROOT}/build/long-path.manifest macro WINDOWS_MANIFEST(Manifest) { SET(WINDOWS_MANIFEST $Manifest) } +# tag:deprecated # https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation#enable-long-paths-in-windows-10-version-1607-and-later macro WINDOWS_LONG_PATH_MANIFEST() { - SET(WINDOWS_MANIFEST build/long-path.manifest) + ENABLE(UNUSED_MACRO) } # tag:windows-specific -when ($MSVC == "yes" && $WINDOWS_MANIFEST) { - LDFLAGS+=/MANIFEST:EMBED /MANIFESTINPUT:${input:WINDOWS_MANIFEST} +macro DISABLE_WINDOWS_MANIFEST() { + SET(WINDOWS_MANIFEST) } # tag:cpp-specific diff --git a/build/ymake_conf.py b/build/ymake_conf.py index 238ef5172f..8ed86d8cde 100755 --- a/build/ymake_conf.py +++ b/build/ymake_conf.py @@ -1600,8 +1600,6 @@ class GnuCompiler(Compiler): super(GnuCompiler, self).print_compiler() emit('C_COMPILER', '"{}"'.format(self.tc.c_compiler)) - emit('C_COMPILER_OLD_UNQUOTED', self.tc.c_compiler) - emit('C_COMPILER_OLD', '${quo:C_COMPILER_OLD_UNQUOTED}') emit('OPTIMIZE', self.optimize) emit('WERROR_MODE', self.tc.werror_mode) emit('_C_FLAGS', self.c_flags) @@ -2126,7 +2124,6 @@ class MSVCCompiler(MSVC, Compiler): emit('CXX_COMPILER_UNQUOTED', '"{}"'.format(self.tc.cxx_compiler)) emit('CXX_COMPILER_OLD_UNQUOTED', self.tc.cxx_compiler) emit('C_COMPILER_UNQUOTED', '"{}"'.format(self.tc.c_compiler)) - emit('C_COMPILER_OLD_UNQUOTED', self.tc.c_compiler) emit('MASM_COMPILER_UNQUOTED', '"{}"'.format(self.tc.masm_compiler)) emit('MASM_COMPILER_OLD_UNQUOTED', self.tc.masm_compiler) append('C_DEFINES', defines) diff --git a/contrib/libs/croaring/README.md b/contrib/libs/croaring/README.md index f582d31154..eb5ee92752 100644 --- a/contrib/libs/croaring/README.md +++ b/contrib/libs/croaring/README.md @@ -410,10 +410,17 @@ int main() { // we can write a bitmap to a pointer and recover it later uint32_t expectedsize = roaring_bitmap_portable_size_in_bytes(r1); char *serializedbytes = malloc(expectedsize); + // When serializing data to a file, we recommend that you also use + // checksums so that, at deserialization, you can be confident + // that you are recovering the correct data. roaring_bitmap_portable_serialize(r1, serializedbytes); // Note: it is expected that the input follows the specification // https://github.com/RoaringBitmap/RoaringFormatSpec // otherwise the result may be unusable. + // The 'roaring_bitmap_portable_deserialize_safe' function will not read + // beyond expectedsize bytes. + // We recommend you further use checksums to make sure that the input is from + // serialized data. roaring_bitmap_t *t = roaring_bitmap_portable_deserialize_safe(serializedbytes, expectedsize); if(t == NULL) { return EXIT_FAILURE; } const char *reason = NULL; @@ -428,7 +435,11 @@ int main() { roaring_bitmap_portable_deserialize_size(serializedbytes, expectedsize); assert(sizeofbitmap == expectedsize); // sizeofbitmap would be zero if no bitmap were found - // we can also read the bitmap "safely" by specifying a byte size limit: + // We can also read the bitmap "safely" by specifying a byte size limit. + // The 'roaring_bitmap_portable_deserialize_safe' function will not read + // beyond expectedsize bytes. + // We recommend you further use checksums to make sure that the input is from + // serialized data. t = roaring_bitmap_portable_deserialize_safe(serializedbytes, expectedsize); if(t == NULL) { printf("Problem during deserialization.\n"); @@ -500,6 +511,8 @@ We also support efficient 64-bit compressed bitmaps in C: roaring64_bitmap_free(r2); ``` +The API is similar to the conventional 32-bit bitmaps. Please see +the header file `roaring64.h` (compare with `roaring.h`). # Conventional bitsets (C) diff --git a/contrib/libs/croaring/include/roaring/roaring.h b/contrib/libs/croaring/include/roaring/roaring.h index 295bc3cb33..4256ad0ca5 100644 --- a/contrib/libs/croaring/include/roaring/roaring.h +++ b/contrib/libs/croaring/include/roaring/roaring.h @@ -552,6 +552,10 @@ size_t roaring_bitmap_shrink_to_fit(roaring_bitmap_t *r); * This function is endian-sensitive. If you have a big-endian system (e.g., a * mainframe IBM s390x), the data format is going to be big-endian and not * compatible with little-endian systems. + * + * When serializing data to a file, we recommend that you also use + * checksums so that, at deserialization, you can be confident + * that you are recovering the correct data. */ size_t roaring_bitmap_serialize(const roaring_bitmap_t *r, char *buf); @@ -615,7 +619,10 @@ roaring_bitmap_t *roaring_bitmap_portable_deserialize(const char *buf); * https://github.com/RoaringBitmap/RoaringFormatSpec * * The function itself is safe in the sense that it will not cause buffer - * overflows. However, for correct operations, it is assumed that the bitmap + * overflows: it will not read beyond the scope of the provided buffer + * (buf,maxbytes). + * + * However, for correct operations, it is assumed that the bitmap * read was once serialized from a valid bitmap (i.e., it follows the format * specification). If you provided an incorrect input (garbage), then the bitmap * read may not be in a valid state and following operations may not lead to @@ -625,8 +632,10 @@ roaring_bitmap_t *roaring_bitmap_portable_deserialize(const char *buf); * but not for random inputs. * * You may use roaring_bitmap_internal_validate to check the validity of the - * bitmap prior to using it. You may also use other strategies to check for - * corrupted inputs (e.g., checksums). + * bitmap prior to using it. + * + * We recommend that you use checksums to check that serialized data corresponds + * to a serialized bitmap. * * This function is endian-sensitive. If you have a big-endian system (e.g., a * mainframe IBM s390x), the data format is going to be big-endian and not @@ -688,6 +697,10 @@ size_t roaring_bitmap_portable_size_in_bytes(const roaring_bitmap_t *r); * This function is endian-sensitive. If you have a big-endian system (e.g., a * mainframe IBM s390x), the data format is going to be big-endian and not * compatible with little-endian systems. + * + * When serializing data to a file, we recommend that you also use + * checksums so that, at deserialization, you can be confident + * that you are recovering the correct data. */ size_t roaring_bitmap_portable_serialize(const roaring_bitmap_t *r, char *buf); @@ -722,6 +735,10 @@ size_t roaring_bitmap_frozen_size_in_bytes(const roaring_bitmap_t *r); * This function is endian-sensitive. If you have a big-endian system (e.g., a * mainframe IBM s390x), the data format is going to be big-endian and not * compatible with little-endian systems. + * + * When serializing data to a file, we recommend that you also use + * checksums so that, at deserialization, you can be confident + * that you are recovering the correct data. */ void roaring_bitmap_frozen_serialize(const roaring_bitmap_t *r, char *buf); diff --git a/contrib/libs/croaring/include/roaring/roaring64.h b/contrib/libs/croaring/include/roaring/roaring64.h index fd89feb5e0..c1f574d605 100644 --- a/contrib/libs/croaring/include/roaring/roaring64.h +++ b/contrib/libs/croaring/include/roaring/roaring64.h @@ -1,13 +1,13 @@ #ifndef ROARING64_H #define ROARING64_H -#include <roaring.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <roaring/memory.h> #include <roaring/portability.h> +#include <roaring/roaring.h> #include <roaring/roaring_types.h> #ifdef __cplusplus @@ -511,6 +511,10 @@ size_t roaring64_bitmap_portable_size_in_bytes(const roaring64_bitmap_t *r); * This function is endian-sensitive. If you have a big-endian system (e.g., a * mainframe IBM s390x), the data format is going to be big-endian and not * compatible with little-endian systems. + * + * When serializing data to a file, we recommend that you also use + * checksums so that, at deserialization, you can be confident + * that you are recovering the correct data. */ size_t roaring64_bitmap_portable_serialize(const roaring64_bitmap_t *r, char *buf); @@ -525,14 +529,17 @@ size_t roaring64_bitmap_portable_deserialize_size(const char *buf, size_t maxbytes); /** - * Read a bitmap from a serialized buffer safely (reading up to maxbytes). + * Read a bitmap from a serialized buffer (reading up to maxbytes). * In case of failure, NULL is returned. * * This is meant to be compatible with other languages * https://github.com/RoaringBitmap/RoaringFormatSpec#extension-for-64-bit-implementations * * The function itself is safe in the sense that it will not cause buffer - * overflows. However, for correct operations, it is assumed that the bitmap + * overflows: it will not read beyond the scope of the provided buffer + * (buf,maxbytes). + * + * However, for correct operations, it is assumed that the bitmap * read was once serialized from a valid bitmap (i.e., it follows the format * specification). If you provided an incorrect input (garbage), then the bitmap * read may not be in a valid state and following operations may not lead to @@ -541,6 +548,12 @@ size_t roaring64_bitmap_portable_deserialize_size(const char *buf, * order. This is is guaranteed to happen when serializing an existing bitmap, * but not for random inputs. * + * You may use roaring64_bitmap_internal_validate to check the validity of the + * bitmap prior to using it. + * + * We recommend that you use checksums to check that serialized data corresponds + * to a serialized bitmap. + * * This function is endian-sensitive. If you have a big-endian system (e.g., a * mainframe IBM s390x), the data format is going to be big-endian and not * compatible with little-endian systems. diff --git a/contrib/libs/croaring/include/roaring/roaring_version.h b/contrib/libs/croaring/include/roaring/roaring_version.h index 0d136bbbd3..f211339f45 100644 --- a/contrib/libs/croaring/include/roaring/roaring_version.h +++ b/contrib/libs/croaring/include/roaring/roaring_version.h @@ -2,11 +2,11 @@ // /include/roaring/roaring_version.h automatically generated by release.py, do not change by hand #ifndef ROARING_INCLUDE_ROARING_VERSION #define ROARING_INCLUDE_ROARING_VERSION -#define ROARING_VERSION "4.1.2" +#define ROARING_VERSION "4.1.7" enum { ROARING_VERSION_MAJOR = 4, ROARING_VERSION_MINOR = 1, - ROARING_VERSION_REVISION = 2 + ROARING_VERSION_REVISION = 7 }; #endif // ROARING_INCLUDE_ROARING_VERSION // clang-format on
\ No newline at end of file diff --git a/contrib/libs/croaring/src/bitset_util.c b/contrib/libs/croaring/src/bitset_util.c index 0ae7d92582..6bc12b44b4 100644 --- a/contrib/libs/croaring/src/bitset_util.c +++ b/contrib/libs/croaring/src/bitset_util.c @@ -613,16 +613,13 @@ size_t bitset_extract_setbits_avx512(const uint64_t *words, size_t length, for (; (i < length) && (out < safeout); ++i) { uint64_t w = words[i]; while ((w != 0) && (out < safeout)) { - uint64_t t = - w & (~w + 1); // on x64, should compile to BLSI (careful: the - // Intel compiler seems to fail) int r = roaring_trailing_zeroes(w); // on x64, should compile to TZCNT uint32_t val = r + base; memcpy(out, &val, sizeof(uint32_t)); // should be compiled as a MOV on x64 out++; - w ^= t; + w &= (w - 1); } base += 64; } @@ -667,15 +664,12 @@ size_t bitset_extract_setbits_avx512_uint16(const uint64_t *array, for (; (i < length) && (out < safeout); ++i) { uint64_t w = array[i]; while ((w != 0) && (out < safeout)) { - uint64_t t = - w & (~w + 1); // on x64, should compile to BLSI (careful: the - // Intel compiler seems to fail) int r = roaring_trailing_zeroes(w); // on x64, should compile to TZCNT uint32_t val = r + base; memcpy(out, &val, sizeof(uint16_t)); out++; - w ^= t; + w &= (w - 1); } base += 64; } @@ -725,16 +719,13 @@ size_t bitset_extract_setbits_avx2(const uint64_t *words, size_t length, for (; (i < length) && (out < safeout); ++i) { uint64_t w = words[i]; while ((w != 0) && (out < safeout)) { - uint64_t t = - w & (~w + 1); // on x64, should compile to BLSI (careful: the - // Intel compiler seems to fail) int r = roaring_trailing_zeroes(w); // on x64, should compile to TZCNT uint32_t val = r + base; memcpy(out, &val, sizeof(uint32_t)); // should be compiled as a MOV on x64 out++; - w ^= t; + w &= (w - 1); } base += 64; } @@ -749,16 +740,13 @@ size_t bitset_extract_setbits(const uint64_t *words, size_t length, for (size_t i = 0; i < length; ++i) { uint64_t w = words[i]; while (w != 0) { - uint64_t t = - w & (~w + 1); // on x64, should compile to BLSI (careful: the - // Intel compiler seems to fail) int r = roaring_trailing_zeroes(w); // on x64, should compile to TZCNT uint32_t val = r + base; memcpy(out + outpos, &val, sizeof(uint32_t)); // should be compiled as a MOV on x64 outpos++; - w ^= t; + w &= (w - 1); } base += 64; } @@ -772,10 +760,9 @@ size_t bitset_extract_intersection_setbits_uint16( for (size_t i = 0; i < length; ++i) { uint64_t w = words1[i] & words2[i]; while (w != 0) { - uint64_t t = w & (~w + 1); int r = roaring_trailing_zeroes(w); out[outpos++] = (uint16_t)(r + base); - w ^= t; + w &= (w - 1); } base += 64; } @@ -836,11 +823,10 @@ size_t bitset_extract_setbits_sse_uint16(const uint64_t *words, size_t length, for (; (i < length) && (out < safeout); ++i) { uint64_t w = words[i]; while ((w != 0) && (out < safeout)) { - uint64_t t = w & (~w + 1); int r = roaring_trailing_zeroes(w); *out = (uint16_t)(r + base); out++; - w ^= t; + w &= (w - 1); } base += 64; } @@ -864,10 +850,9 @@ size_t bitset_extract_setbits_uint16(const uint64_t *words, size_t length, for (size_t i = 0; i < length; ++i) { uint64_t w = words[i]; while (w != 0) { - uint64_t t = w & (~w + 1); int r = roaring_trailing_zeroes(w); out[outpos++] = (uint16_t)(r + base); - w ^= t; + w &= (w - 1); } base += 64; } @@ -1158,4 +1143,4 @@ void bitset_flip_list(uint64_t *words, const uint16_t *list, uint64_t length) { #endif #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop -#endif
\ No newline at end of file +#endif diff --git a/contrib/libs/croaring/src/roaring.c b/contrib/libs/croaring/src/roaring.c index e3847bae92..5a71fd39c3 100644 --- a/contrib/libs/croaring/src/roaring.c +++ b/contrib/libs/croaring/src/roaring.c @@ -3319,7 +3319,7 @@ roaring_bitmap_t *roaring_bitmap_portable_deserialize_frozen(const char *buf) { bool roaring_bitmap_to_bitset(const roaring_bitmap_t *r, bitset_t *bitset) { uint32_t max_value = roaring_bitmap_maximum(r); - size_t new_array_size = (size_t)(((uint64_t)max_value + 63) / 64); + size_t new_array_size = (size_t)(max_value / 64 + 1); bool resize_ok = bitset_resize(bitset, new_array_size, true); if (!resize_ok) { return false; diff --git a/contrib/libs/croaring/src/roaring64.c b/contrib/libs/croaring/src/roaring64.c index e63d3d965c..914faefe0b 100644 --- a/contrib/libs/croaring/src/roaring64.c +++ b/contrib/libs/croaring/src/roaring64.c @@ -1954,6 +1954,7 @@ roaring64_bitmap_t *roaring64_bitmap_portable_deserialize_safe( roaring64_bitmap_t *r = roaring64_bitmap_create(); // Iterate through buckets ordered by increasing keys. + int64_t previous_high32 = -1; for (uint64_t bucket = 0; bucket < buckets; ++bucket) { // Read as uint32 the most significant 32 bits of the bucket. uint32_t high32; @@ -1964,6 +1965,12 @@ roaring64_bitmap_t *roaring64_bitmap_portable_deserialize_safe( memcpy(&high32, buf, sizeof(high32)); buf += sizeof(high32); read_bytes += sizeof(high32); + // High 32 bits must be strictly increasing. + if (high32 <= previous_high32) { + roaring64_bitmap_free(r); + return NULL; + } + previous_high32 = high32; // Read the 32-bit Roaring bitmaps representing the least significant // bits of a set of elements. @@ -1983,6 +1990,24 @@ roaring64_bitmap_t *roaring64_bitmap_portable_deserialize_safe( buf += bitmap32_size; read_bytes += bitmap32_size; + // While we don't attempt to validate much, we must ensure that there + // is no duplication in the high 48 bits - inserting into the ART + // assumes (or UB) no duplicate keys. The top 32 bits must be unique + // because we check for strict increasing values of high32, but we + // must also ensure the top 16 bits within each 32-bit bitmap are also + // at least unique (we ensure they're strictly increasing as well, + // which they must be for a _valid_ bitmap, since it's cheaper to check) + int32_t last_bitmap_key = -1; + for (int i = 0; i < bitmap32->high_low_container.size; i++) { + uint16_t key = bitmap32->high_low_container.keys[i]; + if (key <= last_bitmap_key) { + roaring_bitmap_free(bitmap32); + roaring64_bitmap_free(r); + return NULL; + } + last_bitmap_key = key; + } + // Insert all containers of the 32-bit bitmap into the 64-bit bitmap. move_from_roaring32_offset(r, bitmap32, high32); roaring_bitmap_free(bitmap32); diff --git a/contrib/libs/croaring/src/roaring_array.c b/contrib/libs/croaring/src/roaring_array.c index fabc8b5b64..e3bc6ce5c7 100644 --- a/contrib/libs/croaring/src/roaring_array.c +++ b/contrib/libs/croaring/src/roaring_array.c @@ -637,7 +637,7 @@ size_t ra_portable_deserialize_size(const char *buf, const size_t maxbytes) { memcpy(&size, buf, sizeof(int32_t)); buf += sizeof(uint32_t); } - if (size > (1 << 16)) { + if (size > (1 << 16) || size < 0) { return 0; } char *bitmapOfRunContainers = NULL; diff --git a/contrib/libs/croaring/ya.make b/contrib/libs/croaring/ya.make index 55acab5673..03863f4f54 100644 --- a/contrib/libs/croaring/ya.make +++ b/contrib/libs/croaring/ya.make @@ -10,13 +10,12 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(4.1.2) +VERSION(4.1.7) -ORIGINAL_SOURCE(https://github.com/RoaringBitmap/CRoaring/archive/v4.1.2.tar.gz) +ORIGINAL_SOURCE(https://github.com/RoaringBitmap/CRoaring/archive/v4.1.7.tar.gz) ADDINCL( GLOBAL contrib/libs/croaring/include - contrib/libs/croaring/include/roaring ) NO_COMPILER_WARNINGS() diff --git a/contrib/python/aioresponses/.dist-info/METADATA b/contrib/python/aioresponses/.dist-info/METADATA new file mode 100644 index 0000000000..54b686eb71 --- /dev/null +++ b/contrib/python/aioresponses/.dist-info/METADATA @@ -0,0 +1,333 @@ +Metadata-Version: 2.1 +Name: aioresponses +Version: 0.7.6 +Summary: Mock out requests made by ClientSession from aiohttp package +Home-page: https://github.com/pnuckowski/aioresponses +Author: Pawel Nuckowski +Author-email: p.nuckowski@gmail.com +Classifier: Development Status :: 4 - Beta +Classifier: Intended Audience :: Developers +Classifier: Operating System :: OS Independent +Classifier: Topic :: Internet :: WWW/HTTP +Classifier: Topic :: Software Development :: Testing +Classifier: Topic :: Software Development :: Testing :: Mocking +Classifier: License :: OSI Approved :: MIT License +Classifier: Natural Language :: English +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +License-File: LICENSE +License-File: AUTHORS +License-File: AUTHORS.rst +Requires-Dist: aiohttp (<4.0.0,>=3.3.0) + +=============================== +aioresponses +=============================== + +.. image:: https://travis-ci.org/pnuckowski/aioresponses.svg?branch=master + :target: https://travis-ci.org/pnuckowski/aioresponses + +.. image:: https://coveralls.io/repos/github/pnuckowski/aioresponses/badge.svg?branch=master + :target: https://coveralls.io/github/pnuckowski/aioresponses?branch=master + +.. image:: https://landscape.io/github/pnuckowski/aioresponses/master/landscape.svg?style=flat + :target: https://landscape.io/github/pnuckowski/aioresponses/master + :alt: Code Health + +.. image:: https://pyup.io/repos/github/pnuckowski/aioresponses/shield.svg + :target: https://pyup.io/repos/github/pnuckowski/aioresponses/ + :alt: Updates + +.. image:: https://img.shields.io/pypi/v/aioresponses.svg + :target: https://pypi.python.org/pypi/aioresponses + +.. image:: https://readthedocs.org/projects/aioresponses/badge/?version=latest + :target: https://aioresponses.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + + +Aioresponses is a helper to mock/fake web requests in python aiohttp package. + +For *requests* module there are a lot of packages that help us with testing (eg. *httpretty*, *responses*, *requests-mock*). + +When it comes to testing asynchronous HTTP requests it is a bit harder (at least at the beginning). +The purpose of this package is to provide an easy way to test asynchronous HTTP requests. + +Installing +---------- + +.. code:: bash + + $ pip install aioresponses + +Supported versions +------------------ +- Python 3.7+ +- aiohttp>=3.3.0,<4.0.0 + +Usage +-------- + +To mock out HTTP request use *aioresponses* as a method decorator or as a context manager. + +Response *status* code, *body*, *payload* (for json response) and *headers* can be mocked. + +Supported HTTP methods: **GET**, **POST**, **PUT**, **PATCH**, **DELETE** and **OPTIONS**. + +.. code:: python + + import aiohttp + import asyncio + from aioresponses import aioresponses + + @aioresponses() + def test_request(mocked): + loop = asyncio.get_event_loop() + mocked.get('http://example.com', status=200, body='test') + session = aiohttp.ClientSession() + resp = loop.run_until_complete(session.get('http://example.com')) + + assert resp.status == 200 + mocked.assert_called_once_with('http://example.com') + + +for convenience use *payload* argument to mock out json response. Example below. + +**as a context manager** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + def test_ctx(): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + with aioresponses() as m: + m.get('http://test.example.com', payload=dict(foo='bar')) + + resp = loop.run_until_complete(session.get('http://test.example.com')) + data = loop.run_until_complete(resp.json()) + + assert dict(foo='bar') == data + m.assert_called_once_with('http://test.example.com') + +**aioresponses allows to mock out any HTTP headers** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses() + def test_http_headers(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + m.post( + 'http://example.com', + payload=dict(), + headers=dict(connection='keep-alive'), + ) + + resp = loop.run_until_complete(session.post('http://example.com')) + + # note that we pass 'connection' but get 'Connection' (capitalized) + # under the neath `multidict` is used to work with HTTP headers + assert resp.headers['Connection'] == 'keep-alive' + m.assert_called_once_with('http://example.com', method='POST') + +**allows to register different responses for the same url** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses() + def test_multiple_responses(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + m.get('http://example.com', status=500) + m.get('http://example.com', status=200) + + resp1 = loop.run_until_complete(session.get('http://example.com')) + resp2 = loop.run_until_complete(session.get('http://example.com')) + + assert resp1.status == 500 + assert resp2.status == 200 + + +**Repeat response for the same url** + +E.g. for cases you want to test retrying mechanisms + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses() + def test_multiple_responses(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + m.get('http://example.com', status=500, repeat=True) + m.get('http://example.com', status=200) # will not take effect + + resp1 = loop.run_until_complete(session.get('http://example.com')) + resp2 = loop.run_until_complete(session.get('http://example.com')) + + assert resp1.status == 500 + assert resp2.status == 500 + + +**match URLs with regular expressions** + +.. code:: python + + import asyncio + import aiohttp + import re + from aioresponses import aioresponses + + @aioresponses() + def test_regexp_example(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + pattern = re.compile(r'^http://example\.com/api\?foo=.*$') + m.get(pattern, status=200) + + resp = loop.run_until_complete(session.get('http://example.com/api?foo=bar')) + + assert resp.status == 200 + +**allows to make redirects responses** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses() + def test_redirect_example(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + + # absolute urls are supported + m.get( + 'http://example.com/', + headers={'Location': 'http://another.com/'}, + status=307 + ) + + resp = loop.run_until_complete( + session.get('http://example.com/', allow_redirects=True) + ) + assert resp.url == 'http://another.com/' + + # and also relative + m.get( + 'http://example.com/', + headers={'Location': '/test'}, + status=307 + ) + resp = loop.run_until_complete( + session.get('http://example.com/', allow_redirects=True) + ) + assert resp.url == 'http://example.com/test' + +**allows to passthrough to a specified list of servers** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses(passthrough=['http://backend']) + def test_passthrough(m, test_client): + session = aiohttp.ClientSession() + # this will actually perform a request + resp = loop.run_until_complete(session.get('http://backend/api')) + + +**aioresponses allows to throw an exception** + +.. code:: python + + import asyncio + from aiohttp import ClientSession + from aiohttp.http_exceptions import HttpProcessingError + from aioresponses import aioresponses + + @aioresponses() + def test_how_to_throw_an_exception(m, test_client): + loop = asyncio.get_event_loop() + session = ClientSession() + m.get('http://example.com/api', exception=HttpProcessingError('test')) + + # calling + # loop.run_until_complete(session.get('http://example.com/api')) + # will throw an exception. + + +**aioresponses allows to use callbacks to provide dynamic responses** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import CallbackResult, aioresponses + + def callback(url, **kwargs): + return CallbackResult(status=418) + + @aioresponses() + def test_callback(m, test_client): + loop = asyncio.get_event_loop() + session = ClientSession() + m.get('http://example.com', callback=callback) + + resp = loop.run_until_complete(session.get('http://example.com')) + + assert resp.status == 418 + + +**aioresponses can be used in a pytest fixture** + +.. code:: python + + import pytest + from aioresponses import aioresponses + + @pytest.fixture + def mock_aioresponse(): + with aioresponses() as m: + yield m + + +Features +-------- +* Easy to mock out HTTP requests made by *aiohttp.ClientSession* + + +License +------- +* Free software: MIT license + +Credits +------- + +This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. + +.. _Cookiecutter: https://github.com/audreyr/cookiecutter +.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage + diff --git a/contrib/python/aioresponses/.dist-info/top_level.txt b/contrib/python/aioresponses/.dist-info/top_level.txt new file mode 100644 index 0000000000..46cd566df0 --- /dev/null +++ b/contrib/python/aioresponses/.dist-info/top_level.txt @@ -0,0 +1 @@ +aioresponses diff --git a/contrib/python/aioresponses/AUTHORS b/contrib/python/aioresponses/AUTHORS new file mode 100644 index 0000000000..3854a29412 --- /dev/null +++ b/contrib/python/aioresponses/AUTHORS @@ -0,0 +1,51 @@ +Alan Briolat <alan.briolat@gmail.com> +Aleksei Maslakov <lesha.maslakov@gmail.com> +Alexey Nikitenko <wblxyxolb.khv@mail.ru> +Alexey Sveshnikov <a.sveshnikov@rambler-co.ru> +Alexey Sveshnikov <alexey.sveshnikov@gmail.com> +Allisson Azevedo <allisson@gmail.com> +Andrew Grinevich <andrew.grinevich@pandadoc.com> +Anthony Lukach <anthonylukach@gmail.com> +Ben Greiner <code@bnavigator.de> +Brett Wandel <brett.wandel@interferex.com> +Bryce Drennan <github@accounts.brycedrennan.com> +Colin-b <Colin-b@users.noreply.github.com> +Daniel Hahler <git@thequod.de> +Daniel Tan <danieltanjiawang@gmail.com> +David Buxton <david@gasmark6.com> +Fred Thomsen <fred.thomsen@sciencelogic.com> +Georg Sauthoff <mail@gms.tf> +Gordon Rogers <gordonrogers@skyscanner.net> +Hadrien David <hadrien.david@dialogue.co> +Hadrien David <hadrien@ectobal.com> +Ibrahim <8592115+iamibi@users.noreply.github.com> +Ilaï Deutel <ilai-deutel@users.noreply.github.com> +Jakub Boukal <www.bagr@gmail.com> +Joongi Kim <me@daybreaker.info> +Jordi Soucheiron <jordi@soucheiron.cat> +Jordi Soucheiron <jsoucheiron@users.noreply.github.com> +Joshua Coats <joshu@fearchar.net> +Juan Cruz <juancruzmencia@gmail.com> +Lee Treveil <leetreveil@gmail.com> +Louis Sautier <sautier.louis@gmail.com> +Lukasz Jernas <lukasz.jernas@allegrogroup.com> +Marat Sharafutdinov <decaz89@gmail.com> +Marcin Sulikowski <marcin.k.sulikowski@gmail.com> +Marek Kowalski <kowalski0123@gmail.com> +Pavel Savchenko <asfaltboy@gmail.com> +Pawel Nuckowski <p.nuckowski@gmail.com> +Petr Belskiy <petr.belskiy@gmail.com> +Rémy HUBSCHER <rhubscher@mozilla.com> +Sam Bull <aa6bs0@sambull.org> +TyVik <tyvik8@gmail.com> +Ulrik Johansson <ulrik.johansson@blocket.se> +Ville Skyttä <ville.skytta@iki.fi> +d-ryzhikov <d.ryzhykau@gmail.com> +iamnotaprogrammer <iamnotaprogrammer@yandex.ru> +iamnotaprogrammer <issmirnov@domclick.ru> +konstantin <konstantin.klein@hochfrequenz.de> +oren0e <countx@gmail.com> +pnuckowski <p.nuckowski@gmail.com> +pnuckowski <pnuckowski@users.noreply.github.com> +pyup-bot <github-bot@pyup.io> +vangheem <vangheem@gmail.com> diff --git a/contrib/python/aioresponses/AUTHORS.rst b/contrib/python/aioresponses/AUTHORS.rst new file mode 100644 index 0000000000..3b1fc8e0ec --- /dev/null +++ b/contrib/python/aioresponses/AUTHORS.rst @@ -0,0 +1,13 @@ +======= +Credits +======= + +Development Lead +---------------- + +* Pawel Nuckowski <p.nuckowski@gmail.com> + +Contributors +------------ + +None yet. Why not be the first? diff --git a/contrib/python/aioresponses/LICENSE b/contrib/python/aioresponses/LICENSE new file mode 100644 index 0000000000..fe5490da64 --- /dev/null +++ b/contrib/python/aioresponses/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 pnuckowski + +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. diff --git a/contrib/python/aioresponses/README.rst b/contrib/python/aioresponses/README.rst new file mode 100644 index 0000000000..ae63650d0a --- /dev/null +++ b/contrib/python/aioresponses/README.rst @@ -0,0 +1,306 @@ +=============================== +aioresponses +=============================== + +.. image:: https://travis-ci.org/pnuckowski/aioresponses.svg?branch=master + :target: https://travis-ci.org/pnuckowski/aioresponses + +.. image:: https://coveralls.io/repos/github/pnuckowski/aioresponses/badge.svg?branch=master + :target: https://coveralls.io/github/pnuckowski/aioresponses?branch=master + +.. image:: https://landscape.io/github/pnuckowski/aioresponses/master/landscape.svg?style=flat + :target: https://landscape.io/github/pnuckowski/aioresponses/master + :alt: Code Health + +.. image:: https://pyup.io/repos/github/pnuckowski/aioresponses/shield.svg + :target: https://pyup.io/repos/github/pnuckowski/aioresponses/ + :alt: Updates + +.. image:: https://img.shields.io/pypi/v/aioresponses.svg + :target: https://pypi.python.org/pypi/aioresponses + +.. image:: https://readthedocs.org/projects/aioresponses/badge/?version=latest + :target: https://aioresponses.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + + +Aioresponses is a helper to mock/fake web requests in python aiohttp package. + +For *requests* module there are a lot of packages that help us with testing (eg. *httpretty*, *responses*, *requests-mock*). + +When it comes to testing asynchronous HTTP requests it is a bit harder (at least at the beginning). +The purpose of this package is to provide an easy way to test asynchronous HTTP requests. + +Installing +---------- + +.. code:: bash + + $ pip install aioresponses + +Supported versions +------------------ +- Python 3.7+ +- aiohttp>=3.3.0,<4.0.0 + +Usage +-------- + +To mock out HTTP request use *aioresponses* as a method decorator or as a context manager. + +Response *status* code, *body*, *payload* (for json response) and *headers* can be mocked. + +Supported HTTP methods: **GET**, **POST**, **PUT**, **PATCH**, **DELETE** and **OPTIONS**. + +.. code:: python + + import aiohttp + import asyncio + from aioresponses import aioresponses + + @aioresponses() + def test_request(mocked): + loop = asyncio.get_event_loop() + mocked.get('http://example.com', status=200, body='test') + session = aiohttp.ClientSession() + resp = loop.run_until_complete(session.get('http://example.com')) + + assert resp.status == 200 + mocked.assert_called_once_with('http://example.com') + + +for convenience use *payload* argument to mock out json response. Example below. + +**as a context manager** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + def test_ctx(): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + with aioresponses() as m: + m.get('http://test.example.com', payload=dict(foo='bar')) + + resp = loop.run_until_complete(session.get('http://test.example.com')) + data = loop.run_until_complete(resp.json()) + + assert dict(foo='bar') == data + m.assert_called_once_with('http://test.example.com') + +**aioresponses allows to mock out any HTTP headers** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses() + def test_http_headers(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + m.post( + 'http://example.com', + payload=dict(), + headers=dict(connection='keep-alive'), + ) + + resp = loop.run_until_complete(session.post('http://example.com')) + + # note that we pass 'connection' but get 'Connection' (capitalized) + # under the neath `multidict` is used to work with HTTP headers + assert resp.headers['Connection'] == 'keep-alive' + m.assert_called_once_with('http://example.com', method='POST') + +**allows to register different responses for the same url** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses() + def test_multiple_responses(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + m.get('http://example.com', status=500) + m.get('http://example.com', status=200) + + resp1 = loop.run_until_complete(session.get('http://example.com')) + resp2 = loop.run_until_complete(session.get('http://example.com')) + + assert resp1.status == 500 + assert resp2.status == 200 + + +**Repeat response for the same url** + +E.g. for cases you want to test retrying mechanisms + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses() + def test_multiple_responses(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + m.get('http://example.com', status=500, repeat=True) + m.get('http://example.com', status=200) # will not take effect + + resp1 = loop.run_until_complete(session.get('http://example.com')) + resp2 = loop.run_until_complete(session.get('http://example.com')) + + assert resp1.status == 500 + assert resp2.status == 500 + + +**match URLs with regular expressions** + +.. code:: python + + import asyncio + import aiohttp + import re + from aioresponses import aioresponses + + @aioresponses() + def test_regexp_example(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + pattern = re.compile(r'^http://example\.com/api\?foo=.*$') + m.get(pattern, status=200) + + resp = loop.run_until_complete(session.get('http://example.com/api?foo=bar')) + + assert resp.status == 200 + +**allows to make redirects responses** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses() + def test_redirect_example(m): + loop = asyncio.get_event_loop() + session = aiohttp.ClientSession() + + # absolute urls are supported + m.get( + 'http://example.com/', + headers={'Location': 'http://another.com/'}, + status=307 + ) + + resp = loop.run_until_complete( + session.get('http://example.com/', allow_redirects=True) + ) + assert resp.url == 'http://another.com/' + + # and also relative + m.get( + 'http://example.com/', + headers={'Location': '/test'}, + status=307 + ) + resp = loop.run_until_complete( + session.get('http://example.com/', allow_redirects=True) + ) + assert resp.url == 'http://example.com/test' + +**allows to passthrough to a specified list of servers** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import aioresponses + + @aioresponses(passthrough=['http://backend']) + def test_passthrough(m, test_client): + session = aiohttp.ClientSession() + # this will actually perform a request + resp = loop.run_until_complete(session.get('http://backend/api')) + + +**aioresponses allows to throw an exception** + +.. code:: python + + import asyncio + from aiohttp import ClientSession + from aiohttp.http_exceptions import HttpProcessingError + from aioresponses import aioresponses + + @aioresponses() + def test_how_to_throw_an_exception(m, test_client): + loop = asyncio.get_event_loop() + session = ClientSession() + m.get('http://example.com/api', exception=HttpProcessingError('test')) + + # calling + # loop.run_until_complete(session.get('http://example.com/api')) + # will throw an exception. + + +**aioresponses allows to use callbacks to provide dynamic responses** + +.. code:: python + + import asyncio + import aiohttp + from aioresponses import CallbackResult, aioresponses + + def callback(url, **kwargs): + return CallbackResult(status=418) + + @aioresponses() + def test_callback(m, test_client): + loop = asyncio.get_event_loop() + session = ClientSession() + m.get('http://example.com', callback=callback) + + resp = loop.run_until_complete(session.get('http://example.com')) + + assert resp.status == 418 + + +**aioresponses can be used in a pytest fixture** + +.. code:: python + + import pytest + from aioresponses import aioresponses + + @pytest.fixture + def mock_aioresponse(): + with aioresponses() as m: + yield m + + +Features +-------- +* Easy to mock out HTTP requests made by *aiohttp.ClientSession* + + +License +------- +* Free software: MIT license + +Credits +------- + +This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. + +.. _Cookiecutter: https://github.com/audreyr/cookiecutter +.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage diff --git a/contrib/python/aioresponses/aioresponses/__init__.py b/contrib/python/aioresponses/aioresponses/__init__.py new file mode 100644 index 0000000000..c61652c9aa --- /dev/null +++ b/contrib/python/aioresponses/aioresponses/__init__.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- +from .core import CallbackResult, aioresponses + +__version__ = '0.7.3' + +__all__ = [ + 'CallbackResult', + 'aioresponses', +] diff --git a/contrib/python/aioresponses/aioresponses/compat.py b/contrib/python/aioresponses/aioresponses/compat.py new file mode 100644 index 0000000000..aa8771d8d6 --- /dev/null +++ b/contrib/python/aioresponses/aioresponses/compat.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +import asyncio # noqa: F401 +import sys +from typing import Dict, Optional, Union # noqa +from urllib.parse import parse_qsl, urlencode + +from aiohttp import __version__ as aiohttp_version, StreamReader +from aiohttp.client_proto import ResponseHandler +from multidict import MultiDict +from packaging.version import Version +from yarl import URL + +if sys.version_info < (3, 7): + from re import _pattern_type as Pattern +else: + from re import Pattern + +AIOHTTP_VERSION = Version(aiohttp_version) + + +def stream_reader_factory( # noqa + loop: 'Optional[asyncio.AbstractEventLoop]' = None +) -> StreamReader: + protocol = ResponseHandler(loop=loop) + return StreamReader(protocol, limit=2 ** 16, loop=loop) + + +def merge_params( + url: 'Union[URL, str]', + params: Optional[Dict] = None +) -> 'URL': + url = URL(url) + if params: + query_params = MultiDict(url.query) + query_params.extend(url.with_query(params).query) + return url.with_query(query_params) + return url + + +def normalize_url(url: 'Union[URL, str]') -> 'URL': + """Normalize url to make comparisons.""" + url = URL(url) + return url.with_query(urlencode(sorted(parse_qsl(url.query_string)))) + + +try: + from aiohttp import RequestInfo +except ImportError: + class RequestInfo(object): + __slots__ = ('url', 'method', 'headers', 'real_url') + + def __init__( + self, url: URL, method: str, headers: Dict, real_url: str + ): + self.url = url + self.method = method + self.headers = headers + self.real_url = real_url + +__all__ = [ + 'URL', + 'Pattern', + 'RequestInfo', + 'AIOHTTP_VERSION', + 'merge_params', + 'stream_reader_factory', + 'normalize_url', +] diff --git a/contrib/python/aioresponses/aioresponses/core.py b/contrib/python/aioresponses/aioresponses/core.py new file mode 100644 index 0000000000..2bb6d57365 --- /dev/null +++ b/contrib/python/aioresponses/aioresponses/core.py @@ -0,0 +1,549 @@ +# -*- coding: utf-8 -*- +import asyncio +import copy +import inspect +import json +from collections import namedtuple +from functools import wraps +from typing import ( + Any, + Callable, + cast, + Dict, + List, + Optional, + Tuple, + Type, + TypeVar, + Union, +) +from unittest.mock import Mock, patch +from uuid import uuid4 + +from aiohttp import ( + ClientConnectionError, + ClientResponse, + ClientSession, + hdrs, + http +) +from aiohttp.helpers import TimerNoop +from multidict import CIMultiDict, CIMultiDictProxy + +from .compat import ( + URL, + Pattern, + stream_reader_factory, + merge_params, + normalize_url, + RequestInfo, +) + + +_FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) + + +class CallbackResult: + + def __init__(self, method: str = hdrs.METH_GET, + status: int = 200, + body: Union[str, bytes] = '', + content_type: str = 'application/json', + payload: Optional[Dict] = None, + headers: Optional[Dict] = None, + response_class: Optional[Type[ClientResponse]] = None, + reason: Optional[str] = None): + self.method = method + self.status = status + self.body = body + self.content_type = content_type + self.payload = payload + self.headers = headers + self.response_class = response_class + self.reason = reason + + +class RequestMatch(object): + url_or_pattern = None # type: Union[URL, Pattern] + + def __init__(self, url: Union[URL, str, Pattern], + method: str = hdrs.METH_GET, + status: int = 200, + body: Union[str, bytes] = '', + payload: Optional[Dict] = None, + exception: Optional[Exception] = None, + headers: Optional[Dict] = None, + content_type: str = 'application/json', + response_class: Optional[Type[ClientResponse]] = None, + timeout: bool = False, + repeat: bool = False, + reason: Optional[str] = None, + callback: Optional[Callable] = None): + if isinstance(url, Pattern): + self.url_or_pattern = url + self.match_func = self.match_regexp + else: + self.url_or_pattern = normalize_url(url) + self.match_func = self.match_str + self.method = method.lower() + self.status = status + self.body = body + self.payload = payload + self.exception = exception + if timeout: + self.exception = asyncio.TimeoutError('Connection timeout test') + self.headers = headers + self.content_type = content_type + self.response_class = response_class + self.repeat = repeat + self.reason = reason + if self.reason is None: + try: + self.reason = http.RESPONSES[self.status][0] + except (IndexError, KeyError): + self.reason = '' + self.callback = callback + + def match_str(self, url: URL) -> bool: + return self.url_or_pattern == url + + def match_regexp(self, url: URL) -> bool: + # This method is used if and only if self.url_or_pattern is a pattern. + return bool( + self.url_or_pattern.match(str(url)) # type:ignore[union-attr] + ) + + def match(self, method: str, url: URL) -> bool: + if self.method != method.lower(): + return False + return self.match_func(url) + + def _build_raw_headers(self, headers: Dict) -> Tuple: + """ + Convert a dict of headers to a tuple of tuples + + Mimics the format of ClientResponse. + """ + raw_headers = [] + for k, v in headers.items(): + raw_headers.append((k.encode('utf8'), v.encode('utf8'))) + return tuple(raw_headers) + + def _build_response(self, url: 'Union[URL, str]', + method: str = hdrs.METH_GET, + request_headers: Optional[Dict] = None, + status: int = 200, + body: Union[str, bytes] = '', + content_type: str = 'application/json', + payload: Optional[Dict] = None, + headers: Optional[Dict] = None, + response_class: Optional[Type[ClientResponse]] = None, + reason: Optional[str] = None) -> ClientResponse: + if response_class is None: + response_class = ClientResponse + if payload is not None: + body = json.dumps(payload) + if not isinstance(body, bytes): + body = str.encode(body) + if request_headers is None: + request_headers = {} + loop = Mock() + loop.get_debug = Mock() + loop.get_debug.return_value = True + kwargs = {} # type: Dict[str, Any] + kwargs['request_info'] = RequestInfo( + url=url, + method=method, + headers=CIMultiDictProxy(CIMultiDict(**request_headers)), + ) + kwargs['writer'] = None + kwargs['continue100'] = None + kwargs['timer'] = TimerNoop() + kwargs['traces'] = [] + kwargs['loop'] = loop + kwargs['session'] = None + + # We need to initialize headers manually + _headers = CIMultiDict({hdrs.CONTENT_TYPE: content_type}) + if headers: + _headers.update(headers) + raw_headers = self._build_raw_headers(_headers) + resp = response_class(method, url, **kwargs) + + for hdr in _headers.getall(hdrs.SET_COOKIE, ()): + resp.cookies.load(hdr) + + # Reified attributes + resp._headers = _headers + resp._raw_headers = raw_headers + + resp.status = status + resp.reason = reason + resp.content = stream_reader_factory(loop) + resp.content.feed_data(body) + resp.content.feed_eof() + return resp + + async def build_response( + self, url: URL, **kwargs: Any + ) -> 'Union[ClientResponse, Exception]': + if callable(self.callback): + if asyncio.iscoroutinefunction(self.callback): + result = await self.callback(url, **kwargs) + else: + result = self.callback(url, **kwargs) + else: + result = None + + if self.exception is not None: + return self.exception + + result = self if result is None else result + resp = self._build_response( + url=url, + method=result.method, + request_headers=kwargs.get("headers"), + status=result.status, + body=result.body, + content_type=result.content_type, + payload=result.payload, + headers=result.headers, + response_class=result.response_class, + reason=result.reason) + return resp + + +RequestCall = namedtuple('RequestCall', ['args', 'kwargs']) + + +class aioresponses(object): + """Mock aiohttp requests made by ClientSession.""" + _matches = None # type: Dict[str, RequestMatch] + _responses = None # type: List[ClientResponse] + requests = None # type: Dict + + def __init__(self, **kwargs: Any): + self._param = kwargs.pop('param', None) + self._passthrough = kwargs.pop('passthrough', []) + self.patcher = patch('aiohttp.client.ClientSession._request', + side_effect=self._request_mock, + autospec=True) + self.requests = {} + + def __enter__(self) -> 'aioresponses': + self.start() + return self + + def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: + self.stop() + + def __call__(self, f: _FuncT) -> _FuncT: + def _pack_arguments(ctx, *args, **kwargs) -> Tuple[Tuple, Dict]: + if self._param: + kwargs[self._param] = ctx + else: + args += (ctx,) + return args, kwargs + + if asyncio.iscoroutinefunction(f): + @wraps(f) + async def wrapped(*args, **kwargs): + with self as ctx: + args, kwargs = _pack_arguments(ctx, *args, **kwargs) + return await f(*args, **kwargs) + else: + @wraps(f) + def wrapped(*args, **kwargs): + with self as ctx: + args, kwargs = _pack_arguments(ctx, *args, **kwargs) + return f(*args, **kwargs) + return cast(_FuncT, wrapped) + + def clear(self) -> None: + self._responses.clear() + self._matches.clear() + + def start(self) -> None: + self._responses = [] + self._matches = {} + self.patcher.start() + self.patcher.return_value = self._request_mock + + def stop(self) -> None: + for response in self._responses: + response.close() + self.patcher.stop() + self.clear() + + def head(self, url: 'Union[URL, str, Pattern]', **kwargs: Any) -> None: + self.add(url, method=hdrs.METH_HEAD, **kwargs) + + def get(self, url: 'Union[URL, str, Pattern]', **kwargs: Any) -> None: + self.add(url, method=hdrs.METH_GET, **kwargs) + + def post(self, url: 'Union[URL, str, Pattern]', **kwargs: Any) -> None: + self.add(url, method=hdrs.METH_POST, **kwargs) + + def put(self, url: 'Union[URL, str, Pattern]', **kwargs: Any) -> None: + self.add(url, method=hdrs.METH_PUT, **kwargs) + + def patch(self, url: 'Union[URL, str, Pattern]', **kwargs: Any) -> None: + self.add(url, method=hdrs.METH_PATCH, **kwargs) + + def delete(self, url: 'Union[URL, str, Pattern]', **kwargs: Any) -> None: + self.add(url, method=hdrs.METH_DELETE, **kwargs) + + def options(self, url: 'Union[URL, str, Pattern]', **kwargs: Any) -> None: + self.add(url, method=hdrs.METH_OPTIONS, **kwargs) + + def add(self, url: 'Union[URL, str, Pattern]', method: str = hdrs.METH_GET, + status: int = 200, + body: Union[str, bytes] = '', + exception: Optional[Exception] = None, + content_type: str = 'application/json', + payload: Optional[Dict] = None, + headers: Optional[Dict] = None, + response_class: Optional[Type[ClientResponse]] = None, + repeat: bool = False, + timeout: bool = False, + reason: Optional[str] = None, + callback: Optional[Callable] = None) -> None: + + self._matches[str(uuid4())] = (RequestMatch( + url, + method=method, + status=status, + content_type=content_type, + body=body, + exception=exception, + payload=payload, + headers=headers, + response_class=response_class, + repeat=repeat, + timeout=timeout, + reason=reason, + callback=callback, + )) + + def _format_call_signature(self, *args, **kwargs) -> str: + message = '%s(%%s)' % self.__class__.__name__ or 'mock' + formatted_args = '' + args_string = ', '.join([repr(arg) for arg in args]) + kwargs_string = ', '.join([ + '%s=%r' % (key, value) for key, value in kwargs.items() + ]) + if args_string: + formatted_args = args_string + if kwargs_string: + if formatted_args: + formatted_args += ', ' + formatted_args += kwargs_string + + return message % formatted_args + + def assert_not_called(self): + """assert that the mock was never called. + """ + if len(self.requests) != 0: + msg = ("Expected '%s' to not have been called. Called %s times." + % (self.__class__.__name__, + len(self._responses))) + raise AssertionError(msg) + + def assert_called(self): + """assert that the mock was called at least once. + """ + if len(self.requests) == 0: + msg = ("Expected '%s' to have been called." + % (self.__class__.__name__,)) + raise AssertionError(msg) + + def assert_called_once(self): + """assert that the mock was called only once. + """ + call_count = len(self.requests) + if call_count == 1: + call_count = len(list(self.requests.values())[0]) + if not call_count == 1: + msg = ("Expected '%s' to have been called once. Called %s times." + % (self.__class__.__name__, + call_count)) + + raise AssertionError(msg) + + def assert_called_with(self, url: 'Union[URL, str, Pattern]', + method: str = hdrs.METH_GET, + *args: Any, + **kwargs: Any): + """assert that the last call was made with the specified arguments. + + Raises an AssertionError if the args and keyword args passed in are + different to the last call to the mock.""" + url = normalize_url(merge_params(url, kwargs.get('params'))) + method = method.upper() + key = (method, url) + try: + expected = self.requests[key][-1] + except KeyError: + expected_string = self._format_call_signature( + url, method=method, *args, **kwargs + ) + raise AssertionError( + '%s call not found' % expected_string + ) + actual = self._build_request_call(method, *args, **kwargs) + if not expected == actual: + expected_string = self._format_call_signature( + expected, + ) + actual_string = self._format_call_signature( + actual + ) + raise AssertionError( + '%s != %s' % (expected_string, actual_string) + ) + + def assert_any_call(self, url: 'Union[URL, str, Pattern]', + method: str = hdrs.METH_GET, + *args: Any, + **kwargs: Any): + """assert the mock has been called with the specified arguments. + The assert passes if the mock has *ever* been called, unlike + `assert_called_with` and `assert_called_once_with` that only pass if + the call is the most recent one.""" + url = normalize_url(merge_params(url, kwargs.get('params'))) + method = method.upper() + key = (method, url) + + try: + self.requests[key] + except KeyError: + expected_string = self._format_call_signature( + url, method=method, *args, **kwargs + ) + raise AssertionError( + '%s call not found' % expected_string + ) + + def assert_called_once_with(self, *args: Any, **kwargs: Any): + """assert that the mock was called once with the specified arguments. + Raises an AssertionError if the args and keyword args passed in are + different to the only call to the mock.""" + self.assert_called_once() + self.assert_called_with(*args, **kwargs) + + @staticmethod + def is_exception(resp_or_exc: Union[ClientResponse, Exception]) -> bool: + if inspect.isclass(resp_or_exc): + parent_classes = set(inspect.getmro(resp_or_exc)) + if {Exception, BaseException} & parent_classes: + return True + else: + if isinstance(resp_or_exc, (Exception, BaseException)): + return True + return False + + async def match( + self, method: str, + url: URL, + allow_redirects: bool = True, + **kwargs: Any + ) -> Optional['ClientResponse']: + history = [] + while True: + for key, matcher in self._matches.items(): + if matcher.match(method, url): + response_or_exc = await matcher.build_response( + url, allow_redirects=allow_redirects, **kwargs + ) + break + else: + return None + + if matcher.repeat is False: + del self._matches[key] + + if self.is_exception(response_or_exc): + raise response_or_exc + # If response_or_exc was an exception, it would have been raised. + # At this point we can be sure it's a ClientResponse + response: ClientResponse + response = response_or_exc # type:ignore[assignment] + is_redirect = response.status in (301, 302, 303, 307, 308) + if is_redirect and allow_redirects: + if hdrs.LOCATION not in response.headers: + break + history.append(response) + redirect_url = URL(response.headers[hdrs.LOCATION]) + if redirect_url.is_absolute(): + url = redirect_url + else: + url = url.join(redirect_url) + method = 'get' + continue + else: + break + + response._history = tuple(history) + return response + + async def _request_mock(self, orig_self: ClientSession, + method: str, url: 'Union[URL, str]', + *args: Tuple, + **kwargs: Any) -> 'ClientResponse': + """Return mocked response object or raise connection error.""" + if orig_self.closed: + raise RuntimeError('Session is closed') + + url_origin = url + url = normalize_url(merge_params(url, kwargs.get('params'))) + url_str = str(url) + for prefix in self._passthrough: + if url_str.startswith(prefix): + return (await self.patcher.temp_original( + orig_self, method, url_origin, *args, **kwargs + )) + + key = (method, url) + self.requests.setdefault(key, []) + request_call = self._build_request_call(method, *args, **kwargs) + self.requests[key].append(request_call) + + response = await self.match(method, url, **kwargs) + + if response is None: + raise ClientConnectionError( + 'Connection refused: {} {}'.format(method, url) + ) + self._responses.append(response) + + # Automatically call response.raise_for_status() on a request if the + # request was initialized with raise_for_status=True. Also call + # response.raise_for_status() if the client session was initialized + # with raise_for_status=True, unless the request was called with + # raise_for_status=False. + raise_for_status = kwargs.get('raise_for_status') + if raise_for_status is None: + raise_for_status = getattr( + orig_self, '_raise_for_status', False + ) + if raise_for_status: + response.raise_for_status() + + return response + + def _build_request_call(self, method: str = hdrs.METH_GET, + *args: Any, + allow_redirects: bool = True, + **kwargs: Any): + """Return request call.""" + kwargs.setdefault('allow_redirects', allow_redirects) + if method == 'POST': + kwargs.setdefault('data', None) + + try: + kwargs_copy = copy.deepcopy(kwargs) + except (TypeError, ValueError): + # Handle the fact that some values cannot be deep copied + kwargs_copy = kwargs + return RequestCall(args, kwargs_copy) diff --git a/contrib/python/aioresponses/aioresponses/py.typed b/contrib/python/aioresponses/aioresponses/py.typed new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/contrib/python/aioresponses/aioresponses/py.typed diff --git a/contrib/python/aioresponses/ya.make b/contrib/python/aioresponses/ya.make new file mode 100644 index 0000000000..574b5f85f1 --- /dev/null +++ b/contrib/python/aioresponses/ya.make @@ -0,0 +1,33 @@ +# Generated by devtools/yamaker (pypi). + +PY3_LIBRARY() + +VERSION(0.7.6) + +LICENSE(MIT) + +PEERDIR( + contrib/python/aiohttp +) + +NO_LINT() + +PY_SRCS( + TOP_LEVEL + aioresponses/__init__.py + aioresponses/compat.py + aioresponses/core.py +) + +RESOURCE_FILES( + PREFIX contrib/python/aioresponses/ + .dist-info/METADATA + .dist-info/top_level.txt + aioresponses/py.typed +) + +END() + +RECURSE_FOR_TESTS( + tests +) diff --git a/contrib/python/anyio/.dist-info/METADATA b/contrib/python/anyio/.dist-info/METADATA index be13c8aa0f..747e994c6b 100644 --- a/contrib/python/anyio/.dist-info/METADATA +++ b/contrib/python/anyio/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: anyio -Version: 4.4.0 +Version: 4.6.0 Summary: High level compatibility layer for multiple asynchronous event loop implementations Author-email: Alex Grönholm <alex.gronholm@nextday.fi> License: MIT @@ -15,12 +15,12 @@ Classifier: Framework :: AnyIO Classifier: Typing :: Typed Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 -Requires-Python: >=3.8 +Classifier: Programming Language :: Python :: 3.13 +Requires-Python: >=3.9 Description-Content-Type: text/x-rst License-File: LICENSE Requires-Dist: idna >=2.8 @@ -29,7 +29,7 @@ Requires-Dist: exceptiongroup >=1.0.2 ; python_version < "3.11" Requires-Dist: typing-extensions >=4.1 ; python_version < "3.11" Provides-Extra: doc Requires-Dist: packaging ; extra == 'doc' -Requires-Dist: Sphinx >=7 ; extra == 'doc' +Requires-Dist: Sphinx ~=7.4 ; extra == 'doc' Requires-Dist: sphinx-rtd-theme ; extra == 'doc' Requires-Dist: sphinx-autodoc-typehints >=1.2.0 ; extra == 'doc' Provides-Extra: test @@ -41,9 +41,9 @@ Requires-Dist: psutil >=5.9 ; extra == 'test' Requires-Dist: pytest >=7.0 ; extra == 'test' Requires-Dist: pytest-mock >=3.6.1 ; extra == 'test' Requires-Dist: trustme ; extra == 'test' -Requires-Dist: uvloop >=0.17 ; (platform_python_implementation == "CPython" and platform_system != "Windows") and extra == 'test' +Requires-Dist: uvloop >=0.21.0b1 ; (platform_python_implementation == "CPython" and platform_system != "Windows") and extra == 'test' Provides-Extra: trio -Requires-Dist: trio >=0.23 ; extra == 'trio' +Requires-Dist: trio >=0.26.1 ; extra == 'trio' .. image:: https://github.com/agronholm/anyio/actions/workflows/test.yml/badge.svg :target: https://github.com/agronholm/anyio/actions/workflows/test.yml diff --git a/contrib/python/anyio/anyio/__init__.py b/contrib/python/anyio/anyio/__init__.py index 7bfe231645..fd9fe06bcf 100644 --- a/contrib/python/anyio/anyio/__init__.py +++ b/contrib/python/anyio/anyio/__init__.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import Any - from ._core._eventloop import current_time as current_time from ._core._eventloop import get_all_backends as get_all_backends from ._core._eventloop import get_cancelled_exc_class as get_cancelled_exc_class @@ -69,8 +67,8 @@ from ._core._typedattr import TypedAttributeSet as TypedAttributeSet from ._core._typedattr import typed_attribute as typed_attribute # Re-export imports so they look like they live directly in this package -key: str -value: Any -for key, value in list(locals().items()): - if getattr(value, "__module__", "").startswith("anyio."): - value.__module__ = __name__ +for __value in list(locals().values()): + if getattr(__value, "__module__", "").startswith("anyio."): + __value.__module__ = __name__ + +del __value diff --git a/contrib/python/anyio/anyio/_backends/_asyncio.py b/contrib/python/anyio/anyio/_backends/_asyncio.py index 43b7cb0e0c..9342fab818 100644 --- a/contrib/python/anyio/anyio/_backends/_asyncio.py +++ b/contrib/python/anyio/anyio/_backends/_asyncio.py @@ -4,6 +4,7 @@ import array import asyncio import concurrent.futures import math +import os import socket import sys import threading @@ -19,9 +20,18 @@ from asyncio import ( ) from asyncio.base_events import _run_until_complete_cb # type: ignore[attr-defined] from collections import OrderedDict, deque -from collections.abc import AsyncIterator, Generator, Iterable +from collections.abc import ( + AsyncGenerator, + AsyncIterator, + Awaitable, + Callable, + Collection, + Coroutine, + Iterable, + Sequence, +) from concurrent.futures import Future -from contextlib import suppress +from contextlib import AbstractContextManager, suppress from contextvars import Context, copy_context from dataclasses import dataclass from functools import partial, wraps @@ -41,16 +51,7 @@ from types import TracebackType from typing import ( IO, Any, - AsyncGenerator, - Awaitable, - Callable, - Collection, - ContextManager, - Coroutine, - Mapping, Optional, - Sequence, - Tuple, TypeVar, cast, ) @@ -58,7 +59,13 @@ from weakref import WeakKeyDictionary import sniffio -from .. import CapacityLimiterStatistics, EventStatistics, TaskInfo, abc +from .. import ( + CapacityLimiterStatistics, + EventStatistics, + LockStatistics, + TaskInfo, + abc, +) from .._core._eventloop import claim_worker_thread, threadlocals from .._core._exceptions import ( BrokenResourceError, @@ -66,12 +73,20 @@ from .._core._exceptions import ( ClosedResourceError, EndOfStream, WouldBlock, + iterate_exceptions, ) from .._core._sockets import convert_ipv6_sockaddr from .._core._streams import create_memory_object_stream -from .._core._synchronization import CapacityLimiter as BaseCapacityLimiter +from .._core._synchronization import ( + CapacityLimiter as BaseCapacityLimiter, +) from .._core._synchronization import Event as BaseEvent -from .._core._synchronization import ResourceGuard +from .._core._synchronization import Lock as BaseLock +from .._core._synchronization import ( + ResourceGuard, + SemaphoreStatistics, +) +from .._core._synchronization import Semaphore as BaseSemaphore from .._core._tasks import CancelScope as BaseCancelScope from ..abc import ( AsyncBackend, @@ -80,6 +95,7 @@ from ..abc import ( UDPPacketType, UNIXDatagramPacketType, ) +from ..abc._eventloop import StrOrBytesPath from ..lowlevel import RunVar from ..streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream @@ -343,6 +359,14 @@ def _task_started(task: asyncio.Task) -> bool: # +def is_anyio_cancellation(exc: CancelledError) -> bool: + return ( + bool(exc.args) + and isinstance(exc.args[0], str) + and exc.args[0].startswith("Cancelled by cancel scope ") + ) + + class CancelScope(BaseCancelScope): def __new__( cls, *, deadline: float = math.inf, shield: bool = False @@ -429,35 +453,77 @@ class CancelScope(BaseCancelScope): host_task_state.cancel_scope = self._parent_scope - # Restart the cancellation effort in the closest directly cancelled parent - # scope if this one was shielded - self._restart_cancellation_in_parent() + # Undo all cancellations done by this scope + if self._cancelling is not None: + while self._cancel_calls: + self._cancel_calls -= 1 + if self._host_task.uncancel() <= self._cancelling: + break - if self._cancel_called and exc_val is not None: + # We only swallow the exception iff it was an AnyIO CancelledError, either + # directly as exc_val or inside an exception group and there are no cancelled + # parent cancel scopes visible to us here + not_swallowed_exceptions = 0 + swallow_exception = False + if exc_val is not None: for exc in iterate_exceptions(exc_val): - if isinstance(exc, CancelledError): - self._cancelled_caught = self._uncancel(exc) - if self._cancelled_caught: - break + if self._cancel_called and isinstance(exc, CancelledError): + if not (swallow_exception := self._uncancel(exc)): + not_swallowed_exceptions += 1 + else: + not_swallowed_exceptions += 1 - return self._cancelled_caught + # Restart the cancellation effort in the closest visible, cancelled parent + # scope if necessary + self._restart_cancellation_in_parent() + return swallow_exception and not not_swallowed_exceptions - return None + @property + def _effectively_cancelled(self) -> bool: + cancel_scope: CancelScope | None = self + while cancel_scope is not None: + if cancel_scope._cancel_called: + return True + + if cancel_scope.shield: + return False + + cancel_scope = cancel_scope._parent_scope + + return False + + @property + def _parent_cancellation_is_visible_to_us(self) -> bool: + return ( + self._parent_scope is not None + and not self.shield + and self._parent_scope._effectively_cancelled + ) def _uncancel(self, cancelled_exc: CancelledError) -> bool: - if sys.version_info < (3, 9) or self._host_task is None: + if self._host_task is None: self._cancel_calls = 0 return True - # Undo all cancellations done by this scope - if self._cancelling is not None: - while self._cancel_calls: - self._cancel_calls -= 1 - if self._host_task.uncancel() <= self._cancelling: - return True + while True: + if is_anyio_cancellation(cancelled_exc): + # Only swallow the cancellation exception if it's an AnyIO cancel + # exception and there are no other cancel scopes down the line pending + # cancellation + self._cancelled_caught = ( + self._effectively_cancelled + and not self._parent_cancellation_is_visible_to_us + ) + return self._cancelled_caught - self._cancel_calls = 0 - return f"Cancelled by cancel scope {id(self):x}" in cancelled_exc.args + # Sometimes third party frameworks catch a CancelledError and raise a new + # one, so as a workaround we have to look at the previous ones in + # __context__ too for a matching cancel message + if isinstance(cancelled_exc.__context__, CancelledError): + cancelled_exc = cancelled_exc.__context__ + continue + + return False def _timeout(self) -> None: if self._deadline != math.inf: @@ -481,19 +547,17 @@ class CancelScope(BaseCancelScope): should_retry = False current = current_task() for task in self._tasks: + should_retry = True if task._must_cancel: # type: ignore[attr-defined] continue # The task is eligible for cancellation if it has started - should_retry = True if task is not current and (task is self._host_task or _task_started(task)): waiter = task._fut_waiter # type: ignore[attr-defined] if not isinstance(waiter, asyncio.Future) or not waiter.done(): - origin._cancel_calls += 1 - if sys.version_info >= (3, 9): - task.cancel(f"Cancelled by cancel scope {id(origin):x}") - else: - task.cancel() + task.cancel(f"Cancelled by cancel scope {id(origin):x}") + if task is origin._host_task: + origin._cancel_calls += 1 # Deliver cancellation to child scopes that aren't shielded or running their own # cancellation callbacks @@ -531,17 +595,6 @@ class CancelScope(BaseCancelScope): scope = scope._parent_scope - def _parent_cancelled(self) -> bool: - # Check whether any parent has been cancelled - cancel_scope = self._parent_scope - while cancel_scope is not None and not cancel_scope._shield: - if cancel_scope._cancel_called: - return True - else: - cancel_scope = cancel_scope._parent_scope - - return False - def cancel(self) -> None: if not self._cancel_called: if self._timeout_handle: @@ -630,16 +683,6 @@ class _AsyncioTaskStatus(abc.TaskStatus): _task_states[task].parent_id = self._parent_id -def iterate_exceptions( - exception: BaseException, -) -> Generator[BaseException, None, None]: - if isinstance(exception, BaseExceptionGroup): - for exc in exception.exceptions: - yield from iterate_exceptions(exc) - else: - yield exception - - class TaskGroup(abc.TaskGroup): def __init__(self) -> None: self.cancel_scope: CancelScope = CancelScope() @@ -658,38 +701,50 @@ class TaskGroup(abc.TaskGroup): exc_val: BaseException | None, exc_tb: TracebackType | None, ) -> bool | None: - ignore_exception = self.cancel_scope.__exit__(exc_type, exc_val, exc_tb) if exc_val is not None: self.cancel_scope.cancel() if not isinstance(exc_val, CancelledError): self._exceptions.append(exc_val) - cancelled_exc_while_waiting_tasks: CancelledError | None = None - while self._tasks: - try: - await asyncio.wait(self._tasks) - except CancelledError as exc: - # This task was cancelled natively; reraise the CancelledError later - # unless this task was already interrupted by another exception - self.cancel_scope.cancel() - if cancelled_exc_while_waiting_tasks is None: - cancelled_exc_while_waiting_tasks = exc + try: + if self._tasks: + with CancelScope() as wait_scope: + while self._tasks: + try: + await asyncio.wait(self._tasks) + except CancelledError as exc: + # Shield the scope against further cancellation attempts, + # as they're not productive (#695) + wait_scope.shield = True + self.cancel_scope.cancel() + + # Set exc_val from the cancellation exception if it was + # previously unset. However, we should not replace a native + # cancellation exception with one raise by a cancel scope. + if exc_val is None or ( + isinstance(exc_val, CancelledError) + and not is_anyio_cancellation(exc) + ): + exc_val = exc + else: + # If there are no child tasks to wait on, run at least one checkpoint + # anyway + await AsyncIOBackend.cancel_shielded_checkpoint() - self._active = False - if self._exceptions: - raise BaseExceptionGroup( - "unhandled errors in a TaskGroup", self._exceptions - ) + self._active = False + if self._exceptions: + raise BaseExceptionGroup( + "unhandled errors in a TaskGroup", self._exceptions + ) + elif exc_val: + raise exc_val + except BaseException as exc: + if self.cancel_scope.__exit__(type(exc), exc, exc.__traceback__): + return True - # Raise the CancelledError received while waiting for child tasks to exit, - # unless the context manager itself was previously exited with another - # exception, or if any of the child tasks raised an exception other than - # CancelledError - if cancelled_exc_while_waiting_tasks: - if exc_val is None or ignore_exception: - raise cancelled_exc_while_waiting_tasks + raise - return ignore_exception + return self.cancel_scope.__exit__(exc_type, exc_val, exc_tb) def _spawn( self, @@ -725,7 +780,7 @@ class TaskGroup(abc.TaskGroup): if not isinstance(exc, CancelledError): self._exceptions.append(exc) - if not self.cancel_scope._parent_cancelled(): + if not self.cancel_scope._effectively_cancelled: self.cancel_scope.cancel() else: task_status_future.set_exception(exc) @@ -801,7 +856,7 @@ class TaskGroup(abc.TaskGroup): # Threads # -_Retval_Queue_Type = Tuple[Optional[T_Retval], Optional[BaseException]] +_Retval_Queue_Type = tuple[Optional[T_Retval], Optional[BaseException]] class WorkerThread(Thread): @@ -925,7 +980,7 @@ class StreamReaderWrapper(abc.ByteReceiveStream): raise EndOfStream async def aclose(self) -> None: - self._stream.feed_eof() + self._stream.set_exception(ClosedResourceError()) await AsyncIOBackend.checkpoint() @@ -950,7 +1005,7 @@ class Process(abc.Process): _stderr: StreamReaderWrapper | None async def aclose(self) -> None: - with CancelScope(shield=True): + with CancelScope(shield=True) as scope: if self._stdin: await self._stdin.aclose() if self._stdout: @@ -958,14 +1013,14 @@ class Process(abc.Process): if self._stderr: await self._stderr.aclose() - try: - await self.wait() - except BaseException: - self.kill() - with CancelScope(shield=True): + scope.shield = False + try: await self.wait() - - raise + except BaseException: + scope.shield = True + self.kill() + await self.wait() + raise async def wait(self) -> int: return await self._process.wait() @@ -1073,7 +1128,8 @@ class StreamProtocol(asyncio.Protocol): self.write_event.set() def data_received(self, data: bytes) -> None: - self.read_queue.append(data) + # ProactorEventloop sometimes sends bytearray instead of bytes + self.read_queue.append(bytes(data)) self.read_event.set() def eof_received(self) -> bool | None: @@ -1665,6 +1721,154 @@ class Event(BaseEvent): return EventStatistics(len(self._event._waiters)) +class Lock(BaseLock): + def __new__(cls, *, fast_acquire: bool = False) -> Lock: + return object.__new__(cls) + + def __init__(self, *, fast_acquire: bool = False) -> None: + self._fast_acquire = fast_acquire + self._owner_task: asyncio.Task | None = None + self._waiters: deque[tuple[asyncio.Task, asyncio.Future]] = deque() + + async def acquire(self) -> None: + if self._owner_task is None and not self._waiters: + await AsyncIOBackend.checkpoint_if_cancelled() + self._owner_task = current_task() + + # Unless on the "fast path", yield control of the event loop so that other + # tasks can run too + if not self._fast_acquire: + try: + await AsyncIOBackend.cancel_shielded_checkpoint() + except CancelledError: + self.release() + raise + + return + + task = cast(asyncio.Task, current_task()) + fut: asyncio.Future[None] = asyncio.Future() + item = task, fut + self._waiters.append(item) + try: + await fut + except CancelledError: + self._waiters.remove(item) + if self._owner_task is task: + self.release() + + raise + + self._waiters.remove(item) + + def acquire_nowait(self) -> None: + if self._owner_task is None and not self._waiters: + self._owner_task = current_task() + return + + raise WouldBlock + + def locked(self) -> bool: + return self._owner_task is not None + + def release(self) -> None: + if self._owner_task != current_task(): + raise RuntimeError("The current task is not holding this lock") + + for task, fut in self._waiters: + if not fut.cancelled(): + self._owner_task = task + fut.set_result(None) + return + + self._owner_task = None + + def statistics(self) -> LockStatistics: + task_info = AsyncIOTaskInfo(self._owner_task) if self._owner_task else None + return LockStatistics(self.locked(), task_info, len(self._waiters)) + + +class Semaphore(BaseSemaphore): + def __new__( + cls, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ) -> Semaphore: + return object.__new__(cls) + + def __init__( + self, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ): + super().__init__(initial_value, max_value=max_value) + self._value = initial_value + self._max_value = max_value + self._fast_acquire = fast_acquire + self._waiters: deque[asyncio.Future[None]] = deque() + + async def acquire(self) -> None: + if self._value > 0 and not self._waiters: + await AsyncIOBackend.checkpoint_if_cancelled() + self._value -= 1 + + # Unless on the "fast path", yield control of the event loop so that other + # tasks can run too + if not self._fast_acquire: + try: + await AsyncIOBackend.cancel_shielded_checkpoint() + except CancelledError: + self.release() + raise + + return + + fut: asyncio.Future[None] = asyncio.Future() + self._waiters.append(fut) + try: + await fut + except CancelledError: + try: + self._waiters.remove(fut) + except ValueError: + self.release() + + raise + + def acquire_nowait(self) -> None: + if self._value == 0: + raise WouldBlock + + self._value -= 1 + + def release(self) -> None: + if self._max_value is not None and self._value == self._max_value: + raise ValueError("semaphore released too many times") + + for fut in self._waiters: + if not fut.cancelled(): + fut.set_result(None) + self._waiters.remove(fut) + return + + self._value += 1 + + @property + def value(self) -> int: + return self._value + + @property + def max_value(self) -> int | None: + return self._max_value + + def statistics(self) -> SemaphoreStatistics: + return SemaphoreStatistics(len(self._waiters)) + + class CapacityLimiter(BaseCapacityLimiter): _total_tokens: float = 0 @@ -1861,7 +2065,7 @@ class AsyncIOTaskInfo(TaskInfo): if task_state := _task_states.get(task): if cancel_scope := task_state.cancel_scope: - return cancel_scope.cancel_called or cancel_scope._parent_cancelled() + return cancel_scope._effectively_cancelled return False @@ -1926,13 +2130,23 @@ class TestRunner(abc.TestRunner): tuple[Awaitable[T_Retval], asyncio.Future[T_Retval]] ], ) -> None: + from _pytest.outcomes import OutcomeException + with receive_stream, self._send_stream: async for coro, future in receive_stream: try: retval = await coro + except CancelledError as exc: + if not future.cancelled(): + future.cancel(*exc.args) + + raise except BaseException as exc: if not future.cancelled(): future.set_exception(exc) + + if not isinstance(exc, (Exception, OutcomeException)): + raise else: if not future.cancelled(): future.set_result(retval) @@ -1945,7 +2159,7 @@ class TestRunner(abc.TestRunner): ) -> T_Retval: if not self._runner_task: self._send_stream, receive_stream = create_memory_object_stream[ - Tuple[Awaitable[Any], asyncio.Future] + tuple[Awaitable[Any], asyncio.Future] ](1) self._runner_task = self.get_loop().create_task( self._run_tests_and_fixtures(receive_stream) @@ -2114,6 +2328,20 @@ class AsyncIOBackend(AsyncBackend): return Event() @classmethod + def create_lock(cls, *, fast_acquire: bool) -> abc.Lock: + return Lock(fast_acquire=fast_acquire) + + @classmethod + def create_semaphore( + cls, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ) -> abc.Semaphore: + return Semaphore(initial_value, max_value=max_value, fast_acquire=fast_acquire) + + @classmethod def create_capacity_limiter(cls, total_tokens: float) -> abc.CapacityLimiter: return CapacityLimiter(total_tokens) @@ -2245,26 +2473,24 @@ class AsyncIOBackend(AsyncBackend): @classmethod async def open_process( cls, - command: str | bytes | Sequence[str | bytes], + command: StrOrBytesPath | Sequence[StrOrBytesPath], *, - shell: bool, stdin: int | IO[Any] | None, stdout: int | IO[Any] | None, stderr: int | IO[Any] | None, - cwd: str | bytes | PathLike | None = None, - env: Mapping[str, str] | None = None, - start_new_session: bool = False, + **kwargs: Any, ) -> Process: await cls.checkpoint() - if shell: + if isinstance(command, PathLike): + command = os.fspath(command) + + if isinstance(command, (str, bytes)): process = await asyncio.create_subprocess_shell( - cast("str | bytes", command), + command, stdin=stdin, stdout=stdout, stderr=stderr, - cwd=cwd, - env=env, - start_new_session=start_new_session, + **kwargs, ) else: process = await asyncio.create_subprocess_exec( @@ -2272,9 +2498,7 @@ class AsyncIOBackend(AsyncBackend): stdin=stdin, stdout=stdout, stderr=stderr, - cwd=cwd, - env=env, - start_new_session=start_new_session, + **kwargs, ) stdin_stream = StreamWriterWrapper(process.stdin) if process.stdin else None @@ -2289,7 +2513,7 @@ class AsyncIOBackend(AsyncBackend): name="AnyIO process pool shutdown task", ) find_root_task().add_done_callback( - partial(_forcibly_shutdown_process_pool_on_exit, workers) + partial(_forcibly_shutdown_process_pool_on_exit, workers) # type:ignore[arg-type] ) @classmethod @@ -2297,7 +2521,7 @@ class AsyncIOBackend(AsyncBackend): cls, host: str, port: int, local_address: IPSockAddrType | None = None ) -> abc.SocketStream: transport, protocol = cast( - Tuple[asyncio.Transport, StreamProtocol], + tuple[asyncio.Transport, StreamProtocol], await get_running_loop().create_connection( StreamProtocol, host, port, local_addr=local_address ), @@ -2476,7 +2700,7 @@ class AsyncIOBackend(AsyncBackend): @classmethod def open_signal_receiver( cls, *signals: Signals - ) -> ContextManager[AsyncIterator[Signals]]: + ) -> AbstractContextManager[AsyncIterator[Signals]]: return _SignalReceiver(signals) @classmethod diff --git a/contrib/python/anyio/anyio/_backends/_trio.py b/contrib/python/anyio/anyio/_backends/_trio.py index cf6f3db789..de2189ce78 100644 --- a/contrib/python/anyio/anyio/_backends/_trio.py +++ b/contrib/python/anyio/anyio/_backends/_trio.py @@ -2,12 +2,23 @@ from __future__ import annotations import array import math +import os import socket import sys import types import weakref -from collections.abc import AsyncIterator, Iterable +from collections.abc import ( + AsyncGenerator, + AsyncIterator, + Awaitable, + Callable, + Collection, + Coroutine, + Iterable, + Sequence, +) from concurrent.futures import Future +from contextlib import AbstractContextManager from dataclasses import dataclass from functools import partial from io import IOBase @@ -18,16 +29,8 @@ from types import TracebackType from typing import ( IO, Any, - AsyncGenerator, - Awaitable, - Callable, - Collection, - ContextManager, - Coroutine, Generic, - Mapping, NoReturn, - Sequence, TypeVar, cast, overload, @@ -45,7 +48,14 @@ from trio.lowlevel import ( from trio.socket import SocketType as TrioSocketType from trio.to_thread import run_sync -from .. import CapacityLimiterStatistics, EventStatistics, TaskInfo, abc +from .. import ( + CapacityLimiterStatistics, + EventStatistics, + LockStatistics, + TaskInfo, + WouldBlock, + abc, +) from .._core._eventloop import claim_worker_thread from .._core._exceptions import ( BrokenResourceError, @@ -55,12 +65,19 @@ from .._core._exceptions import ( ) from .._core._sockets import convert_ipv6_sockaddr from .._core._streams import create_memory_object_stream -from .._core._synchronization import CapacityLimiter as BaseCapacityLimiter +from .._core._synchronization import ( + CapacityLimiter as BaseCapacityLimiter, +) from .._core._synchronization import Event as BaseEvent -from .._core._synchronization import ResourceGuard +from .._core._synchronization import Lock as BaseLock +from .._core._synchronization import ( + ResourceGuard, + SemaphoreStatistics, +) +from .._core._synchronization import Semaphore as BaseSemaphore from .._core._tasks import CancelScope as BaseCancelScope from ..abc import IPSockAddrType, UDPPacketType, UNIXDatagramPacketType -from ..abc._eventloop import AsyncBackend +from ..abc._eventloop import AsyncBackend, StrOrBytesPath from ..streams.memory import MemoryObjectSendStream if sys.version_info >= (3, 10): @@ -637,6 +654,100 @@ class Event(BaseEvent): self.__original.set() +class Lock(BaseLock): + def __new__(cls, *, fast_acquire: bool = False) -> Lock: + return object.__new__(cls) + + def __init__(self, *, fast_acquire: bool = False) -> None: + self._fast_acquire = fast_acquire + self.__original = trio.Lock() + + async def acquire(self) -> None: + if not self._fast_acquire: + await self.__original.acquire() + return + + # This is the "fast path" where we don't let other tasks run + await trio.lowlevel.checkpoint_if_cancelled() + try: + self.__original.acquire_nowait() + except trio.WouldBlock: + await self.__original._lot.park() + + def acquire_nowait(self) -> None: + try: + self.__original.acquire_nowait() + except trio.WouldBlock: + raise WouldBlock from None + + def locked(self) -> bool: + return self.__original.locked() + + def release(self) -> None: + self.__original.release() + + def statistics(self) -> LockStatistics: + orig_statistics = self.__original.statistics() + owner = TrioTaskInfo(orig_statistics.owner) if orig_statistics.owner else None + return LockStatistics( + orig_statistics.locked, owner, orig_statistics.tasks_waiting + ) + + +class Semaphore(BaseSemaphore): + def __new__( + cls, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ) -> Semaphore: + return object.__new__(cls) + + def __init__( + self, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ) -> None: + super().__init__(initial_value, max_value=max_value, fast_acquire=fast_acquire) + self.__original = trio.Semaphore(initial_value, max_value=max_value) + + async def acquire(self) -> None: + if not self._fast_acquire: + await self.__original.acquire() + return + + # This is the "fast path" where we don't let other tasks run + await trio.lowlevel.checkpoint_if_cancelled() + try: + self.__original.acquire_nowait() + except trio.WouldBlock: + await self.__original._lot.park() + + def acquire_nowait(self) -> None: + try: + self.__original.acquire_nowait() + except trio.WouldBlock: + raise WouldBlock from None + + @property + def max_value(self) -> int | None: + return self.__original.max_value + + @property + def value(self) -> int: + return self.__original.value + + def release(self) -> None: + self.__original.release() + + def statistics(self) -> SemaphoreStatistics: + orig_statistics = self.__original.statistics() + return SemaphoreStatistics(orig_statistics.tasks_waiting) + + class CapacityLimiter(BaseCapacityLimiter): def __new__( cls, @@ -916,6 +1027,20 @@ class TrioBackend(AsyncBackend): return Event() @classmethod + def create_lock(cls, *, fast_acquire: bool) -> Lock: + return Lock(fast_acquire=fast_acquire) + + @classmethod + def create_semaphore( + cls, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ) -> abc.Semaphore: + return Semaphore(initial_value, max_value=max_value, fast_acquire=fast_acquire) + + @classmethod def create_capacity_limiter(cls, total_tokens: float) -> CapacityLimiter: return CapacityLimiter(total_tokens) @@ -967,26 +1092,39 @@ class TrioBackend(AsyncBackend): @classmethod async def open_process( cls, - command: str | bytes | Sequence[str | bytes], + command: StrOrBytesPath | Sequence[StrOrBytesPath], *, - shell: bool, stdin: int | IO[Any] | None, stdout: int | IO[Any] | None, stderr: int | IO[Any] | None, - cwd: str | bytes | PathLike | None = None, - env: Mapping[str, str] | None = None, - start_new_session: bool = False, + **kwargs: Any, ) -> Process: - process = await trio.lowlevel.open_process( # type: ignore[misc] - command, # type: ignore[arg-type] - stdin=stdin, - stdout=stdout, - stderr=stderr, - shell=shell, - cwd=cwd, - env=env, - start_new_session=start_new_session, - ) + def convert_item(item: StrOrBytesPath) -> str: + str_or_bytes = os.fspath(item) + if isinstance(str_or_bytes, str): + return str_or_bytes + else: + return os.fsdecode(str_or_bytes) + + if isinstance(command, (str, bytes, PathLike)): + process = await trio.lowlevel.open_process( + convert_item(command), + stdin=stdin, + stdout=stdout, + stderr=stderr, + shell=True, + **kwargs, + ) + else: + process = await trio.lowlevel.open_process( + [convert_item(item) for item in command], + stdin=stdin, + stdout=stdout, + stderr=stderr, + shell=False, + **kwargs, + ) + stdin_stream = SendStreamWrapper(process.stdin) if process.stdin else None stdout_stream = ReceiveStreamWrapper(process.stdout) if process.stdout else None stderr_stream = ReceiveStreamWrapper(process.stderr) if process.stderr else None @@ -1138,7 +1276,7 @@ class TrioBackend(AsyncBackend): @classmethod def open_signal_receiver( cls, *signals: Signals - ) -> ContextManager[AsyncIterator[Signals]]: + ) -> AbstractContextManager[AsyncIterator[Signals]]: return _SignalReceiver(signals) @classmethod diff --git a/contrib/python/anyio/anyio/_core/_exceptions.py b/contrib/python/anyio/anyio/_core/_exceptions.py index 571c3b8531..6e3f8ccc67 100644 --- a/contrib/python/anyio/anyio/_core/_exceptions.py +++ b/contrib/python/anyio/anyio/_core/_exceptions.py @@ -1,5 +1,11 @@ from __future__ import annotations +import sys +from collections.abc import Generator + +if sys.version_info < (3, 11): + from exceptiongroup import BaseExceptionGroup + class BrokenResourceError(Exception): """ @@ -71,3 +77,13 @@ class TypedAttributeLookupError(LookupError): class WouldBlock(Exception): """Raised by ``X_nowait`` functions if ``X()`` would block.""" + + +def iterate_exceptions( + exception: BaseException, +) -> Generator[BaseException, None, None]: + if isinstance(exception, BaseExceptionGroup): + for exc in exception.exceptions: + yield from iterate_exceptions(exc) + else: + yield exception diff --git a/contrib/python/anyio/anyio/_core/_fileio.py b/contrib/python/anyio/anyio/_core/_fileio.py index df2057fe34..23ccb0d66f 100644 --- a/contrib/python/anyio/anyio/_core/_fileio.py +++ b/contrib/python/anyio/anyio/_core/_fileio.py @@ -3,7 +3,7 @@ from __future__ import annotations import os import pathlib import sys -from collections.abc import Callable, Iterable, Iterator, Sequence +from collections.abc import AsyncIterator, Callable, Iterable, Iterator, Sequence from dataclasses import dataclass from functools import partial from os import PathLike @@ -12,7 +12,6 @@ from typing import ( TYPE_CHECKING, Any, AnyStr, - AsyncIterator, Final, Generic, overload, @@ -358,8 +357,26 @@ class Path: def as_uri(self) -> str: return self._path.as_uri() - def match(self, path_pattern: str) -> bool: - return self._path.match(path_pattern) + if sys.version_info >= (3, 13): + parser = pathlib.Path.parser + + @classmethod + def from_uri(cls, uri: str) -> Path: + return Path(pathlib.Path.from_uri(uri)) + + def full_match( + self, path_pattern: str, *, case_sensitive: bool | None = None + ) -> bool: + return self._path.full_match(path_pattern, case_sensitive=case_sensitive) + + def match( + self, path_pattern: str, *, case_sensitive: bool | None = None + ) -> bool: + return self._path.match(path_pattern, case_sensitive=case_sensitive) + else: + + def match(self, path_pattern: str) -> bool: + return self._path.match(path_pattern) def is_relative_to(self, other: str | PathLike[str]) -> bool: try: diff --git a/contrib/python/anyio/anyio/_core/_signals.py b/contrib/python/anyio/anyio/_core/_signals.py index 115c749bd9..f3451d302f 100644 --- a/contrib/python/anyio/anyio/_core/_signals.py +++ b/contrib/python/anyio/anyio/_core/_signals.py @@ -1,13 +1,15 @@ from __future__ import annotations from collections.abc import AsyncIterator +from contextlib import AbstractContextManager from signal import Signals -from typing import ContextManager from ._eventloop import get_async_backend -def open_signal_receiver(*signals: Signals) -> ContextManager[AsyncIterator[Signals]]: +def open_signal_receiver( + *signals: Signals, +) -> AbstractContextManager[AsyncIterator[Signals]]: """ Start receiving operating system signals. diff --git a/contrib/python/anyio/anyio/_core/_sockets.py b/contrib/python/anyio/anyio/_core/_sockets.py index 5e09cdbf0f..6070c647fd 100644 --- a/contrib/python/anyio/anyio/_core/_sockets.py +++ b/contrib/python/anyio/anyio/_core/_sockets.py @@ -680,19 +680,26 @@ async def setup_unix_local_socket( :param socktype: socket.SOCK_STREAM or socket.SOCK_DGRAM """ - path_str: str | bytes | None + path_str: str | None if path is not None: - path_str = os.fspath(path) - - # Copied from pathlib... - try: - stat_result = os.stat(path) - except OSError as e: - if e.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EBADF, errno.ELOOP): - raise - else: - if stat.S_ISSOCK(stat_result.st_mode): - os.unlink(path) + path_str = os.fsdecode(path) + + # Linux abstract namespace sockets aren't backed by a concrete file so skip stat call + if not path_str.startswith("\0"): + # Copied from pathlib... + try: + stat_result = os.stat(path) + except OSError as e: + if e.errno not in ( + errno.ENOENT, + errno.ENOTDIR, + errno.EBADF, + errno.ELOOP, + ): + raise + else: + if stat.S_ISSOCK(stat_result.st_mode): + os.unlink(path) else: path_str = None diff --git a/contrib/python/anyio/anyio/_core/_streams.py b/contrib/python/anyio/anyio/_core/_streams.py index aa6b0c222a..6a9814e5a9 100644 --- a/contrib/python/anyio/anyio/_core/_streams.py +++ b/contrib/python/anyio/anyio/_core/_streams.py @@ -1,7 +1,7 @@ from __future__ import annotations import math -from typing import Tuple, TypeVar +from typing import TypeVar from warnings import warn from ..streams.memory import ( @@ -14,7 +14,7 @@ T_Item = TypeVar("T_Item") class create_memory_object_stream( - Tuple[MemoryObjectSendStream[T_Item], MemoryObjectReceiveStream[T_Item]], + tuple[MemoryObjectSendStream[T_Item], MemoryObjectReceiveStream[T_Item]], ): """ Create a memory object stream. diff --git a/contrib/python/anyio/anyio/_core/_subprocesses.py b/contrib/python/anyio/anyio/_core/_subprocesses.py index 5d5d7b768a..7ba41a5b03 100644 --- a/contrib/python/anyio/anyio/_core/_subprocesses.py +++ b/contrib/python/anyio/anyio/_core/_subprocesses.py @@ -1,26 +1,41 @@ from __future__ import annotations -from collections.abc import AsyncIterable, Mapping, Sequence +import sys +from collections.abc import AsyncIterable, Iterable, Mapping, Sequence from io import BytesIO from os import PathLike from subprocess import DEVNULL, PIPE, CalledProcessError, CompletedProcess -from typing import IO, Any, cast +from typing import IO, Any, Union, cast from ..abc import Process from ._eventloop import get_async_backend from ._tasks import create_task_group +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias + +StrOrBytesPath: TypeAlias = Union[str, bytes, "PathLike[str]", "PathLike[bytes]"] + async def run_process( - command: str | bytes | Sequence[str | bytes], + command: StrOrBytesPath | Sequence[StrOrBytesPath], *, input: bytes | None = None, stdout: int | IO[Any] | None = PIPE, stderr: int | IO[Any] | None = PIPE, check: bool = True, - cwd: str | bytes | PathLike[str] | None = None, + cwd: StrOrBytesPath | None = None, env: Mapping[str, str] | None = None, + startupinfo: Any = None, + creationflags: int = 0, start_new_session: bool = False, + pass_fds: Sequence[int] = (), + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, ) -> CompletedProcess[bytes]: """ Run an external command in a subprocess and wait until it completes. @@ -40,8 +55,20 @@ async def run_process( command :param env: if not ``None``, this mapping replaces the inherited environment variables from the parent process + :param startupinfo: an instance of :class:`subprocess.STARTUPINFO` that can be used + to specify process startup parameters (Windows only) + :param creationflags: flags that can be used to control the creation of the + subprocess (see :class:`subprocess.Popen` for the specifics) :param start_new_session: if ``true`` the setsid() system call will be made in the child process prior to the execution of the subprocess. (POSIX only) + :param pass_fds: sequence of file descriptors to keep open between the parent and + child processes. (POSIX only) + :param user: effective user to run the process as (Python >= 3.9, POSIX only) + :param group: effective group to run the process as (Python >= 3.9, POSIX only) + :param extra_groups: supplementary groups to set in the subprocess (Python >= 3.9, + POSIX only) + :param umask: if not negative, this umask is applied in the child process before + running the given command (Python >= 3.9, POSIX only) :return: an object representing the completed process :raises ~subprocess.CalledProcessError: if ``check`` is ``True`` and the process exits with a nonzero return code @@ -62,7 +89,14 @@ async def run_process( stderr=stderr, cwd=cwd, env=env, + startupinfo=startupinfo, + creationflags=creationflags, start_new_session=start_new_session, + pass_fds=pass_fds, + user=user, + group=group, + extra_groups=extra_groups, + umask=umask, ) as process: stream_contents: list[bytes | None] = [None, None] async with create_task_group() as tg: @@ -86,14 +120,21 @@ async def run_process( async def open_process( - command: str | bytes | Sequence[str | bytes], + command: StrOrBytesPath | Sequence[StrOrBytesPath], *, stdin: int | IO[Any] | None = PIPE, stdout: int | IO[Any] | None = PIPE, stderr: int | IO[Any] | None = PIPE, - cwd: str | bytes | PathLike[str] | None = None, + cwd: StrOrBytesPath | None = None, env: Mapping[str, str] | None = None, + startupinfo: Any = None, + creationflags: int = 0, start_new_session: bool = False, + pass_fds: Sequence[int] = (), + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, ) -> Process: """ Start an external command in a subprocess. @@ -111,30 +152,45 @@ async def open_process( :param cwd: If not ``None``, the working directory is changed before executing :param env: If env is not ``None``, it must be a mapping that defines the environment variables for the new process + :param creationflags: flags that can be used to control the creation of the + subprocess (see :class:`subprocess.Popen` for the specifics) + :param startupinfo: an instance of :class:`subprocess.STARTUPINFO` that can be used + to specify process startup parameters (Windows only) :param start_new_session: if ``true`` the setsid() system call will be made in the child process prior to the execution of the subprocess. (POSIX only) + :param pass_fds: sequence of file descriptors to keep open between the parent and + child processes. (POSIX only) + :param user: effective user to run the process as (POSIX only) + :param group: effective group to run the process as (POSIX only) + :param extra_groups: supplementary groups to set in the subprocess (POSIX only) + :param umask: if not negative, this umask is applied in the child process before + running the given command (POSIX only) :return: an asynchronous process object """ - if isinstance(command, (str, bytes)): - return await get_async_backend().open_process( - command, - shell=True, - stdin=stdin, - stdout=stdout, - stderr=stderr, - cwd=cwd, - env=env, - start_new_session=start_new_session, - ) - else: - return await get_async_backend().open_process( - command, - shell=False, - stdin=stdin, - stdout=stdout, - stderr=stderr, - cwd=cwd, - env=env, - start_new_session=start_new_session, - ) + kwargs: dict[str, Any] = {} + if user is not None: + kwargs["user"] = user + + if group is not None: + kwargs["group"] = group + + if extra_groups is not None: + kwargs["extra_groups"] = group + + if umask >= 0: + kwargs["umask"] = umask + + return await get_async_backend().open_process( + command, + stdin=stdin, + stdout=stdout, + stderr=stderr, + cwd=cwd, + env=env, + startupinfo=startupinfo, + creationflags=creationflags, + start_new_session=start_new_session, + pass_fds=pass_fds, + **kwargs, + ) diff --git a/contrib/python/anyio/anyio/_core/_synchronization.py b/contrib/python/anyio/anyio/_core/_synchronization.py index b274a31ea2..023ab73370 100644 --- a/contrib/python/anyio/anyio/_core/_synchronization.py +++ b/contrib/python/anyio/anyio/_core/_synchronization.py @@ -7,9 +7,9 @@ from types import TracebackType from sniffio import AsyncLibraryNotFoundError -from ..lowlevel import cancel_shielded_checkpoint, checkpoint, checkpoint_if_cancelled +from ..lowlevel import checkpoint from ._eventloop import get_async_backend -from ._exceptions import BusyResourceError, WouldBlock +from ._exceptions import BusyResourceError from ._tasks import CancelScope from ._testing import TaskInfo, get_current_task @@ -137,10 +137,11 @@ class EventAdapter(Event): class Lock: - _owner_task: TaskInfo | None = None - - def __init__(self) -> None: - self._waiters: deque[tuple[TaskInfo, Event]] = deque() + def __new__(cls, *, fast_acquire: bool = False) -> Lock: + try: + return get_async_backend().create_lock(fast_acquire=fast_acquire) + except AsyncLibraryNotFoundError: + return LockAdapter(fast_acquire=fast_acquire) async def __aenter__(self) -> None: await self.acquire() @@ -155,31 +156,7 @@ class Lock: async def acquire(self) -> None: """Acquire the lock.""" - await checkpoint_if_cancelled() - try: - self.acquire_nowait() - except WouldBlock: - task = get_current_task() - event = Event() - token = task, event - self._waiters.append(token) - try: - await event.wait() - except BaseException: - if not event.is_set(): - self._waiters.remove(token) - elif self._owner_task == task: - self.release() - - raise - - assert self._owner_task == task - else: - try: - await cancel_shielded_checkpoint() - except BaseException: - self.release() - raise + raise NotImplementedError def acquire_nowait(self) -> None: """ @@ -188,37 +165,87 @@ class Lock: :raises ~anyio.WouldBlock: if the operation would block """ - task = get_current_task() - if self._owner_task == task: - raise RuntimeError("Attempted to acquire an already held Lock") + raise NotImplementedError + + def release(self) -> None: + """Release the lock.""" + raise NotImplementedError + + def locked(self) -> bool: + """Return True if the lock is currently held.""" + raise NotImplementedError + + def statistics(self) -> LockStatistics: + """ + Return statistics about the current state of this lock. + + .. versionadded:: 3.0 + """ + raise NotImplementedError + + +class LockAdapter(Lock): + _internal_lock: Lock | None = None + + def __new__(cls, *, fast_acquire: bool = False) -> LockAdapter: + return object.__new__(cls) + + def __init__(self, *, fast_acquire: bool = False): + self._fast_acquire = fast_acquire + + @property + def _lock(self) -> Lock: + if self._internal_lock is None: + self._internal_lock = get_async_backend().create_lock( + fast_acquire=self._fast_acquire + ) + + return self._internal_lock + + async def __aenter__(self) -> None: + await self._lock.acquire() + + async def __aexit__( + self, + exc_type: type[BaseException] | None, + exc_val: BaseException | None, + exc_tb: TracebackType | None, + ) -> None: + if self._internal_lock is not None: + self._internal_lock.release() + + async def acquire(self) -> None: + """Acquire the lock.""" + await self._lock.acquire() + + def acquire_nowait(self) -> None: + """ + Acquire the lock, without blocking. - if self._owner_task is not None: - raise WouldBlock + :raises ~anyio.WouldBlock: if the operation would block - self._owner_task = task + """ + self._lock.acquire_nowait() def release(self) -> None: """Release the lock.""" - if self._owner_task != get_current_task(): - raise RuntimeError("The current task is not holding this lock") - - if self._waiters: - self._owner_task, event = self._waiters.popleft() - event.set() - else: - del self._owner_task + self._lock.release() def locked(self) -> bool: """Return True if the lock is currently held.""" - return self._owner_task is not None + return self._lock.locked() def statistics(self) -> LockStatistics: """ Return statistics about the current state of this lock. .. versionadded:: 3.0 + """ - return LockStatistics(self.locked(), self._owner_task, len(self._waiters)) + if self._internal_lock is None: + return LockStatistics(False, None, 0) + + return self._internal_lock.statistics() class Condition: @@ -312,7 +339,27 @@ class Condition: class Semaphore: - def __init__(self, initial_value: int, *, max_value: int | None = None): + def __new__( + cls, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ) -> Semaphore: + try: + return get_async_backend().create_semaphore( + initial_value, max_value=max_value, fast_acquire=fast_acquire + ) + except AsyncLibraryNotFoundError: + return SemaphoreAdapter(initial_value, max_value=max_value) + + def __init__( + self, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ): if not isinstance(initial_value, int): raise TypeError("initial_value must be an integer") if initial_value < 0: @@ -325,9 +372,7 @@ class Semaphore: "max_value must be equal to or higher than initial_value" ) - self._value = initial_value - self._max_value = max_value - self._waiters: deque[Event] = deque() + self._fast_acquire = fast_acquire async def __aenter__(self) -> Semaphore: await self.acquire() @@ -343,27 +388,7 @@ class Semaphore: async def acquire(self) -> None: """Decrement the semaphore value, blocking if necessary.""" - await checkpoint_if_cancelled() - try: - self.acquire_nowait() - except WouldBlock: - event = Event() - self._waiters.append(event) - try: - await event.wait() - except BaseException: - if not event.is_set(): - self._waiters.remove(event) - else: - self.release() - - raise - else: - try: - await cancel_shielded_checkpoint() - except BaseException: - self.release() - raise + raise NotImplementedError def acquire_nowait(self) -> None: """ @@ -372,30 +397,21 @@ class Semaphore: :raises ~anyio.WouldBlock: if the operation would block """ - if self._value == 0: - raise WouldBlock - - self._value -= 1 + raise NotImplementedError def release(self) -> None: """Increment the semaphore value.""" - if self._max_value is not None and self._value == self._max_value: - raise ValueError("semaphore released too many times") - - if self._waiters: - self._waiters.popleft().set() - else: - self._value += 1 + raise NotImplementedError @property def value(self) -> int: """The current value of the semaphore.""" - return self._value + raise NotImplementedError @property def max_value(self) -> int | None: """The maximum value of the semaphore.""" - return self._max_value + raise NotImplementedError def statistics(self) -> SemaphoreStatistics: """ @@ -403,7 +419,66 @@ class Semaphore: .. versionadded:: 3.0 """ - return SemaphoreStatistics(len(self._waiters)) + raise NotImplementedError + + +class SemaphoreAdapter(Semaphore): + _internal_semaphore: Semaphore | None = None + + def __new__( + cls, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ) -> SemaphoreAdapter: + return object.__new__(cls) + + def __init__( + self, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ) -> None: + super().__init__(initial_value, max_value=max_value, fast_acquire=fast_acquire) + self._initial_value = initial_value + self._max_value = max_value + + @property + def _semaphore(self) -> Semaphore: + if self._internal_semaphore is None: + self._internal_semaphore = get_async_backend().create_semaphore( + self._initial_value, max_value=self._max_value + ) + + return self._internal_semaphore + + async def acquire(self) -> None: + await self._semaphore.acquire() + + def acquire_nowait(self) -> None: + self._semaphore.acquire_nowait() + + def release(self) -> None: + self._semaphore.release() + + @property + def value(self) -> int: + if self._internal_semaphore is None: + return self._initial_value + + return self._semaphore.value + + @property + def max_value(self) -> int | None: + return self._max_value + + def statistics(self) -> SemaphoreStatistics: + if self._internal_semaphore is None: + return SemaphoreStatistics(tasks_waiting=0) + + return self._semaphore.statistics() class CapacityLimiter: diff --git a/contrib/python/anyio/anyio/abc/_eventloop.py b/contrib/python/anyio/anyio/abc/_eventloop.py index a50afefaa0..93d0e9d25b 100644 --- a/contrib/python/anyio/anyio/abc/_eventloop.py +++ b/contrib/python/anyio/anyio/abc/_eventloop.py @@ -3,7 +3,8 @@ from __future__ import annotations import math import sys from abc import ABCMeta, abstractmethod -from collections.abc import AsyncIterator, Awaitable, Mapping +from collections.abc import AsyncIterator, Awaitable, Callable, Sequence +from contextlib import AbstractContextManager from os import PathLike from signal import Signals from socket import AddressFamily, SocketKind, socket @@ -11,10 +12,8 @@ from typing import ( IO, TYPE_CHECKING, Any, - Callable, - ContextManager, - Sequence, TypeVar, + Union, overload, ) @@ -23,10 +22,13 @@ if sys.version_info >= (3, 11): else: from typing_extensions import TypeVarTuple, Unpack -if TYPE_CHECKING: - from typing import Literal +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias - from .._core._synchronization import CapacityLimiter, Event +if TYPE_CHECKING: + from .._core._synchronization import CapacityLimiter, Event, Lock, Semaphore from .._core._tasks import CancelScope from .._core._testing import TaskInfo from ..from_thread import BlockingPortal @@ -46,6 +48,7 @@ if TYPE_CHECKING: T_Retval = TypeVar("T_Retval") PosArgsT = TypeVarTuple("PosArgsT") +StrOrBytesPath: TypeAlias = Union[str, bytes, "PathLike[str]", "PathLike[bytes]"] class AsyncBackend(metaclass=ABCMeta): @@ -169,6 +172,22 @@ class AsyncBackend(metaclass=ABCMeta): @classmethod @abstractmethod + def create_lock(cls, *, fast_acquire: bool) -> Lock: + pass + + @classmethod + @abstractmethod + def create_semaphore( + cls, + initial_value: int, + *, + max_value: int | None = None, + fast_acquire: bool = False, + ) -> Semaphore: + pass + + @classmethod + @abstractmethod def create_capacity_limiter(cls, total_tokens: float) -> CapacityLimiter: pass @@ -214,50 +233,15 @@ class AsyncBackend(metaclass=ABCMeta): pass @classmethod - @overload - async def open_process( - cls, - command: str | bytes, - *, - shell: Literal[True], - stdin: int | IO[Any] | None, - stdout: int | IO[Any] | None, - stderr: int | IO[Any] | None, - cwd: str | bytes | PathLike[str] | None = None, - env: Mapping[str, str] | None = None, - start_new_session: bool = False, - ) -> Process: - pass - - @classmethod - @overload - async def open_process( - cls, - command: Sequence[str | bytes], - *, - shell: Literal[False], - stdin: int | IO[Any] | None, - stdout: int | IO[Any] | None, - stderr: int | IO[Any] | None, - cwd: str | bytes | PathLike[str] | None = None, - env: Mapping[str, str] | None = None, - start_new_session: bool = False, - ) -> Process: - pass - - @classmethod @abstractmethod async def open_process( cls, - command: str | bytes | Sequence[str | bytes], + command: StrOrBytesPath | Sequence[StrOrBytesPath], *, - shell: bool, stdin: int | IO[Any] | None, stdout: int | IO[Any] | None, stderr: int | IO[Any] | None, - cwd: str | bytes | PathLike[str] | None = None, - env: Mapping[str, str] | None = None, - start_new_session: bool = False, + **kwargs: Any, ) -> Process: pass @@ -366,7 +350,7 @@ class AsyncBackend(metaclass=ABCMeta): @abstractmethod def open_signal_receiver( cls, *signals: Signals - ) -> ContextManager[AsyncIterator[Signals]]: + ) -> AbstractContextManager[AsyncIterator[Signals]]: pass @classmethod diff --git a/contrib/python/anyio/anyio/abc/_sockets.py b/contrib/python/anyio/anyio/abc/_sockets.py index b321225a7b..1c6a450cdc 100644 --- a/contrib/python/anyio/anyio/abc/_sockets.py +++ b/contrib/python/anyio/anyio/abc/_sockets.py @@ -8,7 +8,7 @@ from io import IOBase from ipaddress import IPv4Address, IPv6Address from socket import AddressFamily from types import TracebackType -from typing import Any, Tuple, TypeVar, Union +from typing import Any, TypeVar, Union from .._core._typedattr import ( TypedAttributeProvider, @@ -19,10 +19,10 @@ from ._streams import ByteStream, Listener, UnreliableObjectStream from ._tasks import TaskGroup IPAddressType = Union[str, IPv4Address, IPv6Address] -IPSockAddrType = Tuple[str, int] +IPSockAddrType = tuple[str, int] SockAddrType = Union[IPSockAddrType, str] -UDPPacketType = Tuple[bytes, IPSockAddrType] -UNIXDatagramPacketType = Tuple[bytes, str] +UDPPacketType = tuple[bytes, IPSockAddrType] +UNIXDatagramPacketType = tuple[bytes, str] T_Retval = TypeVar("T_Retval") diff --git a/contrib/python/anyio/anyio/from_thread.py b/contrib/python/anyio/anyio/from_thread.py index 88a854bb91..93a4cfe8e4 100644 --- a/contrib/python/anyio/anyio/from_thread.py +++ b/contrib/python/anyio/anyio/from_thread.py @@ -1,19 +1,20 @@ from __future__ import annotations import sys -import threading from collections.abc import Awaitable, Callable, Generator -from concurrent.futures import FIRST_COMPLETED, Future, ThreadPoolExecutor, wait -from contextlib import AbstractContextManager, contextmanager +from concurrent.futures import Future +from contextlib import ( + AbstractAsyncContextManager, + AbstractContextManager, + contextmanager, +) from dataclasses import dataclass, field from inspect import isawaitable +from threading import Lock, Thread, get_ident from types import TracebackType from typing import ( Any, - AsyncContextManager, - ContextManager, Generic, - Iterable, TypeVar, cast, overload, @@ -88,7 +89,9 @@ class _BlockingAsyncContextManager(Generic[T_co], AbstractContextManager): type[BaseException] | None, BaseException | None, TracebackType | None ] = (None, None, None) - def __init__(self, async_cm: AsyncContextManager[T_co], portal: BlockingPortal): + def __init__( + self, async_cm: AbstractAsyncContextManager[T_co], portal: BlockingPortal + ): self._async_cm = async_cm self._portal = portal @@ -146,7 +149,7 @@ class BlockingPortal: return get_async_backend().create_blocking_portal() def __init__(self) -> None: - self._event_loop_thread_id: int | None = threading.get_ident() + self._event_loop_thread_id: int | None = get_ident() self._stop_event = Event() self._task_group = create_task_group() self._cancelled_exc_class = get_cancelled_exc_class() @@ -167,7 +170,7 @@ class BlockingPortal: def _check_running(self) -> None: if self._event_loop_thread_id is None: raise RuntimeError("This portal is not running") - if self._event_loop_thread_id == threading.get_ident(): + if self._event_loop_thread_id == get_ident(): raise RuntimeError( "This method cannot be called from the event loop thread" ) @@ -202,7 +205,7 @@ class BlockingPortal: def callback(f: Future[T_Retval]) -> None: if f.cancelled() and self._event_loop_thread_id not in ( None, - threading.get_ident(), + get_ident(), ): self.call(scope.cancel) @@ -375,8 +378,8 @@ class BlockingPortal: return f, task_status_future.result() def wrap_async_context_manager( - self, cm: AsyncContextManager[T_co] - ) -> ContextManager[T_co]: + self, cm: AbstractAsyncContextManager[T_co] + ) -> AbstractContextManager[T_co]: """ Wrap an async context manager as a synchronous context manager via this portal. @@ -411,7 +414,7 @@ class BlockingPortalProvider: backend: str = "asyncio" backend_options: dict[str, Any] | None = None - _lock: threading.Lock = field(init=False, default_factory=threading.Lock) + _lock: Lock = field(init=False, default_factory=Lock) _leases: int = field(init=False, default=0) _portal: BlockingPortal = field(init=False) _portal_cm: AbstractContextManager[BlockingPortal] | None = field( @@ -469,43 +472,37 @@ def start_blocking_portal( async def run_portal() -> None: async with BlockingPortal() as portal_: - if future.set_running_or_notify_cancel(): - future.set_result(portal_) - await portal_.sleep_until_stopped() + future.set_result(portal_) + await portal_.sleep_until_stopped() + + def run_blocking_portal() -> None: + if future.set_running_or_notify_cancel(): + try: + _eventloop.run( + run_portal, backend=backend, backend_options=backend_options + ) + except BaseException as exc: + if not future.done(): + future.set_exception(exc) future: Future[BlockingPortal] = Future() - with ThreadPoolExecutor(1) as executor: - run_future = executor.submit( - _eventloop.run, # type: ignore[arg-type] - run_portal, - backend=backend, - backend_options=backend_options, - ) + thread = Thread(target=run_blocking_portal, daemon=True) + thread.start() + try: + cancel_remaining_tasks = False + portal = future.result() try: - wait( - cast(Iterable[Future], [run_future, future]), - return_when=FIRST_COMPLETED, - ) + yield portal except BaseException: - future.cancel() - run_future.cancel() + cancel_remaining_tasks = True raise - - if future.done(): - portal = future.result() - cancel_remaining_tasks = False + finally: try: - yield portal - except BaseException: - cancel_remaining_tasks = True - raise - finally: - try: - portal.call(portal.stop, cancel_remaining_tasks) - except RuntimeError: - pass - - run_future.result() + portal.call(portal.stop, cancel_remaining_tasks) + except RuntimeError: + pass + finally: + thread.join() def check_cancelled() -> None: diff --git a/contrib/python/anyio/anyio/pytest_plugin.py b/contrib/python/anyio/anyio/pytest_plugin.py index a8dd6f3e3f..c9fe1bde92 100644 --- a/contrib/python/anyio/anyio/pytest_plugin.py +++ b/contrib/python/anyio/anyio/pytest_plugin.py @@ -1,16 +1,22 @@ from __future__ import annotations +import sys from collections.abc import Iterator from contextlib import ExitStack, contextmanager from inspect import isasyncgenfunction, iscoroutinefunction -from typing import Any, Dict, Tuple, cast +from typing import Any, cast import pytest import sniffio +from _pytest.outcomes import Exit from ._core._eventloop import get_all_backends, get_async_backend +from ._core._exceptions import iterate_exceptions from .abc import TestRunner +if sys.version_info < (3, 11): + from exceptiongroup import ExceptionGroup + _current_runner: TestRunner | None = None _runner_stack: ExitStack | None = None _runner_leases = 0 @@ -21,7 +27,7 @@ def extract_backend_and_options(backend: object) -> tuple[str, dict[str, Any]]: return backend, {} elif isinstance(backend, tuple) and len(backend) == 2: if isinstance(backend[0], str) and isinstance(backend[1], dict): - return cast(Tuple[str, Dict[str, Any]], backend) + return cast(tuple[str, dict[str, Any]], backend) raise TypeError("anyio_backend must be either a string or tuple of (string, dict)") @@ -121,7 +127,14 @@ def pytest_pyfunc_call(pyfuncitem: Any) -> bool | None: funcargs = pyfuncitem.funcargs testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames} with get_runner(backend_name, backend_options) as runner: - runner.run_test(pyfuncitem.obj, testargs) + try: + runner.run_test(pyfuncitem.obj, testargs) + except ExceptionGroup as excgrp: + for exc in iterate_exceptions(excgrp): + if isinstance(exc, (Exit, KeyboardInterrupt, SystemExit)): + raise exc from excgrp + + raise return True diff --git a/contrib/python/anyio/anyio/streams/memory.py b/contrib/python/anyio/anyio/streams/memory.py index 6840e6242f..b547aa6a48 100644 --- a/contrib/python/anyio/anyio/streams/memory.py +++ b/contrib/python/anyio/anyio/streams/memory.py @@ -38,6 +38,12 @@ class MemoryObjectItemReceiver(Generic[T_Item]): task_info: TaskInfo = field(init=False, default_factory=get_current_task) item: T_Item = field(init=False) + def __repr__(self) -> str: + # When item is not defined, we get following error with default __repr__: + # AttributeError: 'MemoryObjectItemReceiver' object has no attribute 'item' + item = getattr(self, "item", None) + return f"{self.__class__.__name__}(task_info={self.task_info}, item={item!r})" + @dataclass(eq=False) class MemoryObjectStreamState(Generic[T_Item]): @@ -175,7 +181,7 @@ class MemoryObjectReceiveStream(Generic[T_co], ObjectReceiveStream[T_co]): def __del__(self) -> None: if not self._closed: warnings.warn( - f"Unclosed <{self.__class__.__name__}>", + f"Unclosed <{self.__class__.__name__} at {id(self):x}>", ResourceWarning, source=self, ) @@ -305,7 +311,7 @@ class MemoryObjectSendStream(Generic[T_contra], ObjectSendStream[T_contra]): def __del__(self) -> None: if not self._closed: warnings.warn( - f"Unclosed <{self.__class__.__name__}>", + f"Unclosed <{self.__class__.__name__} at {id(self):x}>", ResourceWarning, source=self, ) diff --git a/contrib/python/anyio/anyio/streams/tls.py b/contrib/python/anyio/anyio/streams/tls.py index e913eedbbf..83240b4d35 100644 --- a/contrib/python/anyio/anyio/streams/tls.py +++ b/contrib/python/anyio/anyio/streams/tls.py @@ -7,7 +7,7 @@ import sys from collections.abc import Callable, Mapping from dataclasses import dataclass from functools import wraps -from typing import Any, Tuple, TypeVar +from typing import Any, TypeVar from .. import ( BrokenResourceError, @@ -25,8 +25,8 @@ else: T_Retval = TypeVar("T_Retval") PosArgsT = TypeVarTuple("PosArgsT") -_PCTRTT = Tuple[Tuple[str, str], ...] -_PCTRTTT = Tuple[_PCTRTT, ...] +_PCTRTT = tuple[tuple[str, str], ...] +_PCTRTTT = tuple[_PCTRTT, ...] class TLSAttribute(TypedAttributeSet): diff --git a/contrib/python/anyio/anyio/to_process.py b/contrib/python/anyio/anyio/to_process.py index 1ff06f0b25..5050dee21e 100644 --- a/contrib/python/anyio/anyio/to_process.py +++ b/contrib/python/anyio/anyio/to_process.py @@ -223,7 +223,7 @@ def process_worker() -> None: main_module_path: str | None sys.path, main_module_path = args del sys.modules["__main__"] - if main_module_path: + if main_module_path and os.path.isfile(main_module_path): # Load the parent's main module but as __mp_main__ instead of # __main__ (like multiprocessing does) to avoid infinite recursion try: @@ -234,7 +234,6 @@ def process_worker() -> None: sys.modules["__main__"] = main except BaseException as exc: exception = exc - try: if exception is not None: status = b"EXCEPTION" diff --git a/contrib/python/anyio/ya.make b/contrib/python/anyio/ya.make index 9062121337..cec445229c 100644 --- a/contrib/python/anyio/ya.make +++ b/contrib/python/anyio/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(4.4.0) +VERSION(4.6.0) LICENSE(MIT) diff --git a/contrib/python/google-auth/py3/.dist-info/METADATA b/contrib/python/google-auth/py3/.dist-info/METADATA index 26b8a4974a..261e2a0276 100644 --- a/contrib/python/google-auth/py3/.dist-info/METADATA +++ b/contrib/python/google-auth/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: google-auth -Version: 2.34.0 +Version: 2.35.0 Summary: Google Authentication Library Home-page: https://github.com/googleapis/google-auth-library-python Author: Google Cloud Platform diff --git a/contrib/python/google-auth/py3/google/auth/_default.py b/contrib/python/google-auth/py3/google/auth/_default.py index 63009dfb86..7bbcf85914 100644 --- a/contrib/python/google-auth/py3/google/auth/_default.py +++ b/contrib/python/google-auth/py3/google/auth/_default.py @@ -237,6 +237,7 @@ def _get_gcloud_sdk_credentials(quota_project_id=None): credentials, project_id = load_credentials_from_file( credentials_filename, quota_project_id=quota_project_id ) + credentials._cred_file_path = credentials_filename if not project_id: project_id = _cloud_sdk.get_project_id() @@ -270,6 +271,7 @@ def _get_explicit_environ_credentials(quota_project_id=None): credentials, project_id = load_credentials_from_file( os.environ[environment_vars.CREDENTIALS], quota_project_id=quota_project_id ) + credentials._cred_file_path = f"{explicit_file} file via the GOOGLE_APPLICATION_CREDENTIALS environment variable" return credentials, project_id diff --git a/contrib/python/google-auth/py3/google/auth/_exponential_backoff.py b/contrib/python/google-auth/py3/google/auth/_exponential_backoff.py index 04f9f97641..89853448f9 100644 --- a/contrib/python/google-auth/py3/google/auth/_exponential_backoff.py +++ b/contrib/python/google-auth/py3/google/auth/_exponential_backoff.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import asyncio import random import time @@ -38,9 +39,8 @@ an HTTP request. """ -class ExponentialBackoff: - """An exponential backoff iterator. This can be used in a for loop to - perform requests with exponential backoff. +class _BaseExponentialBackoff: + """An exponential backoff iterator base class. Args: total_attempts Optional[int]: @@ -84,9 +84,40 @@ class ExponentialBackoff: self._multiplier = multiplier self._backoff_count = 0 - def __iter__(self): + @property + def total_attempts(self): + """The total amount of backoff attempts that will be made.""" + return self._total_attempts + + @property + def backoff_count(self): + """The current amount of backoff attempts that have been made.""" + return self._backoff_count + + def _reset(self): self._backoff_count = 0 self._current_wait_in_seconds = self._initial_wait_seconds + + def _calculate_jitter(self): + jitter_variance = self._current_wait_in_seconds * self._randomization_factor + jitter = random.uniform( + self._current_wait_in_seconds - jitter_variance, + self._current_wait_in_seconds + jitter_variance, + ) + + return jitter + + +class ExponentialBackoff(_BaseExponentialBackoff): + """An exponential backoff iterator. This can be used in a for loop to + perform requests with exponential backoff. + """ + + def __init__(self, *args, **kwargs): + super(ExponentialBackoff, self).__init__(*args, **kwargs) + + def __iter__(self): + self._reset() return self def __next__(self): @@ -97,23 +128,37 @@ class ExponentialBackoff: if self._backoff_count <= 1: return self._backoff_count - jitter_variance = self._current_wait_in_seconds * self._randomization_factor - jitter = random.uniform( - self._current_wait_in_seconds - jitter_variance, - self._current_wait_in_seconds + jitter_variance, - ) + jitter = self._calculate_jitter() time.sleep(jitter) self._current_wait_in_seconds *= self._multiplier return self._backoff_count - @property - def total_attempts(self): - """The total amount of backoff attempts that will be made.""" - return self._total_attempts - @property - def backoff_count(self): - """The current amount of backoff attempts that have been made.""" +class AsyncExponentialBackoff(_BaseExponentialBackoff): + """An async exponential backoff iterator. This can be used in a for loop to + perform async requests with exponential backoff. + """ + + def __init__(self, *args, **kwargs): + super(AsyncExponentialBackoff, self).__init__(*args, **kwargs) + + def __aiter__(self): + self._reset() + return self + + async def __anext__(self): + if self._backoff_count >= self._total_attempts: + raise StopAsyncIteration + self._backoff_count += 1 + + if self._backoff_count <= 1: + return self._backoff_count + + jitter = self._calculate_jitter() + + await asyncio.sleep(jitter) + + self._current_wait_in_seconds *= self._multiplier return self._backoff_count diff --git a/contrib/python/google-auth/py3/google/auth/aio/transport/__init__.py b/contrib/python/google-auth/py3/google/auth/aio/transport/__init__.py new file mode 100644 index 0000000000..166a3be509 --- /dev/null +++ b/contrib/python/google-auth/py3/google/auth/aio/transport/__init__.py @@ -0,0 +1,144 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Transport - Asynchronous HTTP client library support. + +:mod:`google.auth.aio` is designed to work with various asynchronous client libraries such +as aiohttp. In order to work across these libraries with different +interfaces some abstraction is needed. + +This module provides two interfaces that are implemented by transport adapters +to support HTTP libraries. :class:`Request` defines the interface expected by +:mod:`google.auth` to make asynchronous requests. :class:`Response` defines the interface +for the return value of :class:`Request`. +""" + +import abc +from typing import AsyncGenerator, Mapping, Optional + +import google.auth.transport + + +_DEFAULT_TIMEOUT_SECONDS = 180 + +DEFAULT_RETRYABLE_STATUS_CODES = google.auth.transport.DEFAULT_RETRYABLE_STATUS_CODES +"""Sequence[int]: HTTP status codes indicating a request can be retried. +""" + + +DEFAULT_MAX_RETRY_ATTEMPTS = 3 +"""int: How many times to retry a request.""" + + +class Response(metaclass=abc.ABCMeta): + """Asynchronous HTTP Response Interface.""" + + @property + @abc.abstractmethod + def status_code(self) -> int: + """ + The HTTP response status code. + + Returns: + int: The HTTP response status code. + + """ + raise NotImplementedError("status_code must be implemented.") + + @property + @abc.abstractmethod + def headers(self) -> Mapping[str, str]: + """The HTTP response headers. + + Returns: + Mapping[str, str]: The HTTP response headers. + """ + raise NotImplementedError("headers must be implemented.") + + @abc.abstractmethod + async def content(self, chunk_size: int) -> AsyncGenerator[bytes, None]: + """The raw response content. + + Args: + chunk_size (int): The size of each chunk. + + Yields: + AsyncGenerator[bytes, None]: An asynchronous generator yielding + response chunks as bytes. + """ + raise NotImplementedError("content must be implemented.") + + @abc.abstractmethod + async def read(self) -> bytes: + """Read the entire response content as bytes. + + Returns: + bytes: The entire response content. + """ + raise NotImplementedError("read must be implemented.") + + @abc.abstractmethod + async def close(self): + """Close the response after it is fully consumed to resource.""" + raise NotImplementedError("close must be implemented.") + + +class Request(metaclass=abc.ABCMeta): + """Interface for a callable that makes HTTP requests. + + Specific transport implementations should provide an implementation of + this that adapts their specific request / response API. + + .. automethod:: __call__ + """ + + @abc.abstractmethod + async def __call__( + self, + url: str, + method: str, + body: Optional[bytes], + headers: Optional[Mapping[str, str]], + timeout: float, + **kwargs + ) -> Response: + """Make an HTTP request. + + Args: + url (str): The URI to be requested. + method (str): The HTTP method to use for the request. Defaults + to 'GET'. + body (Optional[bytes]): The payload / body in HTTP request. + headers (Mapping[str, str]): Request headers. + timeout (float): The number of seconds to wait for a + response from the server. If not specified or if None, the + transport-specific default timeout will be used. + kwargs: Additional arguments passed on to the transport's + request method. + + Returns: + google.auth.aio.transport.Response: The HTTP response. + + Raises: + google.auth.exceptions.TransportError: If any exception occurred. + """ + # pylint: disable=redundant-returns-doc, missing-raises-doc + # (pylint doesn't play well with abstract docstrings.) + raise NotImplementedError("__call__ must be implemented.") + + async def close(self) -> None: + """ + Close the underlying session. + """ + raise NotImplementedError("close must be implemented.") diff --git a/contrib/python/google-auth/py3/google/auth/aio/transport/aiohttp.py b/contrib/python/google-auth/py3/google/auth/aio/transport/aiohttp.py new file mode 100644 index 0000000000..074d1491c7 --- /dev/null +++ b/contrib/python/google-auth/py3/google/auth/aio/transport/aiohttp.py @@ -0,0 +1,184 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Transport adapter for Asynchronous HTTP Requests based on aiohttp. +""" + +import asyncio +from typing import AsyncGenerator, Mapping, Optional + +try: + import aiohttp # type: ignore +except ImportError as caught_exc: # pragma: NO COVER + raise ImportError( + "The aiohttp library is not installed from please install the aiohttp package to use the aiohttp transport." + ) from caught_exc + +from google.auth import _helpers +from google.auth import exceptions +from google.auth.aio import transport + + +class Response(transport.Response): + """ + Represents an HTTP response and its data. It is returned by ``google.auth.aio.transport.sessions.AsyncAuthorizedSession``. + + Args: + response (aiohttp.ClientResponse): An instance of aiohttp.ClientResponse. + + Attributes: + status_code (int): The HTTP status code of the response. + headers (Mapping[str, str]): The HTTP headers of the response. + """ + + def __init__(self, response: aiohttp.ClientResponse): + self._response = response + + @property + @_helpers.copy_docstring(transport.Response) + def status_code(self) -> int: + return self._response.status + + @property + @_helpers.copy_docstring(transport.Response) + def headers(self) -> Mapping[str, str]: + return {key: value for key, value in self._response.headers.items()} + + @_helpers.copy_docstring(transport.Response) + async def content(self, chunk_size: int = 1024) -> AsyncGenerator[bytes, None]: + try: + async for chunk in self._response.content.iter_chunked( + chunk_size + ): # pragma: no branch + yield chunk + except aiohttp.ClientPayloadError as exc: + raise exceptions.ResponseError( + "Failed to read from the payload stream." + ) from exc + + @_helpers.copy_docstring(transport.Response) + async def read(self) -> bytes: + try: + return await self._response.read() + except aiohttp.ClientResponseError as exc: + raise exceptions.ResponseError("Failed to read the response body.") from exc + + @_helpers.copy_docstring(transport.Response) + async def close(self): + self._response.close() + + +class Request(transport.Request): + """Asynchronous Requests request adapter. + + This class is used internally for making requests using aiohttp + in a consistent way. If you use :class:`google.auth.aio.transport.sessions.AsyncAuthorizedSession` + you do not need to construct or use this class directly. + + This class can be useful if you want to configure a Request callable + with a custom ``aiohttp.ClientSession`` in :class:`AuthorizedSession` or if + you want to manually refresh a :class:`~google.auth.aio.credentials.Credentials` instance:: + + import aiohttp + import google.auth.aio.transport.aiohttp + + # Default example: + request = google.auth.aio.transport.aiohttp.Request() + await credentials.refresh(request) + + # Custom aiohttp Session Example: + session = session=aiohttp.ClientSession(auto_decompress=False) + request = google.auth.aio.transport.aiohttp.Request(session=session) + auth_sesion = google.auth.aio.transport.sessions.AsyncAuthorizedSession(auth_request=request) + + Args: + session (aiohttp.ClientSession): An instance :class:`aiohttp.ClientSession` used + to make HTTP requests. If not specified, a session will be created. + + .. automethod:: __call__ + """ + + def __init__(self, session: aiohttp.ClientSession = None): + self._session = session + self._closed = False + + async def __call__( + self, + url: str, + method: str = "GET", + body: Optional[bytes] = None, + headers: Optional[Mapping[str, str]] = None, + timeout: float = transport._DEFAULT_TIMEOUT_SECONDS, + **kwargs, + ) -> transport.Response: + """ + Make an HTTP request using aiohttp. + + Args: + url (str): The URL to be requested. + method (Optional[str]): + The HTTP method to use for the request. Defaults to 'GET'. + body (Optional[bytes]): + The payload or body in HTTP request. + headers (Optional[Mapping[str, str]]): + Request headers. + timeout (float): The number of seconds to wait for a + response from the server. If not specified or if None, the + requests default timeout will be used. + kwargs: Additional arguments passed through to the underlying + aiohttp :meth:`aiohttp.Session.request` method. + + Returns: + google.auth.aio.transport.Response: The HTTP response. + + Raises: + - google.auth.exceptions.TransportError: If the request fails or if the session is closed. + - google.auth.exceptions.TimeoutError: If the request times out. + """ + + try: + if self._closed: + raise exceptions.TransportError("session is closed.") + + if not self._session: + self._session = aiohttp.ClientSession() + + client_timeout = aiohttp.ClientTimeout(total=timeout) + response = await self._session.request( + method, + url, + data=body, + headers=headers, + timeout=client_timeout, + **kwargs, + ) + return Response(response) + + except aiohttp.ClientError as caught_exc: + client_exc = exceptions.TransportError(f"Failed to send request to {url}.") + raise client_exc from caught_exc + + except asyncio.TimeoutError as caught_exc: + timeout_exc = exceptions.TimeoutError( + f"Request timed out after {timeout} seconds." + ) + raise timeout_exc from caught_exc + + async def close(self) -> None: + """ + Close the underlying aiohttp session to release the acquired resources. + """ + if not self._closed and self._session: + await self._session.close() + self._closed = True diff --git a/contrib/python/google-auth/py3/google/auth/aio/transport/sessions.py b/contrib/python/google-auth/py3/google/auth/aio/transport/sessions.py new file mode 100644 index 0000000000..fea7cbbb2c --- /dev/null +++ b/contrib/python/google-auth/py3/google/auth/aio/transport/sessions.py @@ -0,0 +1,268 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio +from contextlib import asynccontextmanager +import functools +import time +from typing import Mapping, Optional + +from google.auth import _exponential_backoff, exceptions +from google.auth.aio import transport +from google.auth.aio.credentials import Credentials +from google.auth.exceptions import TimeoutError + +try: + from google.auth.aio.transport.aiohttp import Request as AiohttpRequest + + AIOHTTP_INSTALLED = True +except ImportError: # pragma: NO COVER + AIOHTTP_INSTALLED = False + + +@asynccontextmanager +async def timeout_guard(timeout): + """ + timeout_guard is an asynchronous context manager to apply a timeout to an asynchronous block of code. + + Args: + timeout (float): The time in seconds before the context manager times out. + + Raises: + google.auth.exceptions.TimeoutError: If the code within the context exceeds the provided timeout. + + Usage: + async with timeout_guard(10) as with_timeout: + await with_timeout(async_function()) + """ + start = time.monotonic() + total_timeout = timeout + + def _remaining_time(): + elapsed = time.monotonic() - start + remaining = total_timeout - elapsed + if remaining <= 0: + raise TimeoutError( + f"Context manager exceeded the configured timeout of {total_timeout}s." + ) + return remaining + + async def with_timeout(coro): + try: + remaining = _remaining_time() + response = await asyncio.wait_for(coro, remaining) + return response + except (asyncio.TimeoutError, TimeoutError) as e: + raise TimeoutError( + f"The operation {coro} exceeded the configured timeout of {total_timeout}s." + ) from e + + try: + yield with_timeout + + finally: + _remaining_time() + + +class AsyncAuthorizedSession: + """This is an asynchronous implementation of :class:`google.auth.requests.AuthorizedSession` class. + We utilize an instance of a class that implements :class:`google.auth.aio.transport.Request` configured + by the caller or otherwise default to `google.auth.aio.transport.aiohttp.Request` if the external aiohttp + package is installed. + + A Requests Session class with credentials. + + This class is used to perform asynchronous requests to API endpoints that require + authorization:: + + import aiohttp + from google.auth.aio.transport import sessions + + async with sessions.AsyncAuthorizedSession(credentials) as authed_session: + response = await authed_session.request( + 'GET', 'https://www.googleapis.com/storage/v1/b') + + The underlying :meth:`request` implementation handles adding the + credentials' headers to the request and refreshing credentials as needed. + + Args: + credentials (google.auth.aio.credentials.Credentials): + The credentials to add to the request. + auth_request (Optional[google.auth.aio.transport.Request]): + An instance of a class that implements + :class:`~google.auth.aio.transport.Request` used to make requests + and refresh credentials. If not passed, + an instance of :class:`~google.auth.aio.transport.aiohttp.Request` + is created. + + Raises: + - google.auth.exceptions.TransportError: If `auth_request` is `None` + and the external package `aiohttp` is not installed. + - google.auth.exceptions.InvalidType: If the provided credentials are + not of type `google.auth.aio.credentials.Credentials`. + """ + + def __init__( + self, credentials: Credentials, auth_request: Optional[transport.Request] = None + ): + if not isinstance(credentials, Credentials): + raise exceptions.InvalidType( + f"The configured credentials of type {type(credentials)} are invalid and must be of type `google.auth.aio.credentials.Credentials`" + ) + self._credentials = credentials + _auth_request = auth_request + if not _auth_request and AIOHTTP_INSTALLED: + _auth_request = AiohttpRequest() + if _auth_request is None: + raise exceptions.TransportError( + "`auth_request` must either be configured or the external package `aiohttp` must be installed to use the default value." + ) + self._auth_request = _auth_request + + async def request( + self, + method: str, + url: str, + data: Optional[bytes] = None, + headers: Optional[Mapping[str, str]] = None, + max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS, + timeout: float = transport._DEFAULT_TIMEOUT_SECONDS, + **kwargs, + ) -> transport.Response: + """ + Args: + method (str): The http method used to make the request. + url (str): The URI to be requested. + data (Optional[bytes]): The payload or body in HTTP request. + headers (Optional[Mapping[str, str]]): Request headers. + timeout (float): + The amount of time in seconds to wait for the server response + with each individual request. + max_allowed_time (float): + If the method runs longer than this, a ``Timeout`` exception is + automatically raised. Unlike the ``timeout`` parameter, this + value applies to the total method execution time, even if + multiple requests are made under the hood. + + Mind that it is not guaranteed that the timeout error is raised + at ``max_allowed_time``. It might take longer, for example, if + an underlying request takes a lot of time, but the request + itself does not timeout, e.g. if a large file is being + transmitted. The timout error will be raised after such + request completes. + + Returns: + google.auth.aio.transport.Response: The HTTP response. + + Raises: + google.auth.exceptions.TimeoutError: If the method does not complete within + the configured `max_allowed_time` or the request exceeds the configured + `timeout`. + """ + + retries = _exponential_backoff.AsyncExponentialBackoff( + total_attempts=transport.DEFAULT_MAX_RETRY_ATTEMPTS + ) + async with timeout_guard(max_allowed_time) as with_timeout: + await with_timeout( + # Note: before_request will attempt to refresh credentials if expired. + self._credentials.before_request( + self._auth_request, method, url, headers + ) + ) + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for _ in retries: # pragma: no branch + response = await with_timeout( + self._auth_request(url, method, data, headers, timeout, **kwargs) + ) + if response.status_code not in transport.DEFAULT_RETRYABLE_STATUS_CODES: + break + return response + + @functools.wraps(request) + async def get( + self, + url: str, + data: Optional[bytes] = None, + headers: Optional[Mapping[str, str]] = None, + max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS, + timeout: float = transport._DEFAULT_TIMEOUT_SECONDS, + **kwargs, + ) -> transport.Response: + return await self.request( + "GET", url, data, headers, max_allowed_time, timeout, **kwargs + ) + + @functools.wraps(request) + async def post( + self, + url: str, + data: Optional[bytes] = None, + headers: Optional[Mapping[str, str]] = None, + max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS, + timeout: float = transport._DEFAULT_TIMEOUT_SECONDS, + **kwargs, + ) -> transport.Response: + return await self.request( + "POST", url, data, headers, max_allowed_time, timeout, **kwargs + ) + + @functools.wraps(request) + async def put( + self, + url: str, + data: Optional[bytes] = None, + headers: Optional[Mapping[str, str]] = None, + max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS, + timeout: float = transport._DEFAULT_TIMEOUT_SECONDS, + **kwargs, + ) -> transport.Response: + return await self.request( + "PUT", url, data, headers, max_allowed_time, timeout, **kwargs + ) + + @functools.wraps(request) + async def patch( + self, + url: str, + data: Optional[bytes] = None, + headers: Optional[Mapping[str, str]] = None, + max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS, + timeout: float = transport._DEFAULT_TIMEOUT_SECONDS, + **kwargs, + ) -> transport.Response: + return await self.request( + "PATCH", url, data, headers, max_allowed_time, timeout, **kwargs + ) + + @functools.wraps(request) + async def delete( + self, + url: str, + data: Optional[bytes] = None, + headers: Optional[Mapping[str, str]] = None, + max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS, + timeout: float = transport._DEFAULT_TIMEOUT_SECONDS, + **kwargs, + ) -> transport.Response: + return await self.request( + "DELETE", url, data, headers, max_allowed_time, timeout, **kwargs + ) + + async def close(self) -> None: + """ + Close the underlying auth request session. + """ + await self._auth_request.close() diff --git a/contrib/python/google-auth/py3/google/auth/compute_engine/credentials.py b/contrib/python/google-auth/py3/google/auth/compute_engine/credentials.py index 008b991bb9..f0126c0a80 100644 --- a/contrib/python/google-auth/py3/google/auth/compute_engine/credentials.py +++ b/contrib/python/google-auth/py3/google/auth/compute_engine/credentials.py @@ -157,6 +157,14 @@ class Credentials( self._universe_domain_cached = True return self._universe_domain + @_helpers.copy_docstring(credentials.Credentials) + def get_cred_info(self): + return { + "credential_source": "metadata server", + "credential_type": "VM credentials", + "principal": self.service_account_email, + } + @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject) def with_quota_project(self, quota_project_id): creds = self.__class__( diff --git a/contrib/python/google-auth/py3/google/auth/credentials.py b/contrib/python/google-auth/py3/google/auth/credentials.py index e31930311b..2c67e04432 100644 --- a/contrib/python/google-auth/py3/google/auth/credentials.py +++ b/contrib/python/google-auth/py3/google/auth/credentials.py @@ -128,6 +128,17 @@ class Credentials(_BaseCredentials): """The universe domain value.""" return self._universe_domain + def get_cred_info(self): + """The credential information JSON. + + The credential information will be added to auth related error messages + by client library. + + Returns: + Mapping[str, str]: The credential information JSON. + """ + return None + @abc.abstractmethod def refresh(self, request): """Refreshes the access token. diff --git a/contrib/python/google-auth/py3/google/auth/exceptions.py b/contrib/python/google-auth/py3/google/auth/exceptions.py index fcbe61b746..feb9f7411e 100644 --- a/contrib/python/google-auth/py3/google/auth/exceptions.py +++ b/contrib/python/google-auth/py3/google/auth/exceptions.py @@ -98,3 +98,11 @@ class InvalidType(DefaultCredentialsError, TypeError): class OSError(DefaultCredentialsError, EnvironmentError): """Used to wrap EnvironmentError(OSError after python3.3).""" + + +class TimeoutError(GoogleAuthError): + """Used to indicate a timeout error occurred during an HTTP request.""" + + +class ResponseError(GoogleAuthError): + """Used to indicate an error occurred when reading an HTTP response.""" diff --git a/contrib/python/google-auth/py3/google/auth/external_account.py b/contrib/python/google-auth/py3/google/auth/external_account.py index df0511f255..161e6c50ce 100644 --- a/contrib/python/google-auth/py3/google/auth/external_account.py +++ b/contrib/python/google-auth/py3/google/auth/external_account.py @@ -186,6 +186,7 @@ class Credentials( self._supplier_context = SupplierContext( self._subject_token_type, self._audience ) + self._cred_file_path = None if not self.is_workforce_pool and self._workforce_pool_user_project: # Workload identity pools do not support workforce pool user projects. @@ -321,11 +322,24 @@ class Credentials( return self._token_info_url + @_helpers.copy_docstring(credentials.Credentials) + def get_cred_info(self): + if self._cred_file_path: + cred_info_json = { + "credential_source": self._cred_file_path, + "credential_type": "external account credentials", + } + if self.service_account_email: + cred_info_json["principal"] = self.service_account_email + return cred_info_json + return None + @_helpers.copy_docstring(credentials.Scoped) def with_scopes(self, scopes, default_scopes=None): kwargs = self._constructor_args() kwargs.update(scopes=scopes, default_scopes=default_scopes) scoped = self.__class__(**kwargs) + scoped._cred_file_path = self._cred_file_path scoped._metrics_options = self._metrics_options return scoped @@ -442,30 +456,31 @@ class Credentials( self.expiry = now + lifetime - @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject) - def with_quota_project(self, quota_project_id): - # Return copy of instance with the provided quota project ID. + def _make_copy(self): kwargs = self._constructor_args() - kwargs.update(quota_project_id=quota_project_id) new_cred = self.__class__(**kwargs) + new_cred._cred_file_path = self._cred_file_path new_cred._metrics_options = self._metrics_options return new_cred + @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject) + def with_quota_project(self, quota_project_id): + # Return copy of instance with the provided quota project ID. + cred = self._make_copy() + cred._quota_project_id = quota_project_id + return cred + @_helpers.copy_docstring(credentials.CredentialsWithTokenUri) def with_token_uri(self, token_uri): - kwargs = self._constructor_args() - kwargs.update(token_url=token_uri) - new_cred = self.__class__(**kwargs) - new_cred._metrics_options = self._metrics_options - return new_cred + cred = self._make_copy() + cred._token_url = token_uri + return cred @_helpers.copy_docstring(credentials.CredentialsWithUniverseDomain) def with_universe_domain(self, universe_domain): - kwargs = self._constructor_args() - kwargs.update(universe_domain=universe_domain) - new_cred = self.__class__(**kwargs) - new_cred._metrics_options = self._metrics_options - return new_cred + cred = self._make_copy() + cred._universe_domain = universe_domain + return cred def _should_initialize_impersonated_credentials(self): return ( diff --git a/contrib/python/google-auth/py3/google/auth/external_account_authorized_user.py b/contrib/python/google-auth/py3/google/auth/external_account_authorized_user.py index f73387172c..4d0c3c6806 100644 --- a/contrib/python/google-auth/py3/google/auth/external_account_authorized_user.py +++ b/contrib/python/google-auth/py3/google/auth/external_account_authorized_user.py @@ -120,6 +120,7 @@ class Credentials( self._quota_project_id = quota_project_id self._scopes = scopes self._universe_domain = universe_domain or credentials.DEFAULT_UNIVERSE_DOMAIN + self._cred_file_path = None if not self.valid and not self.can_refresh: raise exceptions.InvalidOperation( @@ -290,23 +291,38 @@ class Credentials( def _make_sts_request(self, request): return self._sts_client.refresh_token(request, self._refresh_token) + @_helpers.copy_docstring(credentials.Credentials) + def get_cred_info(self): + if self._cred_file_path: + return { + "credential_source": self._cred_file_path, + "credential_type": "external account authorized user credentials", + } + return None + + def _make_copy(self): + kwargs = self.constructor_args() + cred = self.__class__(**kwargs) + cred._cred_file_path = self._cred_file_path + return cred + @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject) def with_quota_project(self, quota_project_id): - kwargs = self.constructor_args() - kwargs.update(quota_project_id=quota_project_id) - return self.__class__(**kwargs) + cred = self._make_copy() + cred._quota_project_id = quota_project_id + return cred @_helpers.copy_docstring(credentials.CredentialsWithTokenUri) def with_token_uri(self, token_uri): - kwargs = self.constructor_args() - kwargs.update(token_url=token_uri) - return self.__class__(**kwargs) + cred = self._make_copy() + cred._token_url = token_uri + return cred @_helpers.copy_docstring(credentials.CredentialsWithUniverseDomain) def with_universe_domain(self, universe_domain): - kwargs = self.constructor_args() - kwargs.update(universe_domain=universe_domain) - return self.__class__(**kwargs) + cred = self._make_copy() + cred._universe_domain = universe_domain + return cred @classmethod def from_info(cls, info, **kwargs): diff --git a/contrib/python/google-auth/py3/google/auth/impersonated_credentials.py b/contrib/python/google-auth/py3/google/auth/impersonated_credentials.py index 3c6f8712a9..c42a936433 100644 --- a/contrib/python/google-auth/py3/google/auth/impersonated_credentials.py +++ b/contrib/python/google-auth/py3/google/auth/impersonated_credentials.py @@ -226,6 +226,7 @@ class Credentials( self.expiry = _helpers.utcnow() self._quota_project_id = quota_project_id self._iam_endpoint_override = iam_endpoint_override + self._cred_file_path = None def _metric_header_for_usage(self): return metrics.CRED_TYPE_SA_IMPERSONATE @@ -316,29 +317,40 @@ class Credentials( def requires_scopes(self): return not self._target_scopes - @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject) - def with_quota_project(self, quota_project_id): - return self.__class__( + @_helpers.copy_docstring(credentials.Credentials) + def get_cred_info(self): + if self._cred_file_path: + return { + "credential_source": self._cred_file_path, + "credential_type": "impersonated credentials", + "principal": self._target_principal, + } + return None + + def _make_copy(self): + cred = self.__class__( self._source_credentials, target_principal=self._target_principal, target_scopes=self._target_scopes, delegates=self._delegates, lifetime=self._lifetime, - quota_project_id=quota_project_id, + quota_project_id=self._quota_project_id, iam_endpoint_override=self._iam_endpoint_override, ) + cred._cred_file_path = self._cred_file_path + return cred + + @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject) + def with_quota_project(self, quota_project_id): + cred = self._make_copy() + cred._quota_project_id = quota_project_id + return cred @_helpers.copy_docstring(credentials.Scoped) def with_scopes(self, scopes, default_scopes=None): - return self.__class__( - self._source_credentials, - target_principal=self._target_principal, - target_scopes=scopes or default_scopes, - delegates=self._delegates, - lifetime=self._lifetime, - quota_project_id=self._quota_project_id, - iam_endpoint_override=self._iam_endpoint_override, - ) + cred = self._make_copy() + cred._target_scopes = scopes or default_scopes + return cred class IDTokenCredentials(credentials.CredentialsWithQuotaProject): diff --git a/contrib/python/google-auth/py3/google/auth/version.py b/contrib/python/google-auth/py3/google/auth/version.py index 297e18a45f..6610120c69 100644 --- a/contrib/python/google-auth/py3/google/auth/version.py +++ b/contrib/python/google-auth/py3/google/auth/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "2.34.0" +__version__ = "2.35.0" diff --git a/contrib/python/google-auth/py3/google/oauth2/credentials.py b/contrib/python/google-auth/py3/google/oauth2/credentials.py index 5ca00d4c5a..6e158089f3 100644 --- a/contrib/python/google-auth/py3/google/oauth2/credentials.py +++ b/contrib/python/google-auth/py3/google/oauth2/credentials.py @@ -50,6 +50,9 @@ _LOGGER = logging.getLogger(__name__) # The Google OAuth 2.0 token endpoint. Used for authorized user credentials. _GOOGLE_OAUTH2_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token" +# The Google OAuth 2.0 token info endpoint. Used for getting token info JSON from access tokens. +_GOOGLE_OAUTH2_TOKEN_INFO_ENDPOINT = "https://oauth2.googleapis.com/tokeninfo" + class Credentials(credentials.ReadOnlyScoped, credentials.CredentialsWithQuotaProject): """Credentials using OAuth 2.0 access and refresh tokens. @@ -151,6 +154,7 @@ class Credentials(credentials.ReadOnlyScoped, credentials.CredentialsWithQuotaPr self._trust_boundary = trust_boundary self._universe_domain = universe_domain or credentials.DEFAULT_UNIVERSE_DOMAIN self._account = account or "" + self._cred_file_path = None def __getstate__(self): """A __getstate__ method must exist for the __setstate__ to be called @@ -189,6 +193,7 @@ class Credentials(credentials.ReadOnlyScoped, credentials.CredentialsWithQuotaPr self._universe_domain = ( d.get("_universe_domain") or credentials.DEFAULT_UNIVERSE_DOMAIN ) + self._cred_file_path = d.get("_cred_file_path") # The refresh_handler setter should be used to repopulate this. self._refresh_handler = None self._refresh_worker = None @@ -278,10 +283,8 @@ class Credentials(credentials.ReadOnlyScoped, credentials.CredentialsWithQuotaPr """str: The user account associated with the credential. If the account is unknown an empty string is returned.""" return self._account - @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject) - def with_quota_project(self, quota_project_id): - - return self.__class__( + def _make_copy(self): + cred = self.__class__( self.token, refresh_token=self.refresh_token, id_token=self.id_token, @@ -291,34 +294,39 @@ class Credentials(credentials.ReadOnlyScoped, credentials.CredentialsWithQuotaPr scopes=self.scopes, default_scopes=self.default_scopes, granted_scopes=self.granted_scopes, - quota_project_id=quota_project_id, + quota_project_id=self.quota_project_id, rapt_token=self.rapt_token, enable_reauth_refresh=self._enable_reauth_refresh, trust_boundary=self._trust_boundary, universe_domain=self._universe_domain, account=self._account, ) + cred._cred_file_path = self._cred_file_path + return cred + + @_helpers.copy_docstring(credentials.Credentials) + def get_cred_info(self): + if self._cred_file_path: + cred_info = { + "credential_source": self._cred_file_path, + "credential_type": "user credentials", + } + if self.account: + cred_info["principal"] = self.account + return cred_info + return None + + @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject) + def with_quota_project(self, quota_project_id): + cred = self._make_copy() + cred._quota_project_id = quota_project_id + return cred @_helpers.copy_docstring(credentials.CredentialsWithTokenUri) def with_token_uri(self, token_uri): - - return self.__class__( - self.token, - refresh_token=self.refresh_token, - id_token=self.id_token, - token_uri=token_uri, - client_id=self.client_id, - client_secret=self.client_secret, - scopes=self.scopes, - default_scopes=self.default_scopes, - granted_scopes=self.granted_scopes, - quota_project_id=self.quota_project_id, - rapt_token=self.rapt_token, - enable_reauth_refresh=self._enable_reauth_refresh, - trust_boundary=self._trust_boundary, - universe_domain=self._universe_domain, - account=self._account, - ) + cred = self._make_copy() + cred._token_uri = token_uri + return cred def with_account(self, account): """Returns a copy of these credentials with a modified account. @@ -329,45 +337,15 @@ class Credentials(credentials.ReadOnlyScoped, credentials.CredentialsWithQuotaPr Returns: google.oauth2.credentials.Credentials: A new credentials instance. """ - - return self.__class__( - self.token, - refresh_token=self.refresh_token, - id_token=self.id_token, - token_uri=self._token_uri, - client_id=self.client_id, - client_secret=self.client_secret, - scopes=self.scopes, - default_scopes=self.default_scopes, - granted_scopes=self.granted_scopes, - quota_project_id=self.quota_project_id, - rapt_token=self.rapt_token, - enable_reauth_refresh=self._enable_reauth_refresh, - trust_boundary=self._trust_boundary, - universe_domain=self._universe_domain, - account=account, - ) + cred = self._make_copy() + cred._account = account + return cred @_helpers.copy_docstring(credentials.CredentialsWithUniverseDomain) def with_universe_domain(self, universe_domain): - - return self.__class__( - self.token, - refresh_token=self.refresh_token, - id_token=self.id_token, - token_uri=self._token_uri, - client_id=self.client_id, - client_secret=self.client_secret, - scopes=self.scopes, - default_scopes=self.default_scopes, - granted_scopes=self.granted_scopes, - quota_project_id=self.quota_project_id, - rapt_token=self.rapt_token, - enable_reauth_refresh=self._enable_reauth_refresh, - trust_boundary=self._trust_boundary, - universe_domain=universe_domain, - account=self._account, - ) + cred = self._make_copy() + cred._universe_domain = universe_domain + return cred def _metric_header_for_usage(self): return metrics.CRED_TYPE_USER diff --git a/contrib/python/google-auth/py3/google/oauth2/service_account.py b/contrib/python/google-auth/py3/google/oauth2/service_account.py index 0e12868f14..98dafa3e38 100644 --- a/contrib/python/google-auth/py3/google/oauth2/service_account.py +++ b/contrib/python/google-auth/py3/google/oauth2/service_account.py @@ -173,6 +173,7 @@ class Credentials( """ super(Credentials, self).__init__() + self._cred_file_path = None self._scopes = scopes self._default_scopes = default_scopes self._signer = signer @@ -220,7 +221,7 @@ class Credentials( "universe_domain", credentials.DEFAULT_UNIVERSE_DOMAIN ), trust_boundary=info.get("trust_boundary"), - **kwargs + **kwargs, ) @classmethod @@ -294,6 +295,7 @@ class Credentials( always_use_jwt_access=self._always_use_jwt_access, universe_domain=self._universe_domain, ) + cred._cred_file_path = self._cred_file_path return cred @_helpers.copy_docstring(credentials.Scoped) @@ -503,6 +505,16 @@ class Credentials( def signer_email(self): return self._service_account_email + @_helpers.copy_docstring(credentials.Credentials) + def get_cred_info(self): + if self._cred_file_path: + return { + "credential_source": self._cred_file_path, + "credential_type": "service account credentials", + "principal": self.service_account_email, + } + return None + class IDTokenCredentials( credentials.Signing, diff --git a/contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py b/contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py index bb29f8c6e2..662210fa41 100644 --- a/contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py +++ b/contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py @@ -72,6 +72,13 @@ class TestCredentials(object): universe_domain=FAKE_UNIVERSE_DOMAIN, ) + def test_get_cred_info(self): + assert self.credentials.get_cred_info() == { + "credential_source": "metadata server", + "credential_type": "VM credentials", + "principal": "default", + } + def test_default_state(self): assert not self.credentials.valid # Expiration hasn't been set yet diff --git a/contrib/python/google-auth/py3/tests/oauth2/test_credentials.py b/contrib/python/google-auth/py3/tests/oauth2/test_credentials.py index 67b6b9c1ad..a4cac7a463 100644 --- a/contrib/python/google-auth/py3/tests/oauth2/test_credentials.py +++ b/contrib/python/google-auth/py3/tests/oauth2/test_credentials.py @@ -72,6 +72,34 @@ class TestCredentials(object): assert credentials.rapt_token == self.RAPT_TOKEN assert credentials.refresh_handler is None + def test_get_cred_info(self): + credentials = self.make_credentials() + credentials._account = "fake-account" + assert not credentials.get_cred_info() + + credentials._cred_file_path = "/path/to/file" + assert credentials.get_cred_info() == { + "credential_source": "/path/to/file", + "credential_type": "user credentials", + "principal": "fake-account", + } + + def test_get_cred_info_no_account(self): + credentials = self.make_credentials() + assert not credentials.get_cred_info() + + credentials._cred_file_path = "/path/to/file" + assert credentials.get_cred_info() == { + "credential_source": "/path/to/file", + "credential_type": "user credentials", + } + + def test__make_copy_get_cred_info(self): + credentials = self.make_credentials() + credentials._cred_file_path = "/path/to/file" + cred_copy = credentials._make_copy() + assert cred_copy._cred_file_path == "/path/to/file" + def test_token_usage_metrics(self): credentials = self.make_credentials() credentials.token = "token" diff --git a/contrib/python/google-auth/py3/tests/oauth2/test_service_account.py b/contrib/python/google-auth/py3/tests/oauth2/test_service_account.py index 0dbe316a0f..fe02e828e7 100644 --- a/contrib/python/google-auth/py3/tests/oauth2/test_service_account.py +++ b/contrib/python/google-auth/py3/tests/oauth2/test_service_account.py @@ -69,6 +69,23 @@ class TestCredentials(object): universe_domain=universe_domain, ) + def test_get_cred_info(self): + credentials = self.make_credentials() + assert not credentials.get_cred_info() + + credentials._cred_file_path = "/path/to/file" + assert credentials.get_cred_info() == { + "credential_source": "/path/to/file", + "credential_type": "service account credentials", + "principal": "service-account@example.com", + } + + def test__make_copy_get_cred_info(self): + credentials = self.make_credentials() + credentials._cred_file_path = "/path/to/file" + cred_copy = credentials._make_copy() + assert cred_copy._cred_file_path == "/path/to/file" + def test_constructor_no_universe_domain(self): credentials = service_account.Credentials( SIGNER, self.SERVICE_ACCOUNT_EMAIL, self.TOKEN_URI, universe_domain=None diff --git a/contrib/python/google-auth/py3/tests/test__default.py b/contrib/python/google-auth/py3/tests/test__default.py index aaf892f6d0..3147d505da 100644 --- a/contrib/python/google-auth/py3/tests/test__default.py +++ b/contrib/python/google-auth/py3/tests/test__default.py @@ -884,6 +884,38 @@ def test_default_early_out(unused_get): @mock.patch( + "google.auth._default.load_credentials_from_file", + return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id), + autospec=True, +) +def test_default_cred_file_path_env_var(unused_load_cred, monkeypatch): + monkeypatch.setenv(environment_vars.CREDENTIALS, "/path/to/file") + cred, _ = _default.default() + assert ( + cred._cred_file_path + == "/path/to/file file via the GOOGLE_APPLICATION_CREDENTIALS environment variable" + ) + + +@mock.patch("os.path.isfile", return_value=True, autospec=True) +@mock.patch( + "google.auth._cloud_sdk.get_application_default_credentials_path", + return_value="/path/to/adc/file", + autospec=True, +) +@mock.patch( + "google.auth._default.load_credentials_from_file", + return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id), + autospec=True, +) +def test_default_cred_file_path_gcloud( + unused_load_cred, unused_get_adc_file, unused_isfile +): + cred, _ = _default.default() + assert cred._cred_file_path == "/path/to/adc/file" + + +@mock.patch( "google.auth._default._get_explicit_environ_credentials", return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id), autospec=True, diff --git a/contrib/python/google-auth/py3/tests/test__exponential_backoff.py b/contrib/python/google-auth/py3/tests/test__exponential_backoff.py index 95422502b0..b7b6877b2c 100644 --- a/contrib/python/google-auth/py3/tests/test__exponential_backoff.py +++ b/contrib/python/google-auth/py3/tests/test__exponential_backoff.py @@ -54,3 +54,44 @@ def test_minimum_total_attempts(): with pytest.raises(exceptions.InvalidValue): _exponential_backoff.ExponentialBackoff(total_attempts=-1) _exponential_backoff.ExponentialBackoff(total_attempts=1) + + +@pytest.mark.asyncio +@mock.patch("asyncio.sleep", return_value=None) +async def test_exponential_backoff_async(mock_time_async): + eb = _exponential_backoff.AsyncExponentialBackoff() + curr_wait = eb._current_wait_in_seconds + iteration_count = 0 + + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for attempt in eb: # pragma: no branch + if attempt == 1: + assert mock_time_async.call_count == 0 + else: + backoff_interval = mock_time_async.call_args[0][0] + jitter = curr_wait * eb._randomization_factor + + assert (curr_wait - jitter) <= backoff_interval <= (curr_wait + jitter) + assert attempt == iteration_count + 1 + assert eb.backoff_count == iteration_count + 1 + assert eb._current_wait_in_seconds == eb._multiplier ** iteration_count + + curr_wait = eb._current_wait_in_seconds + iteration_count += 1 + + assert eb.total_attempts == _exponential_backoff._DEFAULT_RETRY_TOTAL_ATTEMPTS + assert eb.backoff_count == _exponential_backoff._DEFAULT_RETRY_TOTAL_ATTEMPTS + assert iteration_count == _exponential_backoff._DEFAULT_RETRY_TOTAL_ATTEMPTS + assert ( + mock_time_async.call_count + == _exponential_backoff._DEFAULT_RETRY_TOTAL_ATTEMPTS - 1 + ) + + +def test_minimum_total_attempts_async(): + with pytest.raises(exceptions.InvalidValue): + _exponential_backoff.AsyncExponentialBackoff(total_attempts=0) + with pytest.raises(exceptions.InvalidValue): + _exponential_backoff.AsyncExponentialBackoff(total_attempts=-1) + _exponential_backoff.AsyncExponentialBackoff(total_attempts=1) diff --git a/contrib/python/google-auth/py3/tests/test_credentials.py b/contrib/python/google-auth/py3/tests/test_credentials.py index 8e6bbc9633..e11bcb4e55 100644 --- a/contrib/python/google-auth/py3/tests/test_credentials.py +++ b/contrib/python/google-auth/py3/tests/test_credentials.py @@ -52,6 +52,11 @@ def test_credentials_constructor(): assert not credentials._use_non_blocking_refresh +def test_credentials_get_cred_info(): + credentials = CredentialsImpl() + assert not credentials.get_cred_info() + + def test_with_non_blocking_refresh(): c = CredentialsImpl() c.with_non_blocking_refresh() diff --git a/contrib/python/google-auth/py3/tests/test_external_account.py b/contrib/python/google-auth/py3/tests/test_external_account.py index 3c372e6291..bddcb4afa1 100644 --- a/contrib/python/google-auth/py3/tests/test_external_account.py +++ b/contrib/python/google-auth/py3/tests/test_external_account.py @@ -275,6 +275,31 @@ class TestCredentials(object): assert request_kwargs["headers"] == headers assert "body" not in request_kwargs + def test_get_cred_info(self): + credentials = self.make_credentials() + assert not credentials.get_cred_info() + + credentials._cred_file_path = "/path/to/file" + assert credentials.get_cred_info() == { + "credential_source": "/path/to/file", + "credential_type": "external account credentials", + } + + credentials._service_account_impersonation_url = ( + self.SERVICE_ACCOUNT_IMPERSONATION_URL + ) + assert credentials.get_cred_info() == { + "credential_source": "/path/to/file", + "credential_type": "external account credentials", + "principal": SERVICE_ACCOUNT_EMAIL, + } + + def test__make_copy_get_cred_info(self): + credentials = self.make_credentials() + credentials._cred_file_path = "/path/to/file" + cred_copy = credentials._make_copy() + assert cred_copy._cred_file_path == "/path/to/file" + def test_default_state(self): credentials = self.make_credentials( service_account_impersonation_url=self.SERVICE_ACCOUNT_IMPERSONATION_URL @@ -469,25 +494,29 @@ class TestCredentials(object): with mock.patch.object( external_account.Credentials, "__init__", return_value=None ) as mock_init: - credentials.with_quota_project("project-foo") + new_cred = credentials.with_quota_project("project-foo") - # Confirm with_quota_project initialized the credential with the - # expected parameters and quota project ID. - mock_init.assert_called_once_with( - audience=self.AUDIENCE, - subject_token_type=self.SUBJECT_TOKEN_TYPE, - token_url=self.TOKEN_URL, - token_info_url=self.TOKEN_INFO_URL, - credential_source=self.CREDENTIAL_SOURCE, - service_account_impersonation_url=self.SERVICE_ACCOUNT_IMPERSONATION_URL, - service_account_impersonation_options={"token_lifetime_seconds": 2800}, - client_id=CLIENT_ID, - client_secret=CLIENT_SECRET, - quota_project_id="project-foo", - scopes=self.SCOPES, - default_scopes=["default1"], - universe_domain=DEFAULT_UNIVERSE_DOMAIN, - ) + # Confirm with_quota_project initialized the credential with the + # expected parameters. + mock_init.assert_called_once_with( + audience=self.AUDIENCE, + subject_token_type=self.SUBJECT_TOKEN_TYPE, + token_url=self.TOKEN_URL, + token_info_url=self.TOKEN_INFO_URL, + credential_source=self.CREDENTIAL_SOURCE, + service_account_impersonation_url=self.SERVICE_ACCOUNT_IMPERSONATION_URL, + service_account_impersonation_options={"token_lifetime_seconds": 2800}, + client_id=CLIENT_ID, + client_secret=CLIENT_SECRET, + quota_project_id=self.QUOTA_PROJECT_ID, + scopes=self.SCOPES, + default_scopes=["default1"], + universe_domain=DEFAULT_UNIVERSE_DOMAIN, + ) + + # Confirm with_quota_project sets the correct quota project after + # initialization. + assert new_cred.quota_project_id == "project-foo" def test_info(self): credentials = self.make_credentials(universe_domain="dummy_universe.com") diff --git a/contrib/python/google-auth/py3/tests/test_external_account_authorized_user.py b/contrib/python/google-auth/py3/tests/test_external_account_authorized_user.py index 743ee9c848..93926a1314 100644 --- a/contrib/python/google-auth/py3/tests/test_external_account_authorized_user.py +++ b/contrib/python/google-auth/py3/tests/test_external_account_authorized_user.py @@ -83,6 +83,22 @@ class TestCredentials(object): return request + def test_get_cred_info(self): + credentials = self.make_credentials() + assert not credentials.get_cred_info() + + credentials._cred_file_path = "/path/to/file" + assert credentials.get_cred_info() == { + "credential_source": "/path/to/file", + "credential_type": "external account authorized user credentials", + } + + def test__make_copy_get_cred_info(self): + credentials = self.make_credentials() + credentials._cred_file_path = "/path/to/file" + cred_copy = credentials._make_copy() + assert cred_copy._cred_file_path == "/path/to/file" + def test_default_state(self): creds = self.make_credentials() diff --git a/contrib/python/google-auth/py3/tests/test_impersonated_credentials.py b/contrib/python/google-auth/py3/tests/test_impersonated_credentials.py index 7295bba429..4fb68103a8 100644 --- a/contrib/python/google-auth/py3/tests/test_impersonated_credentials.py +++ b/contrib/python/google-auth/py3/tests/test_impersonated_credentials.py @@ -136,6 +136,23 @@ class TestImpersonatedCredentials(object): iam_endpoint_override=iam_endpoint_override, ) + def test_get_cred_info(self): + credentials = self.make_credentials() + assert not credentials.get_cred_info() + + credentials._cred_file_path = "/path/to/file" + assert credentials.get_cred_info() == { + "credential_source": "/path/to/file", + "credential_type": "impersonated credentials", + "principal": "impersonated@project.iam.gserviceaccount.com", + } + + def test__make_copy_get_cred_info(self): + credentials = self.make_credentials() + credentials._cred_file_path = "/path/to/file" + cred_copy = credentials._make_copy() + assert cred_copy._cred_file_path == "/path/to/file" + def test_make_from_user_credentials(self): credentials = self.make_credentials( source_credentials=self.USER_SOURCE_CREDENTIALS diff --git a/contrib/python/google-auth/py3/tests/transport/aio/test_aiohttp.py b/contrib/python/google-auth/py3/tests/transport/aio/test_aiohttp.py new file mode 100644 index 0000000000..632abff25a --- /dev/null +++ b/contrib/python/google-auth/py3/tests/transport/aio/test_aiohttp.py @@ -0,0 +1,170 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio + +from aioresponses import aioresponses # type: ignore +from mock import AsyncMock, Mock, patch +import pytest # type: ignore +import pytest_asyncio # type: ignore + +from google.auth import exceptions +import google.auth.aio.transport.aiohttp as auth_aiohttp + + +try: + import aiohttp # type: ignore +except ImportError as caught_exc: # pragma: NO COVER + raise ImportError( + "The aiohttp library is not installed from please install the aiohttp package to use the aiohttp transport." + ) from caught_exc + + +@pytest.fixture +def mock_response(): + response = Mock() + response.status = 200 + response.headers = {"Content-Type": "application/json", "Content-Length": "100"} + mock_iterator = AsyncMock() + mock_iterator.__aiter__.return_value = iter( + [b"Cavefish ", b"have ", b"no ", b"sight."] + ) + response.content.iter_chunked = lambda chunk_size: mock_iterator + response.read = AsyncMock(return_value=b"Cavefish have no sight.") + response.close = AsyncMock() + + return auth_aiohttp.Response(response) + + +class TestResponse(object): + @pytest.mark.asyncio + async def test_response_status_code(self, mock_response): + assert mock_response.status_code == 200 + + @pytest.mark.asyncio + async def test_response_headers(self, mock_response): + assert mock_response.headers["Content-Type"] == "application/json" + assert mock_response.headers["Content-Length"] == "100" + + @pytest.mark.asyncio + async def test_response_content(self, mock_response): + content = b"".join([chunk async for chunk in mock_response.content()]) + assert content == b"Cavefish have no sight." + + @pytest.mark.asyncio + async def test_response_content_raises_error(self, mock_response): + with patch.object( + mock_response._response.content, + "iter_chunked", + side_effect=aiohttp.ClientPayloadError, + ): + with pytest.raises(exceptions.ResponseError) as exc: + [chunk async for chunk in mock_response.content()] + exc.match("Failed to read from the payload stream") + + @pytest.mark.asyncio + async def test_response_read(self, mock_response): + content = await mock_response.read() + assert content == b"Cavefish have no sight." + + @pytest.mark.asyncio + async def test_response_read_raises_error(self, mock_response): + with patch.object( + mock_response._response, + "read", + side_effect=aiohttp.ClientResponseError(None, None), + ): + with pytest.raises(exceptions.ResponseError) as exc: + await mock_response.read() + exc.match("Failed to read the response body.") + + @pytest.mark.asyncio + async def test_response_close(self, mock_response): + await mock_response.close() + mock_response._response.close.assert_called_once() + + @pytest.mark.asyncio + async def test_response_content_stream(self, mock_response): + itr = mock_response.content().__aiter__() + content = [] + try: + while True: + chunk = await itr.__anext__() + content.append(chunk) + except StopAsyncIteration: + pass + assert b"".join(content) == b"Cavefish have no sight." + + +@pytest.mark.asyncio +class TestRequest: + @pytest_asyncio.fixture + async def aiohttp_request(self): + request = auth_aiohttp.Request() + yield request + await request.close() + + async def test_request_call_success(self, aiohttp_request): + with aioresponses() as m: + mocked_chunks = [b"Cavefish ", b"have ", b"no ", b"sight."] + mocked_response = b"".join(mocked_chunks) + m.get("http://example.com", status=200, body=mocked_response) + response = await aiohttp_request("http://example.com") + assert response.status_code == 200 + assert response.headers == {"Content-Type": "application/json"} + content = b"".join([chunk async for chunk in response.content()]) + assert content == b"Cavefish have no sight." + + async def test_request_call_success_with_provided_session(self): + mock_session = aiohttp.ClientSession() + request = auth_aiohttp.Request(mock_session) + with aioresponses() as m: + mocked_chunks = [b"Cavefish ", b"have ", b"no ", b"sight."] + mocked_response = b"".join(mocked_chunks) + m.get("http://example.com", status=200, body=mocked_response) + response = await request("http://example.com") + assert response.status_code == 200 + assert response.headers == {"Content-Type": "application/json"} + content = b"".join([chunk async for chunk in response.content()]) + assert content == b"Cavefish have no sight." + + async def test_request_call_raises_client_error(self, aiohttp_request): + with aioresponses() as m: + m.get("http://example.com", exception=aiohttp.ClientError) + + with pytest.raises(exceptions.TransportError) as exc: + await aiohttp_request("http://example.com/api") + + exc.match("Failed to send request to http://example.com/api.") + + async def test_request_call_raises_timeout_error(self, aiohttp_request): + with aioresponses() as m: + m.get("http://example.com", exception=asyncio.TimeoutError) + + with pytest.raises(exceptions.TimeoutError) as exc: + await aiohttp_request("http://example.com") + + exc.match("Request timed out after 180 seconds.") + + async def test_request_call_raises_transport_error_for_closed_session( + self, aiohttp_request + ): + with aioresponses() as m: + m.get("http://example.com", exception=asyncio.TimeoutError) + aiohttp_request._closed = True + with pytest.raises(exceptions.TransportError) as exc: + await aiohttp_request("http://example.com") + + exc.match("session is closed.") + aiohttp_request._closed = False diff --git a/contrib/python/google-auth/py3/tests/transport/aio/test_sessions.py b/contrib/python/google-auth/py3/tests/transport/aio/test_sessions.py new file mode 100644 index 0000000000..c91a7c40ae --- /dev/null +++ b/contrib/python/google-auth/py3/tests/transport/aio/test_sessions.py @@ -0,0 +1,311 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio +from typing import AsyncGenerator + +from aioresponses import aioresponses # type: ignore +from mock import Mock, patch +import pytest # type: ignore + +from google.auth.aio.credentials import AnonymousCredentials +from google.auth.aio.transport import ( + _DEFAULT_TIMEOUT_SECONDS, + DEFAULT_MAX_RETRY_ATTEMPTS, + DEFAULT_RETRYABLE_STATUS_CODES, + Request, + Response, + sessions, +) +from google.auth.exceptions import InvalidType, TimeoutError, TransportError + + +@pytest.fixture +async def simple_async_task(): + return True + + +class MockRequest(Request): + def __init__(self, response=None, side_effect=None): + self._closed = False + self._response = response + self._side_effect = side_effect + self.call_count = 0 + + async def __call__( + self, + url, + method="GET", + body=None, + headers=None, + timeout=_DEFAULT_TIMEOUT_SECONDS, + **kwargs, + ): + self.call_count += 1 + if self._side_effect: + raise self._side_effect + return self._response + + async def close(self): + self._closed = True + return None + + +class MockResponse(Response): + def __init__(self, status_code, headers=None, content=None): + self._status_code = status_code + self._headers = headers + self._content = content + self._close = False + + @property + def status_code(self): + return self._status_code + + @property + def headers(self): + return self._headers + + async def read(self) -> bytes: + content = await self.content(1024) + return b"".join([chunk async for chunk in content]) + + async def content(self, chunk_size=None) -> AsyncGenerator: + return self._content + + async def close(self) -> None: + self._close = True + + +class TestTimeoutGuard(object): + default_timeout = 1 + + def make_timeout_guard(self, timeout): + return sessions.timeout_guard(timeout) + + @pytest.mark.asyncio + async def test_timeout_with_simple_async_task_within_bounds( + self, simple_async_task + ): + task = False + with patch("time.monotonic", side_effect=[0, 0.25, 0.75]): + with patch("asyncio.wait_for", lambda coro, _: coro): + async with self.make_timeout_guard( + timeout=self.default_timeout + ) as with_timeout: + task = await with_timeout(simple_async_task) + + # Task succeeds. + assert task is True + + @pytest.mark.asyncio + async def test_timeout_with_simple_async_task_out_of_bounds( + self, simple_async_task + ): + task = False + with patch("time.monotonic", side_effect=[0, 1, 1]): + with pytest.raises(TimeoutError) as exc: + async with self.make_timeout_guard( + timeout=self.default_timeout + ) as with_timeout: + task = await with_timeout(simple_async_task) + + # Task does not succeed and the context manager times out i.e. no remaining time left. + assert task is False + assert exc.match( + f"Context manager exceeded the configured timeout of {self.default_timeout}s." + ) + + @pytest.mark.asyncio + async def test_timeout_with_async_task_timing_out_before_context( + self, simple_async_task + ): + task = False + with pytest.raises(TimeoutError) as exc: + async with self.make_timeout_guard( + timeout=self.default_timeout + ) as with_timeout: + with patch("asyncio.wait_for", side_effect=asyncio.TimeoutError): + task = await with_timeout(simple_async_task) + + # Task does not complete i.e. the operation times out. + assert task is False + assert exc.match( + f"The operation {simple_async_task} exceeded the configured timeout of {self.default_timeout}s." + ) + + +class TestAsyncAuthorizedSession(object): + TEST_URL = "http://example.com/" + credentials = AnonymousCredentials() + + @pytest.fixture + async def mocked_content(self): + content = [b"Cavefish ", b"have ", b"no ", b"sight."] + for chunk in content: + yield chunk + + @pytest.mark.asyncio + async def test_constructor_with_default_auth_request(self): + with patch("google.auth.aio.transport.sessions.AIOHTTP_INSTALLED", True): + authed_session = sessions.AsyncAuthorizedSession(self.credentials) + assert authed_session._credentials == self.credentials + await authed_session.close() + + @pytest.mark.asyncio + async def test_constructor_with_provided_auth_request(self): + auth_request = MockRequest() + authed_session = sessions.AsyncAuthorizedSession( + self.credentials, auth_request=auth_request + ) + + assert authed_session._auth_request is auth_request + await authed_session.close() + + @pytest.mark.asyncio + async def test_constructor_raises_no_auth_request_error(self): + with patch("google.auth.aio.transport.sessions.AIOHTTP_INSTALLED", False): + with pytest.raises(TransportError) as exc: + sessions.AsyncAuthorizedSession(self.credentials) + + exc.match( + "`auth_request` must either be configured or the external package `aiohttp` must be installed to use the default value." + ) + + @pytest.mark.asyncio + async def test_constructor_raises_incorrect_credentials_error(self): + credentials = Mock() + with pytest.raises(InvalidType) as exc: + sessions.AsyncAuthorizedSession(credentials) + + exc.match( + f"The configured credentials of type {type(credentials)} are invalid and must be of type `google.auth.aio.credentials.Credentials`" + ) + + @pytest.mark.asyncio + async def test_request_default_auth_request_success(self): + with aioresponses() as m: + mocked_chunks = [b"Cavefish ", b"have ", b"no ", b"sight."] + mocked_response = b"".join(mocked_chunks) + m.get(self.TEST_URL, status=200, body=mocked_response) + authed_session = sessions.AsyncAuthorizedSession(self.credentials) + response = await authed_session.request("GET", self.TEST_URL) + assert response.status_code == 200 + assert response.headers == {"Content-Type": "application/json"} + assert await response.read() == b"Cavefish have no sight." + await response.close() + + await authed_session.close() + + @pytest.mark.asyncio + async def test_request_provided_auth_request_success(self, mocked_content): + mocked_response = MockResponse( + status_code=200, + headers={"Content-Type": "application/json"}, + content=mocked_content, + ) + auth_request = MockRequest(mocked_response) + authed_session = sessions.AsyncAuthorizedSession(self.credentials, auth_request) + response = await authed_session.request("GET", self.TEST_URL) + assert response.status_code == 200 + assert response.headers == {"Content-Type": "application/json"} + assert await response.read() == b"Cavefish have no sight." + await response.close() + assert response._close + + await authed_session.close() + + @pytest.mark.asyncio + async def test_request_raises_timeout_error(self): + auth_request = MockRequest(side_effect=asyncio.TimeoutError) + authed_session = sessions.AsyncAuthorizedSession(self.credentials, auth_request) + with pytest.raises(TimeoutError): + await authed_session.request("GET", self.TEST_URL) + + @pytest.mark.asyncio + async def test_request_raises_transport_error(self): + auth_request = MockRequest(side_effect=TransportError) + authed_session = sessions.AsyncAuthorizedSession(self.credentials, auth_request) + with pytest.raises(TransportError): + await authed_session.request("GET", self.TEST_URL) + + @pytest.mark.asyncio + async def test_request_max_allowed_time_exceeded_error(self): + auth_request = MockRequest(side_effect=TransportError) + authed_session = sessions.AsyncAuthorizedSession(self.credentials, auth_request) + with patch("time.monotonic", side_effect=[0, 1, 1]): + with pytest.raises(TimeoutError): + await authed_session.request("GET", self.TEST_URL, max_allowed_time=1) + + @pytest.mark.parametrize("retry_status", DEFAULT_RETRYABLE_STATUS_CODES) + @pytest.mark.asyncio + async def test_request_max_retries(self, retry_status): + mocked_response = MockResponse(status_code=retry_status) + auth_request = MockRequest(mocked_response) + with patch("asyncio.sleep", return_value=None): + authed_session = sessions.AsyncAuthorizedSession( + self.credentials, auth_request + ) + await authed_session.request("GET", self.TEST_URL) + assert auth_request.call_count == DEFAULT_MAX_RETRY_ATTEMPTS + + @pytest.mark.asyncio + async def test_http_get_method_success(self): + expected_payload = b"content is retrieved." + authed_session = sessions.AsyncAuthorizedSession(self.credentials) + with aioresponses() as m: + m.get(self.TEST_URL, status=200, body=expected_payload) + response = await authed_session.get(self.TEST_URL) + assert await response.read() == expected_payload + response = await authed_session.close() + + @pytest.mark.asyncio + async def test_http_post_method_success(self): + expected_payload = b"content is posted." + authed_session = sessions.AsyncAuthorizedSession(self.credentials) + with aioresponses() as m: + m.post(self.TEST_URL, status=200, body=expected_payload) + response = await authed_session.post(self.TEST_URL) + assert await response.read() == expected_payload + response = await authed_session.close() + + @pytest.mark.asyncio + async def test_http_put_method_success(self): + expected_payload = b"content is retrieved." + authed_session = sessions.AsyncAuthorizedSession(self.credentials) + with aioresponses() as m: + m.put(self.TEST_URL, status=200, body=expected_payload) + response = await authed_session.put(self.TEST_URL) + assert await response.read() == expected_payload + response = await authed_session.close() + + @pytest.mark.asyncio + async def test_http_patch_method_success(self): + expected_payload = b"content is retrieved." + authed_session = sessions.AsyncAuthorizedSession(self.credentials) + with aioresponses() as m: + m.patch(self.TEST_URL, status=200, body=expected_payload) + response = await authed_session.patch(self.TEST_URL) + assert await response.read() == expected_payload + response = await authed_session.close() + + @pytest.mark.asyncio + async def test_http_delete_method_success(self): + expected_payload = b"content is deleted." + authed_session = sessions.AsyncAuthorizedSession(self.credentials) + with aioresponses() as m: + m.delete(self.TEST_URL, status=200, body=expected_payload) + response = await authed_session.delete(self.TEST_URL) + assert await response.read() == expected_payload + response = await authed_session.close() diff --git a/contrib/python/google-auth/py3/tests/ya.make b/contrib/python/google-auth/py3/tests/ya.make index 6c6db898c4..23e821bb9a 100644 --- a/contrib/python/google-auth/py3/tests/ya.make +++ b/contrib/python/google-auth/py3/tests/ya.make @@ -9,6 +9,8 @@ PEERDIR( contrib/python/pytest-localserver contrib/python/oauth2client contrib/python/freezegun + contrib/python/aioresponses + contrib/python/pytest-asyncio ) DATA( @@ -22,16 +24,16 @@ PY_SRCS( ) TEST_SRCS( - __init__.py compute_engine/__init__.py - compute_engine/test__metadata.py compute_engine/test_credentials.py + compute_engine/test__metadata.py conftest.py crypt/__init__.py crypt/test__cryptography_rsa.py - crypt/test__python_rsa.py crypt/test_crypt.py crypt/test_es256.py + crypt/test__python_rsa.py + __init__.py oauth2/__init__.py oauth2/test__client.py # oauth2/test_challenges.py - need pyu2f @@ -42,35 +44,38 @@ TEST_SRCS( oauth2/test_service_account.py oauth2/test_sts.py oauth2/test_utils.py - oauth2/test_webauthn_handler.py oauth2/test_webauthn_handler_factory.py + oauth2/test_webauthn_handler.py oauth2/test_webauthn_types.py - test__cloud_sdk.py - test__default.py - test__exponential_backoff.py - test__helpers.py - test__oauth2client.py - test__refresh_worker.py - test__service_account_info.py test_api_key.py test_app_engine.py test_aws.py + test__cloud_sdk.py + test_credentials_async.py test_credentials.py + test__default.py test_downscoped.py test_exceptions.py - test_external_account.py + test__exponential_backoff.py test_external_account_authorized_user.py + test_external_account.py + test__helpers.py test_iam.py test_identity_pool.py test_impersonated_credentials.py test_jwt.py test_metrics.py + test__oauth2client.py test_packaging.py test_pluggable.py + test__refresh_worker.py + test__service_account_info.py + transport/aio/test_aiohttp.py + # transport/aio/test_sessions.py # transport/test__custom_tls_signer.py + transport/test_grpc.py transport/test__http_client.py transport/test__mtls_helper.py - transport/test_grpc.py transport/test_mtls.py # transport/test_requests.py # transport/test_urllib3.py diff --git a/contrib/python/google-auth/py3/ya.make b/contrib/python/google-auth/py3/ya.make index 4f5c4e4ad8..60146f91a4 100644 --- a/contrib/python/google-auth/py3/ya.make +++ b/contrib/python/google-auth/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(2.34.0) +VERSION(2.35.0) LICENSE(Apache-2.0) @@ -20,6 +20,7 @@ NO_LINT() NO_CHECK_IMPORTS( google.auth._oauth2client + google.auth.aio.transport.aiohttp google.auth.transport._aiohttp_requests ) @@ -39,6 +40,9 @@ PY_SRCS( google/auth/_service_account_info.py google/auth/aio/__init__.py google/auth/aio/credentials.py + google/auth/aio/transport/__init__.py + google/auth/aio/transport/aiohttp.py + google/auth/aio/transport/sessions.py google/auth/api_key.py google/auth/app_engine.py google/auth/aws.py diff --git a/contrib/python/idna/py3/.dist-info/METADATA b/contrib/python/idna/py3/.dist-info/METADATA index f7a5e62e40..c42623e942 100644 --- a/contrib/python/idna/py3/.dist-info/METADATA +++ b/contrib/python/idna/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: idna -Version: 3.9 +Version: 3.10 Summary: Internationalized Domain Names in Applications (IDNA) Author-email: Kim Davies <kim+pypi@gumleaf.org> Requires-Python: >=3.6 diff --git a/contrib/python/idna/py3/idna/core.py b/contrib/python/idna/py3/idna/core.py index d303b3835b..9115f123f0 100644 --- a/contrib/python/idna/py3/idna/core.py +++ b/contrib/python/idna/py3/idna/core.py @@ -9,45 +9,6 @@ from .intranges import intranges_contain _virama_combining_class = 9 _alabel_prefix = b"xn--" _unicode_dots_re = re.compile("[\u002e\u3002\uff0e\uff61]") -_ldh = ( - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 95, - 97, - 98, - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, -) class IDNAError(UnicodeError): @@ -380,16 +341,17 @@ def uts46_remap(domain: str, std3_rules: bool = True, transitional: bool = False uts46row = uts46data[code_point if code_point < 256 else bisect.bisect_left(uts46data, (code_point, "Z")) - 1] status = uts46row[1] replacement: Optional[str] = None - if std3_rules and code_point <= 0x7F: - if code_point not in _ldh: - raise InvalidCodepoint( - "Codepoint {} at position {} does not follow STD3 rules".format(_unot(code_point), pos + 1) - ) if len(uts46row) == 3: replacement = uts46row[2] - if status == "V" or (status == "D" and not transitional): + if ( + status == "V" + or (status == "D" and not transitional) + or (status == "3" and not std3_rules and replacement is None) + ): output += char - elif replacement is not None and (status == "M" or (status == "D" and transitional)): + elif replacement is not None and ( + status == "M" or (status == "3" and not std3_rules) or (status == "D" and transitional) + ): output += replacement elif status != "I": raise IndexError() diff --git a/contrib/python/idna/py3/idna/idnadata.py b/contrib/python/idna/py3/idna/idnadata.py index ded47cae0b..4be6004622 100644 --- a/contrib/python/idna/py3/idna/idnadata.py +++ b/contrib/python/idna/py3/idna/idnadata.py @@ -1,7 +1,6 @@ # This file is automatically generated by tools/idna-data -__version__ = "16.0.0" - +__version__ = "15.1.0" scripts = { "Greek": ( 0x37000000374, @@ -728,7 +727,6 @@ joining_types = { 0x88C: 68, 0x88D: 68, 0x88E: 82, - 0x897: 84, 0x898: 84, 0x899: 84, 0x89A: 84, @@ -1875,17 +1873,8 @@ joining_types = { 0x10D25: 84, 0x10D26: 84, 0x10D27: 84, - 0x10D69: 84, - 0x10D6A: 84, - 0x10D6B: 84, - 0x10D6C: 84, - 0x10D6D: 84, 0x10EAB: 84, 0x10EAC: 84, - 0x10EC2: 82, - 0x10EC3: 68, - 0x10EC4: 68, - 0x10EFC: 84, 0x10EFD: 84, 0x10EFE: 84, 0x10EFF: 84, @@ -2064,17 +2053,6 @@ joining_types = { 0x11372: 84, 0x11373: 84, 0x11374: 84, - 0x113BB: 84, - 0x113BC: 84, - 0x113BD: 84, - 0x113BE: 84, - 0x113BF: 84, - 0x113C0: 84, - 0x113CE: 84, - 0x113D0: 84, - 0x113D2: 84, - 0x113E1: 84, - 0x113E2: 84, 0x11438: 84, 0x11439: 84, 0x1143A: 84, @@ -2130,6 +2108,7 @@ joining_types = { 0x116B5: 84, 0x116B7: 84, 0x1171D: 84, + 0x1171E: 84, 0x1171F: 84, 0x11722: 84, 0x11723: 84, @@ -2286,7 +2265,6 @@ joining_types = { 0x11F3A: 84, 0x11F40: 84, 0x11F42: 84, - 0x11F5A: 84, 0x13430: 84, 0x13431: 84, 0x13432: 84, @@ -2319,21 +2297,6 @@ joining_types = { 0x13453: 84, 0x13454: 84, 0x13455: 84, - 0x1611E: 84, - 0x1611F: 84, - 0x16120: 84, - 0x16121: 84, - 0x16122: 84, - 0x16123: 84, - 0x16124: 84, - 0x16125: 84, - 0x16126: 84, - 0x16127: 84, - 0x16128: 84, - 0x16129: 84, - 0x1612D: 84, - 0x1612E: 84, - 0x1612F: 84, 0x16AF0: 84, 0x16AF1: 84, 0x16AF2: 84, @@ -2642,8 +2605,6 @@ joining_types = { 0x1E4ED: 84, 0x1E4EE: 84, 0x1E4EF: 84, - 0x1E5EE: 84, - 0x1E5EF: 84, 0x1E8D0: 84, 0x1E8D1: 84, 0x1E8D2: 84, @@ -3367,7 +3328,7 @@ codepoint_classes = { 0x8600000086B, 0x87000000888, 0x8890000088F, - 0x897000008E2, + 0x898000008E2, 0x8E300000958, 0x96000000964, 0x96600000970, @@ -3602,7 +3563,6 @@ codepoint_classes = { 0x1C0000001C38, 0x1C4000001C4A, 0x1C4D00001C7E, - 0x1C8A00001C8B, 0x1CD000001CD3, 0x1CD400001CFB, 0x1D0000001D2C, @@ -3966,13 +3926,11 @@ codepoint_classes = { 0xA7C30000A7C4, 0xA7C80000A7C9, 0xA7CA0000A7CB, - 0xA7CD0000A7CE, 0xA7D10000A7D2, 0xA7D30000A7D4, 0xA7D50000A7D6, 0xA7D70000A7D8, 0xA7D90000A7DA, - 0xA7DB0000A7DC, 0xA7F60000A7F8, 0xA7FA0000A828, 0xA82C0000A82D, @@ -4042,7 +4000,6 @@ codepoint_classes = { 0x105A3000105B2, 0x105B3000105BA, 0x105BB000105BD, - 0x105C0000105F4, 0x1060000010737, 0x1074000010756, 0x1076000010768, @@ -4080,14 +4037,10 @@ codepoint_classes = { 0x10CC000010CF3, 0x10D0000010D28, 0x10D3000010D3A, - 0x10D4000010D50, - 0x10D6900010D6E, - 0x10D6F00010D86, 0x10E8000010EAA, 0x10EAB00010EAD, 0x10EB000010EB2, - 0x10EC200010EC5, - 0x10EFC00010F1D, + 0x10EFD00010F1D, 0x10F2700010F28, 0x10F3000010F51, 0x10F7000010F86, @@ -4133,16 +4086,6 @@ codepoint_classes = { 0x1135D00011364, 0x113660001136D, 0x1137000011375, - 0x113800001138A, - 0x1138B0001138C, - 0x1138E0001138F, - 0x11390000113B6, - 0x113B7000113C1, - 0x113C2000113C3, - 0x113C5000113C6, - 0x113C7000113CB, - 0x113CC000113D4, - 0x113E1000113E3, 0x114000001144B, 0x114500001145A, 0x1145E00011462, @@ -4157,7 +4100,6 @@ codepoint_classes = { 0x116500001165A, 0x11680000116B9, 0x116C0000116CA, - 0x116D0000116E4, 0x117000001171B, 0x1171D0001172C, 0x117300001173A, @@ -4181,8 +4123,6 @@ codepoint_classes = { 0x11A5000011A9A, 0x11A9D00011A9E, 0x11AB000011AF9, - 0x11BC000011BE1, - 0x11BF000011BFA, 0x11C0000011C09, 0x11C0A00011C37, 0x11C3800011C41, @@ -4207,16 +4147,14 @@ codepoint_classes = { 0x11F0000011F11, 0x11F1200011F3B, 0x11F3E00011F43, - 0x11F5000011F5B, + 0x11F5000011F5A, 0x11FB000011FB1, 0x120000001239A, 0x1248000012544, 0x12F9000012FF1, 0x1300000013430, 0x1344000013456, - 0x13460000143FB, 0x1440000014647, - 0x161000001613A, 0x1680000016A39, 0x16A4000016A5F, 0x16A6000016A6A, @@ -4229,8 +4167,6 @@ codepoint_classes = { 0x16B5000016B5A, 0x16B6300016B78, 0x16B7D00016B90, - 0x16D4000016D6D, - 0x16D7000016D7A, 0x16E6000016E80, 0x16F0000016F4B, 0x16F4F00016F88, @@ -4240,7 +4176,7 @@ codepoint_classes = { 0x16FF000016FF2, 0x17000000187F8, 0x1880000018CD6, - 0x18CFF00018D09, + 0x18D0000018D09, 0x1AFF00001AFF4, 0x1AFF50001AFFC, 0x1AFFD0001AFFF, @@ -4255,7 +4191,6 @@ codepoint_classes = { 0x1BC800001BC89, 0x1BC900001BC9A, 0x1BC9D0001BC9F, - 0x1CCF00001CCFA, 0x1CF000001CF2E, 0x1CF300001CF47, 0x1DA000001DA37, @@ -4279,7 +4214,6 @@ codepoint_classes = { 0x1E2900001E2AF, 0x1E2C00001E2FA, 0x1E4D00001E4FA, - 0x1E5D00001E5FB, 0x1E7E00001E7E7, 0x1E7E80001E7EC, 0x1E7ED0001E7EF, diff --git a/contrib/python/idna/py3/idna/package_data.py b/contrib/python/idna/py3/idna/package_data.py index ddd1e6912e..514ff7e2e6 100644 --- a/contrib/python/idna/py3/idna/package_data.py +++ b/contrib/python/idna/py3/idna/package_data.py @@ -1 +1 @@ -__version__ = "3.9" +__version__ = "3.10" diff --git a/contrib/python/idna/py3/idna/uts46data.py b/contrib/python/idna/py3/idna/uts46data.py index 4610b71dad..eb89432741 100644 --- a/contrib/python/idna/py3/idna/uts46data.py +++ b/contrib/python/idna/py3/idna/uts46data.py @@ -6,59 +6,59 @@ from typing import List, Tuple, Union """IDNA Mapping Table from UTS46.""" -__version__ = "16.0.0" +__version__ = "15.1.0" def _seg_0() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: return [ - (0x0, "V"), - (0x1, "V"), - (0x2, "V"), - (0x3, "V"), - (0x4, "V"), - (0x5, "V"), - (0x6, "V"), - (0x7, "V"), - (0x8, "V"), - (0x9, "V"), - (0xA, "V"), - (0xB, "V"), - (0xC, "V"), - (0xD, "V"), - (0xE, "V"), - (0xF, "V"), - (0x10, "V"), - (0x11, "V"), - (0x12, "V"), - (0x13, "V"), - (0x14, "V"), - (0x15, "V"), - (0x16, "V"), - (0x17, "V"), - (0x18, "V"), - (0x19, "V"), - (0x1A, "V"), - (0x1B, "V"), - (0x1C, "V"), - (0x1D, "V"), - (0x1E, "V"), - (0x1F, "V"), - (0x20, "V"), - (0x21, "V"), - (0x22, "V"), - (0x23, "V"), - (0x24, "V"), - (0x25, "V"), - (0x26, "V"), - (0x27, "V"), - (0x28, "V"), - (0x29, "V"), - (0x2A, "V"), - (0x2B, "V"), - (0x2C, "V"), + (0x0, "3"), + (0x1, "3"), + (0x2, "3"), + (0x3, "3"), + (0x4, "3"), + (0x5, "3"), + (0x6, "3"), + (0x7, "3"), + (0x8, "3"), + (0x9, "3"), + (0xA, "3"), + (0xB, "3"), + (0xC, "3"), + (0xD, "3"), + (0xE, "3"), + (0xF, "3"), + (0x10, "3"), + (0x11, "3"), + (0x12, "3"), + (0x13, "3"), + (0x14, "3"), + (0x15, "3"), + (0x16, "3"), + (0x17, "3"), + (0x18, "3"), + (0x19, "3"), + (0x1A, "3"), + (0x1B, "3"), + (0x1C, "3"), + (0x1D, "3"), + (0x1E, "3"), + (0x1F, "3"), + (0x20, "3"), + (0x21, "3"), + (0x22, "3"), + (0x23, "3"), + (0x24, "3"), + (0x25, "3"), + (0x26, "3"), + (0x27, "3"), + (0x28, "3"), + (0x29, "3"), + (0x2A, "3"), + (0x2B, "3"), + (0x2C, "3"), (0x2D, "V"), (0x2E, "V"), - (0x2F, "V"), + (0x2F, "3"), (0x30, "V"), (0x31, "V"), (0x32, "V"), @@ -69,13 +69,13 @@ def _seg_0() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x37, "V"), (0x38, "V"), (0x39, "V"), - (0x3A, "V"), - (0x3B, "V"), - (0x3C, "V"), - (0x3D, "V"), - (0x3E, "V"), - (0x3F, "V"), - (0x40, "V"), + (0x3A, "3"), + (0x3B, "3"), + (0x3C, "3"), + (0x3D, "3"), + (0x3E, "3"), + (0x3F, "3"), + (0x40, "3"), (0x41, "M", "a"), (0x42, "M", "b"), (0x43, "M", "c"), @@ -102,12 +102,12 @@ def _seg_0() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x58, "M", "x"), (0x59, "M", "y"), (0x5A, "M", "z"), - (0x5B, "V"), - (0x5C, "V"), - (0x5D, "V"), - (0x5E, "V"), - (0x5F, "V"), - (0x60, "V"), + (0x5B, "3"), + (0x5C, "3"), + (0x5D, "3"), + (0x5E, "3"), + (0x5F, "3"), + (0x60, "3"), (0x61, "V"), (0x62, "V"), (0x63, "V"), @@ -139,11 +139,11 @@ def _seg_1() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x78, "V"), (0x79, "V"), (0x7A, "V"), - (0x7B, "V"), - (0x7C, "V"), - (0x7D, "V"), - (0x7E, "V"), - (0x7F, "V"), + (0x7B, "3"), + (0x7C, "3"), + (0x7D, "3"), + (0x7E, "3"), + (0x7F, "3"), (0x80, "X"), (0x81, "X"), (0x82, "X"), @@ -176,7 +176,7 @@ def _seg_1() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x9D, "X"), (0x9E, "X"), (0x9F, "X"), - (0xA0, "M", " "), + (0xA0, "3", " "), (0xA1, "V"), (0xA2, "V"), (0xA3, "V"), @@ -184,23 +184,23 @@ def _seg_1() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xA5, "V"), (0xA6, "V"), (0xA7, "V"), - (0xA8, "M", " ̈"), + (0xA8, "3", " ̈"), (0xA9, "V"), (0xAA, "M", "a"), (0xAB, "V"), (0xAC, "V"), (0xAD, "I"), (0xAE, "V"), - (0xAF, "M", " ̄"), + (0xAF, "3", " ̄"), (0xB0, "V"), (0xB1, "V"), (0xB2, "M", "2"), (0xB3, "M", "3"), - (0xB4, "M", " ́"), + (0xB4, "3", " ́"), (0xB5, "M", "μ"), (0xB6, "V"), (0xB7, "V"), - (0xB8, "M", " ̧"), + (0xB8, "3", " ̧"), (0xB9, "M", "1"), (0xBA, "M", "o"), (0xBB, "V"), @@ -606,12 +606,12 @@ def _seg_5() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2B7, "M", "w"), (0x2B8, "M", "y"), (0x2B9, "V"), - (0x2D8, "M", " ̆"), - (0x2D9, "M", " ̇"), - (0x2DA, "M", " ̊"), - (0x2DB, "M", " ̨"), - (0x2DC, "M", " ̃"), - (0x2DD, "M", " ̋"), + (0x2D8, "3", " ̆"), + (0x2D9, "3", " ̇"), + (0x2DA, "3", " ̊"), + (0x2DB, "3", " ̨"), + (0x2DC, "3", " ̃"), + (0x2DD, "3", " ̋"), (0x2DE, "V"), (0x2E0, "M", "ɣ"), (0x2E1, "M", "l"), @@ -642,13 +642,13 @@ def _seg_5() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: def _seg_6() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: return [ (0x378, "X"), - (0x37A, "M", " ι"), + (0x37A, "3", " ι"), (0x37B, "V"), - (0x37E, "M", ";"), + (0x37E, "3", ";"), (0x37F, "M", "ϳ"), (0x380, "X"), - (0x384, "M", " ́"), - (0x385, "M", " ̈́"), + (0x384, "3", " ́"), + (0x385, "3", " ̈́"), (0x386, "M", "ά"), (0x387, "M", "·"), (0x388, "M", "έ"), @@ -885,7 +885,7 @@ def _seg_8() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x4BD, "V"), (0x4BE, "M", "ҿ"), (0x4BF, "V"), - (0x4C0, "M", "ӏ"), + (0x4C0, "X"), (0x4C1, "M", "ӂ"), (0x4C2, "V"), (0x4C3, "M", "ӄ"), @@ -1087,7 +1087,7 @@ def _seg_10() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x86B, "X"), (0x870, "V"), (0x88F, "X"), - (0x897, "V"), + (0x898, "V"), (0x8E2, "X"), (0x8E3, "V"), (0x958, "M", "क़"), @@ -1438,50 +1438,7 @@ def _seg_13() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFCE, "V"), (0xFDB, "X"), (0x1000, "V"), - (0x10A0, "M", "ⴀ"), - (0x10A1, "M", "ⴁ"), - (0x10A2, "M", "ⴂ"), - (0x10A3, "M", "ⴃ"), - (0x10A4, "M", "ⴄ"), - (0x10A5, "M", "ⴅ"), - (0x10A6, "M", "ⴆ"), - (0x10A7, "M", "ⴇ"), - (0x10A8, "M", "ⴈ"), - (0x10A9, "M", "ⴉ"), - (0x10AA, "M", "ⴊ"), - (0x10AB, "M", "ⴋ"), - (0x10AC, "M", "ⴌ"), - (0x10AD, "M", "ⴍ"), - (0x10AE, "M", "ⴎ"), - (0x10AF, "M", "ⴏ"), - (0x10B0, "M", "ⴐ"), - (0x10B1, "M", "ⴑ"), - (0x10B2, "M", "ⴒ"), - (0x10B3, "M", "ⴓ"), - (0x10B4, "M", "ⴔ"), - (0x10B5, "M", "ⴕ"), - (0x10B6, "M", "ⴖ"), - (0x10B7, "M", "ⴗ"), - (0x10B8, "M", "ⴘ"), - (0x10B9, "M", "ⴙ"), - (0x10BA, "M", "ⴚ"), - (0x10BB, "M", "ⴛ"), - (0x10BC, "M", "ⴜ"), - (0x10BD, "M", "ⴝ"), - (0x10BE, "M", "ⴞ"), - (0x10BF, "M", "ⴟ"), - (0x10C0, "M", "ⴠ"), - (0x10C1, "M", "ⴡ"), - (0x10C2, "M", "ⴢ"), - (0x10C3, "M", "ⴣ"), - (0x10C4, "M", "ⴤ"), - (0x10C5, "M", "ⴥ"), - ] - - -def _seg_14() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ - (0x10C6, "X"), + (0x10A0, "X"), (0x10C7, "M", "ⴧ"), (0x10C8, "X"), (0x10CD, "M", "ⴭ"), @@ -1489,7 +1446,7 @@ def _seg_14() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x10D0, "V"), (0x10FC, "M", "ნ"), (0x10FD, "V"), - (0x115F, "I"), + (0x115F, "X"), (0x1161, "V"), (0x1249, "X"), (0x124A, "V"), @@ -1519,6 +1476,11 @@ def _seg_14() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x12D8, "V"), (0x1311, "X"), (0x1312, "V"), + ] + + +def _seg_14() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1316, "X"), (0x1318, "V"), (0x135B, "X"), @@ -1554,7 +1516,7 @@ def _seg_14() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1772, "V"), (0x1774, "X"), (0x1780, "V"), - (0x17B4, "I"), + (0x17B4, "X"), (0x17B6, "V"), (0x17DE, "X"), (0x17E0, "V"), @@ -1562,7 +1524,11 @@ def _seg_14() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x17F0, "V"), (0x17FA, "X"), (0x1800, "V"), + (0x1806, "X"), + (0x1807, "V"), (0x180B, "I"), + (0x180E, "X"), + (0x180F, "I"), (0x1810, "V"), (0x181A, "X"), (0x1820, "V"), @@ -1581,11 +1547,6 @@ def _seg_14() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1941, "X"), (0x1944, "V"), (0x196E, "X"), - ] - - -def _seg_15() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1970, "V"), (0x1975, "X"), (0x1980, "V"), @@ -1610,7 +1571,9 @@ def _seg_15() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1ACF, "X"), (0x1B00, "V"), (0x1B4D, "X"), - (0x1B4E, "V"), + (0x1B50, "V"), + (0x1B7F, "X"), + (0x1B80, "V"), (0x1BF4, "X"), (0x1BFC, "V"), (0x1C38, "X"), @@ -1618,6 +1581,11 @@ def _seg_15() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1C4A, "X"), (0x1C4D, "V"), (0x1C80, "M", "в"), + ] + + +def _seg_15() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1C81, "M", "д"), (0x1C82, "M", "о"), (0x1C83, "M", "с"), @@ -1625,9 +1593,7 @@ def _seg_15() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1C86, "M", "ъ"), (0x1C87, "M", "ѣ"), (0x1C88, "M", "ꙋ"), - (0x1C89, "M", ""), - (0x1C8A, "V"), - (0x1C8B, "X"), + (0x1C89, "X"), (0x1C90, "M", "ა"), (0x1C91, "M", "ბ"), (0x1C92, "M", "გ"), @@ -1686,11 +1652,6 @@ def _seg_15() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D2F, "V"), (0x1D30, "M", "d"), (0x1D31, "M", "e"), - ] - - -def _seg_16() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D32, "M", "ǝ"), (0x1D33, "M", "g"), (0x1D34, "M", "h"), @@ -1725,6 +1686,11 @@ def _seg_16() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D51, "M", "ŋ"), (0x1D52, "M", "o"), (0x1D53, "M", "ɔ"), + ] + + +def _seg_16() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D54, "M", "ᴖ"), (0x1D55, "M", "ᴗ"), (0x1D56, "M", "p"), @@ -1791,11 +1757,6 @@ def _seg_16() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1DC0, "V"), (0x1E00, "M", "ḁ"), (0x1E01, "V"), - ] - - -def _seg_17() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1E02, "M", "ḃ"), (0x1E03, "V"), (0x1E04, "M", "ḅ"), @@ -1830,6 +1791,11 @@ def _seg_17() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1E21, "V"), (0x1E22, "M", "ḣ"), (0x1E23, "V"), + ] + + +def _seg_17() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1E24, "M", "ḥ"), (0x1E25, "V"), (0x1E26, "M", "ḧ"), @@ -1896,11 +1862,6 @@ def _seg_17() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1E63, "V"), (0x1E64, "M", "ṥ"), (0x1E65, "V"), - ] - - -def _seg_18() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1E66, "M", "ṧ"), (0x1E67, "V"), (0x1E68, "M", "ṩ"), @@ -1935,6 +1896,11 @@ def _seg_18() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1E85, "V"), (0x1E86, "M", "ẇ"), (0x1E87, "V"), + ] + + +def _seg_18() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1E88, "M", "ẉ"), (0x1E89, "V"), (0x1E8A, "M", "ẋ"), @@ -2001,11 +1967,6 @@ def _seg_18() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1ECC, "M", "ọ"), (0x1ECD, "V"), (0x1ECE, "M", "ỏ"), - ] - - -def _seg_19() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1ECF, "V"), (0x1ED0, "M", "ố"), (0x1ED1, "V"), @@ -2040,6 +2001,11 @@ def _seg_19() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1EEE, "M", "ữ"), (0x1EEF, "V"), (0x1EF0, "M", "ự"), + ] + + +def _seg_19() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1EF1, "V"), (0x1EF2, "M", "ỳ"), (0x1EF3, "V"), @@ -2106,11 +2072,6 @@ def _seg_19() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1F5B, "M", "ὓ"), (0x1F5C, "X"), (0x1F5D, "M", "ὕ"), - ] - - -def _seg_20() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1F5E, "X"), (0x1F5F, "M", "ὗ"), (0x1F60, "V"), @@ -2145,6 +2106,11 @@ def _seg_20() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1F85, "M", "ἅι"), (0x1F86, "M", "ἆι"), (0x1F87, "M", "ἇι"), + ] + + +def _seg_20() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1F88, "M", "ἀι"), (0x1F89, "M", "ἁι"), (0x1F8A, "M", "ἂι"), @@ -2197,11 +2163,11 @@ def _seg_20() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1FBA, "M", "ὰ"), (0x1FBB, "M", "ά"), (0x1FBC, "M", "αι"), - (0x1FBD, "M", " ̓"), + (0x1FBD, "3", " ̓"), (0x1FBE, "M", "ι"), - (0x1FBF, "M", " ̓"), - (0x1FC0, "M", " ͂"), - (0x1FC1, "M", " ̈͂"), + (0x1FBF, "3", " ̓"), + (0x1FC0, "3", " ͂"), + (0x1FC1, "3", " ̈͂"), (0x1FC2, "M", "ὴι"), (0x1FC3, "M", "ηι"), (0x1FC4, "M", "ήι"), @@ -2211,16 +2177,11 @@ def _seg_20() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1FC8, "M", "ὲ"), (0x1FC9, "M", "έ"), (0x1FCA, "M", "ὴ"), - ] - - -def _seg_21() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1FCB, "M", "ή"), (0x1FCC, "M", "ηι"), - (0x1FCD, "M", " ̓̀"), - (0x1FCE, "M", " ̓́"), - (0x1FCF, "M", " ̓͂"), + (0x1FCD, "3", " ̓̀"), + (0x1FCE, "3", " ̓́"), + (0x1FCF, "3", " ̓͂"), (0x1FD0, "V"), (0x1FD3, "M", "ΐ"), (0x1FD4, "X"), @@ -2230,9 +2191,9 @@ def _seg_21() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1FDA, "M", "ὶ"), (0x1FDB, "M", "ί"), (0x1FDC, "X"), - (0x1FDD, "M", " ̔̀"), - (0x1FDE, "M", " ̔́"), - (0x1FDF, "M", " ̔͂"), + (0x1FDD, "3", " ̔̀"), + (0x1FDE, "3", " ̔́"), + (0x1FDF, "3", " ̔͂"), (0x1FE0, "V"), (0x1FE3, "M", "ΰ"), (0x1FE4, "V"), @@ -2241,37 +2202,42 @@ def _seg_21() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1FEA, "M", "ὺ"), (0x1FEB, "M", "ύ"), (0x1FEC, "M", "ῥ"), - (0x1FED, "M", " ̈̀"), - (0x1FEE, "M", " ̈́"), - (0x1FEF, "M", "`"), + (0x1FED, "3", " ̈̀"), + (0x1FEE, "3", " ̈́"), + (0x1FEF, "3", "`"), (0x1FF0, "X"), (0x1FF2, "M", "ὼι"), (0x1FF3, "M", "ωι"), (0x1FF4, "M", "ώι"), (0x1FF5, "X"), (0x1FF6, "V"), + ] + + +def _seg_21() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1FF7, "M", "ῶι"), (0x1FF8, "M", "ὸ"), (0x1FF9, "M", "ό"), (0x1FFA, "M", "ὼ"), (0x1FFB, "M", "ώ"), (0x1FFC, "M", "ωι"), - (0x1FFD, "M", " ́"), - (0x1FFE, "M", " ̔"), + (0x1FFD, "3", " ́"), + (0x1FFE, "3", " ̔"), (0x1FFF, "X"), - (0x2000, "M", " "), + (0x2000, "3", " "), (0x200B, "I"), (0x200C, "D", ""), (0x200E, "X"), (0x2010, "V"), (0x2011, "M", "‐"), (0x2012, "V"), - (0x2017, "M", " ̳"), + (0x2017, "3", " ̳"), (0x2018, "V"), (0x2024, "X"), (0x2027, "V"), (0x2028, "X"), - (0x202F, "M", " "), + (0x202F, "3", " "), (0x2030, "V"), (0x2033, "M", "′′"), (0x2034, "M", "′′′"), @@ -2279,20 +2245,21 @@ def _seg_21() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2036, "M", "‵‵"), (0x2037, "M", "‵‵‵"), (0x2038, "V"), - (0x203C, "M", "!!"), + (0x203C, "3", "!!"), (0x203D, "V"), - (0x203E, "M", " ̅"), + (0x203E, "3", " ̅"), (0x203F, "V"), - (0x2047, "M", "??"), - (0x2048, "M", "?!"), - (0x2049, "M", "!?"), + (0x2047, "3", "??"), + (0x2048, "3", "?!"), + (0x2049, "3", "!?"), (0x204A, "V"), (0x2057, "M", "′′′′"), (0x2058, "V"), - (0x205F, "M", " "), + (0x205F, "3", " "), (0x2060, "I"), + (0x2061, "X"), + (0x2064, "I"), (0x2065, "X"), - (0x206A, "I"), (0x2070, "M", "0"), (0x2071, "M", "i"), (0x2072, "X"), @@ -2302,11 +2269,11 @@ def _seg_21() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2077, "M", "7"), (0x2078, "M", "8"), (0x2079, "M", "9"), - (0x207A, "M", "+"), + (0x207A, "3", "+"), (0x207B, "M", "−"), - (0x207C, "M", "="), - (0x207D, "M", "("), - (0x207E, "M", ")"), + (0x207C, "3", "="), + (0x207D, "3", "("), + (0x207E, "3", ")"), (0x207F, "M", "n"), (0x2080, "M", "0"), (0x2081, "M", "1"), @@ -2316,18 +2283,13 @@ def _seg_21() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2085, "M", "5"), (0x2086, "M", "6"), (0x2087, "M", "7"), - ] - - -def _seg_22() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2088, "M", "8"), (0x2089, "M", "9"), - (0x208A, "M", "+"), + (0x208A, "3", "+"), (0x208B, "M", "−"), - (0x208C, "M", "="), - (0x208D, "M", "("), - (0x208E, "M", ")"), + (0x208C, "3", "="), + (0x208D, "3", "("), + (0x208E, "3", ")"), (0x208F, "X"), (0x2090, "M", "a"), (0x2091, "M", "e"), @@ -2349,13 +2311,18 @@ def _seg_22() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x20C1, "X"), (0x20D0, "V"), (0x20F1, "X"), - (0x2100, "M", "a/c"), - (0x2101, "M", "a/s"), + (0x2100, "3", "a/c"), + (0x2101, "3", "a/s"), (0x2102, "M", "c"), (0x2103, "M", "°c"), (0x2104, "V"), - (0x2105, "M", "c/o"), - (0x2106, "M", "c/u"), + ] + + +def _seg_22() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ + (0x2105, "3", "c/o"), + (0x2106, "3", "c/u"), (0x2107, "M", "ɛ"), (0x2108, "V"), (0x2109, "M", "°f"), @@ -2389,7 +2356,7 @@ def _seg_22() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x212E, "V"), (0x212F, "M", "e"), (0x2131, "M", "f"), - (0x2132, "M", "ⅎ"), + (0x2132, "X"), (0x2133, "M", "m"), (0x2134, "M", "o"), (0x2135, "M", "א"), @@ -2421,11 +2388,6 @@ def _seg_22() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2159, "M", "1⁄6"), (0x215A, "M", "5⁄6"), (0x215B, "M", "1⁄8"), - ] - - -def _seg_23() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x215C, "M", "3⁄8"), (0x215D, "M", "5⁄8"), (0x215E, "M", "7⁄8"), @@ -2459,11 +2421,16 @@ def _seg_23() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x217A, "M", "xi"), (0x217B, "M", "xii"), (0x217C, "M", "l"), + ] + + +def _seg_23() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x217D, "M", "c"), (0x217E, "M", "d"), (0x217F, "M", "m"), (0x2180, "V"), - (0x2183, "M", "ↄ"), + (0x2183, "X"), (0x2184, "V"), (0x2189, "M", "0⁄3"), (0x218A, "V"), @@ -2478,7 +2445,7 @@ def _seg_23() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2329, "M", "〈"), (0x232A, "M", "〉"), (0x232B, "V"), - (0x242A, "X"), + (0x2427, "X"), (0x2440, "V"), (0x244B, "X"), (0x2460, "M", "1"), @@ -2501,58 +2468,53 @@ def _seg_23() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2471, "M", "18"), (0x2472, "M", "19"), (0x2473, "M", "20"), - (0x2474, "M", "(1)"), - (0x2475, "M", "(2)"), - (0x2476, "M", "(3)"), - (0x2477, "M", "(4)"), - (0x2478, "M", "(5)"), - (0x2479, "M", "(6)"), - (0x247A, "M", "(7)"), - (0x247B, "M", "(8)"), - (0x247C, "M", "(9)"), - (0x247D, "M", "(10)"), - (0x247E, "M", "(11)"), - (0x247F, "M", "(12)"), - (0x2480, "M", "(13)"), - (0x2481, "M", "(14)"), - (0x2482, "M", "(15)"), - (0x2483, "M", "(16)"), - (0x2484, "M", "(17)"), - (0x2485, "M", "(18)"), - (0x2486, "M", "(19)"), - (0x2487, "M", "(20)"), + (0x2474, "3", "(1)"), + (0x2475, "3", "(2)"), + (0x2476, "3", "(3)"), + (0x2477, "3", "(4)"), + (0x2478, "3", "(5)"), + (0x2479, "3", "(6)"), + (0x247A, "3", "(7)"), + (0x247B, "3", "(8)"), + (0x247C, "3", "(9)"), + (0x247D, "3", "(10)"), + (0x247E, "3", "(11)"), + (0x247F, "3", "(12)"), + (0x2480, "3", "(13)"), + (0x2481, "3", "(14)"), + (0x2482, "3", "(15)"), + (0x2483, "3", "(16)"), + (0x2484, "3", "(17)"), + (0x2485, "3", "(18)"), + (0x2486, "3", "(19)"), + (0x2487, "3", "(20)"), (0x2488, "X"), - (0x249C, "M", "(a)"), - (0x249D, "M", "(b)"), - (0x249E, "M", "(c)"), - (0x249F, "M", "(d)"), - ] - - -def _seg_24() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ - (0x24A0, "M", "(e)"), - (0x24A1, "M", "(f)"), - (0x24A2, "M", "(g)"), - (0x24A3, "M", "(h)"), - (0x24A4, "M", "(i)"), - (0x24A5, "M", "(j)"), - (0x24A6, "M", "(k)"), - (0x24A7, "M", "(l)"), - (0x24A8, "M", "(m)"), - (0x24A9, "M", "(n)"), - (0x24AA, "M", "(o)"), - (0x24AB, "M", "(p)"), - (0x24AC, "M", "(q)"), - (0x24AD, "M", "(r)"), - (0x24AE, "M", "(s)"), - (0x24AF, "M", "(t)"), - (0x24B0, "M", "(u)"), - (0x24B1, "M", "(v)"), - (0x24B2, "M", "(w)"), - (0x24B3, "M", "(x)"), - (0x24B4, "M", "(y)"), - (0x24B5, "M", "(z)"), + (0x249C, "3", "(a)"), + (0x249D, "3", "(b)"), + (0x249E, "3", "(c)"), + (0x249F, "3", "(d)"), + (0x24A0, "3", "(e)"), + (0x24A1, "3", "(f)"), + (0x24A2, "3", "(g)"), + (0x24A3, "3", "(h)"), + (0x24A4, "3", "(i)"), + (0x24A5, "3", "(j)"), + (0x24A6, "3", "(k)"), + (0x24A7, "3", "(l)"), + (0x24A8, "3", "(m)"), + (0x24A9, "3", "(n)"), + (0x24AA, "3", "(o)"), + (0x24AB, "3", "(p)"), + (0x24AC, "3", "(q)"), + (0x24AD, "3", "(r)"), + (0x24AE, "3", "(s)"), + (0x24AF, "3", "(t)"), + (0x24B0, "3", "(u)"), + (0x24B1, "3", "(v)"), + (0x24B2, "3", "(w)"), + (0x24B3, "3", "(x)"), + (0x24B4, "3", "(y)"), + (0x24B5, "3", "(z)"), (0x24B6, "M", "a"), (0x24B7, "M", "b"), (0x24B8, "M", "c"), @@ -2564,6 +2526,11 @@ def _seg_24() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x24BE, "M", "i"), (0x24BF, "M", "j"), (0x24C0, "M", "k"), + ] + + +def _seg_24() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x24C1, "M", "l"), (0x24C2, "M", "m"), (0x24C3, "M", "n"), @@ -2609,9 +2576,9 @@ def _seg_24() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x24EB, "V"), (0x2A0C, "M", "∫∫∫∫"), (0x2A0D, "V"), - (0x2A74, "M", "::="), - (0x2A75, "M", "=="), - (0x2A76, "M", "==="), + (0x2A74, "3", "::="), + (0x2A75, "3", "=="), + (0x2A76, "3", "==="), (0x2A77, "V"), (0x2ADC, "M", "⫝̸"), (0x2ADD, "V"), @@ -2631,11 +2598,6 @@ def _seg_24() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2C09, "M", "ⰹ"), (0x2C0A, "M", "ⰺ"), (0x2C0B, "M", "ⰻ"), - ] - - -def _seg_25() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2C0C, "M", "ⰼ"), (0x2C0D, "M", "ⰽ"), (0x2C0E, "M", "ⰾ"), @@ -2669,6 +2631,11 @@ def _seg_25() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2C2A, "M", "ⱚ"), (0x2C2B, "M", "ⱛ"), (0x2C2C, "M", "ⱜ"), + ] + + +def _seg_25() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x2C2D, "M", "ⱝ"), (0x2C2E, "M", "ⱞ"), (0x2C2F, "M", "ⱟ"), @@ -2736,11 +2703,6 @@ def _seg_25() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2CA3, "V"), (0x2CA4, "M", "ⲥ"), (0x2CA5, "V"), - ] - - -def _seg_26() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2CA6, "M", "ⲧ"), (0x2CA7, "V"), (0x2CA8, "M", "ⲩ"), @@ -2774,6 +2736,11 @@ def _seg_26() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2CC4, "M", "ⳅ"), (0x2CC5, "V"), (0x2CC6, "M", "ⳇ"), + ] + + +def _seg_26() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x2CC7, "V"), (0x2CC8, "M", "ⳉ"), (0x2CC9, "V"), @@ -2841,11 +2808,6 @@ def _seg_26() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2DDF, "X"), (0x2DE0, "V"), (0x2E5E, "X"), - ] - - -def _seg_27() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2E80, "V"), (0x2E9A, "X"), (0x2E9B, "V"), @@ -2879,6 +2841,11 @@ def _seg_27() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F17, "M", "十"), (0x2F18, "M", "卜"), (0x2F19, "M", "卩"), + ] + + +def _seg_27() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x2F1A, "M", "厂"), (0x2F1B, "M", "厶"), (0x2F1C, "M", "又"), @@ -2946,11 +2913,6 @@ def _seg_27() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F5A, "M", "片"), (0x2F5B, "M", "牙"), (0x2F5C, "M", "牛"), - ] - - -def _seg_28() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2F5D, "M", "犬"), (0x2F5E, "M", "玄"), (0x2F5F, "M", "玉"), @@ -2984,6 +2946,11 @@ def _seg_28() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F7B, "M", "羽"), (0x2F7C, "M", "老"), (0x2F7D, "M", "而"), + ] + + +def _seg_28() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x2F7E, "M", "耒"), (0x2F7F, "M", "耳"), (0x2F80, "M", "聿"), @@ -3051,11 +3018,6 @@ def _seg_28() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2FBE, "M", "鬥"), (0x2FBF, "M", "鬯"), (0x2FC0, "M", "鬲"), - ] - - -def _seg_29() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2FC1, "M", "鬼"), (0x2FC2, "M", "魚"), (0x2FC3, "M", "鳥"), @@ -3078,7 +3040,7 @@ def _seg_29() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2FD4, "M", "龜"), (0x2FD5, "M", "龠"), (0x2FD6, "X"), - (0x3000, "M", " "), + (0x3000, "3", " "), (0x3001, "V"), (0x3002, "M", "."), (0x3003, "V"), @@ -3089,11 +3051,16 @@ def _seg_29() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x303A, "M", "卅"), (0x303B, "V"), (0x3040, "X"), + ] + + +def _seg_29() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x3041, "V"), (0x3097, "X"), (0x3099, "V"), - (0x309B, "M", " ゙"), - (0x309C, "M", " ゚"), + (0x309B, "3", " ゙"), + (0x309C, "3", " ゚"), (0x309D, "V"), (0x309F, "M", "より"), (0x30A0, "V"), @@ -3152,15 +3119,10 @@ def _seg_29() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x3161, "M", "ᅳ"), (0x3162, "M", "ᅴ"), (0x3163, "M", "ᅵ"), - (0x3164, "I"), + (0x3164, "X"), (0x3165, "M", "ᄔ"), (0x3166, "M", "ᄕ"), (0x3167, "M", "ᇇ"), - ] - - -def _seg_30() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x3168, "M", "ᇈ"), (0x3169, "M", "ᇌ"), (0x316A, "M", "ᇎ"), @@ -3194,6 +3156,11 @@ def _seg_30() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x3186, "M", "ᅙ"), (0x3187, "M", "ᆄ"), (0x3188, "M", "ᆅ"), + ] + + +def _seg_30() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x3189, "M", "ᆈ"), (0x318A, "M", "ᆑ"), (0x318B, "M", "ᆒ"), @@ -3217,81 +3184,76 @@ def _seg_30() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x319E, "M", "地"), (0x319F, "M", "人"), (0x31A0, "V"), - (0x31E6, "X"), + (0x31E4, "X"), (0x31F0, "V"), - (0x3200, "M", "(ᄀ)"), - (0x3201, "M", "(ᄂ)"), - (0x3202, "M", "(ᄃ)"), - (0x3203, "M", "(ᄅ)"), - (0x3204, "M", "(ᄆ)"), - (0x3205, "M", "(ᄇ)"), - (0x3206, "M", "(ᄉ)"), - (0x3207, "M", "(ᄋ)"), - (0x3208, "M", "(ᄌ)"), - (0x3209, "M", "(ᄎ)"), - (0x320A, "M", "(ᄏ)"), - (0x320B, "M", "(ᄐ)"), - (0x320C, "M", "(ᄑ)"), - (0x320D, "M", "(ᄒ)"), - (0x320E, "M", "(가)"), - (0x320F, "M", "(나)"), - (0x3210, "M", "(다)"), - (0x3211, "M", "(라)"), - (0x3212, "M", "(마)"), - (0x3213, "M", "(바)"), - (0x3214, "M", "(사)"), - (0x3215, "M", "(아)"), - (0x3216, "M", "(자)"), - (0x3217, "M", "(차)"), - (0x3218, "M", "(카)"), - (0x3219, "M", "(타)"), - (0x321A, "M", "(파)"), - (0x321B, "M", "(하)"), - (0x321C, "M", "(주)"), - (0x321D, "M", "(오전)"), - (0x321E, "M", "(오후)"), + (0x3200, "3", "(ᄀ)"), + (0x3201, "3", "(ᄂ)"), + (0x3202, "3", "(ᄃ)"), + (0x3203, "3", "(ᄅ)"), + (0x3204, "3", "(ᄆ)"), + (0x3205, "3", "(ᄇ)"), + (0x3206, "3", "(ᄉ)"), + (0x3207, "3", "(ᄋ)"), + (0x3208, "3", "(ᄌ)"), + (0x3209, "3", "(ᄎ)"), + (0x320A, "3", "(ᄏ)"), + (0x320B, "3", "(ᄐ)"), + (0x320C, "3", "(ᄑ)"), + (0x320D, "3", "(ᄒ)"), + (0x320E, "3", "(가)"), + (0x320F, "3", "(나)"), + (0x3210, "3", "(다)"), + (0x3211, "3", "(라)"), + (0x3212, "3", "(마)"), + (0x3213, "3", "(바)"), + (0x3214, "3", "(사)"), + (0x3215, "3", "(아)"), + (0x3216, "3", "(자)"), + (0x3217, "3", "(차)"), + (0x3218, "3", "(카)"), + (0x3219, "3", "(타)"), + (0x321A, "3", "(파)"), + (0x321B, "3", "(하)"), + (0x321C, "3", "(주)"), + (0x321D, "3", "(오전)"), + (0x321E, "3", "(오후)"), (0x321F, "X"), - (0x3220, "M", "(一)"), - (0x3221, "M", "(二)"), - (0x3222, "M", "(三)"), - (0x3223, "M", "(四)"), - (0x3224, "M", "(五)"), - (0x3225, "M", "(六)"), - (0x3226, "M", "(七)"), - (0x3227, "M", "(八)"), - (0x3228, "M", "(九)"), - (0x3229, "M", "(十)"), - ] - - -def _seg_31() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ - (0x322A, "M", "(月)"), - (0x322B, "M", "(火)"), - (0x322C, "M", "(水)"), - (0x322D, "M", "(木)"), - (0x322E, "M", "(金)"), - (0x322F, "M", "(土)"), - (0x3230, "M", "(日)"), - (0x3231, "M", "(株)"), - (0x3232, "M", "(有)"), - (0x3233, "M", "(社)"), - (0x3234, "M", "(名)"), - (0x3235, "M", "(特)"), - (0x3236, "M", "(財)"), - (0x3237, "M", "(祝)"), - (0x3238, "M", "(労)"), - (0x3239, "M", "(代)"), - (0x323A, "M", "(呼)"), - (0x323B, "M", "(学)"), - (0x323C, "M", "(監)"), - (0x323D, "M", "(企)"), - (0x323E, "M", "(資)"), - (0x323F, "M", "(協)"), - (0x3240, "M", "(祭)"), - (0x3241, "M", "(休)"), - (0x3242, "M", "(自)"), - (0x3243, "M", "(至)"), + (0x3220, "3", "(一)"), + (0x3221, "3", "(二)"), + (0x3222, "3", "(三)"), + (0x3223, "3", "(四)"), + (0x3224, "3", "(五)"), + (0x3225, "3", "(六)"), + (0x3226, "3", "(七)"), + (0x3227, "3", "(八)"), + (0x3228, "3", "(九)"), + (0x3229, "3", "(十)"), + (0x322A, "3", "(月)"), + (0x322B, "3", "(火)"), + (0x322C, "3", "(水)"), + (0x322D, "3", "(木)"), + (0x322E, "3", "(金)"), + (0x322F, "3", "(土)"), + (0x3230, "3", "(日)"), + (0x3231, "3", "(株)"), + (0x3232, "3", "(有)"), + (0x3233, "3", "(社)"), + (0x3234, "3", "(名)"), + (0x3235, "3", "(特)"), + (0x3236, "3", "(財)"), + (0x3237, "3", "(祝)"), + (0x3238, "3", "(労)"), + (0x3239, "3", "(代)"), + (0x323A, "3", "(呼)"), + (0x323B, "3", "(学)"), + (0x323C, "3", "(監)"), + (0x323D, "3", "(企)"), + (0x323E, "3", "(資)"), + (0x323F, "3", "(協)"), + (0x3240, "3", "(祭)"), + (0x3241, "3", "(休)"), + (0x3242, "3", "(自)"), + (0x3243, "3", "(至)"), (0x3244, "M", "問"), (0x3245, "M", "幼"), (0x3246, "M", "文"), @@ -3299,6 +3261,11 @@ def _seg_31() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x3248, "V"), (0x3250, "M", "pte"), (0x3251, "M", "21"), + ] + + +def _seg_31() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x3252, "M", "22"), (0x3253, "M", "23"), (0x3254, "M", "24"), @@ -3366,11 +3333,6 @@ def _seg_31() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x3292, "M", "有"), (0x3293, "M", "社"), (0x3294, "M", "名"), - ] - - -def _seg_32() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x3295, "M", "特"), (0x3296, "M", "財"), (0x3297, "M", "祝"), @@ -3404,6 +3366,11 @@ def _seg_32() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x32B3, "M", "38"), (0x32B4, "M", "39"), (0x32B5, "M", "40"), + ] + + +def _seg_32() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x32B6, "M", "41"), (0x32B7, "M", "42"), (0x32B8, "M", "43"), @@ -3471,11 +3438,6 @@ def _seg_32() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x32F6, "M", "ラ"), (0x32F7, "M", "リ"), (0x32F8, "M", "ル"), - ] - - -def _seg_33() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x32F9, "M", "レ"), (0x32FA, "M", "ロ"), (0x32FB, "M", "ワ"), @@ -3509,6 +3471,11 @@ def _seg_33() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x3317, "M", "キロワット"), (0x3318, "M", "グラム"), (0x3319, "M", "グラムトン"), + ] + + +def _seg_33() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x331A, "M", "クルゼイロ"), (0x331B, "M", "クローネ"), (0x331C, "M", "ケース"), @@ -3576,11 +3543,6 @@ def _seg_33() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x335A, "M", "2点"), (0x335B, "M", "3点"), (0x335C, "M", "4点"), - ] - - -def _seg_34() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x335D, "M", "5点"), (0x335E, "M", "6点"), (0x335F, "M", "7点"), @@ -3614,6 +3576,11 @@ def _seg_34() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x337B, "M", "平成"), (0x337C, "M", "昭和"), (0x337D, "M", "大正"), + ] + + +def _seg_34() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x337E, "M", "明治"), (0x337F, "M", "株式会社"), (0x3380, "M", "pa"), @@ -3681,11 +3648,6 @@ def _seg_34() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x33BE, "M", "kw"), (0x33BF, "M", "mw"), (0x33C0, "M", "kω"), - ] - - -def _seg_35() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x33C1, "M", "mω"), (0x33C2, "X"), (0x33C3, "M", "bq"), @@ -3719,6 +3681,11 @@ def _seg_35() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x33DF, "M", "a∕m"), (0x33E0, "M", "1日"), (0x33E1, "M", "2日"), + ] + + +def _seg_35() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x33E2, "M", "3日"), (0x33E3, "M", "4日"), (0x33E4, "M", "5日"), @@ -3786,11 +3753,6 @@ def _seg_35() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xA65C, "M", "ꙝ"), (0xA65D, "V"), (0xA65E, "M", "ꙟ"), - ] - - -def _seg_36() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xA65F, "V"), (0xA660, "M", "ꙡ"), (0xA661, "V"), @@ -3824,6 +3786,11 @@ def _seg_36() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xA68F, "V"), (0xA690, "M", "ꚑ"), (0xA691, "V"), + ] + + +def _seg_36() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xA692, "M", "ꚓ"), (0xA693, "V"), (0xA694, "M", "ꚕ"), @@ -3891,11 +3858,6 @@ def _seg_36() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xA755, "V"), (0xA756, "M", "ꝗ"), (0xA757, "V"), - ] - - -def _seg_37() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xA758, "M", "ꝙ"), (0xA759, "V"), (0xA75A, "M", "ꝛ"), @@ -3929,6 +3891,11 @@ def _seg_37() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xA77D, "M", "ᵹ"), (0xA77E, "M", "ꝿ"), (0xA77F, "V"), + ] + + +def _seg_37() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xA780, "M", "ꞁ"), (0xA781, "V"), (0xA782, "M", "ꞃ"), @@ -3996,17 +3963,9 @@ def _seg_37() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xA7C6, "M", "ᶎ"), (0xA7C7, "M", "ꟈ"), (0xA7C8, "V"), - ] - - -def _seg_38() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xA7C9, "M", "ꟊ"), (0xA7CA, "V"), - (0xA7CB, "M", "ɤ"), - (0xA7CC, "M", ""), - (0xA7CD, "V"), - (0xA7CE, "X"), + (0xA7CB, "X"), (0xA7D0, "M", "ꟑ"), (0xA7D1, "V"), (0xA7D2, "X"), @@ -4017,10 +3976,7 @@ def _seg_38() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xA7D7, "V"), (0xA7D8, "M", "ꟙ"), (0xA7D9, "V"), - (0xA7DA, "M", ""), - (0xA7DB, "V"), - (0xA7DC, "M", "ƛ"), - (0xA7DD, "X"), + (0xA7DA, "X"), (0xA7F2, "M", "c"), (0xA7F3, "M", "f"), (0xA7F4, "M", "q"), @@ -4040,6 +3996,11 @@ def _seg_38() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xA8DA, "X"), (0xA8E0, "V"), (0xA954, "X"), + ] + + +def _seg_38() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xA95F, "V"), (0xA97D, "X"), (0xA980, "V"), @@ -4101,11 +4062,6 @@ def _seg_38() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xAB85, "M", "Ꮅ"), (0xAB86, "M", "Ꮆ"), (0xAB87, "M", "Ꮇ"), - ] - - -def _seg_39() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xAB88, "M", "Ꮈ"), (0xAB89, "M", "Ꮉ"), (0xAB8A, "M", "Ꮊ"), @@ -4145,6 +4101,11 @@ def _seg_39() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xABAC, "M", "Ꮬ"), (0xABAD, "M", "Ꮭ"), (0xABAE, "M", "Ꮮ"), + ] + + +def _seg_39() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xABAF, "M", "Ꮯ"), (0xABB0, "M", "Ꮰ"), (0xABB1, "M", "Ꮱ"), @@ -4206,11 +4167,6 @@ def _seg_39() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xF920, "M", "鸞"), (0xF921, "M", "嵐"), (0xF922, "M", "濫"), - ] - - -def _seg_40() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xF923, "M", "藍"), (0xF924, "M", "襤"), (0xF925, "M", "拉"), @@ -4250,6 +4206,11 @@ def _seg_40() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xF947, "M", "磊"), (0xF948, "M", "賂"), (0xF949, "M", "雷"), + ] + + +def _seg_40() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xF94A, "M", "壘"), (0xF94B, "M", "屢"), (0xF94C, "M", "樓"), @@ -4311,11 +4272,6 @@ def _seg_40() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xF984, "M", "濾"), (0xF985, "M", "礪"), (0xF986, "M", "閭"), - ] - - -def _seg_41() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xF987, "M", "驪"), (0xF988, "M", "麗"), (0xF989, "M", "黎"), @@ -4355,6 +4311,11 @@ def _seg_41() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xF9AB, "M", "嶺"), (0xF9AC, "M", "怜"), (0xF9AD, "M", "玲"), + ] + + +def _seg_41() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xF9AE, "M", "瑩"), (0xF9AF, "M", "羚"), (0xF9B0, "M", "聆"), @@ -4416,11 +4377,6 @@ def _seg_41() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xF9E8, "M", "裡"), (0xF9E9, "M", "里"), (0xF9EA, "M", "離"), - ] - - -def _seg_42() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xF9EB, "M", "匿"), (0xF9EC, "M", "溺"), (0xF9ED, "M", "吝"), @@ -4460,6 +4416,11 @@ def _seg_42() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFA10, "M", "塚"), (0xFA11, "V"), (0xFA12, "M", "晴"), + ] + + +def _seg_42() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFA13, "V"), (0xFA15, "M", "凞"), (0xFA16, "M", "猪"), @@ -4521,11 +4482,6 @@ def _seg_42() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFA51, "M", "祝"), (0xFA52, "M", "禍"), (0xFA53, "M", "禎"), - ] - - -def _seg_43() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xFA54, "M", "穀"), (0xFA55, "M", "突"), (0xFA56, "M", "節"), @@ -4565,6 +4521,11 @@ def _seg_43() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFA7A, "M", "喙"), (0xFA7B, "M", "嗢"), (0xFA7C, "M", "塚"), + ] + + +def _seg_43() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFA7D, "M", "墳"), (0xFA7E, "M", "奄"), (0xFA7F, "M", "奔"), @@ -4626,11 +4587,6 @@ def _seg_43() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFAB7, "M", "覆"), (0xFAB8, "M", "視"), (0xFAB9, "M", "調"), - ] - - -def _seg_44() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xFABA, "M", "諸"), (0xFABB, "M", "請"), (0xFABC, "M", "謁"), @@ -4670,6 +4626,11 @@ def _seg_44() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFB03, "M", "ffi"), (0xFB04, "M", "ffl"), (0xFB05, "M", "st"), + ] + + +def _seg_44() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFB07, "X"), (0xFB13, "M", "մն"), (0xFB14, "M", "մե"), @@ -4689,7 +4650,7 @@ def _seg_44() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFB26, "M", "ם"), (0xFB27, "M", "ר"), (0xFB28, "M", "ת"), - (0xFB29, "M", "+"), + (0xFB29, "3", "+"), (0xFB2A, "M", "שׁ"), (0xFB2B, "M", "שׂ"), (0xFB2C, "M", "שּׁ"), @@ -4731,11 +4692,6 @@ def _seg_44() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFB50, "M", "ٱ"), (0xFB52, "M", "ٻ"), (0xFB56, "M", "پ"), - ] - - -def _seg_45() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xFB5A, "M", "ڀ"), (0xFB5E, "M", "ٺ"), (0xFB62, "M", "ٿ"), @@ -4775,6 +4731,11 @@ def _seg_45() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFBE2, "M", "ۉ"), (0xFBE4, "M", "ې"), (0xFBE8, "M", "ى"), + ] + + +def _seg_45() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFBEA, "M", "ئا"), (0xFBEC, "M", "ئە"), (0xFBEE, "M", "ئو"), @@ -4836,11 +4797,6 @@ def _seg_45() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFC31, "M", "فى"), (0xFC32, "M", "في"), (0xFC33, "M", "قح"), - ] - - -def _seg_46() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xFC34, "M", "قم"), (0xFC35, "M", "قى"), (0xFC36, "M", "قي"), @@ -4880,15 +4836,20 @@ def _seg_46() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFC58, "M", "يم"), (0xFC59, "M", "يى"), (0xFC5A, "M", "يي"), + ] + + +def _seg_46() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFC5B, "M", "ذٰ"), (0xFC5C, "M", "رٰ"), (0xFC5D, "M", "ىٰ"), - (0xFC5E, "M", " ٌّ"), - (0xFC5F, "M", " ٍّ"), - (0xFC60, "M", " َّ"), - (0xFC61, "M", " ُّ"), - (0xFC62, "M", " ِّ"), - (0xFC63, "M", " ّٰ"), + (0xFC5E, "3", " ٌّ"), + (0xFC5F, "3", " ٍّ"), + (0xFC60, "3", " َّ"), + (0xFC61, "3", " ُّ"), + (0xFC62, "3", " ِّ"), + (0xFC63, "3", " ّٰ"), (0xFC64, "M", "ئر"), (0xFC65, "M", "ئز"), (0xFC66, "M", "ئم"), @@ -4941,11 +4902,6 @@ def _seg_46() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFC95, "M", "يى"), (0xFC96, "M", "يي"), (0xFC97, "M", "ئج"), - ] - - -def _seg_47() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xFC98, "M", "ئح"), (0xFC99, "M", "ئخ"), (0xFC9A, "M", "ئم"), @@ -4985,6 +4941,11 @@ def _seg_47() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFCBC, "M", "غج"), (0xFCBD, "M", "غم"), (0xFCBE, "M", "فج"), + ] + + +def _seg_47() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFCBF, "M", "فح"), (0xFCC0, "M", "فخ"), (0xFCC1, "M", "فم"), @@ -5046,11 +5007,6 @@ def _seg_47() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFCF9, "M", "غى"), (0xFCFA, "M", "غي"), (0xFCFB, "M", "سى"), - ] - - -def _seg_48() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xFCFC, "M", "سي"), (0xFCFD, "M", "شى"), (0xFCFE, "M", "شي"), @@ -5090,6 +5046,11 @@ def _seg_48() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFD20, "M", "خي"), (0xFD21, "M", "صى"), (0xFD22, "M", "صي"), + ] + + +def _seg_48() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFD23, "M", "ضى"), (0xFD24, "M", "ضي"), (0xFD25, "M", "شج"), @@ -5151,11 +5112,6 @@ def _seg_48() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFD7A, "M", "غمي"), (0xFD7B, "M", "غمى"), (0xFD7C, "M", "فخم"), - ] - - -def _seg_49() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xFD7E, "M", "قمح"), (0xFD7F, "M", "قمم"), (0xFD80, "M", "لحم"), @@ -5195,6 +5151,11 @@ def _seg_49() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFDA8, "M", "سخى"), (0xFDA9, "M", "صحي"), (0xFDAA, "M", "شحي"), + ] + + +def _seg_49() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFDAB, "M", "ضحي"), (0xFDAC, "M", "لجي"), (0xFDAD, "M", "لمي"), @@ -5237,18 +5198,18 @@ def _seg_49() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFDF7, "M", "عليه"), (0xFDF8, "M", "وسلم"), (0xFDF9, "M", "صلى"), - (0xFDFA, "M", "صلى الله عليه وسلم"), - (0xFDFB, "M", "جل جلاله"), + (0xFDFA, "3", "صلى الله عليه وسلم"), + (0xFDFB, "3", "جل جلاله"), (0xFDFC, "M", "ریال"), (0xFDFD, "V"), (0xFE00, "I"), - (0xFE10, "M", ","), + (0xFE10, "3", ","), (0xFE11, "M", "、"), (0xFE12, "X"), - (0xFE13, "M", ":"), - (0xFE14, "M", ";"), - (0xFE15, "M", "!"), - (0xFE16, "M", "?"), + (0xFE13, "3", ":"), + (0xFE14, "3", ";"), + (0xFE15, "3", "!"), + (0xFE16, "3", "?"), (0xFE17, "M", "〖"), (0xFE18, "M", "〗"), (0xFE19, "X"), @@ -5256,16 +5217,11 @@ def _seg_49() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFE30, "X"), (0xFE31, "M", "—"), (0xFE32, "M", "–"), - ] - - -def _seg_50() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ - (0xFE33, "M", "_"), - (0xFE35, "M", "("), - (0xFE36, "M", ")"), - (0xFE37, "M", "{"), - (0xFE38, "M", "}"), + (0xFE33, "3", "_"), + (0xFE35, "3", "("), + (0xFE36, "3", ")"), + (0xFE37, "3", "{"), + (0xFE38, "3", "}"), (0xFE39, "M", "〔"), (0xFE3A, "M", "〕"), (0xFE3B, "M", "【"), @@ -5279,53 +5235,58 @@ def _seg_50() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFE43, "M", "『"), (0xFE44, "M", "』"), (0xFE45, "V"), - (0xFE47, "M", "["), - (0xFE48, "M", "]"), - (0xFE49, "M", " ̅"), - (0xFE4D, "M", "_"), - (0xFE50, "M", ","), + (0xFE47, "3", "["), + (0xFE48, "3", "]"), + (0xFE49, "3", " ̅"), + (0xFE4D, "3", "_"), + (0xFE50, "3", ","), (0xFE51, "M", "、"), (0xFE52, "X"), - (0xFE54, "M", ";"), - (0xFE55, "M", ":"), - (0xFE56, "M", "?"), - (0xFE57, "M", "!"), + (0xFE54, "3", ";"), + (0xFE55, "3", ":"), + (0xFE56, "3", "?"), + (0xFE57, "3", "!"), (0xFE58, "M", "—"), - (0xFE59, "M", "("), - (0xFE5A, "M", ")"), - (0xFE5B, "M", "{"), - (0xFE5C, "M", "}"), + (0xFE59, "3", "("), + (0xFE5A, "3", ")"), + (0xFE5B, "3", "{"), + (0xFE5C, "3", "}"), (0xFE5D, "M", "〔"), (0xFE5E, "M", "〕"), - (0xFE5F, "M", "#"), - (0xFE60, "M", "&"), - (0xFE61, "M", "*"), - (0xFE62, "M", "+"), + (0xFE5F, "3", "#"), + (0xFE60, "3", "&"), + (0xFE61, "3", "*"), + ] + + +def _seg_50() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ + (0xFE62, "3", "+"), (0xFE63, "M", "-"), - (0xFE64, "M", "<"), - (0xFE65, "M", ">"), - (0xFE66, "M", "="), + (0xFE64, "3", "<"), + (0xFE65, "3", ">"), + (0xFE66, "3", "="), (0xFE67, "X"), - (0xFE68, "M", "\\"), - (0xFE69, "M", "$"), - (0xFE6A, "M", "%"), - (0xFE6B, "M", "@"), + (0xFE68, "3", "\\"), + (0xFE69, "3", "$"), + (0xFE6A, "3", "%"), + (0xFE6B, "3", "@"), (0xFE6C, "X"), - (0xFE70, "M", " ً"), + (0xFE70, "3", " ً"), (0xFE71, "M", "ـً"), - (0xFE72, "M", " ٌ"), + (0xFE72, "3", " ٌ"), (0xFE73, "V"), - (0xFE74, "M", " ٍ"), + (0xFE74, "3", " ٍ"), (0xFE75, "X"), - (0xFE76, "M", " َ"), + (0xFE76, "3", " َ"), (0xFE77, "M", "ـَ"), - (0xFE78, "M", " ُ"), + (0xFE78, "3", " ُ"), (0xFE79, "M", "ـُ"), - (0xFE7A, "M", " ِ"), + (0xFE7A, "3", " ِ"), (0xFE7B, "M", "ـِ"), - (0xFE7C, "M", " ّ"), + (0xFE7C, "3", " ّ"), (0xFE7D, "M", "ـّ"), - (0xFE7E, "M", " ْ"), + (0xFE7E, "3", " ْ"), (0xFE7F, "M", "ـْ"), (0xFE80, "M", "ء"), (0xFE81, "M", "آ"), @@ -5361,11 +5322,6 @@ def _seg_50() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFEE5, "M", "ن"), (0xFEE9, "M", "ه"), (0xFEED, "M", "و"), - ] - - -def _seg_51() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xFEEF, "M", "ى"), (0xFEF1, "M", "ي"), (0xFEF5, "M", "لآ"), @@ -5375,21 +5331,21 @@ def _seg_51() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFEFD, "X"), (0xFEFF, "I"), (0xFF00, "X"), - (0xFF01, "M", "!"), - (0xFF02, "M", '"'), - (0xFF03, "M", "#"), - (0xFF04, "M", "$"), - (0xFF05, "M", "%"), - (0xFF06, "M", "&"), - (0xFF07, "M", "'"), - (0xFF08, "M", "("), - (0xFF09, "M", ")"), - (0xFF0A, "M", "*"), - (0xFF0B, "M", "+"), - (0xFF0C, "M", ","), + (0xFF01, "3", "!"), + (0xFF02, "3", '"'), + (0xFF03, "3", "#"), + (0xFF04, "3", "$"), + (0xFF05, "3", "%"), + (0xFF06, "3", "&"), + (0xFF07, "3", "'"), + (0xFF08, "3", "("), + (0xFF09, "3", ")"), + (0xFF0A, "3", "*"), + (0xFF0B, "3", "+"), + (0xFF0C, "3", ","), (0xFF0D, "M", "-"), (0xFF0E, "M", "."), - (0xFF0F, "M", "/"), + (0xFF0F, "3", "/"), (0xFF10, "M", "0"), (0xFF11, "M", "1"), (0xFF12, "M", "2"), @@ -5400,13 +5356,18 @@ def _seg_51() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFF17, "M", "7"), (0xFF18, "M", "8"), (0xFF19, "M", "9"), - (0xFF1A, "M", ":"), - (0xFF1B, "M", ";"), - (0xFF1C, "M", "<"), - (0xFF1D, "M", "="), - (0xFF1E, "M", ">"), - (0xFF1F, "M", "?"), - (0xFF20, "M", "@"), + (0xFF1A, "3", ":"), + (0xFF1B, "3", ";"), + (0xFF1C, "3", "<"), + (0xFF1D, "3", "="), + (0xFF1E, "3", ">"), + ] + + +def _seg_51() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ + (0xFF1F, "3", "?"), + (0xFF20, "3", "@"), (0xFF21, "M", "a"), (0xFF22, "M", "b"), (0xFF23, "M", "c"), @@ -5433,12 +5394,12 @@ def _seg_51() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFF38, "M", "x"), (0xFF39, "M", "y"), (0xFF3A, "M", "z"), - (0xFF3B, "M", "["), - (0xFF3C, "M", "\\"), - (0xFF3D, "M", "]"), - (0xFF3E, "M", "^"), - (0xFF3F, "M", "_"), - (0xFF40, "M", "`"), + (0xFF3B, "3", "["), + (0xFF3C, "3", "\\"), + (0xFF3D, "3", "]"), + (0xFF3E, "3", "^"), + (0xFF3F, "3", "_"), + (0xFF40, "3", "`"), (0xFF41, "M", "a"), (0xFF42, "M", "b"), (0xFF43, "M", "c"), @@ -5465,15 +5426,10 @@ def _seg_51() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFF58, "M", "x"), (0xFF59, "M", "y"), (0xFF5A, "M", "z"), - (0xFF5B, "M", "{"), - ] - - -def _seg_52() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ - (0xFF5C, "M", "|"), - (0xFF5D, "M", "}"), - (0xFF5E, "M", "~"), + (0xFF5B, "3", "{"), + (0xFF5C, "3", "|"), + (0xFF5D, "3", "}"), + (0xFF5E, "3", "~"), (0xFF5F, "M", "⦅"), (0xFF60, "M", "⦆"), (0xFF61, "M", "."), @@ -5510,6 +5466,11 @@ def _seg_52() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFF80, "M", "タ"), (0xFF81, "M", "チ"), (0xFF82, "M", "ツ"), + ] + + +def _seg_52() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFF83, "M", "テ"), (0xFF84, "M", "ト"), (0xFF85, "M", "ナ"), @@ -5539,7 +5500,7 @@ def _seg_52() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFF9D, "M", "ン"), (0xFF9E, "M", "゙"), (0xFF9F, "M", "゚"), - (0xFFA0, "I"), + (0xFFA0, "X"), (0xFFA1, "M", "ᄀ"), (0xFFA2, "M", "ᄁ"), (0xFFA3, "M", "ᆪ"), @@ -5571,11 +5532,6 @@ def _seg_52() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFFBD, "M", "ᄑ"), (0xFFBE, "M", "ᄒ"), (0xFFBF, "X"), - ] - - -def _seg_53() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0xFFC2, "M", "ᅡ"), (0xFFC3, "M", "ᅢ"), (0xFFC4, "M", "ᅣ"), @@ -5604,7 +5560,7 @@ def _seg_53() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFFE0, "M", "¢"), (0xFFE1, "M", "£"), (0xFFE2, "M", "¬"), - (0xFFE3, "M", " ̄"), + (0xFFE3, "3", " ̄"), (0xFFE4, "M", "¦"), (0xFFE5, "M", "¥"), (0xFFE6, "M", "₩"), @@ -5615,6 +5571,11 @@ def _seg_53() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0xFFEB, "M", "→"), (0xFFEC, "M", "↓"), (0xFFED, "M", "■"), + ] + + +def _seg_53() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0xFFEE, "M", "○"), (0xFFEF, "X"), (0x10000, "V"), @@ -5676,11 +5637,6 @@ def _seg_53() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1040C, "M", "𐐴"), (0x1040D, "M", "𐐵"), (0x1040E, "M", "𐐶"), - ] - - -def _seg_54() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1040F, "M", "𐐷"), (0x10410, "M", "𐐸"), (0x10411, "M", "𐐹"), @@ -5720,6 +5676,11 @@ def _seg_54() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x104B7, "M", "𐓟"), (0x104B8, "M", "𐓠"), (0x104B9, "M", "𐓡"), + ] + + +def _seg_54() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x104BA, "M", "𐓢"), (0x104BB, "M", "𐓣"), (0x104BC, "M", "𐓤"), @@ -5781,11 +5742,6 @@ def _seg_54() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x10588, "M", "𐖯"), (0x10589, "M", "𐖰"), (0x1058A, "M", "𐖱"), - ] - - -def _seg_55() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1058B, "X"), (0x1058C, "M", "𐖳"), (0x1058D, "M", "𐖴"), @@ -5806,8 +5762,6 @@ def _seg_55() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x105BA, "X"), (0x105BB, "V"), (0x105BD, "X"), - (0x105C0, "V"), - (0x105F4, "X"), (0x10600, "V"), (0x10737, "X"), (0x10740, "V"), @@ -5827,6 +5781,11 @@ def _seg_55() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1078A, "M", "ʤ"), (0x1078B, "M", "ɖ"), (0x1078C, "M", "ɗ"), + ] + + +def _seg_55() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1078D, "M", "ᶑ"), (0x1078E, "M", "ɘ"), (0x1078F, "M", "ɞ"), @@ -5886,11 +5845,6 @@ def _seg_55() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1083D, "X"), (0x1083F, "V"), (0x10856, "X"), - ] - - -def _seg_56() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x10857, "V"), (0x1089F, "X"), (0x108A7, "V"), @@ -5932,6 +5886,11 @@ def _seg_56() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x10AEB, "V"), (0x10AF7, "X"), (0x10B00, "V"), + ] + + +def _seg_56() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x10B36, "X"), (0x10B39, "V"), (0x10B56, "X"), @@ -5991,11 +5950,6 @@ def _seg_56() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x10CAB, "M", "𐳫"), (0x10CAC, "M", "𐳬"), (0x10CAD, "M", "𐳭"), - ] - - -def _seg_57() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x10CAE, "M", "𐳮"), (0x10CAF, "M", "𐳯"), (0x10CB0, "M", "𐳰"), @@ -6008,34 +5962,6 @@ def _seg_57() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x10D28, "X"), (0x10D30, "V"), (0x10D3A, "X"), - (0x10D40, "V"), - (0x10D50, "M", ""), - (0x10D51, "M", ""), - (0x10D52, "M", ""), - (0x10D53, "M", ""), - (0x10D54, "M", ""), - (0x10D55, "M", ""), - (0x10D56, "M", ""), - (0x10D57, "M", ""), - (0x10D58, "M", ""), - (0x10D59, "M", ""), - (0x10D5A, "M", ""), - (0x10D5B, "M", ""), - (0x10D5C, "M", ""), - (0x10D5D, "M", ""), - (0x10D5E, "M", ""), - (0x10D5F, "M", ""), - (0x10D60, "M", ""), - (0x10D61, "M", ""), - (0x10D62, "M", ""), - (0x10D63, "M", ""), - (0x10D64, "M", ""), - (0x10D65, "M", ""), - (0x10D66, "X"), - (0x10D69, "V"), - (0x10D86, "X"), - (0x10D8E, "V"), - (0x10D90, "X"), (0x10E60, "V"), (0x10E7F, "X"), (0x10E80, "V"), @@ -6044,9 +5970,7 @@ def _seg_57() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x10EAE, "X"), (0x10EB0, "V"), (0x10EB2, "X"), - (0x10EC2, "V"), - (0x10EC5, "X"), - (0x10EFC, "V"), + (0x10EFD, "V"), (0x10F28, "X"), (0x10F30, "V"), (0x10F5A, "X"), @@ -6067,6 +5991,11 @@ def _seg_57() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x110D0, "V"), (0x110E9, "X"), (0x110F0, "V"), + ] + + +def _seg_57() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x110FA, "X"), (0x11100, "V"), (0x11135, "X"), @@ -6096,11 +6025,6 @@ def _seg_57() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x112EB, "X"), (0x112F0, "V"), (0x112FA, "X"), - ] - - -def _seg_58() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x11300, "V"), (0x11304, "X"), (0x11305, "V"), @@ -6131,28 +6055,6 @@ def _seg_58() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1136D, "X"), (0x11370, "V"), (0x11375, "X"), - (0x11380, "V"), - (0x1138A, "X"), - (0x1138B, "V"), - (0x1138C, "X"), - (0x1138E, "V"), - (0x1138F, "X"), - (0x11390, "V"), - (0x113B6, "X"), - (0x113B7, "V"), - (0x113C1, "X"), - (0x113C2, "V"), - (0x113C3, "X"), - (0x113C5, "V"), - (0x113C6, "X"), - (0x113C7, "V"), - (0x113CB, "X"), - (0x113CC, "V"), - (0x113D6, "X"), - (0x113D7, "V"), - (0x113D9, "X"), - (0x113E1, "V"), - (0x113E3, "X"), (0x11400, "V"), (0x1145C, "X"), (0x1145D, "V"), @@ -6175,8 +6077,6 @@ def _seg_58() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x116BA, "X"), (0x116C0, "V"), (0x116CA, "X"), - (0x116D0, "V"), - (0x116E4, "X"), (0x11700, "V"), (0x1171B, "X"), (0x1171D, "V"), @@ -6196,16 +6096,16 @@ def _seg_58() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x118A8, "M", "𑣈"), (0x118A9, "M", "𑣉"), (0x118AA, "M", "𑣊"), + ] + + +def _seg_58() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x118AB, "M", "𑣋"), (0x118AC, "M", "𑣌"), (0x118AD, "M", "𑣍"), (0x118AE, "M", "𑣎"), (0x118AF, "M", "𑣏"), - ] - - -def _seg_59() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x118B0, "M", "𑣐"), (0x118B1, "M", "𑣑"), (0x118B2, "M", "𑣒"), @@ -6254,10 +6154,6 @@ def _seg_59() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x11AF9, "X"), (0x11B00, "V"), (0x11B0A, "X"), - (0x11BC0, "V"), - (0x11BE2, "X"), - (0x11BF0, "V"), - (0x11BFA, "X"), (0x11C00, "V"), (0x11C09, "X"), (0x11C0A, "V"), @@ -6305,12 +6201,12 @@ def _seg_59() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x11F12, "V"), (0x11F3B, "X"), (0x11F3E, "V"), - (0x11F5B, "X"), ] -def _seg_60() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: +def _seg_59() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: return [ + (0x11F5A, "X"), (0x11FB0, "V"), (0x11FB1, "X"), (0x11FC0, "V"), @@ -6329,12 +6225,8 @@ def _seg_60() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x13430, "X"), (0x13440, "V"), (0x13456, "X"), - (0x13460, "V"), - (0x143FB, "X"), (0x14400, "V"), (0x14647, "X"), - (0x16100, "V"), - (0x1613A, "X"), (0x16800, "V"), (0x16A39, "X"), (0x16A40, "V"), @@ -6359,8 +6251,6 @@ def _seg_60() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x16B78, "X"), (0x16B7D, "V"), (0x16B90, "X"), - (0x16D40, "V"), - (0x16D7A, "X"), (0x16E40, "M", "𖹠"), (0x16E41, "M", "𖹡"), (0x16E42, "M", "𖹢"), @@ -6409,18 +6299,18 @@ def _seg_60() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x187F8, "X"), (0x18800, "V"), (0x18CD6, "X"), - (0x18CFF, "V"), + (0x18D00, "V"), (0x18D09, "X"), - ] - - -def _seg_61() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1AFF0, "V"), (0x1AFF4, "X"), (0x1AFF5, "V"), (0x1AFFC, "X"), (0x1AFFD, "V"), + ] + + +def _seg_60() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1AFFF, "X"), (0x1B000, "V"), (0x1B123, "X"), @@ -6445,46 +6335,6 @@ def _seg_61() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1BC9C, "V"), (0x1BCA0, "I"), (0x1BCA4, "X"), - (0x1CC00, "V"), - (0x1CCD6, "M", "a"), - (0x1CCD7, "M", "b"), - (0x1CCD8, "M", "c"), - (0x1CCD9, "M", "d"), - (0x1CCDA, "M", "e"), - (0x1CCDB, "M", "f"), - (0x1CCDC, "M", "g"), - (0x1CCDD, "M", "h"), - (0x1CCDE, "M", "i"), - (0x1CCDF, "M", "j"), - (0x1CCE0, "M", "k"), - (0x1CCE1, "M", "l"), - (0x1CCE2, "M", "m"), - (0x1CCE3, "M", "n"), - (0x1CCE4, "M", "o"), - (0x1CCE5, "M", "p"), - (0x1CCE6, "M", "q"), - (0x1CCE7, "M", "r"), - (0x1CCE8, "M", "s"), - (0x1CCE9, "M", "t"), - (0x1CCEA, "M", "u"), - (0x1CCEB, "M", "v"), - (0x1CCEC, "M", "w"), - (0x1CCED, "M", "x"), - (0x1CCEE, "M", "y"), - (0x1CCEF, "M", "z"), - (0x1CCF0, "M", "0"), - (0x1CCF1, "M", "1"), - (0x1CCF2, "M", "2"), - (0x1CCF3, "M", "3"), - (0x1CCF4, "M", "4"), - (0x1CCF5, "M", "5"), - (0x1CCF6, "M", "6"), - (0x1CCF7, "M", "7"), - (0x1CCF8, "M", "8"), - (0x1CCF9, "M", "9"), - (0x1CCFA, "X"), - (0x1CD00, "V"), - (0x1CEB4, "X"), (0x1CF00, "V"), (0x1CF2E, "X"), (0x1CF30, "V"), @@ -6504,7 +6354,7 @@ def _seg_61() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D163, "M", "𝅘𝅥𝅱"), (0x1D164, "M", "𝅘𝅥𝅲"), (0x1D165, "V"), - (0x1D173, "I"), + (0x1D173, "X"), (0x1D17B, "V"), (0x1D1BB, "M", "𝆹𝅥"), (0x1D1BC, "M", "𝆺𝅥"), @@ -6516,11 +6366,6 @@ def _seg_61() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D1EB, "X"), (0x1D200, "V"), (0x1D246, "X"), - ] - - -def _seg_62() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D2C0, "V"), (0x1D2D4, "X"), (0x1D2E0, "V"), @@ -6566,6 +6411,11 @@ def _seg_62() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D422, "M", "i"), (0x1D423, "M", "j"), (0x1D424, "M", "k"), + ] + + +def _seg_61() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D425, "M", "l"), (0x1D426, "M", "m"), (0x1D427, "M", "n"), @@ -6621,11 +6471,6 @@ def _seg_62() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D459, "M", "l"), (0x1D45A, "M", "m"), (0x1D45B, "M", "n"), - ] - - -def _seg_63() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D45C, "M", "o"), (0x1D45D, "M", "p"), (0x1D45E, "M", "q"), @@ -6671,6 +6516,11 @@ def _seg_63() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D486, "M", "e"), (0x1D487, "M", "f"), (0x1D488, "M", "g"), + ] + + +def _seg_62() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D489, "M", "h"), (0x1D48A, "M", "i"), (0x1D48B, "M", "j"), @@ -6726,11 +6576,6 @@ def _seg_63() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D4C0, "M", "k"), (0x1D4C1, "M", "l"), (0x1D4C2, "M", "m"), - ] - - -def _seg_64() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D4C3, "M", "n"), (0x1D4C4, "X"), (0x1D4C5, "M", "p"), @@ -6776,6 +6621,11 @@ def _seg_64() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D4ED, "M", "d"), (0x1D4EE, "M", "e"), (0x1D4EF, "M", "f"), + ] + + +def _seg_63() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D4F0, "M", "g"), (0x1D4F1, "M", "h"), (0x1D4F2, "M", "i"), @@ -6831,11 +6681,6 @@ def _seg_64() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D525, "M", "h"), (0x1D526, "M", "i"), (0x1D527, "M", "j"), - ] - - -def _seg_65() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D528, "M", "k"), (0x1D529, "M", "l"), (0x1D52A, "M", "m"), @@ -6881,6 +6726,11 @@ def _seg_65() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D554, "M", "c"), (0x1D555, "M", "d"), (0x1D556, "M", "e"), + ] + + +def _seg_64() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D557, "M", "f"), (0x1D558, "M", "g"), (0x1D559, "M", "h"), @@ -6936,11 +6786,6 @@ def _seg_65() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D58B, "M", "f"), (0x1D58C, "M", "g"), (0x1D58D, "M", "h"), - ] - - -def _seg_66() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D58E, "M", "i"), (0x1D58F, "M", "j"), (0x1D590, "M", "k"), @@ -6986,6 +6831,11 @@ def _seg_66() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D5B8, "M", "y"), (0x1D5B9, "M", "z"), (0x1D5BA, "M", "a"), + ] + + +def _seg_65() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D5BB, "M", "b"), (0x1D5BC, "M", "c"), (0x1D5BD, "M", "d"), @@ -7041,11 +6891,6 @@ def _seg_66() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D5EF, "M", "b"), (0x1D5F0, "M", "c"), (0x1D5F1, "M", "d"), - ] - - -def _seg_67() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D5F2, "M", "e"), (0x1D5F3, "M", "f"), (0x1D5F4, "M", "g"), @@ -7091,6 +6936,11 @@ def _seg_67() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D61C, "M", "u"), (0x1D61D, "M", "v"), (0x1D61E, "M", "w"), + ] + + +def _seg_66() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D61F, "M", "x"), (0x1D620, "M", "y"), (0x1D621, "M", "z"), @@ -7146,11 +6996,6 @@ def _seg_67() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D653, "M", "x"), (0x1D654, "M", "y"), (0x1D655, "M", "z"), - ] - - -def _seg_68() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D656, "M", "a"), (0x1D657, "M", "b"), (0x1D658, "M", "c"), @@ -7196,6 +7041,11 @@ def _seg_68() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D680, "M", "q"), (0x1D681, "M", "r"), (0x1D682, "M", "s"), + ] + + +def _seg_67() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D683, "M", "t"), (0x1D684, "M", "u"), (0x1D685, "M", "v"), @@ -7251,11 +7101,6 @@ def _seg_68() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D6B8, "M", "ρ"), (0x1D6B9, "M", "θ"), (0x1D6BA, "M", "σ"), - ] - - -def _seg_69() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D6BB, "M", "τ"), (0x1D6BC, "M", "υ"), (0x1D6BD, "M", "φ"), @@ -7301,6 +7146,11 @@ def _seg_69() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D6E6, "M", "ε"), (0x1D6E7, "M", "ζ"), (0x1D6E8, "M", "η"), + ] + + +def _seg_68() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D6E9, "M", "θ"), (0x1D6EA, "M", "ι"), (0x1D6EB, "M", "κ"), @@ -7356,11 +7206,6 @@ def _seg_69() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D71E, "M", "γ"), (0x1D71F, "M", "δ"), (0x1D720, "M", "ε"), - ] - - -def _seg_70() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D721, "M", "ζ"), (0x1D722, "M", "η"), (0x1D723, "M", "θ"), @@ -7406,6 +7251,11 @@ def _seg_70() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D74C, "M", "χ"), (0x1D74D, "M", "ψ"), (0x1D74E, "M", "ω"), + ] + + +def _seg_69() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D74F, "M", "∂"), (0x1D750, "M", "ε"), (0x1D751, "M", "θ"), @@ -7461,11 +7311,6 @@ def _seg_70() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D784, "M", "υ"), (0x1D785, "M", "φ"), (0x1D786, "M", "χ"), - ] - - -def _seg_71() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D787, "M", "ψ"), (0x1D788, "M", "ω"), (0x1D789, "M", "∂"), @@ -7511,6 +7356,11 @@ def _seg_71() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D7B1, "M", "θ"), (0x1D7B2, "M", "ι"), (0x1D7B3, "M", "κ"), + ] + + +def _seg_70() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1D7B4, "M", "λ"), (0x1D7B5, "M", "μ"), (0x1D7B6, "M", "ν"), @@ -7566,11 +7416,6 @@ def _seg_71() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1D7EB, "M", "9"), (0x1D7EC, "M", "0"), (0x1D7ED, "M", "1"), - ] - - -def _seg_72() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1D7EE, "M", "2"), (0x1D7EF, "M", "3"), (0x1D7F0, "M", "4"), @@ -7616,6 +7461,11 @@ def _seg_72() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1E034, "M", "д"), (0x1E035, "M", "е"), (0x1E036, "M", "ж"), + ] + + +def _seg_71() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1E037, "M", "з"), (0x1E038, "M", "и"), (0x1E039, "M", "к"), @@ -7671,11 +7521,6 @@ def _seg_72() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1E06B, "M", "ҫ"), (0x1E06C, "M", "ꙑ"), (0x1E06D, "M", "ұ"), - ] - - -def _seg_73() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1E06E, "X"), (0x1E08F, "V"), (0x1E090, "X"), @@ -7695,10 +7540,6 @@ def _seg_73() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1E300, "X"), (0x1E4D0, "V"), (0x1E4FA, "X"), - (0x1E5D0, "V"), - (0x1E5FB, "X"), - (0x1E5FF, "V"), - (0x1E600, "X"), (0x1E7E0, "V"), (0x1E7E7, "X"), (0x1E7E8, "V"), @@ -7725,6 +7566,11 @@ def _seg_73() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1E90B, "M", "𞤭"), (0x1E90C, "M", "𞤮"), (0x1E90D, "M", "𞤯"), + ] + + +def _seg_72() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1E90E, "M", "𞤰"), (0x1E90F, "M", "𞤱"), (0x1E910, "M", "𞤲"), @@ -7776,11 +7622,6 @@ def _seg_73() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1EE12, "M", "ق"), (0x1EE13, "M", "ر"), (0x1EE14, "M", "ش"), - ] - - -def _seg_74() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1EE15, "M", "ت"), (0x1EE16, "M", "ث"), (0x1EE17, "M", "خ"), @@ -7830,6 +7671,11 @@ def _seg_74() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1EE4C, "X"), (0x1EE4D, "M", "ن"), (0x1EE4E, "M", "س"), + ] + + +def _seg_73() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1EE4F, "M", "ع"), (0x1EE50, "X"), (0x1EE51, "M", "ص"), @@ -7881,11 +7727,6 @@ def _seg_74() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1EE81, "M", "ب"), (0x1EE82, "M", "ج"), (0x1EE83, "M", "د"), - ] - - -def _seg_75() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1EE84, "M", "ه"), (0x1EE85, "M", "و"), (0x1EE86, "M", "ز"), @@ -7935,6 +7776,11 @@ def _seg_75() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1EEB6, "M", "ث"), (0x1EEB7, "M", "خ"), (0x1EEB8, "M", "ذ"), + ] + + +def _seg_74() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1EEB9, "M", "ض"), (0x1EEBA, "M", "ظ"), (0x1EEBB, "M", "غ"), @@ -7953,48 +7799,43 @@ def _seg_75() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1F0D0, "X"), (0x1F0D1, "V"), (0x1F0F6, "X"), - (0x1F101, "M", "0,"), - (0x1F102, "M", "1,"), - (0x1F103, "M", "2,"), - (0x1F104, "M", "3,"), - (0x1F105, "M", "4,"), - (0x1F106, "M", "5,"), - (0x1F107, "M", "6,"), - (0x1F108, "M", "7,"), - (0x1F109, "M", "8,"), - (0x1F10A, "M", "9,"), + (0x1F101, "3", "0,"), + (0x1F102, "3", "1,"), + (0x1F103, "3", "2,"), + (0x1F104, "3", "3,"), + (0x1F105, "3", "4,"), + (0x1F106, "3", "5,"), + (0x1F107, "3", "6,"), + (0x1F108, "3", "7,"), + (0x1F109, "3", "8,"), + (0x1F10A, "3", "9,"), (0x1F10B, "V"), - (0x1F110, "M", "(a)"), - (0x1F111, "M", "(b)"), - (0x1F112, "M", "(c)"), - (0x1F113, "M", "(d)"), - (0x1F114, "M", "(e)"), - (0x1F115, "M", "(f)"), - (0x1F116, "M", "(g)"), - (0x1F117, "M", "(h)"), - (0x1F118, "M", "(i)"), - (0x1F119, "M", "(j)"), - (0x1F11A, "M", "(k)"), - (0x1F11B, "M", "(l)"), - (0x1F11C, "M", "(m)"), - (0x1F11D, "M", "(n)"), - (0x1F11E, "M", "(o)"), - (0x1F11F, "M", "(p)"), - (0x1F120, "M", "(q)"), - (0x1F121, "M", "(r)"), - (0x1F122, "M", "(s)"), - (0x1F123, "M", "(t)"), - (0x1F124, "M", "(u)"), - (0x1F125, "M", "(v)"), - ] - - -def _seg_76() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ - (0x1F126, "M", "(w)"), - (0x1F127, "M", "(x)"), - (0x1F128, "M", "(y)"), - (0x1F129, "M", "(z)"), + (0x1F110, "3", "(a)"), + (0x1F111, "3", "(b)"), + (0x1F112, "3", "(c)"), + (0x1F113, "3", "(d)"), + (0x1F114, "3", "(e)"), + (0x1F115, "3", "(f)"), + (0x1F116, "3", "(g)"), + (0x1F117, "3", "(h)"), + (0x1F118, "3", "(i)"), + (0x1F119, "3", "(j)"), + (0x1F11A, "3", "(k)"), + (0x1F11B, "3", "(l)"), + (0x1F11C, "3", "(m)"), + (0x1F11D, "3", "(n)"), + (0x1F11E, "3", "(o)"), + (0x1F11F, "3", "(p)"), + (0x1F120, "3", "(q)"), + (0x1F121, "3", "(r)"), + (0x1F122, "3", "(s)"), + (0x1F123, "3", "(t)"), + (0x1F124, "3", "(u)"), + (0x1F125, "3", "(v)"), + (0x1F126, "3", "(w)"), + (0x1F127, "3", "(x)"), + (0x1F128, "3", "(y)"), + (0x1F129, "3", "(z)"), (0x1F12A, "M", "〔s〕"), (0x1F12B, "M", "c"), (0x1F12C, "M", "r"), @@ -8040,6 +7881,11 @@ def _seg_76() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1F16D, "V"), (0x1F190, "M", "dj"), (0x1F191, "V"), + ] + + +def _seg_75() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x1F1AE, "X"), (0x1F1E6, "V"), (0x1F200, "M", "ほか"), @@ -8091,11 +7937,6 @@ def _seg_76() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1F23A, "M", "営"), (0x1F23B, "M", "配"), (0x1F23C, "X"), - ] - - -def _seg_77() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x1F240, "M", "〔本〕"), (0x1F241, "M", "〔三〕"), (0x1F242, "M", "〔二〕"), @@ -8136,9 +7977,7 @@ def _seg_77() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1F890, "V"), (0x1F8AE, "X"), (0x1F8B0, "V"), - (0x1F8BC, "X"), - (0x1F8C0, "V"), - (0x1F8C2, "X"), + (0x1F8B2, "X"), (0x1F900, "V"), (0x1FA54, "X"), (0x1FA60, "V"), @@ -8146,18 +7985,26 @@ def _seg_77() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x1FA70, "V"), (0x1FA7D, "X"), (0x1FA80, "V"), - (0x1FA8A, "X"), - (0x1FA8F, "V"), - (0x1FAC7, "X"), + (0x1FA89, "X"), + ] + + +def _seg_76() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ + (0x1FA90, "V"), + (0x1FABE, "X"), + (0x1FABF, "V"), + (0x1FAC6, "X"), (0x1FACE, "V"), - (0x1FADD, "X"), - (0x1FADF, "V"), - (0x1FAEA, "X"), + (0x1FADC, "X"), + (0x1FAE0, "V"), + (0x1FAE9, "X"), (0x1FAF0, "V"), (0x1FAF9, "X"), (0x1FB00, "V"), (0x1FB93, "X"), (0x1FB94, "V"), + (0x1FBCB, "X"), (0x1FBF0, "M", "0"), (0x1FBF1, "M", "1"), (0x1FBF2, "M", "2"), @@ -8196,11 +8043,6 @@ def _seg_77() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F80C, "M", "㒞"), (0x2F80D, "M", "𠘺"), (0x2F80E, "M", "免"), - ] - - -def _seg_78() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2F80F, "M", "兔"), (0x2F810, "M", "兤"), (0x2F811, "M", "具"), @@ -8249,6 +8091,11 @@ def _seg_78() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F83E, "M", "呈"), (0x2F83F, "M", "周"), (0x2F840, "M", "咢"), + ] + + +def _seg_77() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x2F841, "M", "哶"), (0x2F842, "M", "唐"), (0x2F843, "M", "啓"), @@ -8287,7 +8134,7 @@ def _seg_78() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F865, "M", "姘"), (0x2F866, "M", "婦"), (0x2F867, "M", "㛮"), - (0x2F868, "M", "㛼"), + (0x2F868, "X"), (0x2F869, "M", "嬈"), (0x2F86A, "M", "嬾"), (0x2F86C, "M", "𡧈"), @@ -8298,14 +8145,9 @@ def _seg_78() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F871, "M", "𡬘"), (0x2F872, "M", "寿"), (0x2F873, "M", "将"), - (0x2F874, "M", "当"), + (0x2F874, "X"), (0x2F875, "M", "尢"), (0x2F876, "M", "㞁"), - ] - - -def _seg_79() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2F877, "M", "屠"), (0x2F878, "M", "屮"), (0x2F879, "M", "峀"), @@ -8354,6 +8196,11 @@ def _seg_79() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F8A6, "M", "慈"), (0x2F8A7, "M", "慌"), (0x2F8A8, "M", "慎"), + ] + + +def _seg_78() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x2F8A9, "M", "慌"), (0x2F8AA, "M", "慺"), (0x2F8AB, "M", "憎"), @@ -8406,11 +8253,6 @@ def _seg_79() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F8DA, "M", "朡"), (0x2F8DB, "M", "杞"), (0x2F8DC, "M", "杓"), - ] - - -def _seg_80() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2F8DD, "M", "𣏃"), (0x2F8DE, "M", "㭉"), (0x2F8DF, "M", "柺"), @@ -8459,6 +8301,11 @@ def _seg_80() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F90A, "M", "㴳"), (0x2F90B, "M", "滋"), (0x2F90C, "M", "滇"), + ] + + +def _seg_79() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x2F90D, "M", "𣻑"), (0x2F90E, "M", "淹"), (0x2F90F, "M", "潮"), @@ -8477,7 +8324,7 @@ def _seg_80() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F91C, "M", "煅"), (0x2F91D, "M", "𤉣"), (0x2F91E, "M", "熜"), - (0x2F91F, "M", "𤎫"), + (0x2F91F, "X"), (0x2F920, "M", "爨"), (0x2F921, "M", "爵"), (0x2F922, "M", "牐"), @@ -8511,11 +8358,6 @@ def _seg_80() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F93F, "M", "䀈"), (0x2F940, "M", "直"), (0x2F941, "M", "𥃳"), - ] - - -def _seg_81() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2F942, "M", "𥃲"), (0x2F943, "M", "𥄙"), (0x2F944, "M", "𥄳"), @@ -8543,7 +8385,7 @@ def _seg_81() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F95B, "M", "穏"), (0x2F95C, "M", "𥥼"), (0x2F95D, "M", "𥪧"), - (0x2F95F, "M", "竮"), + (0x2F95F, "X"), (0x2F960, "M", "䈂"), (0x2F961, "M", "𥮫"), (0x2F962, "M", "篆"), @@ -8564,6 +8406,11 @@ def _seg_81() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F971, "M", "䌴"), (0x2F972, "M", "𦈨"), (0x2F973, "M", "𦉇"), + ] + + +def _seg_80() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x2F974, "M", "䍙"), (0x2F975, "M", "𦋙"), (0x2F976, "M", "罺"), @@ -8616,11 +8463,6 @@ def _seg_81() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F9A5, "M", "𦵫"), (0x2F9A6, "M", "𦳕"), (0x2F9A7, "M", "䔫"), - ] - - -def _seg_82() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2F9A8, "M", "蓱"), (0x2F9A9, "M", "蓳"), (0x2F9AA, "M", "蔖"), @@ -8644,7 +8486,7 @@ def _seg_82() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F9BC, "M", "蜨"), (0x2F9BD, "M", "蝫"), (0x2F9BE, "M", "螆"), - (0x2F9BF, "M", "䗗"), + (0x2F9BF, "X"), (0x2F9C0, "M", "蟡"), (0x2F9C1, "M", "蠁"), (0x2F9C2, "M", "䗹"), @@ -8669,6 +8511,11 @@ def _seg_82() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2F9D5, "M", "賁"), (0x2F9D6, "M", "贛"), (0x2F9D7, "M", "起"), + ] + + +def _seg_81() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: + return [ (0x2F9D8, "M", "𧼯"), (0x2F9D9, "M", "𠠄"), (0x2F9DA, "M", "跋"), @@ -8721,11 +8568,6 @@ def _seg_82() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: (0x2FA0A, "M", "鬒"), (0x2FA0B, "M", "鱀"), (0x2FA0C, "M", "鳽"), - ] - - -def _seg_83() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]: - return [ (0x2FA0D, "M", "䳎"), (0x2FA0E, "M", "䳭"), (0x2FA0F, "M", "鵧"), @@ -8836,6 +8678,4 @@ uts46data = tuple( + _seg_79() + _seg_80() + _seg_81() - + _seg_82() - + _seg_83() ) # type: Tuple[Union[Tuple[int, str], Tuple[int, str, str]], ...] diff --git a/contrib/python/idna/py3/ya.make b/contrib/python/idna/py3/ya.make index 98acf283f7..24aa33c733 100644 --- a/contrib/python/idna/py3/ya.make +++ b/contrib/python/idna/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(3.9) +VERSION(3.10) LICENSE(BSD-3-Clause) diff --git a/contrib/python/mypy-protobuf/.dist-info/METADATA b/contrib/python/mypy-protobuf/.dist-info/METADATA index 934bb64a10..eaa67dc8dc 100644 --- a/contrib/python/mypy-protobuf/.dist-info/METADATA +++ b/contrib/python/mypy-protobuf/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: mypy-protobuf -Version: 3.5.0 +Version: 3.6.0 Summary: Generate mypy stub files from protobuf specs Home-page: https://github.com/nipunn1313/mypy-protobuf Download-URL: https://github.com/nipunn1313/mypy-protobuf/releases @@ -10,6 +10,6 @@ License: Apache License 2.0 Keywords: mypy proto dropbox Requires-Python: >=3.8 License-File: LICENSE -Requires-Dist: protobuf (>=4.23.4) -Requires-Dist: types-protobuf (>=4.23.0.2) +Requires-Dist: protobuf >=4.25.3 +Requires-Dist: types-protobuf >=4.24 diff --git a/contrib/python/mypy-protobuf/README.md b/contrib/python/mypy-protobuf/README.md index a1bfe29279..bccb090c9c 100644 --- a/contrib/python/mypy-protobuf/README.md +++ b/contrib/python/mypy-protobuf/README.md @@ -16,7 +16,7 @@ See [Changelog](CHANGELOG.md) for recent changes. Earlier releases might work, but aren't tested - [protoc >= 23.4](https://github.com/protocolbuffers/protobuf/releases) -- [python-protobuf >= 4.23.4](https://pypi.org/project/protobuf/) - matching protoc release +- [python-protobuf >= 4.25.3](https://pypi.org/project/protobuf/) - matching protoc release - [python >= 3.8](https://www.python.org/downloads/source/) - for running mypy-protobuf plugin. ## Requirements to run typecheckers on stubs generated by mypy-protobuf @@ -24,8 +24,8 @@ Earlier releases might work, but aren't tested Earlier releases might work, but aren't tested - [mypy >= v1.4.1](https://pypi.org/project/mypy) or [pyright >= 1.1.206](https://github.com/microsoft/pyright) -- [python-protobuf >= 4.23.4](https://pypi.org/project/protobuf/) - matching protoc release -- [types-protobuf >= 4.23.0.2](https://pypi.org/project/types-protobuf/) - for stubs from the google.protobuf library +- [python-protobuf >= 4.25.3](https://pypi.org/project/protobuf/) - matching protoc release +- [types-protobuf >= 4.24](https://pypi.org/project/types-protobuf/) - for stubs from the google.protobuf library ### To run typecheckers on code generated with grpc plugin - you'll additionally need diff --git a/contrib/python/mypy-protobuf/mypy_protobuf/extensions_pb2.py b/contrib/python/mypy-protobuf/mypy_protobuf/extensions_pb2.py index a638958a1b..5d48735c20 100644 --- a/contrib/python/mypy-protobuf/mypy_protobuf/extensions_pb2.py +++ b/contrib/python/mypy-protobuf/mypy_protobuf/extensions_pb2.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: mypy_protobuf/extensions.proto +# Protobuf Python Version: 4.25.3 """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool @@ -20,18 +21,13 @@ _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'mypy_protobuf.extensions_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(options) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(casttype) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(keytype) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(valuetype) - DESCRIPTOR._options = None - casttype._options = None - casttype._serialized_options = b'\030\001' - keytype._options = None - keytype._serialized_options = b'\030\001' - valuetype._options = None - valuetype._serialized_options = b'\030\001' + _globals['casttype']._options = None + _globals['casttype']._serialized_options = b'\030\001' + _globals['keytype']._options = None + _globals['keytype']._serialized_options = b'\030\001' + _globals['valuetype']._options = None + _globals['valuetype']._serialized_options = b'\030\001' _globals['_FIELDOPTIONS']._serialized_start=83 _globals['_FIELDOPTIONS']._serialized_end=151 # @@protoc_insertion_point(module_scope) diff --git a/contrib/python/mypy-protobuf/mypy_protobuf/main.py b/contrib/python/mypy-protobuf/mypy_protobuf/main.py index f0b3dbc7e8..343b80b3af 100644 --- a/contrib/python/mypy-protobuf/mypy_protobuf/main.py +++ b/contrib/python/mypy-protobuf/mypy_protobuf/main.py @@ -24,7 +24,7 @@ from google.protobuf.internal.containers import RepeatedCompositeFieldContainer from google.protobuf.internal.well_known_types import WKTBASES from . import extensions_pb2 -__version__ = "3.5.0" +__version__ = "3.6.0" # SourceCodeLocation is defined by `message Location` here # https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/descriptor.proto @@ -169,9 +169,7 @@ class PkgWriter(object): """ if path == "typing_extensions": stabilization = { - "Literal": (3, 8), "TypeAlias": (3, 10), - "final": (3, 8), } assert name in stabilization if not self.typing_extensions_min or self.typing_extensions_min < stabilization[name]: @@ -407,7 +405,7 @@ class PkgWriter(object): class_name = desc.name if desc.name not in PYTHON_RESERVED else "_r_" + desc.name message_class = self._import("google.protobuf.message", "Message") - wl("@{}", self._import("typing_extensions", "final")) + wl("@{}", self._import("typing", "final")) wl(f"class {class_name}({message_class}{addl_base}):") with self._indent(): scl = scl_prefix + [i] @@ -438,12 +436,16 @@ class PkgWriter(object): if field.name in PYTHON_RESERVED: continue field_type = self.python_type(field) - if is_scalar(field) and field.label != d.FieldDescriptorProto.LABEL_REPEATED: # Scalar non repeated fields are r/w wl(f"{field.name}: {field_type}") self._write_comments(scl + [d.DescriptorProto.FIELD_FIELD_NUMBER, idx]) - else: + + for idx, field in enumerate(desc.field): + if field.name in PYTHON_RESERVED: + continue + field_type = self.python_type(field) + if not (is_scalar(field) and field.label != d.FieldDescriptorProto.LABEL_REPEATED): # r/o Getters for non-scalar fields and scalar-repeated fields scl_field = scl + [d.DescriptorProto.FIELD_FIELD_NUMBER, idx] wl("@property") @@ -452,6 +454,7 @@ class PkgWriter(object): if self._has_comments(scl_field): with self._indent(): self._write_comments(scl_field) + wl("") self.write_extensions(desc.extension, scl + [d.DescriptorProto.EXTENSION_FIELD_NUMBER]) @@ -506,14 +509,14 @@ class PkgWriter(object): if hf_fields: wl( "def HasField(self, field_name: {}[{}]) -> {}: ...", - self._import("typing_extensions", "Literal"), + self._import("typing", "Literal"), hf_fields_text, self._builtin("bool"), ) if cf_fields: wl( "def ClearField(self, field_name: {}[{}]) -> None: ...", - self._import("typing_extensions", "Literal"), + self._import("typing", "Literal"), cf_fields_text, ) @@ -522,10 +525,10 @@ class PkgWriter(object): wl("@{}", self._import("typing", "overload")) wl( "def WhichOneof(self, oneof_group: {}[{}]) -> {}[{}] | None: ...", - self._import("typing_extensions", "Literal"), + self._import("typing", "Literal"), # Accepts both str and bytes f'"{wo_field}", b"{wo_field}"', - self._import("typing_extensions", "Literal"), + self._import("typing", "Literal"), # Returns `str` ", ".join(f'"{m}"' for m in members), ) @@ -599,6 +602,7 @@ class PkgWriter(object): with self._indent(): if not self._write_comments(scl_method): wl("...") + wl("") def write_services( self, @@ -620,7 +624,6 @@ class PkgWriter(object): if self._write_comments(scl): wl("") self.write_methods(service, class_name, is_abstract=True, scl_prefix=scl) - wl("") # The stub client stub_class_name = service.name + "_Stub" @@ -633,7 +636,6 @@ class PkgWriter(object): self._import("google.protobuf.service", "RpcChannel"), ) self.write_methods(service, stub_class_name, is_abstract=False, scl_prefix=scl) - wl("") def _import_casttype(self, casttype: str) -> str: split = casttype.split(".") @@ -709,22 +711,20 @@ class PkgWriter(object): wl = self._write_line # _MaybeAsyncIterator[Req] is supertyped by Iterator[Req] and AsyncIterator[Req]. # So both can be used in the contravariant function parameter position. - wl("_T = {}('_T')", self._import("typing", "TypeVar")) + wl('_T = {}("_T")', self._import("typing", "TypeVar")) wl("") wl( - "class _MaybeAsyncIterator({}[_T], {}[_T], metaclass={}):", + "class _MaybeAsyncIterator({}[_T], {}[_T], metaclass={}): ...", self._import("collections.abc", "AsyncIterator"), self._import("collections.abc", "Iterator"), self._import("abc", "ABCMeta"), ) - with self._indent(): - wl("...") wl("") # _ServicerContext is supertyped by grpc.ServicerContext and grpc.aio.ServicerContext # So both can be used in the contravariant function parameter position. wl( - "class _ServicerContext({}, {}): # type: ignore", + "class _ServicerContext({}, {}): # type: ignore[misc, type-arg]", self._import("grpc", "ServicerContext"), self._import("grpc.aio", "ServicerContext"), ) @@ -758,6 +758,7 @@ class PkgWriter(object): with self._indent(): if not self._write_comments(scl): wl("...") + wl("") def write_grpc_stub_methods(self, service: d.ServiceDescriptorProto, scl_prefix: SourceCodeLocation, is_async: bool = False) -> None: wl = self._write_line @@ -774,6 +775,7 @@ class PkgWriter(object): wl("{},", self._output_type(method)) wl("]") self._write_comments(scl) + wl("") def write_grpc_services( self, @@ -799,7 +801,6 @@ class PkgWriter(object): channel = f"{self._import('typing', 'Union')}[{self._import('grpc', 'Channel')}, {self._import('grpc.aio', 'Channel')}]" wl("def __init__(self, channel: {}) -> None: ...", channel) self.write_grpc_stub_methods(service, scl) - wl("") # The (fake) async stub client wl( @@ -811,7 +812,6 @@ class PkgWriter(object): wl("") # No __init__ since this isn't a real class (yet), and requires manual casting to work. self.write_grpc_stub_methods(service, scl, is_async=True) - wl("") # The service definition interface wl( @@ -823,7 +823,6 @@ class PkgWriter(object): if self._write_comments(scl): wl("") self.write_grpc_methods(service, scl) - wl("") server = self._import("grpc", "Server") aserver = self._import("grpc.aio", "Server") wl( @@ -925,8 +924,9 @@ class PkgWriter(object): if self.lines: assert self.lines[0].startswith('"""') self.lines[0] = f'"""{HEADER}{self.lines[0][3:]}' + self._write_line("") else: - self._write_line(f'"""{HEADER}"""') + self._write_line(f'"""{HEADER}"""\n') for reexport_idx in self.fd.public_dependency: reexport_file = self.fd.dependency[reexport_idx] diff --git a/contrib/python/mypy-protobuf/ya.make b/contrib/python/mypy-protobuf/ya.make index 6ac24b9c93..efdb299b36 100644 --- a/contrib/python/mypy-protobuf/ya.make +++ b/contrib/python/mypy-protobuf/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(3.5.0) +VERSION(3.6.0) LICENSE(Apache-2.0) diff --git a/contrib/python/pytest-asyncio/.dist-info/METADATA b/contrib/python/pytest-asyncio/.dist-info/METADATA new file mode 100644 index 0000000000..c73b027ba5 --- /dev/null +++ b/contrib/python/pytest-asyncio/.dist-info/METADATA @@ -0,0 +1,91 @@ +Metadata-Version: 2.1 +Name: pytest-asyncio +Version: 0.21.1 +Summary: Pytest support for asyncio +Home-page: https://github.com/pytest-dev/pytest-asyncio +Author: Tin Tvrtković <tinchester@gmail.com> +Author-email: tinchester@gmail.com +License: Apache 2.0 +Project-URL: Documentation, https://pytest-asyncio.readthedocs.io +Project-URL: Changelog, https://pytest-asyncio.readthedocs.io/en/latest/reference/changelog.html +Project-URL: Source Code, https://github.com/pytest-dev/pytest-asyncio +Project-URL: Bug Tracker, https://github.com/pytest-dev/pytest-asyncio/issues +Classifier: Development Status :: 4 - Beta +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +Classifier: Topic :: Software Development :: Testing +Classifier: Framework :: AsyncIO +Classifier: Framework :: Pytest +Classifier: Typing :: Typed +Requires-Python: >=3.7 +Description-Content-Type: text/x-rst +License-File: LICENSE +Requires-Dist: pytest (>=7.0.0) +Requires-Dist: typing-extensions (>=3.7.2) ; python_version < "3.8" +Provides-Extra: docs +Requires-Dist: sphinx (>=5.3) ; extra == 'docs' +Requires-Dist: sphinx-rtd-theme (>=1.0) ; extra == 'docs' +Provides-Extra: testing +Requires-Dist: coverage (>=6.2) ; extra == 'testing' +Requires-Dist: hypothesis (>=5.7.1) ; extra == 'testing' +Requires-Dist: flaky (>=3.5.0) ; extra == 'testing' +Requires-Dist: mypy (>=0.931) ; extra == 'testing' +Requires-Dist: pytest-trio (>=0.7.0) ; extra == 'testing' + +pytest-asyncio +============== + +.. image:: https://img.shields.io/pypi/v/pytest-asyncio.svg + :target: https://pypi.python.org/pypi/pytest-asyncio +.. image:: https://github.com/pytest-dev/pytest-asyncio/workflows/CI/badge.svg + :target: https://github.com/pytest-dev/pytest-asyncio/actions?workflow=CI +.. image:: https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/main/graph/badge.svg + :target: https://codecov.io/gh/pytest-dev/pytest-asyncio +.. image:: https://img.shields.io/pypi/pyversions/pytest-asyncio.svg + :target: https://github.com/pytest-dev/pytest-asyncio + :alt: Supported Python versions +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/ambv/black + +`pytest-asyncio <https://pytest-asyncio.readthedocs.io/en/latest/>`_ is a `pytest <https://docs.pytest.org/en/latest/contents.html>`_ plugin. It facilitates testing of code that uses the `asyncio <https://docs.python.org/3/library/asyncio.html>`_ library. + +Specifically, pytest-asyncio provides support for coroutines as test functions. This allows users to *await* code inside their tests. For example, the following code is executed as a test item by pytest: + +.. code-block:: python + + @pytest.mark.asyncio + async def test_some_asyncio_code(): + res = await library.do_something() + assert b"expected result" == res + +More details can be found in the `documentation <https://pytest-asyncio.readthedocs.io/en/latest/>`_. + +Note that test classes subclassing the standard `unittest <https://docs.python.org/3/library/unittest.html>`__ library are not supported. Users +are advised to use `unittest.IsolatedAsyncioTestCase <https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase>`__ +or an async framework such as `asynctest <https://asynctest.readthedocs.io/en/latest>`__. + + +pytest-asyncio is available under the `Apache License 2.0 <https://github.com/pytest-dev/pytest-asyncio/blob/main/LICENSE>`_. + + +Installation +------------ + +To install pytest-asyncio, simply: + +.. code-block:: bash + + $ pip install pytest-asyncio + +This is enough for pytest to pick up pytest-asyncio. + + +Contributing +------------ +Contributions are very welcome. Tests can be run with ``tox``, please ensure +the coverage at least stays the same before you submit a pull request. diff --git a/contrib/python/pytest-asyncio/.dist-info/entry_points.txt b/contrib/python/pytest-asyncio/.dist-info/entry_points.txt new file mode 100644 index 0000000000..88db714dad --- /dev/null +++ b/contrib/python/pytest-asyncio/.dist-info/entry_points.txt @@ -0,0 +1,2 @@ +[pytest11] +asyncio = pytest_asyncio.plugin diff --git a/contrib/python/pytest-asyncio/.dist-info/top_level.txt b/contrib/python/pytest-asyncio/.dist-info/top_level.txt new file mode 100644 index 0000000000..08d05d1ecf --- /dev/null +++ b/contrib/python/pytest-asyncio/.dist-info/top_level.txt @@ -0,0 +1 @@ +pytest_asyncio diff --git a/contrib/python/pytest-asyncio/LICENSE b/contrib/python/pytest-asyncio/LICENSE new file mode 100644 index 0000000000..5c304d1a4a --- /dev/null +++ b/contrib/python/pytest-asyncio/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/contrib/python/pytest-asyncio/README.rst b/contrib/python/pytest-asyncio/README.rst new file mode 100644 index 0000000000..0682b74430 --- /dev/null +++ b/contrib/python/pytest-asyncio/README.rst @@ -0,0 +1,52 @@ +pytest-asyncio +============== + +.. image:: https://img.shields.io/pypi/v/pytest-asyncio.svg + :target: https://pypi.python.org/pypi/pytest-asyncio +.. image:: https://github.com/pytest-dev/pytest-asyncio/workflows/CI/badge.svg + :target: https://github.com/pytest-dev/pytest-asyncio/actions?workflow=CI +.. image:: https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/main/graph/badge.svg + :target: https://codecov.io/gh/pytest-dev/pytest-asyncio +.. image:: https://img.shields.io/pypi/pyversions/pytest-asyncio.svg + :target: https://github.com/pytest-dev/pytest-asyncio + :alt: Supported Python versions +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/ambv/black + +`pytest-asyncio <https://pytest-asyncio.readthedocs.io/en/latest/>`_ is a `pytest <https://docs.pytest.org/en/latest/contents.html>`_ plugin. It facilitates testing of code that uses the `asyncio <https://docs.python.org/3/library/asyncio.html>`_ library. + +Specifically, pytest-asyncio provides support for coroutines as test functions. This allows users to *await* code inside their tests. For example, the following code is executed as a test item by pytest: + +.. code-block:: python + + @pytest.mark.asyncio + async def test_some_asyncio_code(): + res = await library.do_something() + assert b"expected result" == res + +More details can be found in the `documentation <https://pytest-asyncio.readthedocs.io/en/latest/>`_. + +Note that test classes subclassing the standard `unittest <https://docs.python.org/3/library/unittest.html>`__ library are not supported. Users +are advised to use `unittest.IsolatedAsyncioTestCase <https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase>`__ +or an async framework such as `asynctest <https://asynctest.readthedocs.io/en/latest>`__. + + +pytest-asyncio is available under the `Apache License 2.0 <https://github.com/pytest-dev/pytest-asyncio/blob/main/LICENSE>`_. + + +Installation +------------ + +To install pytest-asyncio, simply: + +.. code-block:: bash + + $ pip install pytest-asyncio + +This is enough for pytest to pick up pytest-asyncio. + + +Contributing +------------ +Contributions are very welcome. Tests can be run with ``tox``, please ensure +the coverage at least stays the same before you submit a pull request. diff --git a/contrib/python/pytest-asyncio/pytest_asyncio/__init__.py b/contrib/python/pytest-asyncio/pytest_asyncio/__init__.py new file mode 100644 index 0000000000..1bc2811d93 --- /dev/null +++ b/contrib/python/pytest-asyncio/pytest_asyncio/__init__.py @@ -0,0 +1,5 @@ +"""The main point for importing pytest-asyncio items.""" +from ._version import version as __version__ # noqa +from .plugin import fixture + +__all__ = ("fixture",) diff --git a/contrib/python/pytest-asyncio/pytest_asyncio/_version.py b/contrib/python/pytest-asyncio/pytest_asyncio/_version.py new file mode 100644 index 0000000000..11f23015fb --- /dev/null +++ b/contrib/python/pytest-asyncio/pytest_asyncio/_version.py @@ -0,0 +1,4 @@ +# file generated by setuptools_scm +# don't change, don't track in version control +__version__ = version = '0.21.1' +__version_tuple__ = version_tuple = (0, 21, 1) diff --git a/contrib/python/pytest-asyncio/pytest_asyncio/plugin.py b/contrib/python/pytest-asyncio/pytest_asyncio/plugin.py new file mode 100644 index 0000000000..db93b851de --- /dev/null +++ b/contrib/python/pytest-asyncio/pytest_asyncio/plugin.py @@ -0,0 +1,624 @@ +"""pytest-asyncio implementation.""" +import asyncio +import contextlib +import enum +import functools +import inspect +import socket +import sys +import warnings +from textwrap import dedent +from typing import ( + Any, + AsyncIterator, + Awaitable, + Callable, + Dict, + Iterable, + Iterator, + List, + Optional, + Set, + TypeVar, + Union, + cast, + overload, +) + +import pytest +from pytest import ( + Config, + FixtureRequest, + Function, + Item, + Parser, + PytestPluginManager, + Session, +) + +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + +_R = TypeVar("_R") + +_ScopeName = Literal["session", "package", "module", "class", "function"] +_T = TypeVar("_T") + +SimpleFixtureFunction = TypeVar( + "SimpleFixtureFunction", bound=Callable[..., Awaitable[_R]] +) +FactoryFixtureFunction = TypeVar( + "FactoryFixtureFunction", bound=Callable[..., AsyncIterator[_R]] +) +FixtureFunction = Union[SimpleFixtureFunction, FactoryFixtureFunction] +FixtureFunctionMarker = Callable[[FixtureFunction], FixtureFunction] + +# https://github.com/pytest-dev/pytest/pull/9510 +FixtureDef = Any +SubRequest = Any + + +class Mode(str, enum.Enum): + AUTO = "auto" + STRICT = "strict" + + +ASYNCIO_MODE_HELP = """\ +'auto' - for automatically handling all async functions by the plugin +'strict' - for autoprocessing disabling (useful if different async frameworks \ +should be tested together, e.g. \ +both pytest-asyncio and pytest-trio are used in the same project) +""" + + +def pytest_addoption(parser: Parser, pluginmanager: PytestPluginManager) -> None: + group = parser.getgroup("asyncio") + group.addoption( + "--asyncio-mode", + dest="asyncio_mode", + default=None, + metavar="MODE", + help=ASYNCIO_MODE_HELP, + ) + parser.addini( + "asyncio_mode", + help="default value for --asyncio-mode", + default="auto", + ) + + +@overload +def fixture( + fixture_function: FixtureFunction, + *, + scope: "Union[_ScopeName, Callable[[str, Config], _ScopeName]]" = ..., + params: Optional[Iterable[object]] = ..., + autouse: bool = ..., + ids: Union[ + Iterable[Union[str, float, int, bool, None]], + Callable[[Any], Optional[object]], + None, + ] = ..., + name: Optional[str] = ..., +) -> FixtureFunction: + ... + + +@overload +def fixture( + fixture_function: None = ..., + *, + scope: "Union[_ScopeName, Callable[[str, Config], _ScopeName]]" = ..., + params: Optional[Iterable[object]] = ..., + autouse: bool = ..., + ids: Union[ + Iterable[Union[str, float, int, bool, None]], + Callable[[Any], Optional[object]], + None, + ] = ..., + name: Optional[str] = None, +) -> FixtureFunctionMarker: + ... + + +def fixture( + fixture_function: Optional[FixtureFunction] = None, **kwargs: Any +) -> Union[FixtureFunction, FixtureFunctionMarker]: + if fixture_function is not None: + _make_asyncio_fixture_function(fixture_function) + return pytest.fixture(fixture_function, **kwargs) + + else: + + @functools.wraps(fixture) + def inner(fixture_function: FixtureFunction) -> FixtureFunction: + return fixture(fixture_function, **kwargs) + + return inner + + +def _is_asyncio_fixture_function(obj: Any) -> bool: + obj = getattr(obj, "__func__", obj) # instance method maybe? + return getattr(obj, "_force_asyncio_fixture", False) + + +def _make_asyncio_fixture_function(obj: Any) -> None: + if hasattr(obj, "__func__"): + # instance method, check the function object + obj = obj.__func__ + obj._force_asyncio_fixture = True + + +def _is_coroutine(obj: Any) -> bool: + """Check to see if an object is really an asyncio coroutine.""" + return asyncio.iscoroutinefunction(obj) + + +def _is_coroutine_or_asyncgen(obj: Any) -> bool: + return _is_coroutine(obj) or inspect.isasyncgenfunction(obj) + + +def _get_asyncio_mode(config: Config) -> Mode: + val = config.getoption("asyncio_mode") + if val is None: + val = config.getini("asyncio_mode") + try: + return Mode(val) + except ValueError: + modes = ", ".join(m.value for m in Mode) + raise pytest.UsageError( + f"{val!r} is not a valid asyncio_mode. Valid modes: {modes}." + ) + + +def pytest_configure(config: Config) -> None: + """Inject documentation.""" + config.addinivalue_line( + "markers", + "asyncio: " + "mark the test as a coroutine, it will be " + "run using an asyncio event loop", + ) + + +@pytest.hookimpl(tryfirst=True) +def pytest_report_header(config: Config) -> List[str]: + """Add asyncio config to pytest header.""" + mode = _get_asyncio_mode(config) + return [f"asyncio: mode={mode}"] + + +def _preprocess_async_fixtures( + config: Config, + processed_fixturedefs: Set[FixtureDef], +) -> None: + asyncio_mode = _get_asyncio_mode(config) + fixturemanager = config.pluginmanager.get_plugin("funcmanage") + for fixtures in fixturemanager._arg2fixturedefs.values(): + for fixturedef in fixtures: + func = fixturedef.func + if fixturedef in processed_fixturedefs or not _is_coroutine_or_asyncgen( + func + ): + continue + if not _is_asyncio_fixture_function(func) and asyncio_mode == Mode.STRICT: + # Ignore async fixtures without explicit asyncio mark in strict mode + # This applies to pytest_trio fixtures, for example + continue + _make_asyncio_fixture_function(func) + _inject_fixture_argnames(fixturedef) + _synchronize_async_fixture(fixturedef) + assert _is_asyncio_fixture_function(fixturedef.func) + processed_fixturedefs.add(fixturedef) + + +def _inject_fixture_argnames(fixturedef: FixtureDef) -> None: + """ + Ensures that `request` and `event_loop` are arguments of the specified fixture. + """ + to_add = [] + for name in ("request", "event_loop"): + if name not in fixturedef.argnames: + to_add.append(name) + if to_add: + fixturedef.argnames += tuple(to_add) + + +def _synchronize_async_fixture(fixturedef: FixtureDef) -> None: + """ + Wraps the fixture function of an async fixture in a synchronous function. + """ + if inspect.isasyncgenfunction(fixturedef.func): + _wrap_asyncgen_fixture(fixturedef) + elif inspect.iscoroutinefunction(fixturedef.func): + _wrap_async_fixture(fixturedef) + + +def _add_kwargs( + func: Callable[..., Any], + kwargs: Dict[str, Any], + event_loop: asyncio.AbstractEventLoop, + request: SubRequest, +) -> Dict[str, Any]: + sig = inspect.signature(func) + ret = kwargs.copy() + if "request" in sig.parameters: + ret["request"] = request + if "event_loop" in sig.parameters: + ret["event_loop"] = event_loop + return ret + + +def _perhaps_rebind_fixture_func( + func: _T, instance: Optional[Any], unittest: bool +) -> _T: + if instance is not None: + # The fixture needs to be bound to the actual request.instance + # so it is bound to the same object as the test method. + unbound, cls = func, None + try: + unbound, cls = func.__func__, type(func.__self__) # type: ignore + except AttributeError: + pass + # If unittest is true, the fixture is bound unconditionally. + # otherwise, only if the fixture was bound before to an instance of + # the same type. + if unittest or (cls is not None and isinstance(instance, cls)): + func = unbound.__get__(instance) # type: ignore + return func + + +def _wrap_asyncgen_fixture(fixturedef: FixtureDef) -> None: + fixture = fixturedef.func + + @functools.wraps(fixture) + def _asyncgen_fixture_wrapper( + event_loop: asyncio.AbstractEventLoop, request: SubRequest, **kwargs: Any + ): + func = _perhaps_rebind_fixture_func( + fixture, request.instance, fixturedef.unittest + ) + gen_obj = func(**_add_kwargs(func, kwargs, event_loop, request)) + + async def setup(): + res = await gen_obj.__anext__() + return res + + def finalizer() -> None: + """Yield again, to finalize.""" + + async def async_finalizer() -> None: + try: + await gen_obj.__anext__() + except StopAsyncIteration: + pass + else: + msg = "Async generator fixture didn't stop." + msg += "Yield only once." + raise ValueError(msg) + + event_loop.run_until_complete(async_finalizer()) + + result = event_loop.run_until_complete(setup()) + request.addfinalizer(finalizer) + return result + + fixturedef.func = _asyncgen_fixture_wrapper + + +def _wrap_async_fixture(fixturedef: FixtureDef) -> None: + fixture = fixturedef.func + + @functools.wraps(fixture) + def _async_fixture_wrapper( + event_loop: asyncio.AbstractEventLoop, request: SubRequest, **kwargs: Any + ): + func = _perhaps_rebind_fixture_func( + fixture, request.instance, fixturedef.unittest + ) + + async def setup(): + res = await func(**_add_kwargs(func, kwargs, event_loop, request)) + return res + + return event_loop.run_until_complete(setup()) + + fixturedef.func = _async_fixture_wrapper + + +_HOLDER: Set[FixtureDef] = set() + + +@pytest.hookimpl(tryfirst=True) +def pytest_pycollect_makeitem( + collector: Union[pytest.Module, pytest.Class], name: str, obj: object +) -> Union[ + pytest.Item, pytest.Collector, List[Union[pytest.Item, pytest.Collector]], None +]: + """A pytest hook to collect asyncio coroutines.""" + if not collector.funcnamefilter(name): + return None + _preprocess_async_fixtures(collector.config, _HOLDER) + return None + + +def pytest_collection_modifyitems( + session: Session, config: Config, items: List[Item] +) -> None: + """ + Marks collected async test items as `asyncio` tests. + + The mark is only applied in `AUTO` mode. It is applied to: + + - coroutines + - staticmethods wrapping coroutines + - Hypothesis tests wrapping coroutines + + """ + if _get_asyncio_mode(config) != Mode.AUTO: + return + function_items = (item for item in items if isinstance(item, Function)) + for function_item in function_items: + function = function_item.obj + if isinstance(function, staticmethod): + # staticmethods need to be unwrapped. + function = function.__func__ + if ( + _is_coroutine(function) + or _is_hypothesis_test(function) + and _hypothesis_test_wraps_coroutine(function) + ): + function_item.add_marker("asyncio") + + +def _hypothesis_test_wraps_coroutine(function: Any) -> bool: + return _is_coroutine(function.hypothesis.inner_test) + + +@pytest.hookimpl(hookwrapper=True) +def pytest_fixture_setup( + fixturedef: FixtureDef, request: SubRequest +) -> Optional[object]: + """Adjust the event loop policy when an event loop is produced.""" + if fixturedef.argname == "event_loop": + # The use of a fixture finalizer is preferred over the + # pytest_fixture_post_finalizer hook. The fixture finalizer is invoked once + # for each fixture, whereas the hook may be invoked multiple times for + # any specific fixture. + # see https://github.com/pytest-dev/pytest/issues/5848 + _add_finalizers( + fixturedef, + _close_event_loop, + _provide_clean_event_loop, + ) + outcome = yield + loop = outcome.get_result() + policy = asyncio.get_event_loop_policy() + try: + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + old_loop = policy.get_event_loop() + if old_loop is not loop: + old_loop.close() + except RuntimeError: + # Either the current event loop has been set to None + # or the loop policy doesn't specify to create new loops + # or we're not in the main thread + pass + policy.set_event_loop(loop) + return + + yield + + +def _add_finalizers(fixturedef: FixtureDef, *finalizers: Callable[[], object]) -> None: + """ + Regsiters the specified fixture finalizers in the fixture. + + Finalizers need to specified in the exact order in which they should be invoked. + + :param fixturedef: Fixture definition which finalizers should be added to + :param finalizers: Finalizers to be added + """ + for finalizer in reversed(finalizers): + fixturedef.addfinalizer(finalizer) + + +_UNCLOSED_EVENT_LOOP_WARNING = dedent( + """\ + pytest-asyncio detected an unclosed event loop when tearing down the event_loop + fixture: %r + pytest-asyncio will close the event loop for you, but future versions of the + library will no longer do so. In order to ensure compatibility with future + versions, please make sure that: + 1. Any custom "event_loop" fixture properly closes the loop after yielding it + 2. The scopes of your custom "event_loop" fixtures do not overlap + 3. Your code does not modify the event loop in async fixtures or tests + """ +) + + +def _close_event_loop() -> None: + policy = asyncio.get_event_loop_policy() + try: + loop = policy.get_event_loop() + except RuntimeError: + loop = None + if loop is not None: + if not loop.is_closed(): + warnings.warn( + _UNCLOSED_EVENT_LOOP_WARNING % loop, + DeprecationWarning, + ) + loop.close() + + +def _provide_clean_event_loop() -> None: + # At this point, the event loop for the current thread is closed. + # When a user calls asyncio.get_event_loop(), they will get a closed loop. + # In order to avoid this side effect from pytest-asyncio, we need to replace + # the current loop with a fresh one. + # Note that we cannot set the loop to None, because get_event_loop only creates + # a new loop, when set_event_loop has not been called. + policy = asyncio.get_event_loop_policy() + new_loop = policy.new_event_loop() + policy.set_event_loop(new_loop) + + +@pytest.hookimpl(tryfirst=True, hookwrapper=True) +def pytest_pyfunc_call(pyfuncitem: pytest.Function) -> Optional[object]: + """ + Pytest hook called before a test case is run. + + Wraps marked tests in a synchronous function + where the wrapped test coroutine is executed in an event loop. + """ + marker = pyfuncitem.get_closest_marker("asyncio") + if marker is not None: + funcargs: Dict[str, object] = pyfuncitem.funcargs # type: ignore[name-defined] + loop = cast(asyncio.AbstractEventLoop, funcargs["event_loop"]) + if _is_hypothesis_test(pyfuncitem.obj): + pyfuncitem.obj.hypothesis.inner_test = wrap_in_sync( + pyfuncitem, + pyfuncitem.obj.hypothesis.inner_test, + _loop=loop, + ) + else: + pyfuncitem.obj = wrap_in_sync( + pyfuncitem, + pyfuncitem.obj, + _loop=loop, + ) + yield + + +def _is_hypothesis_test(function: Any) -> bool: + return getattr(function, "is_hypothesis_test", False) + + +def wrap_in_sync( + pyfuncitem: pytest.Function, + func: Callable[..., Awaitable[Any]], + _loop: asyncio.AbstractEventLoop, +): + """Return a sync wrapper around an async function executing it in the + current event loop.""" + + # if the function is already wrapped, we rewrap using the original one + # not using __wrapped__ because the original function may already be + # a wrapped one + raw_func = getattr(func, "_raw_test_func", None) + if raw_func is not None: + func = raw_func + + @functools.wraps(func) + def inner(*args, **kwargs): + coro = func(*args, **kwargs) + if not inspect.isawaitable(coro): + pyfuncitem.warn( + pytest.PytestWarning( + f"The test {pyfuncitem} is marked with '@pytest.mark.asyncio' " + "but it is not an async function. " + "Please remove asyncio marker. " + "If the test is not marked explicitly, " + "check for global markers applied via 'pytestmark'." + ) + ) + return + task = asyncio.ensure_future(coro, loop=_loop) + try: + return _loop.run_until_complete(task) + except BaseException: + # run_until_complete doesn't get the result from exceptions + # that are not subclasses of `Exception`. Consume all + # exceptions to prevent asyncio's warning from logging. + if task.done() and not task.cancelled(): + task.exception() + raise + + inner._raw_test_func = func # type: ignore[attr-defined] + return inner + + +def pytest_runtest_setup(item: pytest.Item) -> None: + marker = item.get_closest_marker("asyncio") + if marker is None: + return + fixturenames = item.fixturenames # type: ignore[attr-defined] + # inject an event loop fixture for all async tests + if "event_loop" in fixturenames: + fixturenames.remove("event_loop") + fixturenames.insert(0, "event_loop") + obj = getattr(item, "obj", None) + if not getattr(obj, "hypothesis", False) and getattr( + obj, "is_hypothesis_test", False + ): + pytest.fail( + "test function `%r` is using Hypothesis, but pytest-asyncio " + "only works with Hypothesis 3.64.0 or later." % item + ) + + +@pytest.fixture +def event_loop(request: FixtureRequest) -> Iterator[asyncio.AbstractEventLoop]: + """Create an instance of the default event loop for each test case.""" + loop = asyncio.get_event_loop_policy().new_event_loop() + yield loop + loop.close() + + +def _unused_port(socket_type: int) -> int: + """Find an unused localhost port from 1024-65535 and return it.""" + with contextlib.closing(socket.socket(type=socket_type)) as sock: + sock.bind(("127.0.0.1", 0)) + return sock.getsockname()[1] + + +@pytest.fixture +def unused_tcp_port() -> int: + return _unused_port(socket.SOCK_STREAM) + + +@pytest.fixture +def unused_udp_port() -> int: + return _unused_port(socket.SOCK_DGRAM) + + +@pytest.fixture(scope="session") +def unused_tcp_port_factory() -> Callable[[], int]: + """A factory function, producing different unused TCP ports.""" + produced = set() + + def factory(): + """Return an unused port.""" + port = _unused_port(socket.SOCK_STREAM) + + while port in produced: + port = _unused_port(socket.SOCK_STREAM) + + produced.add(port) + + return port + + return factory + + +@pytest.fixture(scope="session") +def unused_udp_port_factory() -> Callable[[], int]: + """A factory function, producing different unused UDP ports.""" + produced = set() + + def factory(): + """Return an unused port.""" + port = _unused_port(socket.SOCK_DGRAM) + + while port in produced: + port = _unused_port(socket.SOCK_DGRAM) + + produced.add(port) + + return port + + return factory diff --git a/contrib/python/pytest-asyncio/pytest_asyncio/py.typed b/contrib/python/pytest-asyncio/pytest_asyncio/py.typed new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/contrib/python/pytest-asyncio/pytest_asyncio/py.typed diff --git a/contrib/python/pytest-asyncio/ya.make b/contrib/python/pytest-asyncio/ya.make new file mode 100644 index 0000000000..e3918ea4b0 --- /dev/null +++ b/contrib/python/pytest-asyncio/ya.make @@ -0,0 +1,30 @@ +# Generated by devtools/yamaker (pypi). + +PY3_LIBRARY() + +VERSION(0.21.1) + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/python/pytest +) + +NO_LINT() + +PY_SRCS( + TOP_LEVEL + pytest_asyncio/__init__.py + pytest_asyncio/_version.py + pytest_asyncio/plugin.py +) + +RESOURCE_FILES( + PREFIX contrib/python/pytest-asyncio/ + .dist-info/METADATA + .dist-info/entry_points.txt + .dist-info/top_level.txt + pytest_asyncio/py.typed +) + +END() diff --git a/contrib/python/types-protobuf/.dist-info/METADATA b/contrib/python/types-protobuf/.dist-info/METADATA index ce1d526999..d4c7134a6a 100644 --- a/contrib/python/types-protobuf/.dist-info/METADATA +++ b/contrib/python/types-protobuf/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: types-protobuf -Version: 5.27.0.20240907 +Version: 5.27.0.20240920 Summary: Typing stubs for protobuf Home-page: https://github.com/python/typeshed License: Apache-2.0 @@ -31,7 +31,7 @@ The source for this package can be found at https://github.com/python/typeshed/tree/main/stubs/protobuf. All fixes for types and metadata should be contributed there. -Partially generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) and libprotoc 26.1 on [protobuf v27.1](https://github.com/protocolbuffers/protobuf/releases/tag/v27.1) (python protobuf==5.27.1). +Partially generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) and libprotoc 26.1 on [protobuf v27.1](https://github.com/protocolbuffers/protobuf/releases/tag/v27.1) (python `protobuf==5.27.1`). This stub package is marked as [partial](https://peps.python.org/pep-0561/#partial-stub-packages). If you find that annotations are missing, feel free to contribute and help complete them. @@ -39,6 +39,6 @@ If you find that annotations are missing, feel free to contribute and help compl See https://github.com/python/typeshed/blob/main/README.md for more details. This package was generated from typeshed commit -[`e8e9291c76f50c3bcde79e7bb61060f5c24c054e`](https://github.com/python/typeshed/commit/e8e9291c76f50c3bcde79e7bb61060f5c24c054e) and was tested -with mypy 1.11.1, pyright 1.1.379, and -pytype 2024.4.11. +[`c025e37bbb67f99f9d83c2eecb79e7405f77359b`](https://github.com/python/typeshed/commit/c025e37bbb67f99f9d83c2eecb79e7405f77359b) and was tested +with mypy 1.11.1, pyright 1.1.381, and +pytype 2024.9.13. diff --git a/contrib/python/types-protobuf/google-stubs/METADATA.toml b/contrib/python/types-protobuf/google-stubs/METADATA.toml index 9e402da864..f08d51e7fc 100644 --- a/contrib/python/types-protobuf/google-stubs/METADATA.toml +++ b/contrib/python/types-protobuf/google-stubs/METADATA.toml @@ -1,8 +1,8 @@ -# Whenever you update version here, PROTOBUF_VERSION should be updated -# in scripts/generate_proto_stubs.sh and vice-versa. +# Whenever you update version here, PACKAGE_VERSION should be updated +# in scripts/sync_proto/google_protobuf.py and vice-versa. version = "5.27.*" upstream_repository = "https://github.com/protocolbuffers/protobuf" -extra_description = "Partially generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) and libprotoc 26.1 on [protobuf v27.1](https://github.com/protocolbuffers/protobuf/releases/tag/v27.1) (python protobuf==5.27.1)." +extra_description = "Partially generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) and libprotoc 26.1 on [protobuf v27.1](https://github.com/protocolbuffers/protobuf/releases/tag/v27.1) (python `protobuf==5.27.1`)." partial_stub = true [tool.stubtest] diff --git a/contrib/python/types-protobuf/ya.make b/contrib/python/types-protobuf/ya.make index f2e94d656a..d817e8af94 100644 --- a/contrib/python/types-protobuf/ya.make +++ b/contrib/python/types-protobuf/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(5.27.0.20240907) +VERSION(5.27.0.20240920) LICENSE(Apache-2.0) diff --git a/contrib/tools/m4/lib/binary-io.h b/contrib/tools/m4/lib/binary-io.h index 423c2ae3ff..256c23a0ea 100644 --- a/contrib/tools/m4/lib/binary-io.h +++ b/contrib/tools/m4/lib/binary-io.h @@ -25,6 +25,14 @@ so we include it here first. */ #include <stdio.h> +#ifndef O_BINARY + #define O_BINARY 0 +#endif + +#ifndef O_TEXT + #define O_TEXT 0 +#endif + #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." #endif diff --git a/contrib/tools/m4/lib/calloc.c b/contrib/tools/m4/lib/calloc.c deleted file mode 100644 index 475d0aeab9..0000000000 --- a/contrib/tools/m4/lib/calloc.c +++ /dev/null @@ -1,73 +0,0 @@ -/* calloc() function that is glibc compatible. - This wrapper function is required at least on Tru64 UNIX 5.1 and mingw. - Copyright (C) 2004-2007, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -/* written by Jim Meyering and Bruno Haible */ - -#include <config.h> -/* Only the AC_FUNC_CALLOC macro defines 'calloc' already in config.h. */ -#ifdef calloc -# define NEED_CALLOC_GNU 1 -# undef calloc -/* Whereas the gnulib module 'calloc-gnu' defines HAVE_CALLOC_GNU. */ -#elif GNULIB_CALLOC_GNU && !HAVE_CALLOC_GNU -# define NEED_CALLOC_GNU 1 -#endif - -/* Specification. */ -#include <stdlib.h> - -#include <errno.h> - -/* Call the system's calloc below. */ -#undef calloc - -/* Allocate and zero-fill an NxS-byte block of memory from the heap. - If N or S is zero, allocate and zero-fill a 1-byte block. */ - -void * -rpl_calloc (size_t n, size_t s) -{ - void *result; - -#if NEED_CALLOC_GNU - if (n == 0 || s == 0) - { - n = 1; - s = 1; - } - else - { - /* Defend against buggy calloc implementations that mishandle - size_t overflow. */ - size_t bytes = n * s; - if (bytes / s != n) - { - errno = ENOMEM; - return NULL; - } - } -#endif - - result = calloc (n, s); - -#if !HAVE_CALLOC_POSIX - if (result == NULL) - errno = ENOMEM; -#endif - - return result; -} diff --git a/contrib/tools/m4/lib/platform/posix/config.h b/contrib/tools/m4/lib/config-linux.h index 8fa4b4f092..8fa4b4f092 100644 --- a/contrib/tools/m4/lib/platform/posix/config.h +++ b/contrib/tools/m4/lib/config-linux.h diff --git a/contrib/tools/m4/lib/platform/win64/config.h b/contrib/tools/m4/lib/config-win.h index e05b4a31af..6122ff773c 100644 --- a/contrib/tools/m4/lib/platform/win64/config.h +++ b/contrib/tools/m4/lib/config-win.h @@ -1,8 +1,6 @@ /* lib/config.h. Generated from config.hin by configure. */ /* lib/config.hin. Generated from configure.ac by autoheader. */ -#include "win_sdk10.h" - /* Define if building universal (internal helper macro) */ /* #undef AC_APPLE_UNIVERSAL_BUILD */ diff --git a/contrib/tools/m4/lib/config.h b/contrib/tools/m4/lib/config.h new file mode 100644 index 0000000000..5623f311fa --- /dev/null +++ b/contrib/tools/m4/lib/config.h @@ -0,0 +1,7 @@ +#pragma once + +#if defined(_MSC_VER) +# include "config-win.h" +#else +# include "config-linux.h" +#endif diff --git a/contrib/tools/m4/lib/platform/posix/configmake.h b/contrib/tools/m4/lib/configmake-linux.h index 75ea1d7d03..75ea1d7d03 100644 --- a/contrib/tools/m4/lib/platform/posix/configmake.h +++ b/contrib/tools/m4/lib/configmake-linux.h diff --git a/contrib/tools/m4/lib/platform/win64/configmake.h b/contrib/tools/m4/lib/configmake-win.h index 736cfb1bc6..736cfb1bc6 100644 --- a/contrib/tools/m4/lib/platform/win64/configmake.h +++ b/contrib/tools/m4/lib/configmake-win.h diff --git a/contrib/tools/m4/lib/configmake.h b/contrib/tools/m4/lib/configmake.h new file mode 100644 index 0000000000..18b15176ab --- /dev/null +++ b/contrib/tools/m4/lib/configmake.h @@ -0,0 +1,7 @@ +#pragma once + +#if defined(_MSC_VER) +# include "configmake-win.h" +#else +# include "configmake-linux.h" +#endif diff --git a/contrib/tools/m4/lib/platform/posix/fcntl.h b/contrib/tools/m4/lib/fcntl.h index a7a7d03b20..39b4f4d5eb 100644 --- a/contrib/tools/m4/lib/platform/posix/fcntl.h +++ b/contrib/tools/m4/lib/fcntl.h @@ -1,7 +1,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Like <fcntl.h>, but with non-working flags defined to 0. - Copyright (C) 2006-2013 Free Software Foundation, Inc. + Copyright (C) 2006-2021 Free Software Foundation, Inc. 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 @@ -14,7 +14,7 @@ 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 <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* written by Paul Eggert */ @@ -35,11 +35,17 @@ extern "C" { ... } block, which leads to errors in C++ mode with the overridden <sys/stat.h> from gnulib. These errors are known to be gone with g++ version >= 4.3. */ -#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) +#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) # include <sys/stat.h> #endif #include_next <fcntl.h> +/* Native Windows platforms declare open(), creat() in <io.h>. */ +#if (IN_M4_GNULIB_TESTS || 1 || defined GNULIB_POSIXCHECK) \ + && (defined _WIN32 && ! defined __CYGWIN__) +# include <io.h> +#endif + #else /* Normal invocation convention. */ @@ -54,12 +60,18 @@ extern "C" { ... } block, which leads to errors in C++ mode with the overridden <sys/stat.h> from gnulib. These errors are known to be gone with g++ version >= 4.3. */ -#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) +#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) # include <sys/stat.h> #endif /* The include_next requires a split double-inclusion guard. */ #include_next <fcntl.h> +/* Native Windows platforms declare open(), creat() in <io.h>. */ +#if (IN_M4_GNULIB_TESTS || 1 || defined GNULIB_POSIXCHECK) \ + && (defined _WIN32 && ! defined __CYGWIN__) +# include <io.h> +#endif + #ifndef _GL_M4_FCNTL_H #define _GL_M4_FCNTL_H @@ -67,17 +79,36 @@ # include <unistd.h> #endif -/* Native Windows platforms declare open(), creat() in <io.h>. */ -#if (1 || defined GNULIB_POSIXCHECK) \ - && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) -# include <io.h> -#endif - /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ +/* C++ compatible function declaration macros. + Copyright (C) 2010-2021 Free Software Foundation, Inc. + + 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/>. */ + #ifndef _GL_CXXDEFS_H #define _GL_CXXDEFS_H +/* Begin/end the GNULIB_NAMESPACE namespace. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { +# define _GL_END_NAMESPACE } +#else +# define _GL_BEGIN_NAMESPACE +# define _GL_END_NAMESPACE +#endif + /* The three most frequent use cases of these macros are: * For providing a substitute for a function that is missing on some @@ -172,14 +203,25 @@ that redirects to rpl_func, if GNULIB_NAMESPACE is defined. Example: _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); - */ + + Wrapping rpl_func in an object with an inline conversion operator + avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is + actually used in the program. */ #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) #if defined __cplusplus && defined GNULIB_NAMESPACE # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ namespace GNULIB_NAMESPACE \ { \ - rettype (*const func) parameters = ::rpl_func; \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return ::rpl_func; \ + } \ + } func = {}; \ } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else @@ -187,6 +229,16 @@ _GL_EXTERN_C int _gl_cxxalias_dummy #endif +/* _GL_CXXALIAS_MDA (func, rettype, parameters); + is to be used when func is a Microsoft deprecated alias, on native Windows. + It declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to _func, if GNULIB_NAMESPACE is defined. + Example: + _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); + */ +#define _GL_CXXALIAS_MDA(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) + /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); except that the C function rpl_func may have a slightly different @@ -196,8 +248,15 @@ # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ namespace GNULIB_NAMESPACE \ { \ - rettype (*const func) parameters = \ - reinterpret_cast<rettype(*)parameters>(::rpl_func); \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast<type>(::rpl_func); \ + } \ + } func = {}; \ } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else @@ -205,25 +264,38 @@ _GL_EXTERN_C int _gl_cxxalias_dummy #endif +/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters); + is like _GL_CXXALIAS_MDA (func, rettype, parameters); + except that the C function func may have a slightly different declaration. + A cast is used to silence the "invalid conversion" error that would + otherwise occur. */ +#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters) + /* _GL_CXXALIAS_SYS (func, rettype, parameters); declares a C++ alias called GNULIB_NAMESPACE::func that redirects to the system provided function func, if GNULIB_NAMESPACE is defined. Example: _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); - */ + + Wrapping func in an object with an inline conversion operator + avoids a reference to func unless GNULIB_NAMESPACE::func is + actually used in the program. */ #if defined __cplusplus && defined GNULIB_NAMESPACE - /* If we were to write - rettype (*const func) parameters = ::func; - like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls - better (remove an indirection through a 'static' pointer variable), - but then the _GL_CXXALIASWARN macro below would cause a warning not only - for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ -# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static rettype (*func) parameters = ::func; \ - } \ +# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return ::func; \ + } \ + } func = {}; \ + } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ @@ -239,8 +311,15 @@ # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ namespace GNULIB_NAMESPACE \ { \ - static rettype (*func) parameters = \ - reinterpret_cast<rettype(*)parameters>(::func); \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast<type>(::func); \ + } \ + } func = {}; \ } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else @@ -263,9 +342,15 @@ # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ namespace GNULIB_NAMESPACE \ { \ - static rettype (*func) parameters = \ - reinterpret_cast<rettype(*)parameters>( \ - (rettype2(*)parameters2)(::func)); \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ + } \ + } func = {}; \ } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else @@ -282,9 +367,9 @@ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) # define _GL_CXXALIASWARN_1(func,namespace) \ _GL_CXXALIASWARN_2 (func, namespace) -/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, +/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ +# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) # define _GL_CXXALIASWARN_2(func,namespace) \ _GL_WARN_ON_USE (func, \ "The symbol ::" #func " refers to the system function. " \ @@ -310,16 +395,13 @@ GNULIB_NAMESPACE) # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) -/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, +/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ +# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ + _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ "The symbol ::" #func " refers to the system function. " \ "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - extern __typeof__ (func) func # else # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ _GL_EXTERN_C int _gl_cxxalias_dummy @@ -332,11 +414,27 @@ #endif /* _GL_CXXDEFS_H */ /* The definition of _GL_ARG_NONNULL is copied here. */ +/* A C macro for declaring that specific arguments must not be NULL. + Copyright (C) 2009-2021 Free Software Foundation, Inc. + + 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/>. */ + /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools that the values passed as arguments n, ..., m must be non-NULL pointers. n = 1 stands for the first argument, n = 2 for the second argument etc. */ #ifndef _GL_ARG_NONNULL -# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) # else # define _GL_ARG_NONNULL(params) @@ -344,40 +442,143 @@ #endif /* The definition of _GL_WARN_ON_USE is copied here. */ +/* A C macro for emitting warnings if a function is used. + Copyright (C) 2010-2021 Free Software Foundation, Inc. + + 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/>. */ + +/* _GL_WARN_ON_USE (function, "literal string") issues a declaration + for FUNCTION which will then trigger a compiler warning containing + the text of "literal string" anywhere that function is called, if + supported by the compiler. If the compiler does not support this + feature, the macro expands to an unused extern declaration. + + _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the + attribute used in _GL_WARN_ON_USE. If the compiler does not support + this feature, it expands to empty. + + These macros are useful for marking a function as a potential + portability trap, with the intent that "literal string" include + instructions on the replacement function that should be used + instead. + _GL_WARN_ON_USE is for functions with 'extern' linkage. + _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' + linkage. + + However, one of the reasons that a function is a portability trap is + if it has the wrong signature. Declaring FUNCTION with a different + signature in C is a compilation error, so this macro must use the + same type as any existing declaration so that programs that avoid + the problematic FUNCTION do not fail to compile merely because they + included a header that poisoned the function. But this implies that + _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already + have a declaration. Use of this macro implies that there must not + be any other macro hiding the declaration of FUNCTION; but + undefining FUNCTION first is part of the poisoning process anyway + (although for symbols that are provided only via a macro, the result + is a compilation error rather than a warning containing + "literal string"). Also note that in C++, it is only safe to use if + FUNCTION has no overloads. + + For an example, it is possible to poison 'getline' by: + - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], + [getline]) in configure.ac, which potentially defines + HAVE_RAW_DECL_GETLINE + - adding this code to a header that wraps the system <stdio.h>: + #undef getline + #if HAVE_RAW_DECL_GETLINE + _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" + "not universally present; use the gnulib module getline"); + #endif + + It is not possible to directly poison global variables. But it is + possible to write a wrapper accessor function, and poison that + (less common usage, like &environ, will cause a compilation error + rather than issue the nice warning, but the end result of informing + the developer about their portability problem is still achieved): + #if HAVE_RAW_DECL_ENVIRON + static char *** + rpl_environ (void) { return &environ; } + _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); + # undef environ + # define environ (*rpl_environ ()) + #endif + or better (avoiding contradictory use of 'static' and 'extern'): + #if HAVE_RAW_DECL_ENVIRON + static char *** + _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") + rpl_environ (void) { return &environ; } + # undef environ + # define environ (*rpl_environ ()) + #endif + */ #ifndef _GL_WARN_ON_USE # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) /* A compiler attribute is available in gcc versions 4.3.0 and later. */ # define _GL_WARN_ON_USE(function, message) \ extern __typeof__ (function) function __attribute__ ((__warning__ (message))) +# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ + __attribute__ ((__warning__ (message))) +# elif __clang_major__ >= 4 +/* Another compiler attribute is available in clang. */ +# define _GL_WARN_ON_USE(function, message) \ +extern __typeof__ (function) function \ + __attribute__ ((__diagnose_if__ (1, message, "warning"))) +# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ + __attribute__ ((__diagnose_if__ (1, message, "warning"))) # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING /* Verify the existence of the function. */ # define _GL_WARN_ON_USE(function, message) \ extern __typeof__ (function) function +# define _GL_WARN_ON_USE_ATTRIBUTE(message) # else /* Unsupported. */ # define _GL_WARN_ON_USE(function, message) \ _GL_WARN_EXTERN_C int _gl_warn_on_use +# define _GL_WARN_ON_USE_ATTRIBUTE(message) # endif #endif -/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") - is like _GL_WARN_ON_USE (function, "string"), except that the function is - declared with the given prototype, consisting of return type, parameters, - and attributes. +/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message") + is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the + function is declared with the given prototype, consisting of return type, + parameters, and attributes. This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does not work in this case. */ #ifndef _GL_WARN_ON_USE_CXX -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes \ - __attribute__ ((__warning__ (msg))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +# if !defined __cplusplus +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ + _GL_WARN_ON_USE (function, msg) +# else +# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +/* A compiler attribute is available in gcc versions 4.3.0 and later. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +extern rettype_gcc function parameters_and_attributes \ + __attribute__ ((__warning__ (msg))) +# elif __clang_major__ >= 4 +/* Another compiler attribute is available in clang. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +extern rettype_clang function parameters_and_attributes \ + __attribute__ ((__diagnose_if__ (1, msg, "warning"))) +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING /* Verify the existence of the function. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes -# else /* Unsupported. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +extern rettype_gcc function parameters_and_attributes +# else /* Unsupported. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ _GL_WARN_EXTERN_C int _gl_warn_on_use +# endif # endif #endif @@ -394,6 +595,47 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use /* Declare overridden functions. */ +#if IN_M4_GNULIB_TESTS +# if 0 +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef creat +# define creat rpl_creat +# endif +_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef creat +# define creat _creat +# endif +_GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode)); +# else +_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); +# endif +_GL_CXXALIASWARN (creat); +#elif defined GNULIB_POSIXCHECK +# undef creat +/* Assume creat is always declared. */ +_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - " + "use gnulib module creat for portability"); +#elif 1 +/* On native Windows, map 'creat' to '_creat', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::creat always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef creat +# define creat _creat +# endif +/* Need to cast, because in mingw the last argument is 'int mode'. */ +_GL_CXXALIAS_MDA_CAST (creat, int, (const char *filename, mode_t mode)); +# else +_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); +# endif +_GL_CXXALIASWARN (creat); +#endif + #if 1 # if 1 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -402,9 +644,15 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use # endif _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); +# if !GNULIB_defined_rpl_fcntl +# define GNULIB_defined_rpl_fcntl 1 +# endif # else # if !1 _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); +# if !GNULIB_defined_fcntl +# define GNULIB_defined_fcntl 1 +# endif # endif _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...)); # endif @@ -426,6 +674,12 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef open +# define open _open +# endif +_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); # else _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); # endif @@ -439,9 +693,25 @@ _GL_CXXALIASWARN (open); /* Assume open is always declared. */ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - " "use gnulib module open for portability"); +#elif 1 +/* On native Windows, map 'open' to '_open', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::open always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef open +# define open _open +# endif +_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); +# else +_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); +# endif +# if !defined __hpux +_GL_CXXALIASWARN (open); +# endif #endif -#if 0 +#if 1 # if 0 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef openat @@ -498,6 +768,22 @@ _GL_WARN_ON_USE (openat, "openat is not portable - " /* Fix up the O_* macros. */ +/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT + to values outside 'int' range, so omit these misdefinitions. + But avoid namespace pollution on non-AIX systems. */ +#ifdef _AIX +# include <limits.h> +# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX) +# undef O_CLOEXEC +# endif +# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX) +# undef O_NOFOLLOW +# endif +# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX) +# undef O_TTY_INIT +# endif +#endif + #if !defined O_DIRECT && defined O_DIRECTIO /* Tru64 spells it 'O_DIRECTIO'. */ # define O_DIRECT O_DIRECTIO @@ -509,7 +795,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - " #endif #ifndef O_CLOEXEC -# define O_CLOEXEC 0 +# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */ +# define GNULIB_defined_O_CLOEXEC 1 +#else +# define GNULIB_defined_O_CLOEXEC 0 #endif #ifndef O_DIRECT diff --git a/contrib/tools/m4/lib/float.c b/contrib/tools/m4/lib/float.c deleted file mode 100644 index 366945fa38..0000000000 --- a/contrib/tools/m4/lib/float.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Auxiliary definitions for <float.h>. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2011. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <float.h> - -#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ -const union gl_long_double_union gl_LDBL_MAX = - { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } }; -#elif defined __i386__ -const union gl_long_double_union gl_LDBL_MAX = - { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } }; -#else -/* This declaration is solely to ensure that after preprocessing - this file is never empty. */ -typedef int dummy; -#endif diff --git a/contrib/tools/m4/lib/fopen.c b/contrib/tools/m4/lib/fopen.c deleted file mode 100644 index f9d6763d21..0000000000 --- a/contrib/tools/m4/lib/fopen.c +++ /dev/null @@ -1,110 +0,0 @@ -/* Open a stream to a file. - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ - -/* If the user's config.h happens to include <stdio.h>, let it include only - the system's <stdio.h> here, so that orig_fopen doesn't recurse to - rpl_fopen. */ -#define __need_FILE -#include <config.h> - -/* Get the original definition of fopen. It might be defined as a macro. */ -#include <stdio.h> -#undef __need_FILE - -static FILE * -orig_fopen (const char *filename, const char *mode) -{ - return fopen (filename, mode); -} - -/* Specification. */ -/* Write "stdio.h" here, not <stdio.h>, otherwise OSF/1 5.1 DTK cc eliminates - this include because of the preliminary #include <stdio.h> above. */ -#include "stdio.h" - -#include <errno.h> -#include <fcntl.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> - -FILE * -rpl_fopen (const char *filename, const char *mode) -{ -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - if (strcmp (filename, "/dev/null") == 0) - filename = "NUL"; -#endif - -#if FOPEN_TRAILING_SLASH_BUG - /* If the filename ends in a slash and a mode that requires write access is - specified, then fail. - Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html> - says that - "A pathname that contains at least one non-slash character and that - ends with one or more trailing slashes shall be resolved as if a - single dot character ( '.' ) were appended to the pathname." - and - "The special filename dot shall refer to the directory specified by - its predecessor." - If the named file already exists as a directory, then if a mode that - requires write access is specified, fopen() must fail because POSIX - <http://www.opengroup.org/susv3/functions/fopen.html> says that it - fails with errno = EISDIR in this case. - If the named file does not exist or does not name a directory, then - fopen() must fail since the file does not contain a '.' directory. */ - { - size_t len = strlen (filename); - if (len > 0 && filename[len - 1] == '/') - { - int fd; - struct stat statbuf; - FILE *fp; - - if (mode[0] == 'w' || mode[0] == 'a') - { - errno = EISDIR; - return NULL; - } - - fd = open (filename, O_RDONLY); - if (fd < 0) - return NULL; - - if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) - { - close (fd); - errno = ENOTDIR; - return NULL; - } - - fp = fdopen (fd, mode); - if (fp == NULL) - { - int saved_errno = errno; - close (fd); - errno = saved_errno; - } - return fp; - } - } -# endif - - return orig_fopen (filename, mode); -} diff --git a/contrib/tools/m4/lib/fpending.c b/contrib/tools/m4/lib/fpending.c index 1bc4568923..7c61f7eea7 100644 --- a/contrib/tools/m4/lib/fpending.c +++ b/contrib/tools/m4/lib/fpending.c @@ -1,5 +1,5 @@ /* fpending.c -- return the number of pending output bytes on a stream - Copyright (C) 2000, 2004, 2006-2007, 2009-2013 Free Software Foundation, + Copyright (C) 2000, 2004, 2006-2007, 2009-2021 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -13,22 +13,51 @@ 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 <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Jim Meyering. */ #include <config.h> +/* Specification. */ #include "fpending.h" +#include "stdio-impl.h" + +/* This file is not used on systems that already have the __fpending function, + namely glibc >= 2.2, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.34, + Android API >= 23. */ + /* Return the number of pending (aka buffered, unflushed) bytes on the stream, FP, that is open for writing. */ size_t __fpending (FILE *fp) { -#if defined(PENDING_OUTPUT_N_BYTES) - return PENDING_OUTPUT_N_BYTES; + /* Most systems provide FILE as a struct and the necessary bitmask in + <stdio.h>, because they need it for implementing getc() and putc() as + fast macros. */ +#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 + /* GNU libc, BeOS, Haiku, Linux libc5 */ + return fp->_IO_write_ptr - fp->_IO_write_base; +#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */ + return fp->_p - fp->_bf._base; +#elif defined __EMX__ /* emx+gcc */ + return fp->_ptr - fp->_buffer; +#elif defined __minix /* Minix */ + return fp_->_ptr - fp_->_buf; +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ + return (fp_->_ptr ? fp_->_ptr - fp_->_base : 0); +#elif defined __UCLIBC__ /* uClibc */ + return (fp->__modeflags & __FLAG_WRITING ? fp->__bufpos - fp->__bufstart : 0); +#elif defined __QNX__ /* QNX */ + return (fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0); +#elif defined __MINT__ /* Atari FreeMiNT */ + return fp->__bufp - fp->__buffer; +#elif defined EPLAN9 /* Plan9 */ + return fp->wp - fp->buf; +#else +# error "Please port gnulib fpending.c to your platform!" + return 1; #endif - - return 0; } diff --git a/contrib/tools/m4/lib/fpurge.c b/contrib/tools/m4/lib/fpurge.c index 09c9ea82c7..139a43627f 100644 --- a/contrib/tools/m4/lib/fpurge.c +++ b/contrib/tools/m4/lib/fpurge.c @@ -1,5 +1,5 @@ /* Flushing buffers of a FILE stream. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2021 Free Software Foundation, Inc. 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 @@ -12,15 +12,17 @@ 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 <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> /* Specification. */ #include <stdio.h> -#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7 */ -# include <stdio_ext.h> +#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */ +# if HAVE_STDIO_EXT_H +# include <stdio_ext.h> +# endif #endif #include <stdlib.h> @@ -29,13 +31,13 @@ int fpurge (FILE *fp) { -#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, musl libc */ +#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */ __fpurge (fp); /* The __fpurge function does not have a return value. */ return 0; -#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin 1.7 */ +#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin >= 1.7 */ /* Call the system's fpurge function. */ # undef fpurge @@ -43,7 +45,8 @@ fpurge (FILE *fp) extern int fpurge (FILE *); # endif int result = fpurge (fp); -# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ +# if defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ if (result == 0) /* Correct the invariants that fpurge broke. <stdio.h> on BSD systems says: @@ -61,7 +64,8 @@ fpurge (FILE *fp) /* Most systems provide FILE as a struct and the necessary bitmask in <stdio.h>, because they need it for implementing getc() and putc() as fast macros. */ -# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ +# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 + /* GNU libc, BeOS, Haiku, Linux libc5 */ fp->_IO_read_end = fp->_IO_read_ptr; fp->_IO_write_ptr = fp->_IO_write_base; /* Avoid memory leak when there is an active ungetc buffer. */ @@ -71,7 +75,8 @@ fpurge (FILE *fp) fp->_IO_save_base = NULL; } return 0; -# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ +# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ fp_->_p = fp_->_bf._base; fp_->_r = 0; fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */ @@ -96,15 +101,10 @@ fpurge (FILE *fp) if (fp->_ptr != NULL) fp->_count = 0; return 0; -# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ - fp->_ptr = fp->_base; - if (fp->_ptr != NULL) - fp->_cnt = 0; - return 0; -# elif WIN_SDK10 - ((TWinSdk10File*)fp)->_ptr = ((TWinSdk10File*)fp)->_base; - if (((TWinSdk10File*)fp)->_ptr != NULL) - ((TWinSdk10File*)fp)->_cnt = 0; +# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ + fp_->_ptr = fp_->_base; + if (fp_->_ptr != NULL) + fp_->_cnt = 0; return 0; # elif defined __UCLIBC__ /* uClibc */ # ifdef __STDIO_BUFFERS diff --git a/contrib/tools/m4/lib/freadahead.c b/contrib/tools/m4/lib/freadahead.c index ae24e3b8a3..cab1b4f4ee 100644 --- a/contrib/tools/m4/lib/freadahead.c +++ b/contrib/tools/m4/lib/freadahead.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2021 Free Software Foundation, Inc. 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 @@ -12,7 +12,7 @@ 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 <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -22,16 +22,26 @@ #include <stdlib.h> #include "stdio-impl.h" +#if defined __DragonFly__ +/* Defined in libc, but not declared in <stdio.h>. */ +extern size_t __sreadahead (FILE *); +#endif + +/* This file is not used on systems that have the __freadahead function, + namely musl libc. */ + size_t freadahead (FILE *fp) { -#if defined _IO_EOF_SEEN || defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ +#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 + /* GNU libc, BeOS, Haiku, Linux libc5 */ if (fp->_IO_write_ptr > fp->_IO_write_base) return 0; return (fp->_IO_read_end - fp->_IO_read_ptr) + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base : 0); -#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ +#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0) return 0; # if defined __DragonFly__ @@ -52,14 +62,10 @@ freadahead (FILE *fp) if ((fp_->_flags & _IOWRITING) != 0) return 0; return fp_->_count; -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ if ((fp_->_flag & _IOWRT) != 0) return 0; return fp_->_cnt; -#elif WIN_SDK10 - if ((((TWinSdk10File*)fp)->_flags & WIN_SDK10_IOWRITE) != 0) - return 0; - return ((TWinSdk10File*)fp)->_cnt; #elif defined __UCLIBC__ /* uClibc */ # ifdef __STDIO_BUFFERS if (fp->__modeflags & __FLAG_WRITING) diff --git a/contrib/tools/m4/lib/freading.c b/contrib/tools/m4/lib/freading.c index c2ffd93735..2c342cddb3 100644 --- a/contrib/tools/m4/lib/freading.c +++ b/contrib/tools/m4/lib/freading.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2021 Free Software Foundation, Inc. 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 @@ -12,7 +12,7 @@ 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 <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -22,7 +22,7 @@ #include "stdio-impl.h" /* Don't use glibc's __freading function in glibc < 2.7, see - <http://sourceware.org/bugzilla/show_bug.cgi?id=4359> */ + <https://sourceware.org/bugzilla/show_bug.cgi?id=4359> */ #if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))) bool @@ -31,24 +31,24 @@ freading (FILE *fp) /* Most systems provide FILE as a struct and the necessary bitmask in <stdio.h>, because they need it for implementing getc() and putc() as fast macros. */ -# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ +# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 + /* GNU libc, BeOS, Haiku, Linux libc5 */ return ((fp->_flags & _IO_NO_WRITES) != 0 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 && fp->_IO_read_base != NULL)); -# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ +# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */ return (fp_->_flags & __SRD) != 0; # elif defined __EMX__ /* emx+gcc */ return (fp->_flags & _IOREAD) != 0; # elif defined __minix /* Minix */ return (fp->_flags & _IOREADING) != 0; -# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ +# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ # if defined __sun /* Solaris */ - return (fp->_flag & _IOREAD) != 0 && (fp->_flag & _IOWRT) == 0; + return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0; # else - return (fp->_flag & _IOREAD) != 0; + return (fp_->_flag & _IOREAD) != 0; # endif -# elif WIN_SDK10 - return (((TWinSdk10File*)fp)->_flags & WIN_SDK10_IOREAD) != 0; # elif defined __UCLIBC__ /* uClibc */ return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0; # elif defined __QNX__ /* QNX */ diff --git a/contrib/tools/m4/lib/frexp.c b/contrib/tools/m4/lib/frexp.c deleted file mode 100644 index d847fa38b3..0000000000 --- a/contrib/tools/m4/lib/frexp.c +++ /dev/null @@ -1,168 +0,0 @@ -/* Split a double into fraction and mantissa. - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -/* Written by Paolo Bonzini <bonzini@gnu.org>, 2003, and - Bruno Haible <bruno@clisp.org>, 2007. */ - -#if ! defined USE_LONG_DOUBLE -# include <config.h> -#endif - -/* Specification. */ -#include <math.h> - -#include <float.h> -#ifdef USE_LONG_DOUBLE -# include "isnanl-nolibm.h" -# include "fpucw.h" -#else -# include "isnand-nolibm.h" -#endif - -/* This file assumes FLT_RADIX = 2. If FLT_RADIX is a power of 2 greater - than 2, or not even a power of 2, some rounding errors can occur, so that - then the returned mantissa is only guaranteed to be <= 1.0, not < 1.0. */ - -#ifdef USE_LONG_DOUBLE -# define FUNC frexpl -# define DOUBLE long double -# define ISNAN isnanl -# define DECL_ROUNDING DECL_LONG_DOUBLE_ROUNDING -# define BEGIN_ROUNDING() BEGIN_LONG_DOUBLE_ROUNDING () -# define END_ROUNDING() END_LONG_DOUBLE_ROUNDING () -# define L_(literal) literal##L -#else -# define FUNC frexp -# define DOUBLE double -# define ISNAN isnand -# define DECL_ROUNDING -# define BEGIN_ROUNDING() -# define END_ROUNDING() -# define L_(literal) literal -#endif - -DOUBLE -FUNC (DOUBLE x, int *expptr) -{ - int sign; - int exponent; - DECL_ROUNDING - - /* Test for NaN, infinity, and zero. */ - if (ISNAN (x) || x + x == x) - { - *expptr = 0; - return x; - } - - sign = 0; - if (x < 0) - { - x = - x; - sign = -1; - } - - BEGIN_ROUNDING (); - - { - /* Since the exponent is an 'int', it fits in 64 bits. Therefore the - loops are executed no more than 64 times. */ - DOUBLE pow2[64]; /* pow2[i] = 2^2^i */ - DOUBLE powh[64]; /* powh[i] = 2^-2^i */ - int i; - - exponent = 0; - if (x >= L_(1.0)) - { - /* A positive exponent. */ - DOUBLE pow2_i; /* = pow2[i] */ - DOUBLE powh_i; /* = powh[i] */ - - /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, - x * 2^exponent = argument, x >= 1.0. */ - for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); - ; - i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) - { - if (x >= pow2_i) - { - exponent += (1 << i); - x *= powh_i; - } - else - break; - - pow2[i] = pow2_i; - powh[i] = powh_i; - } - /* Avoid making x too small, as it could become a denormalized - number and thus lose precision. */ - while (i > 0 && x < pow2[i - 1]) - { - i--; - powh_i = powh[i]; - } - exponent += (1 << i); - x *= powh_i; - /* Here 2^-2^i <= x < 1.0. */ - } - else - { - /* A negative or zero exponent. */ - DOUBLE pow2_i; /* = pow2[i] */ - DOUBLE powh_i; /* = powh[i] */ - - /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, - x * 2^exponent = argument, x < 1.0. */ - for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); - ; - i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) - { - if (x < powh_i) - { - exponent -= (1 << i); - x *= pow2_i; - } - else - break; - - pow2[i] = pow2_i; - powh[i] = powh_i; - } - /* Here 2^-2^i <= x < 1.0. */ - } - - /* Invariants: x * 2^exponent = argument, and 2^-2^i <= x < 1.0. */ - while (i > 0) - { - i--; - if (x < powh[i]) - { - exponent -= (1 << i); - x *= pow2[i]; - } - } - /* Here 0.5 <= x < 1.0. */ - } - - if (sign < 0) - x = - x; - - END_ROUNDING (); - - *expptr = exponent; - return x; -} diff --git a/contrib/tools/m4/lib/fseeko.c b/contrib/tools/m4/lib/fseeko.c index 0c326592b9..0c25a8b712 100644 --- a/contrib/tools/m4/lib/fseeko.c +++ b/contrib/tools/m4/lib/fseeko.c @@ -1,5 +1,5 @@ /* An fseeko() function that, together with fflush(), is POSIX compliant. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2021 Free Software Foundation, Inc. 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 @@ -12,7 +12,7 @@ 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 <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -33,9 +33,9 @@ fseeko (FILE *fp, off_t offset, int whence) #endif #if _GL_WINDOWS_64_BIT_OFF_T # undef fseeko -# if HAVE__FSEEKI64 /* msvc, mingw64 */ +# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, mingw64 */ # define fseeko _fseeki64 -# else /* mingw */ +# else /* mingw before msvcrt8.0 */ # define fseeko fseeko64 # endif #endif @@ -47,11 +47,13 @@ fseeko (FILE *fp, off_t offset, int whence) #endif /* These tests are based on fpurge.c. */ -#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ +#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 + /* GNU libc, BeOS, Haiku, Linux libc5 */ if (fp->_IO_read_end == fp->_IO_read_ptr && fp->_IO_write_ptr == fp->_IO_write_base && fp->_IO_save_base == NULL) -#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ +#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ # if defined __SL64 && defined __SCLE /* Cygwin */ if ((fp->_flags & __SL64) == 0) { @@ -79,12 +81,9 @@ fseeko (FILE *fp, off_t offset, int whence) #elif defined __minix /* Minix */ if (fp_->_ptr == fp_->_buf && (fp_->_ptr == NULL || fp_->_count == 0)) -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ if (fp_->_ptr == fp_->_base && (fp_->_ptr == NULL || fp_->_cnt == 0)) -#elif WIN_SDK10 - if (((TWinSdk10File*)fp)->_ptr == ((TWinSdk10File*)fp)->_base - && (((TWinSdk10File*)fp)->_ptr == NULL || ((TWinSdk10File*)fp)->_cnt == 0)) #elif defined __UCLIBC__ /* uClibc */ if (((fp->__modeflags & __FLAG_WRITING) == 0 || fp->__bufpos == fp->__bufstart) @@ -118,17 +117,20 @@ fseeko (FILE *fp, off_t offset, int whence) off_t pos = lseek (fileno (fp), offset, whence); if (pos == -1) { -#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ +#if defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ fp_->_flags &= ~__SOFF; #endif return -1; } -#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ +#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 + /* GNU libc, BeOS, Haiku, Linux libc5 */ fp->_flags &= ~_IO_EOF_SEEN; fp->_offset = pos; -#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ -# if defined __CYGWIN__ +#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ +# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix /* fp_->_offset is typed as an integer. */ fp_->_offset = pos; # else @@ -150,8 +152,8 @@ fseeko (FILE *fp, off_t offset, int whence) fp_->_flags &= ~__SEOF; #elif defined __EMX__ /* emx+gcc */ fp->_flags &= ~_IOEOF; -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ - fp->_flag &= ~_IOEOF; +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ + fp_->_flag &= ~_IOEOF; #elif defined __MINT__ /* Atari FreeMiNT */ fp->__offset = pos; fp->__eof = 0; diff --git a/contrib/tools/m4/lib/fseterr.c b/contrib/tools/m4/lib/fseterr.c deleted file mode 100644 index f2191b6923..0000000000 --- a/contrib/tools/m4/lib/fseterr.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Set the error indicator of a stream. - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include "fseterr.h" - -#include <errno.h> - -#include "stdio-impl.h" - -void -fseterr (FILE *fp) -{ - /* Most systems provide FILE as a struct and the necessary bitmask in - <stdio.h>, because they need it for implementing getc() and putc() as - fast macros. */ -#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ - fp->_flags |= _IO_ERR_SEEN; -#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ - fp_->_flags |= __SERR; -#elif defined __EMX__ /* emx+gcc */ - fp->_flags |= _IOERR; -#elif defined __minix /* Minix */ - fp->_flags |= _IOERR; -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ - fp_->_flag |= _IOERR; -#elif WIN_SDK10 - ((TWinSdk10File*)fp)->_flags |= WIN_SDK10_IOERROR; -#elif defined __UCLIBC__ /* uClibc */ - fp->__modeflags |= __FLAG_ERROR; -#elif defined __QNX__ /* QNX */ - fp->_Mode |= 0x200 /* _MERR */; -#elif defined __MINT__ /* Atari FreeMiNT */ - fp->__error = 1; -#elif defined EPLAN9 /* Plan9 */ - if (fp->state != 0 /* CLOSED */) - fp->state = 5 /* ERR */; -#elif 0 /* unknown */ - /* Portable fallback, based on an idea by Rich Felker. - Wow! 6 system calls for something that is just a bit operation! - Not activated on any system, because there is no way to repair FP when - the sequence of system calls fails, and library code should not call - abort(). */ - int saved_errno; - int fd; - int fd2; - - saved_errno = errno; - fflush (fp); - fd = fileno (fp); - fd2 = dup (fd); - if (fd2 >= 0) - { - close (fd); - fputc ('\0', fp); /* This should set the error indicator. */ - fflush (fp); /* Or this. */ - if (dup2 (fd2, fd) < 0) - /* Whee... we botched the stream and now cannot restore it! */ - abort (); - close (fd2); - } - errno = saved_errno; -#else - #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib." -#endif -} diff --git a/contrib/tools/m4/lib/fseterr.h b/contrib/tools/m4/lib/fseterr.h deleted file mode 100644 index 630fa8647f..0000000000 --- a/contrib/tools/m4/lib/fseterr.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Set the error indicator of a stream. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#ifndef _FSETERR_H -#define _FSETERR_H - -#include <stdio.h> - -/* Set the error indicator of the stream FP. - The "error indicator" is set when an I/O operation on the stream fails, and - is cleared (together with the "end-of-file" indicator) by clearerr (FP). */ - -#if HAVE___FSETERR /* musl libc */ - -# include <stdio_ext.h> -# define fseterr(fp) __fseterr (fp) - -#else - -# ifdef __cplusplus -extern "C" { -# endif - -extern void fseterr (FILE *fp); - -# ifdef __cplusplus -} -# endif - -#endif - -#endif /* _FSETERR_H */ diff --git a/contrib/tools/m4/lib/ftello.c b/contrib/tools/m4/lib/ftello.c deleted file mode 100644 index 3a2a0f2012..0000000000 --- a/contrib/tools/m4/lib/ftello.c +++ /dev/null @@ -1,85 +0,0 @@ -/* An ftello() function that works around platform bugs. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <stdio.h> - -/* Get lseek. */ -#include <unistd.h> - -#include "stdio-impl.h" - -off_t -ftello (FILE *fp) -#undef ftello -#if !HAVE_FTELLO -# undef ftell -# define ftello ftell -#endif -#if _GL_WINDOWS_64_BIT_OFF_T -# undef ftello -# if HAVE__FTELLI64 /* msvc, mingw64 */ -# define ftello _ftelli64 -# else /* mingw */ -# define ftello ftello64 -# endif -#endif -{ -#if LSEEK_PIPE_BROKEN - /* mingw gives bogus answers rather than failure on non-seekable files. */ - if (lseek (fileno (fp), 0, SEEK_CUR) == -1) - return -1; -#endif - -#if FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE /* Solaris */ - /* The Solaris stdio leaves the _IOREAD flag set after reading from a file - reaches EOF and the program then starts writing to the file. ftello - gets confused by this. */ - if (fp_->_flag & _IOWRT) - { - off_t pos; - - /* Call ftello nevertheless, for the side effects that it does on fp. */ - ftello (fp); - - /* Compute the file position ourselves. */ - pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR); - if (pos >= 0) - { - if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL) - pos += fp_->_ptr - fp_->_base; - } - return pos; - } -#endif - -#if defined __SL64 && defined __SCLE /* Cygwin */ - if ((fp->_flags & __SL64) == 0) - { - /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit - mode; but has an ftello that requires 64-bit mode. */ - FILE *tmp = fopen ("/dev/null", "r"); - if (!tmp) - return -1; - fp->_flags |= __SL64; - fp->_seek64 = tmp->_seek64; - fclose (tmp); - } -#endif - return ftello (fp); -} diff --git a/contrib/tools/m4/lib/get-errno.c b/contrib/tools/m4/lib/get-errno.c deleted file mode 100644 index 7865212cc7..0000000000 --- a/contrib/tools/m4/lib/get-errno.c +++ /dev/null @@ -1,42 +0,0 @@ -/* get-errno.c - get and set errno. - - Copyright (C) 2002, 2006, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -/* Written by Paul Eggert. */ - -#include <config.h> - -#include "get-errno.h" - -#include <errno.h> - -/* Get and set errno. A source file that needs to set or get errno, - but doesn't need to test for specific errno values, can use these - functions to avoid namespace pollution. For example, a file that - defines EQUAL should not include <errno.h>, since <errno.h> might - define EQUAL; such a file can include <get-errno.h> instead. */ - -int -get_errno (void) -{ - return errno; -} - -void -set_errno (int e) -{ - errno = e; -} diff --git a/contrib/tools/m4/lib/get-errno.h b/contrib/tools/m4/lib/get-errno.h deleted file mode 100644 index 04b3d4c8de..0000000000 --- a/contrib/tools/m4/lib/get-errno.h +++ /dev/null @@ -1,19 +0,0 @@ -/* get-errno.h - get and set errno. - - Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -extern int get_errno (void); -extern void set_errno (int); diff --git a/contrib/tools/m4/lib/getopt1.c b/contrib/tools/m4/lib/getopt1.c index 55a6b4eae4..ca24eb811f 100644 --- a/contrib/tools/m4/lib/getopt1.c +++ b/contrib/tools/m4/lib/getopt1.c @@ -1,56 +1,44 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1987-2021 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. - 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. + The GNU C Library 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, + The GNU C Library 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. + 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 <http://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ -#ifdef _LIBC -# include <getopt.h> -#else +#ifndef _LIBC # include <config.h> -# include "getopt.h" #endif -#include "getopt_int.h" - -#include <stdio.h> -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include <stdlib.h> -#endif - -#ifndef NULL -#define NULL 0 -#endif +#include "getopt.h" +#include "getopt_int.h" int getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, - const struct option *long_options, int *opt_index) + const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 0, 0); + opt_index, 0, 0); } int _getopt_long_r (int argc, char **argv, const char *options, - const struct option *long_options, int *opt_index, - struct _getopt_data *d) + const struct option *long_options, int *opt_index, + struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 0, d, 0); + 0, d, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. @@ -60,26 +48,27 @@ _getopt_long_r (int argc, char **argv, const char *options, int getopt_long_only (int argc, char *__getopt_argv_const *argv, - const char *options, - const struct option *long_options, int *opt_index) + const char *options, + const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 1, 0); + opt_index, 1, 0); } int _getopt_long_only_r (int argc, char **argv, const char *options, - const struct option *long_options, int *opt_index, - struct _getopt_data *d) + const struct option *long_options, int *opt_index, + struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 1, d, 0); + 1, d, 0); } #ifdef TEST #include <stdio.h> +#include <stdlib.h> int main (int argc, char **argv) @@ -93,74 +82,74 @@ main (int argc, char **argv) int option_index = 0; static const struct option long_options[] = { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); + long_options, &option_index); if (c == -1) - break; + break; switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value '%s'\n", optarg); - break; - - case 'd': - printf ("option d with value '%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value '%s'\n", optarg); + break; + + case 'd': + printf ("option d with value '%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) - printf ("%s ", argv[optind++]); + printf ("%s ", argv[optind++]); printf ("\n"); } diff --git a/contrib/tools/m4/lib/isnanf-nolibm.h b/contrib/tools/m4/lib/isnanf-nolibm.h deleted file mode 100644 index 804c65f06c..0000000000 --- a/contrib/tools/m4/lib/isnanf-nolibm.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Test for NaN that does not need libm. - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#if HAVE_ISNANF_IN_LIBC -/* Get declaration of isnan macro or (older) isnanf function. */ -# include <math.h> -# if __GNUC__ >= 4 && !__clang__ - /* GCC 4.0 and newer provides three built-ins for isnan. */ -# undef isnanf -# define isnanf(x) __builtin_isnanf ((float)(x)) -# elif defined isnan -# undef isnanf -# define isnanf(x) isnan ((float)(x)) -# else - /* Get declaration of isnanf(), if not declared in <math.h>. */ -# if defined __sgi - /* We can't include <ieeefp.h>, because it conflicts with our definition of - isnand. Therefore declare isnanf separately. */ -extern int isnanf (float x); -# endif -# endif -#else -/* Test whether X is a NaN. */ -# undef isnanf -# define isnanf rpl_isnanf -extern int isnanf (float x); -#endif diff --git a/contrib/tools/m4/lib/itold.c b/contrib/tools/m4/lib/itold.c deleted file mode 100644 index 9aabc7e464..0000000000 --- a/contrib/tools/m4/lib/itold.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Replacement for 'int' to 'long double' conversion routine. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2011. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <float.h> - -void -_Qp_itoq (long double *result, int a) -{ - /* Convert from 'int' to 'double', then from 'double' to 'long double'. */ - *result = (double) a; -} diff --git a/contrib/tools/m4/lib/lstat.c b/contrib/tools/m4/lib/lstat.c deleted file mode 100644 index 1a613a89c8..0000000000 --- a/contrib/tools/m4/lib/lstat.c +++ /dev/null @@ -1,97 +0,0 @@ -/* Work around a bug of lstat on some systems - - Copyright (C) 1997-2006, 2008-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -/* written by Jim Meyering */ - -/* If the user's config.h happens to include <sys/stat.h>, let it include only - the system's <sys/stat.h> here, so that orig_lstat doesn't recurse to - rpl_lstat. */ -#define __need_system_sys_stat_h -#include <config.h> - -#if !HAVE_LSTAT -/* On systems that lack symlinks, our replacement <sys/stat.h> already - defined lstat as stat, so there is nothing further to do other than - avoid an empty file. */ -typedef int dummy; -#else /* HAVE_LSTAT */ - -/* Get the original definition of lstat. It might be defined as a macro. */ -# include <sys/types.h> -# include <sys/stat.h> -# undef __need_system_sys_stat_h - -static int -orig_lstat (const char *filename, struct stat *buf) -{ - return lstat (filename, buf); -} - -/* Specification. */ -/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc - eliminates this include because of the preliminary #include <sys/stat.h> - above. */ -# include "sys/stat.h" - -# include <string.h> -# include <errno.h> - -/* lstat works differently on Linux and Solaris systems. POSIX (see - "pathname resolution" in the glossary) requires that programs like - 'ls' take into consideration the fact that FILE has a trailing slash - when FILE is a symbolic link. On Linux and Solaris 10 systems, the - lstat function already has the desired semantics (in treating - 'lstat ("symlink/", sbuf)' just like 'lstat ("symlink/.", sbuf)', - but on Solaris 9 and earlier it does not. - - If FILE has a trailing slash and specifies a symbolic link, - then use stat() to get more info on the referent of FILE. - If the referent is a non-directory, then set errno to ENOTDIR - and return -1. Otherwise, return stat's result. */ - -int -rpl_lstat (const char *file, struct stat *sbuf) -{ - size_t len; - int lstat_result = orig_lstat (file, sbuf); - - if (lstat_result != 0) - return lstat_result; - - /* This replacement file can blindly check against '/' rather than - using the ISSLASH macro, because all platforms with '\\' either - lack symlinks (mingw) or have working lstat (cygwin) and thus do - not compile this file. 0 len should have already been filtered - out above, with a failure return of ENOENT. */ - len = strlen (file); - if (file[len - 1] != '/' || S_ISDIR (sbuf->st_mode)) - return 0; - - /* At this point, a trailing slash is only permitted on - symlink-to-dir; but it should have found information on the - directory, not the symlink. Call stat() to get info about the - link's referent. Our replacement stat guarantees valid results, - even if the symlink is not pointing to a directory. */ - if (!S_ISLNK (sbuf->st_mode)) - { - errno = ENOTDIR; - return -1; - } - return stat (file, sbuf); -} - -#endif /* HAVE_LSTAT */ diff --git a/contrib/tools/m4/lib/malloc.c b/contrib/tools/m4/lib/malloc.c deleted file mode 100644 index 908735d278..0000000000 --- a/contrib/tools/m4/lib/malloc.c +++ /dev/null @@ -1,56 +0,0 @@ -/* malloc() function that is glibc compatible. - - Copyright (C) 1997-1998, 2006-2007, 2009-2013 Free Software Foundation, Inc. - - 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, 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 <http://www.gnu.org/licenses/>. */ - -/* written by Jim Meyering and Bruno Haible */ - -#define _GL_USE_STDLIB_ALLOC 1 -#include <config.h> -/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */ -#ifdef malloc -# define NEED_MALLOC_GNU 1 -# undef malloc -/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ -#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU -# define NEED_MALLOC_GNU 1 -#endif - -#include <stdlib.h> - -#include <errno.h> - -/* Allocate an N-byte block of memory from the heap. - If N is zero, allocate a 1-byte block. */ - -void * -rpl_malloc (size_t n) -{ - void *result; - -#if NEED_MALLOC_GNU - if (n == 0) - n = 1; -#endif - - result = malloc (n); - -#if !HAVE_MALLOC_POSIX - if (result == NULL) - errno = ENOMEM; -#endif - - return result; -} diff --git a/contrib/tools/m4/lib/mbswidth.c b/contrib/tools/m4/lib/mbswidth.c deleted file mode 100644 index 6571037592..0000000000 --- a/contrib/tools/m4/lib/mbswidth.c +++ /dev/null @@ -1,193 +0,0 @@ -/* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -/* Written by Bruno Haible <haible@clisp.cons.org>. */ - -#include <config.h> - -/* Specification. */ -#include "mbswidth.h" - -/* Get MB_CUR_MAX. */ -#include <stdlib.h> - -#include <string.h> - -/* Get isprint(). */ -#include <ctype.h> - -/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ -#include "wchar--.h" - -/* Get iswcntrl(). */ -#include <wctype.h> - -/* Get INT_MAX. */ -#include <limits.h> - -/* Returns the number of columns needed to represent the multibyte - character string pointed to by STRING. If a non-printable character - occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. - With flags = MBSW_REJECT_INVALID | MBSW_REJECT_UNPRINTABLE, this is - the multibyte analogue of the wcswidth function. */ -int -mbswidth (const char *string, int flags) -{ - return mbsnwidth (string, strlen (string), flags); -} - -/* Returns the number of columns needed to represent the multibyte - character string pointed to by STRING of length NBYTES. If a - non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is - specified, -1 is returned. */ -int -mbsnwidth (const char *string, size_t nbytes, int flags) -{ - const char *p = string; - const char *plimit = p + nbytes; - int width; - - width = 0; - if (MB_CUR_MAX > 1) - { - while (p < plimit) - switch (*p) - { - case ' ': case '!': case '"': case '#': case '%': - case '&': case '\'': case '(': case ')': case '*': - case '+': case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': - case '?': - case 'A': case 'B': case 'C': case 'D': case 'E': - case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'L': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': case 'Y': - case 'Z': - case '[': case '\\': case ']': case '^': case '_': - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': - case 'z': case '{': case '|': case '}': case '~': - /* These characters are printable ASCII characters. */ - p++; - width++; - break; - default: - /* If we have a multibyte sequence, scan it up to its end. */ - { - mbstate_t mbstate; - memset (&mbstate, 0, sizeof mbstate); - do - { - wchar_t wc; - size_t bytes; - int w; - - bytes = mbrtowc (&wc, p, plimit - p, &mbstate); - - if (bytes == (size_t) -1) - /* An invalid multibyte sequence was encountered. */ - { - if (!(flags & MBSW_REJECT_INVALID)) - { - p++; - width++; - break; - } - else - return -1; - } - - if (bytes == (size_t) -2) - /* An incomplete multibyte character at the end. */ - { - if (!(flags & MBSW_REJECT_INVALID)) - { - p = plimit; - width++; - break; - } - else - return -1; - } - - if (bytes == 0) - /* A null wide character was encountered. */ - bytes = 1; - - w = wcwidth (wc); - if (w >= 0) - /* A printable multibyte character. */ - { - if (w > INT_MAX - width) - goto overflow; - width += w; - } - else - /* An unprintable multibyte character. */ - if (!(flags & MBSW_REJECT_UNPRINTABLE)) - { - if (!iswcntrl (wc)) - { - if (width == INT_MAX) - goto overflow; - width++; - } - } - else - return -1; - - p += bytes; - } - while (! mbsinit (&mbstate)); - } - break; - } - return width; - } - - while (p < plimit) - { - unsigned char c = (unsigned char) *p++; - - if (isprint (c)) - { - if (width == INT_MAX) - goto overflow; - width++; - } - else if (!(flags & MBSW_REJECT_UNPRINTABLE)) - { - if (!iscntrl (c)) - { - if (width == INT_MAX) - goto overflow; - width++; - } - } - else - return -1; - } - return width; - - overflow: - return INT_MAX; -} diff --git a/contrib/tools/m4/lib/mbswidth.h b/contrib/tools/m4/lib/mbswidth.h deleted file mode 100644 index e9c0b03938..0000000000 --- a/contrib/tools/m4/lib/mbswidth.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2004, 2007, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <stddef.h> - -/* Avoid a clash of our mbswidth() with a function of the same name defined - in UnixWare 7.1.1 <wchar.h>. We need this #include before the #define - below. - However, we don't want to #include <wchar.h> on all platforms because - - Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before - <wchar.h>. - - BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before - <wchar.h>. */ -#if HAVE_DECL_MBSWIDTH_IN_WCHAR_H -# include <wchar.h> -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Optional flags to influence mbswidth/mbsnwidth behavior. */ - -/* If this bit is set, return -1 upon finding an invalid or incomplete - character. Otherwise, assume invalid characters have width 1. */ -#define MBSW_REJECT_INVALID 1 - -/* If this bit is set, return -1 upon finding a non-printable character. - Otherwise, assume unprintable characters have width 0 if they are - control characters and 1 otherwise. */ -#define MBSW_REJECT_UNPRINTABLE 2 - - -/* Returns the number of screen columns needed for STRING. */ -#define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */ -extern int mbswidth (const char *string, int flags); - -/* Returns the number of screen columns needed for the NBYTES bytes - starting at BUF. */ -extern int mbsnwidth (const char *buf, size_t nbytes, int flags); - - -#ifdef __cplusplus -} -#endif diff --git a/contrib/tools/m4/lib/mkstemp.c b/contrib/tools/m4/lib/mkstemp.c deleted file mode 100644 index 7a9af6c8cc..0000000000 --- a/contrib/tools/m4/lib/mkstemp.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2013 Free Software - Foundation, Inc. - This file is derived from the one in the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#if !_LIBC -# include <config.h> -#endif - -#include <stdlib.h> - -#if !_LIBC -# include "tempname.h" -# define __gen_tempname gen_tempname -# ifndef __GT_FILE -# define __GT_FILE GT_FILE -# endif -#endif - -#include <stdio.h> - -#ifndef __GT_FILE -# define __GT_FILE 0 -#endif - -/* Generate a unique temporary file name from XTEMPLATE. - The last six characters of XTEMPLATE must be "XXXXXX"; - they are replaced with a string that makes the file name unique. - Then open the file and return a fd. - - If you are creating temporary files which will later be removed, - consider using the clean-temp module, which avoids several pitfalls - of using mkstemp directly. */ -int -mkstemp (char *xtemplate) -{ - return __gen_tempname (xtemplate, 0, 0, __GT_FILE); -} diff --git a/contrib/tools/m4/lib/perror.c b/contrib/tools/m4/lib/perror.c deleted file mode 100644 index 74e088cc73..0000000000 --- a/contrib/tools/m4/lib/perror.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Print a message describing error code. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - Written by Bruno Haible and Simon Josefsson. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <stdio.h> - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -void -perror (const char *string) -{ - if (string != NULL && *string != '\0') - fprintf (stderr, "%s\n", string); -} diff --git a/contrib/tools/m4/lib/platform/posix/getopt.h b/contrib/tools/m4/lib/platform/posix/getopt.h deleted file mode 100644 index 2096ceacfe..0000000000 --- a/contrib/tools/m4/lib/platform/posix/getopt.h +++ /dev/null @@ -1,266 +0,0 @@ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Declarations for getopt. - Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#ifndef _GL_M4_GETOPT_H - -#if __GNUC__ >= 3 -#pragma GCC system_header -#endif - - -/* The include_next requires a split double-inclusion guard. We must - also inform the replacement unistd.h to not recursively use - <getopt.h>; our definitions will be present soon enough. */ -#if 1 -# define _GL_SYSTEM_GETOPT -# include_next <getopt.h> -# undef _GL_SYSTEM_GETOPT -#endif - -#ifndef _GL_M4_GETOPT_H - -#ifndef __need_getopt -# define _GL_M4_GETOPT_H 1 -#endif - -/* Standalone applications should #define __GETOPT_PREFIX to an - identifier that prefixes the external functions and variables - defined in this header. When this happens, include the - headers that might declare getopt so that they will not cause - confusion if included after this file (if the system had <getopt.h>, - we have already included it). Then systematically rename - identifiers so that they do not collide with the system functions - and variables. Renaming avoids problems with some compilers and - linkers. */ -#if defined __GETOPT_PREFIX && !defined __need_getopt -# if !1 -# define __need_system_stdlib_h -# include <stdlib.h> -# undef __need_system_stdlib_h -# include <stdio.h> -# include <unistd.h> -# endif -# undef __need_getopt -# undef getopt -# undef getopt_long -# undef getopt_long_only -# undef optarg -# undef opterr -# undef optind -# undef optopt -# undef option -# define __GETOPT_CONCAT(x, y) x ## y -# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) -# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) -# define getopt __GETOPT_ID (getopt) -# define getopt_long __GETOPT_ID (getopt_long) -# define getopt_long_only __GETOPT_ID (getopt_long_only) -# define optarg __GETOPT_ID (optarg) -# define opterr __GETOPT_ID (opterr) -# define optind __GETOPT_ID (optind) -# define optopt __GETOPT_ID (optopt) -# define option __GETOPT_ID (option) -# define _getopt_internal __GETOPT_ID (getopt_internal) -#endif - -/* Standalone applications get correct prototypes for getopt_long and - getopt_long_only; they declare "char **argv". libc uses prototypes - with "char *const *argv" that are incorrect because getopt_long and - getopt_long_only can permute argv; this is required for backward - compatibility (e.g., for LSB 2.0.1). - - This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt', - but it caused redefinition warnings if both unistd.h and getopt.h were - included, since unistd.h includes getopt.h having previously defined - __need_getopt. - - The only place where __getopt_argv_const is used is in definitions - of getopt_long and getopt_long_only below, but these are visible - only if __need_getopt is not defined, so it is quite safe to rewrite - the conditional as follows: -*/ -#if !defined __need_getopt -# if defined __GETOPT_PREFIX -# define __getopt_argv_const /* empty */ -# else -# define __getopt_argv_const const -# endif -#endif - -/* If __GNU_LIBRARY__ is not already defined, either we are being used - standalone, or this is the first header included in the source file. - If we are being used with glibc, we need to include <features.h>, but - that does not exist if we are standalone. So: if __GNU_LIBRARY__ is - not defined, include <ctype.h>, which will pull in <features.h> for us - if it's from glibc. (Why ctype.h? It's guaranteed to exist and it - doesn't flood the namespace with stuff the way some other headers do.) */ -#if !defined __GNU_LIBRARY__ -# include <ctype.h> -#endif - -#ifndef __THROW -# ifndef __GNUC_PREREQ -# define __GNUC_PREREQ(maj, min) (0) -# endif -# if defined __cplusplus && __GNUC_PREREQ (2,8) -# define __THROW noexcept -# else -# define __THROW -# endif -#endif - -/* The definition of _GL_ARG_NONNULL is copied here. */ -/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools - that the values passed as arguments n, ..., m must be non-NULL pointers. - n = 1 stands for the first argument, n = 2 for the second argument etc. */ -#ifndef _GL_ARG_NONNULL -# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 -# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) -# else -# define _GL_ARG_NONNULL(params) -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* For communication from 'getopt' to the caller. - When 'getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when 'ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to 'getopt'. - - On entry to 'getopt', zero means this is the first call; initialize. - - When 'getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, 'optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message 'getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Set to an option character which was unrecognized. */ - -extern int optopt; - -#ifndef __need_getopt -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of 'struct option' terminated by an element containing a name which is - zero. - - The field 'has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field 'flag' is not NULL, it points to a variable that is set - to the value given in the field 'val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an 'int' to - a compiled-in constant, such as set a value from 'optarg', set the - option's 'flag' field to zero and its 'val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero 'flag' field, 'getopt' - returns the contents of the 'val' field. */ - -# if !GNULIB_defined_struct_option -struct option -{ - const char *name; - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; -# define GNULIB_defined_struct_option 1 -# endif - -/* Names for the values of the 'has_arg' field of 'struct option'. */ - -# define no_argument 0 -# define required_argument 1 -# define optional_argument 2 -#endif /* need getopt */ - - -/* Get definitions and prototypes for functions to process the - arguments in ARGV (ARGC of them, minus the program name) for - options given in OPTS. - - Return the option character from OPTS just read. Return -1 when - there are no more options. For unrecognized options, or options - missing arguments, 'optopt' is set to the option letter, and '?' is - returned. - - The OPTS string is a list of characters which are recognized option - letters, optionally followed by colons, specifying that that letter - takes an argument, to be placed in 'optarg'. - - If a letter in OPTS is followed by two colons, its argument is - optional. This behavior is specific to the GNU 'getopt'. - - The argument '--' causes premature termination of argument - scanning, explicitly telling 'getopt' that there are no more - options. - - If OPTS begins with '-', then non-option arguments are treated as - arguments to the option '\1'. This behavior is specific to the GNU - 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in - the environment, then do not permute arguments. */ - -extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) - __THROW _GL_ARG_NONNULL ((2, 3)); - -#ifndef __need_getopt -extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind) - __THROW _GL_ARG_NONNULL ((2, 3)); -extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind) - __THROW _GL_ARG_NONNULL ((2, 3)); - -#endif - -#ifdef __cplusplus -} -#endif - -/* Make sure we later can get all the definitions and declarations. */ -#undef __need_getopt - -#endif /* _GL_M4_GETOPT_H */ -#endif /* _GL_M4_GETOPT_H */ diff --git a/contrib/tools/m4/lib/platform/win64/math.h b/contrib/tools/m4/lib/platform/win64/math.h deleted file mode 100644 index 072a0fbd23..0000000000 --- a/contrib/tools/m4/lib/platform/win64/math.h +++ /dev/null @@ -1,2599 +0,0 @@ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* A GNU-like <math.h>. - - Copyright (C) 2002-2003, 2007-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#ifndef _GL_M4_MATH_H - -#if __GNUC__ >= 3 - -#endif - - -/* The include_next requires a split double-inclusion guard. */ -#if _MSC_VER >= 1900 -#include <../ucrt/math.h> -#else -#error #include <../include/math.h> -#endif - -#ifndef _GL_M4_MATH_H -#define _GL_M4_MATH_H - -#if _MSC_VER >= 1800 // [ -#else // ] _MSC_VER >= 1600 [ - -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif -_GL_INLINE_HEADER_BEGIN -#ifndef _GL_MATH_INLINE -# define _GL_MATH_INLINE _GL_INLINE -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -#ifndef _GL_CXXDEFS_H -#define _GL_CXXDEFS_H - -/* The three most frequent use cases of these macros are: - - * For providing a substitute for a function that is missing on some - platforms, but is declared and works fine on the platforms on which - it exists: - - #if @GNULIB_FOO@ - # if !@HAVE_FOO@ - _GL_FUNCDECL_SYS (foo, ...); - # endif - _GL_CXXALIAS_SYS (foo, ...); - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif - - * For providing a replacement for a function that exists on all platforms, - but is broken/insufficient and needs to be replaced on some platforms: - - #if @GNULIB_FOO@ - # if @REPLACE_FOO@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef foo - # define foo rpl_foo - # endif - _GL_FUNCDECL_RPL (foo, ...); - _GL_CXXALIAS_RPL (foo, ...); - # else - _GL_CXXALIAS_SYS (foo, ...); - # endif - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif - - * For providing a replacement for a function that exists on some platforms - but is broken/insufficient and needs to be replaced on some of them and - is additionally either missing or undeclared on some other platforms: - - #if @GNULIB_FOO@ - # if @REPLACE_FOO@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef foo - # define foo rpl_foo - # endif - _GL_FUNCDECL_RPL (foo, ...); - _GL_CXXALIAS_RPL (foo, ...); - # else - # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ - _GL_FUNCDECL_SYS (foo, ...); - # endif - _GL_CXXALIAS_SYS (foo, ...); - # endif - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif -*/ - -/* _GL_EXTERN_C declaration; - performs the declaration with C linkage. */ -#if defined __cplusplus -# define _GL_EXTERN_C extern "C" -#else -# define _GL_EXTERN_C extern -#endif - -/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); - declares a replacement function, named rpl_func, with the given prototype, - consisting of return type, parameters, and attributes. - Example: - _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) - _GL_ARG_NONNULL ((1))); - */ -#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ - _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) -#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype rpl_func parameters_and_attributes - -/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); - declares the system function, named func, with the given prototype, - consisting of return type, parameters, and attributes. - Example: - _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) - _GL_ARG_NONNULL ((1))); - */ -#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype func parameters_and_attributes - -/* _GL_CXXALIAS_RPL (func, rettype, parameters); - declares a C++ alias called GNULIB_NAMESPACE::func - that redirects to rpl_func, if GNULIB_NAMESPACE is defined. - Example: - _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); - */ -#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ - _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - rettype (*const func) parameters = ::rpl_func; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); - is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); - except that the C function rpl_func may have a slightly different - declaration. A cast is used to silence the "invalid conversion" error - that would otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - rettype (*const func) parameters = \ - reinterpret_cast<rettype(*)parameters>(::rpl_func); \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS (func, rettype, parameters); - declares a C++ alias called GNULIB_NAMESPACE::func - that redirects to the system provided function func, if GNULIB_NAMESPACE - is defined. - Example: - _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); - */ -#if defined __cplusplus && defined GNULIB_NAMESPACE - /* If we were to write - rettype (*const func) parameters = ::func; - like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls - better (remove an indirection through a 'static' pointer variable), - but then the _GL_CXXALIASWARN macro below would cause a warning not only - for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ -# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static rettype (*func) parameters = ::func; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); - is like _GL_CXXALIAS_SYS (func, rettype, parameters); - except that the C function func may have a slightly different declaration. - A cast is used to silence the "invalid conversion" error that would - otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static rettype (*func) parameters = \ - reinterpret_cast<rettype(*)parameters>(::func); \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); - is like _GL_CXXALIAS_SYS (func, rettype, parameters); - except that the C function is picked among a set of overloaded functions, - namely the one with rettype2 and parameters2. Two consecutive casts - are used to silence the "cannot find a match" and "invalid conversion" - errors that would otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE - /* The outer cast must be a reinterpret_cast. - The inner cast: When the function is defined as a set of overloaded - functions, it works as a static_cast<>, choosing the designated variant. - When the function is defined as a single variant, it works as a - reinterpret_cast<>. The parenthesized cast syntax works both ways. */ -# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ - namespace GNULIB_NAMESPACE \ - { \ - static rettype (*func) parameters = \ - reinterpret_cast<rettype(*)parameters>( \ - (rettype2(*)parameters2)(::func)); \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIASWARN (func); - causes a warning to be emitted when ::func is used but not when - GNULIB_NAMESPACE::func is used. func must be defined without overloaded - variants. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIASWARN(func) \ - _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) -# define _GL_CXXALIASWARN_1(func,namespace) \ - _GL_CXXALIASWARN_2 (func, namespace) -/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, - we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ -# define _GL_CXXALIASWARN_2(func,namespace) \ - _GL_WARN_ON_USE (func, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -# define _GL_CXXALIASWARN_2(func,namespace) \ - extern __typeof__ (func) func -# else -# define _GL_CXXALIASWARN_2(func,namespace) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -# endif -#else -# define _GL_CXXALIASWARN(func) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); - causes a warning to be emitted when the given overloaded variant of ::func - is used but not when GNULIB_NAMESPACE::func is used. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ - _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ - GNULIB_NAMESPACE) -# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ - _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) -/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, - we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - extern __typeof__ (func) func -# else -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -# endif -#else -# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -#endif /* _GL_CXXDEFS_H */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ -/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools - that the values passed as arguments n, ..., m must be non-NULL pointers. - n = 1 stands for the first argument, n = 2 for the second argument etc. */ -#ifndef _GL_ARG_NONNULL -# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 -# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) -# else -# define _GL_ARG_NONNULL(params) -# endif -#endif - -/* The definition of _GL_WARN_ON_USE is copied here. */ -#ifndef _GL_WARN_ON_USE - -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -/* A compiler attribute is available in gcc versions 4.3.0 and later. */ -# define _GL_WARN_ON_USE(function, message) \ -extern __typeof__ (function) function __attribute__ ((__warning__ (message))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -/* Verify the existence of the function. */ -# define _GL_WARN_ON_USE(function, message) \ -extern __typeof__ (function) function -# else /* Unsupported. */ -# define _GL_WARN_ON_USE(function, message) \ -_GL_WARN_EXTERN_C int _gl_warn_on_use -# endif -#endif - -/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") - is like _GL_WARN_ON_USE (function, "string"), except that the function is - declared with the given prototype, consisting of return type, parameters, - and attributes. - This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does - not work in this case. */ -#ifndef _GL_WARN_ON_USE_CXX -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes \ - __attribute__ ((__warning__ (msg))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -/* Verify the existence of the function. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes -# else /* Unsupported. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -_GL_WARN_EXTERN_C int _gl_warn_on_use -# endif -#endif - -/* _GL_WARN_EXTERN_C declaration; - performs the declaration with C linkage. */ -#ifndef _GL_WARN_EXTERN_C -# if defined __cplusplus -# define _GL_WARN_EXTERN_C extern "C" -# else -# define _GL_WARN_EXTERN_C extern -# endif -#endif - -#ifdef __cplusplus -/* Helper macros to define type-generic function FUNC as overloaded functions, - rather than as macros like in C. POSIX declares these with an argument of - real-floating (that is, one of float, double, or long double). */ -# define _GL_MATH_CXX_REAL_FLOATING_DECL_1(func) \ -static inline int \ -_gl_cxx_ ## func ## f (float f) \ -{ \ - return func (f); \ -} \ -static inline int \ -_gl_cxx_ ## func ## d (double d) \ -{ \ - return func (d); \ -} \ -static inline int \ -_gl_cxx_ ## func ## l (long double l) \ -{ \ - return func (l); \ -} -# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \ -inline int \ -func (float f) \ -{ \ - return _gl_cxx_ ## func ## f (f); \ -} \ -inline int \ -func (double d) \ -{ \ - return _gl_cxx_ ## func ## d (d); \ -} \ -inline int \ -func (long double l) \ -{ \ - return _gl_cxx_ ## func ## l (l); \ -} -#endif - -/* Helper macros to define a portability warning for the - classification macro FUNC called with VALUE. POSIX declares the - classification macros with an argument of real-floating (that is, - one of float, double, or long double). */ -#define _GL_WARN_REAL_FLOATING_DECL(func) \ -_GL_MATH_INLINE int \ -rpl_ ## func ## f (float f) \ -{ \ - return func (f); \ -} \ -_GL_MATH_INLINE int \ -rpl_ ## func ## d (double d) \ -{ \ - return func (d); \ -} \ -_GL_MATH_INLINE int \ -rpl_ ## func ## l (long double l) \ -{ \ - return func (l); \ -} \ -_GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \ - "use gnulib module " #func " for portability"); \ -_GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \ - "use gnulib module " #func " for portability"); \ -_GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \ - "use gnulib module " #func " for portability") -#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \ - (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \ - : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \ - : rpl_ ## func ## l (value)) - - -#if 0 -/* Pull in a function that fixes the 'int' to 'long double' conversion - of glibc 2.7. */ -_GL_EXTERN_C void _Qp_itoq (long double *, int); -static void (*_gl_math_fix_itold) (long double *, int) = _Qp_itoq; -#endif - - -/* POSIX allows platforms that don't support NAN. But all major - machines in the past 15 years have supported something close to - IEEE NaN, so we define this unconditionally. We also must define - it on platforms like Solaris 10, where NAN is present but defined - as a function pointer rather than a floating point constant. */ -#if !defined NAN || 0 -# if !GNULIB_defined_NAN -# undef NAN - /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler - choke on the expression 0.0 / 0.0. */ -# if defined __DECC || defined _MSC_VER -_GL_MATH_INLINE float -_NaN () -{ - static float zero = 0.0f; - return zero / zero; -} -# define NAN (_NaN()) -# else -# define NAN (0.0f / 0.0f) -# endif -# define GNULIB_defined_NAN 1 -# endif -#endif - -/* Solaris 10 defines HUGE_VAL, but as a function pointer rather - than a floating point constant. */ -#if 0 -# undef HUGE_VALF -# define HUGE_VALF (1.0f / 0.0f) -# undef HUGE_VAL -# define HUGE_VAL (1.0 / 0.0) -# undef HUGE_VALL -# define HUGE_VALL (1.0L / 0.0L) -#endif - -/* HUGE_VALF is a 'float' Infinity. */ -#ifndef HUGE_VALF -# if defined _MSC_VER -/* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. */ -# define HUGE_VALF (1e25f * 1e25f) -# else -# define HUGE_VALF (1.0f / 0.0f) -# endif -#endif - -/* HUGE_VAL is a 'double' Infinity. */ -#ifndef HUGE_VAL -# if defined _MSC_VER -/* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. */ -# define HUGE_VAL (1e250 * 1e250) -# else -# define HUGE_VAL (1.0 / 0.0) -# endif -#endif - -/* HUGE_VALL is a 'long double' Infinity. */ -#ifndef HUGE_VALL -# if defined _MSC_VER -/* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. */ -# define HUGE_VALL (1e250L * 1e250L) -# else -# define HUGE_VALL (1.0L / 0.0L) -# endif -#endif - - -/* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */ -#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN) -# if defined __NetBSD__ || defined __sgi - /* NetBSD, IRIX 6.5: match what ilogb() does */ -# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ -# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */ -# elif defined _AIX - /* AIX 5.1: match what ilogb() does in AIX >= 5.2 */ -# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ -# define FP_ILOGBNAN 2147483647 /* INT_MAX */ -# elif defined __sun - /* Solaris 9: match what ilogb() does */ -# define FP_ILOGB0 (- 2147483647) /* - INT_MAX */ -# define FP_ILOGBNAN 2147483647 /* INT_MAX */ -# else - /* Gnulib defined values. */ -# define FP_ILOGB0 (- 2147483647) /* - INT_MAX */ -# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */ -# endif -#endif - - -#if 0 -# if !1 -# undef acosf -_GL_FUNCDECL_SYS (acosf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (acosf, float, (float x)); -_GL_CXXALIASWARN (acosf); -#elif defined GNULIB_POSIXCHECK -# undef acosf -# if HAVE_RAW_DECL_ACOSF -_GL_WARN_ON_USE (acosf, "acosf is unportable - " - "use gnulib module acosf for portability"); -# endif -#endif - -#if 0 -# if !1 || !1 -# undef acosl -_GL_FUNCDECL_SYS (acosl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (acosl, long double, (long double x)); -_GL_CXXALIASWARN (acosl); -#elif defined GNULIB_POSIXCHECK -# undef acosl -# if HAVE_RAW_DECL_ACOSL -_GL_WARN_ON_USE (acosl, "acosl is unportable - " - "use gnulib module acosl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef asinf -_GL_FUNCDECL_SYS (asinf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (asinf, float, (float x)); -_GL_CXXALIASWARN (asinf); -#elif defined GNULIB_POSIXCHECK -# undef asinf -# if HAVE_RAW_DECL_ASINF -_GL_WARN_ON_USE (asinf, "asinf is unportable - " - "use gnulib module asinf for portability"); -# endif -#endif - -#if 0 -# if !1 || !1 -# undef asinl -_GL_FUNCDECL_SYS (asinl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (asinl, long double, (long double x)); -_GL_CXXALIASWARN (asinl); -#elif defined GNULIB_POSIXCHECK -# undef asinl -# if HAVE_RAW_DECL_ASINL -_GL_WARN_ON_USE (asinl, "asinl is unportable - " - "use gnulib module asinl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef atanf -_GL_FUNCDECL_SYS (atanf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (atanf, float, (float x)); -_GL_CXXALIASWARN (atanf); -#elif defined GNULIB_POSIXCHECK -# undef atanf -# if HAVE_RAW_DECL_ATANF -_GL_WARN_ON_USE (atanf, "atanf is unportable - " - "use gnulib module atanf for portability"); -# endif -#endif - -#if 0 -# if !1 || !1 -# undef atanl -_GL_FUNCDECL_SYS (atanl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (atanl, long double, (long double x)); -_GL_CXXALIASWARN (atanl); -#elif defined GNULIB_POSIXCHECK -# undef atanl -# if HAVE_RAW_DECL_ATANL -_GL_WARN_ON_USE (atanl, "atanl is unportable - " - "use gnulib module atanl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef atan2f -_GL_FUNCDECL_SYS (atan2f, float, (float y, float x)); -# endif -_GL_CXXALIAS_SYS (atan2f, float, (float y, float x)); -_GL_CXXALIASWARN (atan2f); -#elif defined GNULIB_POSIXCHECK -# undef atan2f -# if HAVE_RAW_DECL_ATAN2F -_GL_WARN_ON_USE (atan2f, "atan2f is unportable - " - "use gnulib module atan2f for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef cbrtf -# define cbrtf rpl_cbrtf -# endif -_GL_FUNCDECL_RPL (cbrtf, float, (float x)); -_GL_CXXALIAS_RPL (cbrtf, float, (float x)); -# else -# if !1 -_GL_FUNCDECL_SYS (cbrtf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (cbrtf, float, (float x)); -# endif -_GL_CXXALIASWARN (cbrtf); -#elif defined GNULIB_POSIXCHECK -# undef cbrtf -# if HAVE_RAW_DECL_CBRTF -_GL_WARN_ON_USE (cbrtf, "cbrtf is unportable - " - "use gnulib module cbrtf for portability"); -# endif -#endif - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (cbrt, double, (double x)); -# endif -_GL_CXXALIAS_SYS (cbrt, double, (double x)); -_GL_CXXALIASWARN (cbrt); -#elif defined GNULIB_POSIXCHECK -# undef cbrt -# if HAVE_RAW_DECL_CBRT -_GL_WARN_ON_USE (cbrt, "cbrt is unportable - " - "use gnulib module cbrt for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef cbrtl -# define cbrtl rpl_cbrtl -# endif -_GL_FUNCDECL_RPL (cbrtl, long double, (long double x)); -_GL_CXXALIAS_RPL (cbrtl, long double, (long double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (cbrtl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (cbrtl, long double, (long double x)); -# endif -_GL_CXXALIASWARN (cbrtl); -#elif defined GNULIB_POSIXCHECK -# undef cbrtl -# if HAVE_RAW_DECL_CBRTL -_GL_WARN_ON_USE (cbrtl, "cbrtl is unportable - " - "use gnulib module cbrtl for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ceilf -# define ceilf rpl_ceilf -# endif -_GL_FUNCDECL_RPL (ceilf, float, (float x)); -_GL_CXXALIAS_RPL (ceilf, float, (float x)); -# else -# if !1 -# undef ceilf -_GL_FUNCDECL_SYS (ceilf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (ceilf, float, (float x)); -# endif -_GL_CXXALIASWARN (ceilf); -#elif defined GNULIB_POSIXCHECK -# undef ceilf -# if HAVE_RAW_DECL_CEILF -_GL_WARN_ON_USE (ceilf, "ceilf is unportable - " - "use gnulib module ceilf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define ceil rpl_ceil -# endif -_GL_FUNCDECL_RPL (ceil, double, (double x)); -_GL_CXXALIAS_RPL (ceil, double, (double x)); -# else -_GL_CXXALIAS_SYS (ceil, double, (double x)); -# endif -_GL_CXXALIASWARN (ceil); -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ceill -# define ceill rpl_ceill -# endif -_GL_FUNCDECL_RPL (ceill, long double, (long double x)); -_GL_CXXALIAS_RPL (ceill, long double, (long double x)); -# else -# if !1 -# undef ceill -_GL_FUNCDECL_SYS (ceill, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (ceill, long double, (long double x)); -# endif -_GL_CXXALIASWARN (ceill); -#elif defined GNULIB_POSIXCHECK -# undef ceill -# if HAVE_RAW_DECL_CEILL -_GL_WARN_ON_USE (ceill, "ceill is unportable - " - "use gnulib module ceill for portability"); -# endif -#endif - - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (copysignf, float, (float x, float y)); -# endif -_GL_CXXALIAS_SYS (copysignf, float, (float x, float y)); -_GL_CXXALIASWARN (copysignf); -#elif defined GNULIB_POSIXCHECK -# undef copysignf -# if HAVE_RAW_DECL_COPYSIGNF -_GL_WARN_ON_USE (copysignf, "copysignf is unportable - " - "use gnulib module copysignf for portability"); -# endif -#endif - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (copysign, double, (double x, double y)); -# endif -_GL_CXXALIAS_SYS (copysign, double, (double x, double y)); -_GL_CXXALIASWARN (copysign); -#elif defined GNULIB_POSIXCHECK -# undef copysign -# if HAVE_RAW_DECL_COPYSIGN -_GL_WARN_ON_USE (copysign, "copysign is unportable - " - "use gnulib module copysign for portability"); -# endif -#endif - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y)); -# endif -_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y)); -_GL_CXXALIASWARN (copysignl); -#elif defined GNULIB_POSIXCHECK -# undef copysignl -# if HAVE_RAW_DECL_COPYSIGNL -_GL_WARN_ON_USE (copysign, "copysignl is unportable - " - "use gnulib module copysignl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef cosf -_GL_FUNCDECL_SYS (cosf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (cosf, float, (float x)); -_GL_CXXALIASWARN (cosf); -#elif defined GNULIB_POSIXCHECK -# undef cosf -# if HAVE_RAW_DECL_COSF -_GL_WARN_ON_USE (cosf, "cosf is unportable - " - "use gnulib module cosf for portability"); -# endif -#endif - -#if 0 -# if !1 || !1 -# undef cosl -_GL_FUNCDECL_SYS (cosl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (cosl, long double, (long double x)); -_GL_CXXALIASWARN (cosl); -#elif defined GNULIB_POSIXCHECK -# undef cosl -# if HAVE_RAW_DECL_COSL -_GL_WARN_ON_USE (cosl, "cosl is unportable - " - "use gnulib module cosl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef coshf -_GL_FUNCDECL_SYS (coshf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (coshf, float, (float x)); -_GL_CXXALIASWARN (coshf); -#elif defined GNULIB_POSIXCHECK -# undef coshf -# if HAVE_RAW_DECL_COSHF -_GL_WARN_ON_USE (coshf, "coshf is unportable - " - "use gnulib module coshf for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef expf -_GL_FUNCDECL_SYS (expf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (expf, float, (float x)); -_GL_CXXALIASWARN (expf); -#elif defined GNULIB_POSIXCHECK -# undef expf -# if HAVE_RAW_DECL_EXPF -_GL_WARN_ON_USE (expf, "expf is unportable - " - "use gnulib module expf for portability"); -# endif -#endif - -#if 0 -# if !1 || !1 -# undef expl -_GL_FUNCDECL_SYS (expl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (expl, long double, (long double x)); -_GL_CXXALIASWARN (expl); -#elif defined GNULIB_POSIXCHECK -# undef expl -# if HAVE_RAW_DECL_EXPL -_GL_WARN_ON_USE (expl, "expl is unportable - " - "use gnulib module expl for portability"); -# endif -#endif - - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (exp2f, float, (float x)); -# endif -_GL_CXXALIAS_SYS (exp2f, float, (float x)); -_GL_CXXALIASWARN (exp2f); -#elif defined GNULIB_POSIXCHECK -# undef exp2f -# if HAVE_RAW_DECL_EXP2F -_GL_WARN_ON_USE (exp2f, "exp2f is unportable - " - "use gnulib module exp2f for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef exp2 -# define exp2 rpl_exp2 -# endif -_GL_FUNCDECL_RPL (exp2, double, (double x)); -_GL_CXXALIAS_RPL (exp2, double, (double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (exp2, double, (double x)); -# endif -_GL_CXXALIAS_SYS (exp2, double, (double x)); -# endif -_GL_CXXALIASWARN (exp2); -#elif defined GNULIB_POSIXCHECK -# undef exp2 -# if HAVE_RAW_DECL_EXP2 -_GL_WARN_ON_USE (exp2, "exp2 is unportable - " - "use gnulib module exp2 for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef exp2l -# define exp2l rpl_exp2l -# endif -_GL_FUNCDECL_RPL (exp2l, long double, (long double x)); -_GL_CXXALIAS_RPL (exp2l, long double, (long double x)); -# else -# if !1 -# undef exp2l -_GL_FUNCDECL_SYS (exp2l, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (exp2l, long double, (long double x)); -# endif -_GL_CXXALIASWARN (exp2l); -#elif defined GNULIB_POSIXCHECK -# undef exp2l -# if HAVE_RAW_DECL_EXP2L -_GL_WARN_ON_USE (exp2l, "exp2l is unportable - " - "use gnulib module exp2l for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef expm1f -# define expm1f rpl_expm1f -# endif -_GL_FUNCDECL_RPL (expm1f, float, (float x)); -_GL_CXXALIAS_RPL (expm1f, float, (float x)); -# else -# if !1 -_GL_FUNCDECL_SYS (expm1f, float, (float x)); -# endif -_GL_CXXALIAS_SYS (expm1f, float, (float x)); -# endif -_GL_CXXALIASWARN (expm1f); -#elif defined GNULIB_POSIXCHECK -# undef expm1f -# if HAVE_RAW_DECL_EXPM1F -_GL_WARN_ON_USE (expm1f, "expm1f is unportable - " - "use gnulib module expm1f for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef expm1 -# define expm1 rpl_expm1 -# endif -_GL_FUNCDECL_RPL (expm1, double, (double x)); -_GL_CXXALIAS_RPL (expm1, double, (double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (expm1, double, (double x)); -# endif -_GL_CXXALIAS_SYS (expm1, double, (double x)); -# endif -_GL_CXXALIASWARN (expm1); -#elif defined GNULIB_POSIXCHECK -# undef expm1 -# if HAVE_RAW_DECL_EXPM1 -_GL_WARN_ON_USE (expm1, "expm1 is unportable - " - "use gnulib module expm1 for portability"); -# endif -#endif - -#if 0 -# if !1 -# undef expm1l -_GL_FUNCDECL_SYS (expm1l, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (expm1l, long double, (long double x)); -_GL_CXXALIASWARN (expm1l); -#elif defined GNULIB_POSIXCHECK -# undef expm1l -# if HAVE_RAW_DECL_EXPM1L -_GL_WARN_ON_USE (expm1l, "expm1l is unportable - " - "use gnulib module expm1l for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef fabsf -_GL_FUNCDECL_SYS (fabsf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (fabsf, float, (float x)); -_GL_CXXALIASWARN (fabsf); -#elif defined GNULIB_POSIXCHECK -# undef fabsf -# if HAVE_RAW_DECL_FABSF -_GL_WARN_ON_USE (fabsf, "fabsf is unportable - " - "use gnulib module fabsf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fabsl -# define fabsl rpl_fabsl -# endif -_GL_FUNCDECL_RPL (fabsl, long double, (long double x)); -_GL_CXXALIAS_RPL (fabsl, long double, (long double x)); -# else -# if !1 -# undef fabsl -_GL_FUNCDECL_SYS (fabsl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (fabsl, long double, (long double x)); -# endif -_GL_CXXALIASWARN (fabsl); -#elif defined GNULIB_POSIXCHECK -# undef fabsl -# if HAVE_RAW_DECL_FABSL -_GL_WARN_ON_USE (fabsl, "fabsl is unportable - " - "use gnulib module fabsl for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef floorf -# define floorf rpl_floorf -# endif -_GL_FUNCDECL_RPL (floorf, float, (float x)); -_GL_CXXALIAS_RPL (floorf, float, (float x)); -# else -# if !1 -# undef floorf -_GL_FUNCDECL_SYS (floorf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (floorf, float, (float x)); -# endif -_GL_CXXALIASWARN (floorf); -#elif defined GNULIB_POSIXCHECK -# undef floorf -# if HAVE_RAW_DECL_FLOORF -_GL_WARN_ON_USE (floorf, "floorf is unportable - " - "use gnulib module floorf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define floor rpl_floor -# endif -_GL_FUNCDECL_RPL (floor, double, (double x)); -_GL_CXXALIAS_RPL (floor, double, (double x)); -# else -_GL_CXXALIAS_SYS (floor, double, (double x)); -# endif -_GL_CXXALIASWARN (floor); -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef floorl -# define floorl rpl_floorl -# endif -_GL_FUNCDECL_RPL (floorl, long double, (long double x)); -_GL_CXXALIAS_RPL (floorl, long double, (long double x)); -# else -# if !1 -# undef floorl -_GL_FUNCDECL_SYS (floorl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (floorl, long double, (long double x)); -# endif -_GL_CXXALIASWARN (floorl); -#elif defined GNULIB_POSIXCHECK -# undef floorl -# if HAVE_RAW_DECL_FLOORL -_GL_WARN_ON_USE (floorl, "floorl is unportable - " - "use gnulib module floorl for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fmaf -# define fmaf rpl_fmaf -# endif -_GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z)); -_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z)); -# else -# if !1 -_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z)); -# endif -_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z)); -# endif -_GL_CXXALIASWARN (fmaf); -#elif defined GNULIB_POSIXCHECK -# undef fmaf -# if HAVE_RAW_DECL_FMAF -_GL_WARN_ON_USE (fmaf, "fmaf is unportable - " - "use gnulib module fmaf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fma -# define fma rpl_fma -# endif -_GL_FUNCDECL_RPL (fma, double, (double x, double y, double z)); -_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z)); -# else -# if !1 -_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z)); -# endif -_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z)); -# endif -_GL_CXXALIASWARN (fma); -#elif defined GNULIB_POSIXCHECK -# undef fma -# if HAVE_RAW_DECL_FMA -_GL_WARN_ON_USE (fma, "fma is unportable - " - "use gnulib module fma for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fmal -# define fmal rpl_fmal -# endif -_GL_FUNCDECL_RPL (fmal, long double, - (long double x, long double y, long double z)); -_GL_CXXALIAS_RPL (fmal, long double, - (long double x, long double y, long double z)); -# else -# if !1 -# undef fmal -_GL_FUNCDECL_SYS (fmal, long double, - (long double x, long double y, long double z)); -# endif -_GL_CXXALIAS_SYS (fmal, long double, - (long double x, long double y, long double z)); -# endif -_GL_CXXALIASWARN (fmal); -#elif defined GNULIB_POSIXCHECK -# undef fmal -# if HAVE_RAW_DECL_FMAL -_GL_WARN_ON_USE (fmal, "fmal is unportable - " - "use gnulib module fmal for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fmodf -# define fmodf rpl_fmodf -# endif -_GL_FUNCDECL_RPL (fmodf, float, (float x, float y)); -_GL_CXXALIAS_RPL (fmodf, float, (float x, float y)); -# else -# if !1 -# undef fmodf -_GL_FUNCDECL_SYS (fmodf, float, (float x, float y)); -# endif -_GL_CXXALIAS_SYS (fmodf, float, (float x, float y)); -# endif -_GL_CXXALIASWARN (fmodf); -#elif defined GNULIB_POSIXCHECK -# undef fmodf -# if HAVE_RAW_DECL_FMODF -_GL_WARN_ON_USE (fmodf, "fmodf is unportable - " - "use gnulib module fmodf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fmod -# define fmod rpl_fmod -# endif -_GL_FUNCDECL_RPL (fmod, double, (double x, double y)); -_GL_CXXALIAS_RPL (fmod, double, (double x, double y)); -# else -_GL_CXXALIAS_SYS (fmod, double, (double x, double y)); -# endif -_GL_CXXALIASWARN (fmod); -#elif defined GNULIB_POSIXCHECK -# undef fmod -# if HAVE_RAW_DECL_FMOD -_GL_WARN_ON_USE (fmod, "fmod has portability problems - " - "use gnulib module fmod for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef fmodl -# define fmodl rpl_fmodl -# endif -_GL_FUNCDECL_RPL (fmodl, long double, (long double x, long double y)); -_GL_CXXALIAS_RPL (fmodl, long double, (long double x, long double y)); -# else -# if !1 -# undef fmodl -_GL_FUNCDECL_SYS (fmodl, long double, (long double x, long double y)); -# endif -_GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y)); -# endif -_GL_CXXALIASWARN (fmodl); -#elif defined GNULIB_POSIXCHECK -# undef fmodl -# if HAVE_RAW_DECL_FMODL -_GL_WARN_ON_USE (fmodl, "fmodl is unportable - " - "use gnulib module fmodl for portability"); -# endif -#endif - - -/* Write x as - x = mantissa * 2^exp - where - If x finite and nonzero: 0.5 <= |mantissa| < 1.0. - If x is zero: mantissa = x, exp = 0. - If x is infinite or NaN: mantissa = x, exp unspecified. - Store exp in *EXPPTR and return mantissa. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef frexpf -# define frexpf rpl_frexpf -# endif -_GL_FUNCDECL_RPL (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (frexpf, float, (float x, int *expptr)); -# else -# if !1 -# undef frexpf -_GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr)); -# endif -_GL_CXXALIASWARN (frexpf); -#elif defined GNULIB_POSIXCHECK -# undef frexpf -# if HAVE_RAW_DECL_FREXPF -_GL_WARN_ON_USE (frexpf, "frexpf is unportable - " - "use gnulib module frexpf for portability"); -# endif -#endif - -/* Write x as - x = mantissa * 2^exp - where - If x finite and nonzero: 0.5 <= |mantissa| < 1.0. - If x is zero: mantissa = x, exp = 0. - If x is infinite or NaN: mantissa = x, exp unspecified. - Store exp in *EXPPTR and return mantissa. */ -#if 0 -# if 1 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define frexp rpl_frexp -# endif -_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr)); -# else -_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr)); -# endif -_GL_CXXALIASWARN (frexp); -#elif defined GNULIB_POSIXCHECK -# undef frexp -/* Assume frexp is always declared. */ -_GL_WARN_ON_USE (frexp, "frexp is unportable - " - "use gnulib module frexp for portability"); -#endif - -/* Write x as - x = mantissa * 2^exp - where - If x finite and nonzero: 0.5 <= |mantissa| < 1.0. - If x is zero: mantissa = x, exp = 0. - If x is infinite or NaN: mantissa = x, exp unspecified. - Store exp in *EXPPTR and return mantissa. */ -#if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef frexpl -# define frexpl rpl_frexpl -# endif -_GL_FUNCDECL_RPL (frexpl, long double, - (long double x, int *expptr) _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (frexpl, long double, (long double x, int *expptr)); -#else -# if !1 -_GL_FUNCDECL_SYS (frexpl, long double, - (long double x, int *expptr) _GL_ARG_NONNULL ((2))); -# endif -# if 1 -_GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr)); -# endif -#endif -#if 1 && !(1 && !1) -_GL_CXXALIASWARN (frexpl); -#endif -#if !1 && defined GNULIB_POSIXCHECK -# undef frexpl -# if HAVE_RAW_DECL_FREXPL -_GL_WARN_ON_USE (frexpl, "frexpl is unportable - " - "use gnulib module frexpl for portability"); -# endif -#endif - - -/* Return sqrt(x^2+y^2). */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef hypotf -# define hypotf rpl_hypotf -# endif -_GL_FUNCDECL_RPL (hypotf, float, (float x, float y)); -_GL_CXXALIAS_RPL (hypotf, float, (float x, float y)); -# else -# if !1 -_GL_FUNCDECL_SYS (hypotf, float, (float x, float y)); -# endif -_GL_CXXALIAS_SYS (hypotf, float, (float x, float y)); -# endif -_GL_CXXALIASWARN (hypotf); -#elif defined GNULIB_POSIXCHECK -# undef hypotf -# if HAVE_RAW_DECL_HYPOTF -_GL_WARN_ON_USE (hypotf, "hypotf is unportable - " - "use gnulib module hypotf for portability"); -# endif -#endif - -/* Return sqrt(x^2+y^2). */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef hypot -# define hypot rpl_hypot -# endif -_GL_FUNCDECL_RPL (hypot, double, (double x, double y)); -_GL_CXXALIAS_RPL (hypot, double, (double x, double y)); -# else -_GL_CXXALIAS_SYS (hypot, double, (double x, double y)); -# endif -_GL_CXXALIASWARN (hypot); -#elif defined GNULIB_POSIXCHECK -# undef hypot -# if HAVE_RAW_DECL_HYPOT -_GL_WARN_ON_USE (hypotf, "hypot has portability problems - " - "use gnulib module hypot for portability"); -# endif -#endif - -/* Return sqrt(x^2+y^2). */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef hypotl -# define hypotl rpl_hypotl -# endif -_GL_FUNCDECL_RPL (hypotl, long double, (long double x, long double y)); -_GL_CXXALIAS_RPL (hypotl, long double, (long double x, long double y)); -# else -# if !1 -_GL_FUNCDECL_SYS (hypotl, long double, (long double x, long double y)); -# endif -_GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y)); -# endif -_GL_CXXALIASWARN (hypotl); -#elif defined GNULIB_POSIXCHECK -# undef hypotl -# if HAVE_RAW_DECL_HYPOTL -_GL_WARN_ON_USE (hypotl, "hypotl is unportable - " - "use gnulib module hypotl for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ilogbf -# define ilogbf rpl_ilogbf -# endif -_GL_FUNCDECL_RPL (ilogbf, int, (float x)); -_GL_CXXALIAS_RPL (ilogbf, int, (float x)); -# else -# if !1 -_GL_FUNCDECL_SYS (ilogbf, int, (float x)); -# endif -_GL_CXXALIAS_SYS (ilogbf, int, (float x)); -# endif -_GL_CXXALIASWARN (ilogbf); -#elif defined GNULIB_POSIXCHECK -# undef ilogbf -# if HAVE_RAW_DECL_ILOGBF -_GL_WARN_ON_USE (ilogbf, "ilogbf is unportable - " - "use gnulib module ilogbf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ilogb -# define ilogb rpl_ilogb -# endif -_GL_FUNCDECL_RPL (ilogb, int, (double x)); -_GL_CXXALIAS_RPL (ilogb, int, (double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (ilogb, int, (double x)); -# endif -_GL_CXXALIAS_SYS (ilogb, int, (double x)); -# endif -_GL_CXXALIASWARN (ilogb); -#elif defined GNULIB_POSIXCHECK -# undef ilogb -# if HAVE_RAW_DECL_ILOGB -_GL_WARN_ON_USE (ilogb, "ilogb is unportable - " - "use gnulib module ilogb for portability"); -# endif -#endif - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (ilogbl, int, (long double x)); -# endif -_GL_CXXALIAS_SYS (ilogbl, int, (long double x)); -_GL_CXXALIASWARN (ilogbl); -#elif defined GNULIB_POSIXCHECK -# undef ilogbl -# if HAVE_RAW_DECL_ILOGBL -_GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - " - "use gnulib module ilogbl for portability"); -# endif -#endif - - -/* Return x * 2^exp. */ -#if 0 -# if !1 -# undef ldexpf -_GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp)); -# endif -_GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp)); -_GL_CXXALIASWARN (ldexpf); -#elif defined GNULIB_POSIXCHECK -# undef ldexpf -# if HAVE_RAW_DECL_LDEXPF -_GL_WARN_ON_USE (ldexpf, "ldexpf is unportable - " - "use gnulib module ldexpf for portability"); -# endif -#endif - -/* Return x * 2^exp. */ -#if 0 && 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef ldexpl -# define ldexpl rpl_ldexpl -# endif -_GL_FUNCDECL_RPL (ldexpl, long double, (long double x, int exp)); -_GL_CXXALIAS_RPL (ldexpl, long double, (long double x, int exp)); -#else -# if !1 -_GL_FUNCDECL_SYS (ldexpl, long double, (long double x, int exp)); -# endif -# if 0 -_GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp)); -# endif -#endif -#if 0 -_GL_CXXALIASWARN (ldexpl); -#endif -#if !0 && defined GNULIB_POSIXCHECK -# undef ldexpl -# if HAVE_RAW_DECL_LDEXPL -_GL_WARN_ON_USE (ldexpl, "ldexpl is unportable - " - "use gnulib module ldexpl for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef logf -# define logf rpl_logf -# endif -_GL_FUNCDECL_RPL (logf, float, (float x)); -_GL_CXXALIAS_RPL (logf, float, (float x)); -# else -# if !1 -# undef logf -_GL_FUNCDECL_SYS (logf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (logf, float, (float x)); -# endif -_GL_CXXALIASWARN (logf); -#elif defined GNULIB_POSIXCHECK -# undef logf -# if HAVE_RAW_DECL_LOGF -_GL_WARN_ON_USE (logf, "logf is unportable - " - "use gnulib module logf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log -# define log rpl_log -# endif -_GL_FUNCDECL_RPL (log, double, (double x)); -_GL_CXXALIAS_RPL (log, double, (double x)); -# else -_GL_CXXALIAS_SYS (log, double, (double x)); -# endif -_GL_CXXALIASWARN (log); -#elif defined GNULIB_POSIXCHECK -# undef log -# if HAVE_RAW_DECL_LOG -_GL_WARN_ON_USE (log, "log has portability problems - " - "use gnulib module log for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef logl -# define logl rpl_logl -# endif -_GL_FUNCDECL_RPL (logl, long double, (long double x)); -_GL_CXXALIAS_RPL (logl, long double, (long double x)); -# else -# if !1 || !1 -# undef logl -_GL_FUNCDECL_SYS (logl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (logl, long double, (long double x)); -# endif -_GL_CXXALIASWARN (logl); -#elif defined GNULIB_POSIXCHECK -# undef logl -# if HAVE_RAW_DECL_LOGL -_GL_WARN_ON_USE (logl, "logl is unportable - " - "use gnulib module logl for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log10f -# define log10f rpl_log10f -# endif -_GL_FUNCDECL_RPL (log10f, float, (float x)); -_GL_CXXALIAS_RPL (log10f, float, (float x)); -# else -# if !1 -# undef log10f -_GL_FUNCDECL_SYS (log10f, float, (float x)); -# endif -_GL_CXXALIAS_SYS (log10f, float, (float x)); -# endif -_GL_CXXALIASWARN (log10f); -#elif defined GNULIB_POSIXCHECK -# undef log10f -# if HAVE_RAW_DECL_LOG10F -_GL_WARN_ON_USE (log10f, "log10f is unportable - " - "use gnulib module log10f for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log10 -# define log10 rpl_log10 -# endif -_GL_FUNCDECL_RPL (log10, double, (double x)); -_GL_CXXALIAS_RPL (log10, double, (double x)); -# else -_GL_CXXALIAS_SYS (log10, double, (double x)); -# endif -_GL_CXXALIASWARN (log10); -#elif defined GNULIB_POSIXCHECK -# undef log10 -# if HAVE_RAW_DECL_LOG10 -_GL_WARN_ON_USE (log10, "log10 has portability problems - " - "use gnulib module log10 for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log10l -# define log10l rpl_log10l -# endif -_GL_FUNCDECL_RPL (log10l, long double, (long double x)); -_GL_CXXALIAS_RPL (log10l, long double, (long double x)); -# else -# if !1 || !1 -# undef log10l -_GL_FUNCDECL_SYS (log10l, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (log10l, long double, (long double x)); -# endif -_GL_CXXALIASWARN (log10l); -#elif defined GNULIB_POSIXCHECK -# undef log10l -# if HAVE_RAW_DECL_LOG10L -_GL_WARN_ON_USE (log10l, "log10l is unportable - " - "use gnulib module log10l for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log1pf -# define log1pf rpl_log1pf -# endif -_GL_FUNCDECL_RPL (log1pf, float, (float x)); -_GL_CXXALIAS_RPL (log1pf, float, (float x)); -# else -# if !1 -_GL_FUNCDECL_SYS (log1pf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (log1pf, float, (float x)); -# endif -_GL_CXXALIASWARN (log1pf); -#elif defined GNULIB_POSIXCHECK -# undef log1pf -# if HAVE_RAW_DECL_LOG1PF -_GL_WARN_ON_USE (log1pf, "log1pf is unportable - " - "use gnulib module log1pf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log1p -# define log1p rpl_log1p -# endif -_GL_FUNCDECL_RPL (log1p, double, (double x)); -_GL_CXXALIAS_RPL (log1p, double, (double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (log1p, double, (double x)); -# endif -_GL_CXXALIAS_SYS (log1p, double, (double x)); -# endif -_GL_CXXALIASWARN (log1p); -#elif defined GNULIB_POSIXCHECK -# undef log1p -# if HAVE_RAW_DECL_LOG1P -_GL_WARN_ON_USE (log1p, "log1p has portability problems - " - "use gnulib module log1p for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log1pl -# define log1pl rpl_log1pl -# endif -_GL_FUNCDECL_RPL (log1pl, long double, (long double x)); -_GL_CXXALIAS_RPL (log1pl, long double, (long double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (log1pl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (log1pl, long double, (long double x)); -# endif -_GL_CXXALIASWARN (log1pl); -#elif defined GNULIB_POSIXCHECK -# undef log1pl -# if HAVE_RAW_DECL_LOG1PL -_GL_WARN_ON_USE (log1pl, "log1pl has portability problems - " - "use gnulib module log1pl for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log2f -# define log2f rpl_log2f -# endif -_GL_FUNCDECL_RPL (log2f, float, (float x)); -_GL_CXXALIAS_RPL (log2f, float, (float x)); -# else -# if !1 -# undef log2f -_GL_FUNCDECL_SYS (log2f, float, (float x)); -# endif -_GL_CXXALIAS_SYS (log2f, float, (float x)); -# endif -_GL_CXXALIASWARN (log2f); -#elif defined GNULIB_POSIXCHECK -# undef log2f -# if HAVE_RAW_DECL_LOG2F -_GL_WARN_ON_USE (log2f, "log2f is unportable - " - "use gnulib module log2f for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log2 -# define log2 rpl_log2 -# endif -_GL_FUNCDECL_RPL (log2, double, (double x)); -_GL_CXXALIAS_RPL (log2, double, (double x)); -# else -# if !1 -# undef log2 -_GL_FUNCDECL_SYS (log2, double, (double x)); -# endif -_GL_CXXALIAS_SYS (log2, double, (double x)); -# endif -_GL_CXXALIASWARN (log2); -#elif defined GNULIB_POSIXCHECK -# undef log2 -# if HAVE_RAW_DECL_LOG2 -_GL_WARN_ON_USE (log2, "log2 is unportable - " - "use gnulib module log2 for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef log2l -# define log2l rpl_log2l -# endif -_GL_FUNCDECL_RPL (log2l, long double, (long double x)); -_GL_CXXALIAS_RPL (log2l, long double, (long double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (log2l, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (log2l, long double, (long double x)); -# endif -_GL_CXXALIASWARN (log2l); -#elif defined GNULIB_POSIXCHECK -# undef log2l -# if HAVE_RAW_DECL_LOG2L -_GL_WARN_ON_USE (log2l, "log2l is unportable - " - "use gnulib module log2l for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef logbf -# define logbf rpl_logbf -# endif -_GL_FUNCDECL_RPL (logbf, float, (float x)); -_GL_CXXALIAS_RPL (logbf, float, (float x)); -# else -# if !1 -_GL_FUNCDECL_SYS (logbf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (logbf, float, (float x)); -# endif -_GL_CXXALIASWARN (logbf); -#elif defined GNULIB_POSIXCHECK -# undef logbf -# if HAVE_RAW_DECL_LOGBF -_GL_WARN_ON_USE (logbf, "logbf is unportable - " - "use gnulib module logbf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef logb -# define logb rpl_logb -# endif -_GL_FUNCDECL_RPL (logb, double, (double x)); -_GL_CXXALIAS_RPL (logb, double, (double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (logb, double, (double x)); -# endif -_GL_CXXALIAS_SYS (logb, double, (double x)); -# endif -_GL_CXXALIASWARN (logb); -#elif defined GNULIB_POSIXCHECK -# undef logb -# if HAVE_RAW_DECL_LOGB -_GL_WARN_ON_USE (logb, "logb is unportable - " - "use gnulib module logb for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef logbl -# define logbl rpl_logbl -# endif -_GL_FUNCDECL_RPL (logbl, long double, (long double x)); -_GL_CXXALIAS_RPL (logbl, long double, (long double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (logbl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (logbl, long double, (long double x)); -# endif -_GL_CXXALIASWARN (logbl); -#elif defined GNULIB_POSIXCHECK -# undef logbl -# if HAVE_RAW_DECL_LOGBL -_GL_WARN_ON_USE (logbl, "logbl is unportable - " - "use gnulib module logbl for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef modff -# define modff rpl_modff -# endif -_GL_FUNCDECL_RPL (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (modff, float, (float x, float *iptr)); -# else -# if !1 -# undef modff -_GL_FUNCDECL_SYS (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (modff, float, (float x, float *iptr)); -# endif -_GL_CXXALIASWARN (modff); -#elif defined GNULIB_POSIXCHECK -# undef modff -# if HAVE_RAW_DECL_MODFF -_GL_WARN_ON_USE (modff, "modff is unportable - " - "use gnulib module modff for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef modf -# define modf rpl_modf -# endif -_GL_FUNCDECL_RPL (modf, double, (double x, double *iptr) _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (modf, double, (double x, double *iptr)); -# else -_GL_CXXALIAS_SYS (modf, double, (double x, double *iptr)); -# endif -_GL_CXXALIASWARN (modf); -#elif defined GNULIB_POSIXCHECK -# undef modf -# if HAVE_RAW_DECL_MODF -_GL_WARN_ON_USE (modf, "modf has portability problems - " - "use gnulib module modf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef modfl -# define modfl rpl_modfl -# endif -_GL_FUNCDECL_RPL (modfl, long double, (long double x, long double *iptr) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (modfl, long double, (long double x, long double *iptr)); -# else -# if !1 -# undef modfl -_GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr)); -# endif -_GL_CXXALIASWARN (modfl); -#elif defined GNULIB_POSIXCHECK -# undef modfl -# if HAVE_RAW_DECL_MODFL -_GL_WARN_ON_USE (modfl, "modfl is unportable - " - "use gnulib module modfl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef powf -_GL_FUNCDECL_SYS (powf, float, (float x, float y)); -# endif -_GL_CXXALIAS_SYS (powf, float, (float x, float y)); -_GL_CXXALIASWARN (powf); -#elif defined GNULIB_POSIXCHECK -# undef powf -# if HAVE_RAW_DECL_POWF -_GL_WARN_ON_USE (powf, "powf is unportable - " - "use gnulib module powf for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef remainderf -# define remainderf rpl_remainderf -# endif -_GL_FUNCDECL_RPL (remainderf, float, (float x, float y)); -_GL_CXXALIAS_RPL (remainderf, float, (float x, float y)); -# else -# if !1 -_GL_FUNCDECL_SYS (remainderf, float, (float x, float y)); -# endif -_GL_CXXALIAS_SYS (remainderf, float, (float x, float y)); -# endif -_GL_CXXALIASWARN (remainderf); -#elif defined GNULIB_POSIXCHECK -# undef remainderf -# if HAVE_RAW_DECL_REMAINDERF -_GL_WARN_ON_USE (remainderf, "remainderf is unportable - " - "use gnulib module remainderf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef remainder -# define remainder rpl_remainder -# endif -_GL_FUNCDECL_RPL (remainder, double, (double x, double y)); -_GL_CXXALIAS_RPL (remainder, double, (double x, double y)); -# else -# if !1 || !1 -_GL_FUNCDECL_SYS (remainder, double, (double x, double y)); -# endif -_GL_CXXALIAS_SYS (remainder, double, (double x, double y)); -# endif -_GL_CXXALIASWARN (remainder); -#elif defined GNULIB_POSIXCHECK -# undef remainder -# if HAVE_RAW_DECL_REMAINDER -_GL_WARN_ON_USE (remainder, "remainder is unportable - " - "use gnulib module remainder for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef remainderl -# define remainderl rpl_remainderl -# endif -_GL_FUNCDECL_RPL (remainderl, long double, (long double x, long double y)); -_GL_CXXALIAS_RPL (remainderl, long double, (long double x, long double y)); -# else -# if !1 -# undef remainderl -_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y)); -# endif -_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y)); -# endif -_GL_CXXALIASWARN (remainderl); -#elif defined GNULIB_POSIXCHECK -# undef remainderl -# if HAVE_RAW_DECL_REMAINDERL -_GL_WARN_ON_USE (remainderl, "remainderl is unportable - " - "use gnulib module remainderl for portability"); -# endif -#endif - - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (rintf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (rintf, float, (float x)); -_GL_CXXALIASWARN (rintf); -#elif defined GNULIB_POSIXCHECK -# undef rintf -# if HAVE_RAW_DECL_RINTF -_GL_WARN_ON_USE (rintf, "rintf is unportable - " - "use gnulib module rintf for portability"); -# endif -#endif - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (rint, double, (double x)); -# endif -_GL_CXXALIAS_SYS (rint, double, (double x)); -_GL_CXXALIASWARN (rint); -#elif defined GNULIB_POSIXCHECK -# undef rint -# if HAVE_RAW_DECL_RINT -_GL_WARN_ON_USE (rint, "rint is unportable - " - "use gnulib module rint for portability"); -# endif -#endif - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (rintl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (rintl, long double, (long double x)); -_GL_CXXALIASWARN (rintl); -#elif defined GNULIB_POSIXCHECK -# undef rintl -# if HAVE_RAW_DECL_RINTL -_GL_WARN_ON_USE (rintl, "rintl is unportable - " - "use gnulib module rintl for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef roundf -# define roundf rpl_roundf -# endif -_GL_FUNCDECL_RPL (roundf, float, (float x)); -_GL_CXXALIAS_RPL (roundf, float, (float x)); -# else -# if !1 -_GL_FUNCDECL_SYS (roundf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (roundf, float, (float x)); -# endif -_GL_CXXALIASWARN (roundf); -#elif defined GNULIB_POSIXCHECK -# undef roundf -# if HAVE_RAW_DECL_ROUNDF -_GL_WARN_ON_USE (roundf, "roundf is unportable - " - "use gnulib module roundf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef round -# define round rpl_round -# endif -_GL_FUNCDECL_RPL (round, double, (double x)); -_GL_CXXALIAS_RPL (round, double, (double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (round, double, (double x)); -# endif -_GL_CXXALIAS_SYS (round, double, (double x)); -# endif -_GL_CXXALIASWARN (round); -#elif defined GNULIB_POSIXCHECK -# undef round -# if HAVE_RAW_DECL_ROUND -_GL_WARN_ON_USE (round, "round is unportable - " - "use gnulib module round for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef roundl -# define roundl rpl_roundl -# endif -_GL_FUNCDECL_RPL (roundl, long double, (long double x)); -_GL_CXXALIAS_RPL (roundl, long double, (long double x)); -# else -# if !1 -# undef roundl -_GL_FUNCDECL_SYS (roundl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (roundl, long double, (long double x)); -# endif -_GL_CXXALIASWARN (roundl); -#elif defined GNULIB_POSIXCHECK -# undef roundl -# if HAVE_RAW_DECL_ROUNDL -_GL_WARN_ON_USE (roundl, "roundl is unportable - " - "use gnulib module roundl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef sinf -_GL_FUNCDECL_SYS (sinf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (sinf, float, (float x)); -_GL_CXXALIASWARN (sinf); -#elif defined GNULIB_POSIXCHECK -# undef sinf -# if HAVE_RAW_DECL_SINF -_GL_WARN_ON_USE (sinf, "sinf is unportable - " - "use gnulib module sinf for portability"); -# endif -#endif - -#if 0 -# if !1 || !1 -# undef sinl -_GL_FUNCDECL_SYS (sinl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (sinl, long double, (long double x)); -_GL_CXXALIASWARN (sinl); -#elif defined GNULIB_POSIXCHECK -# undef sinl -# if HAVE_RAW_DECL_SINL -_GL_WARN_ON_USE (sinl, "sinl is unportable - " - "use gnulib module sinl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef sinhf -_GL_FUNCDECL_SYS (sinhf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (sinhf, float, (float x)); -_GL_CXXALIASWARN (sinhf); -#elif defined GNULIB_POSIXCHECK -# undef sinhf -# if HAVE_RAW_DECL_SINHF -_GL_WARN_ON_USE (sinhf, "sinhf is unportable - " - "use gnulib module sinhf for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef sqrtf -_GL_FUNCDECL_SYS (sqrtf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (sqrtf, float, (float x)); -_GL_CXXALIASWARN (sqrtf); -#elif defined GNULIB_POSIXCHECK -# undef sqrtf -# if HAVE_RAW_DECL_SQRTF -_GL_WARN_ON_USE (sqrtf, "sqrtf is unportable - " - "use gnulib module sqrtf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef sqrtl -# define sqrtl rpl_sqrtl -# endif -_GL_FUNCDECL_RPL (sqrtl, long double, (long double x)); -_GL_CXXALIAS_RPL (sqrtl, long double, (long double x)); -# else -# if !1 || !1 -# undef sqrtl -_GL_FUNCDECL_SYS (sqrtl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (sqrtl, long double, (long double x)); -# endif -_GL_CXXALIASWARN (sqrtl); -#elif defined GNULIB_POSIXCHECK -# undef sqrtl -# if HAVE_RAW_DECL_SQRTL -_GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - " - "use gnulib module sqrtl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef tanf -_GL_FUNCDECL_SYS (tanf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (tanf, float, (float x)); -_GL_CXXALIASWARN (tanf); -#elif defined GNULIB_POSIXCHECK -# undef tanf -# if HAVE_RAW_DECL_TANF -_GL_WARN_ON_USE (tanf, "tanf is unportable - " - "use gnulib module tanf for portability"); -# endif -#endif - -#if 0 -# if !1 || !1 -# undef tanl -_GL_FUNCDECL_SYS (tanl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (tanl, long double, (long double x)); -_GL_CXXALIASWARN (tanl); -#elif defined GNULIB_POSIXCHECK -# undef tanl -# if HAVE_RAW_DECL_TANL -_GL_WARN_ON_USE (tanl, "tanl is unportable - " - "use gnulib module tanl for portability"); -# endif -#endif - - -#if 0 -# if !1 -# undef tanhf -_GL_FUNCDECL_SYS (tanhf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (tanhf, float, (float x)); -_GL_CXXALIASWARN (tanhf); -#elif defined GNULIB_POSIXCHECK -# undef tanhf -# if HAVE_RAW_DECL_TANHF -_GL_WARN_ON_USE (tanhf, "tanhf is unportable - " - "use gnulib module tanhf for portability"); -# endif -#endif - - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define truncf rpl_truncf -# endif -_GL_FUNCDECL_RPL (truncf, float, (float x)); -_GL_CXXALIAS_RPL (truncf, float, (float x)); -# else -# if !1 -_GL_FUNCDECL_SYS (truncf, float, (float x)); -# endif -_GL_CXXALIAS_SYS (truncf, float, (float x)); -# endif -_GL_CXXALIASWARN (truncf); -#elif defined GNULIB_POSIXCHECK -# undef truncf -# if HAVE_RAW_DECL_TRUNCF -_GL_WARN_ON_USE (truncf, "truncf is unportable - " - "use gnulib module truncf for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define trunc rpl_trunc -# endif -_GL_FUNCDECL_RPL (trunc, double, (double x)); -_GL_CXXALIAS_RPL (trunc, double, (double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (trunc, double, (double x)); -# endif -_GL_CXXALIAS_SYS (trunc, double, (double x)); -# endif -_GL_CXXALIASWARN (trunc); -#elif defined GNULIB_POSIXCHECK -# undef trunc -# if HAVE_RAW_DECL_TRUNC -_GL_WARN_ON_USE (trunc, "trunc is unportable - " - "use gnulib module trunc for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef truncl -# define truncl rpl_truncl -# endif -_GL_FUNCDECL_RPL (truncl, long double, (long double x)); -_GL_CXXALIAS_RPL (truncl, long double, (long double x)); -# else -# if !1 -_GL_FUNCDECL_SYS (truncl, long double, (long double x)); -# endif -_GL_CXXALIAS_SYS (truncl, long double, (long double x)); -# endif -_GL_CXXALIASWARN (truncl); -#elif defined GNULIB_POSIXCHECK -# undef truncl -# if HAVE_RAW_DECL_TRUNCL -_GL_WARN_ON_USE (truncl, "truncl is unportable - " - "use gnulib module truncl for portability"); -# endif -#endif - - -/* Definitions of function-like macros come here, after the function - declarations. */ - - -#if 0 -# if 0 -_GL_EXTERN_C int gl_isfinitef (float x); -_GL_EXTERN_C int gl_isfinited (double x); -_GL_EXTERN_C int gl_isfinitel (long double x); -# undef isfinite -# define isfinite(x) \ - (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ - sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ - gl_isfinitef (x)) -# endif -# ifdef __cplusplus -# ifdef isfinite -_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite) -# undef isfinite -_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite) -# endif -# endif -#elif defined GNULIB_POSIXCHECK -# if defined isfinite -_GL_WARN_REAL_FLOATING_DECL (isfinite); -# undef isfinite -# define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x) -# endif -#endif - - -#if 0 -# if 0 -_GL_EXTERN_C int gl_isinff (float x); -_GL_EXTERN_C int gl_isinfd (double x); -_GL_EXTERN_C int gl_isinfl (long double x); -# undef isinf -# define isinf(x) \ - (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \ - sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ - gl_isinff (x)) -# endif -# ifdef __cplusplus -# ifdef isinf -_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf) -# undef isinf -_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf) -# endif -# endif -#elif defined GNULIB_POSIXCHECK -# if defined isinf -_GL_WARN_REAL_FLOATING_DECL (isinf); -# undef isinf -# define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x) -# endif -#endif - - -#if 0 -/* Test for NaN for 'float' numbers. */ -# if 1 -/* The original <math.h> included above provides a declaration of isnan macro - or (older) isnanf function. */ -# if __GNUC__ >= 4 - /* GCC 4.0 and newer provides three built-ins for isnan. */ -# undef isnanf -# define isnanf(x) __builtin_isnanf ((float)(x)) -# elif defined isnan -# undef isnanf -# define isnanf(x) isnan ((float)(x)) -# endif -# else -/* Test whether X is a NaN. */ -# undef isnanf -# define isnanf rpl_isnanf -_GL_EXTERN_C int isnanf (float x); -# endif -#endif - -#if 0 -/* Test for NaN for 'double' numbers. - This function is a gnulib extension, unlike isnan() which applied only - to 'double' numbers earlier but now is a type-generic macro. */ -# if 1 -/* The original <math.h> included above provides a declaration of isnan - macro. */ -# if __GNUC__ >= 4 - /* GCC 4.0 and newer provides three built-ins for isnan. */ -# undef isnand -# define isnand(x) __builtin_isnan ((double)(x)) -# else -# undef isnand -# define isnand(x) isnan ((double)(x)) -# endif -# else -/* Test whether X is a NaN. */ -# undef isnand -# define isnand rpl_isnand -_GL_EXTERN_C int isnand (double x); -# endif -#endif - -#if 0 -/* Test for NaN for 'long double' numbers. */ -# if 1 -/* The original <math.h> included above provides a declaration of isnan - macro or (older) isnanl function. */ -# if __GNUC__ >= 4 - /* GCC 4.0 and newer provides three built-ins for isnan. */ -# undef isnanl -# define isnanl(x) __builtin_isnanl ((long double)(x)) -# elif defined isnan -# undef isnanl -# define isnanl(x) isnan ((long double)(x)) -# endif -# else -/* Test whether X is a NaN. */ -# undef isnanl -# define isnanl rpl_isnanl -_GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST; -# endif -#endif - -/* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */ -#if 0 -# if 0 -/* We can't just use the isnanf macro (e.g.) as exposed by - isnanf.h (e.g.) here, because those may end up being macros - that recursively expand back to isnan. So use the gnulib - replacements for them directly. */ -# if 1 && __GNUC__ >= 4 -# define gl_isnan_f(x) __builtin_isnanf ((float)(x)) -# else -_GL_EXTERN_C int rpl_isnanf (float x); -# define gl_isnan_f(x) rpl_isnanf (x) -# endif -# if 1 && __GNUC__ >= 4 -# define gl_isnan_d(x) __builtin_isnan ((double)(x)) -# else -_GL_EXTERN_C int rpl_isnand (double x); -# define gl_isnan_d(x) rpl_isnand (x) -# endif -# if 1 && __GNUC__ >= 4 -# define gl_isnan_l(x) __builtin_isnanl ((long double)(x)) -# else -_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; -# define gl_isnan_l(x) rpl_isnanl (x) -# endif -# undef isnan -# define isnan(x) \ - (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ - sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ - gl_isnan_f (x)) -# elif __GNUC__ >= 4 -# undef isnan -# define isnan(x) \ - (sizeof (x) == sizeof (long double) ? __builtin_isnanl ((long double)(x)) : \ - sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \ - __builtin_isnanf ((float)(x))) -# endif -# ifdef __cplusplus -# ifdef isnan -_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) -# undef isnan -_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan) -# endif -# else -/* Ensure isnan is a macro. */ -# ifndef isnan -# define isnan isnan -# endif -# endif -#elif defined GNULIB_POSIXCHECK -# if defined isnan -_GL_WARN_REAL_FLOATING_DECL (isnan); -# undef isnan -# define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x) -# endif -#endif - - -#if 1 -# if 0 -# undef signbit - /* GCC 4.0 and newer provides three built-ins for signbit. */ -# define signbit(x) \ - (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ - sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ - __builtin_signbitf (x)) -# endif -# if 1 -# undef signbit -_GL_EXTERN_C int gl_signbitf (float arg); -_GL_EXTERN_C int gl_signbitd (double arg); -_GL_EXTERN_C int gl_signbitl (long double arg); -# if __GNUC__ >= 2 && !defined __STRICT_ANSI__ -# define _GL_NUM_UINT_WORDS(type) \ - ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) -# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf -# define gl_signbitf_OPTIMIZED_MACRO -# define gl_signbitf(arg) \ - ({ union { float _value; \ - unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \ - } _m; \ - _m._value = (arg); \ - (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ - }) -# endif -# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd -# define gl_signbitd_OPTIMIZED_MACRO -# define gl_signbitd(arg) \ - ({ union { double _value; \ - unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \ - } _m; \ - _m._value = (arg); \ - (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ - }) -# endif -# if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl -# define gl_signbitl_OPTIMIZED_MACRO -# define gl_signbitl(arg) \ - ({ union { long double _value; \ - unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \ - } _m; \ - _m._value = (arg); \ - (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ - }) -# endif -# endif -# define signbit(x) \ - (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ - sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ - gl_signbitf (x)) -# endif -# ifdef __cplusplus -# ifdef signbit -_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit) -# undef signbit -_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit) -# endif -# endif -#elif defined GNULIB_POSIXCHECK -# if defined signbit -_GL_WARN_REAL_FLOATING_DECL (signbit); -# undef signbit -# define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x) -# endif -#endif - -_GL_INLINE_HEADER_END - -#endif - -#endif /* _GL_M4_MATH_H */ -#endif /* _GL_M4_MATH_H */ diff --git a/contrib/tools/m4/lib/platform/win64/stdbool.h b/contrib/tools/m4/lib/platform/win64/stdbool.h deleted file mode 100644 index 8f918a3123..0000000000 --- a/contrib/tools/m4/lib/platform/win64/stdbool.h +++ /dev/null @@ -1,133 +0,0 @@ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc. - Written by Bruno Haible <haible@clisp.cons.org>, 2001. - - 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, 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 <http://www.gnu.org/licenses/>. */ - -#ifndef _GL_STDBOOL_H -#define _GL_STDBOOL_H - -/* ISO C 99 <stdbool.h> for platforms that lack it. */ - -/* Usage suggestions: - - Programs that use <stdbool.h> should be aware of some limitations - and standards compliance issues. - - Standards compliance: - - - <stdbool.h> must be #included before 'bool', 'false', 'true' - can be used. - - - You cannot assume that sizeof (bool) == 1. - - - Programs should not undefine the macros bool, true, and false, - as C99 lists that as an "obsolescent feature". - - Limitations of this substitute, when used in a C89 environment: - - - <stdbool.h> must be #included before the '_Bool' type can be used. - - - You cannot assume that _Bool is a typedef; it might be a macro. - - - Bit-fields of type 'bool' are not supported. Portable code - should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'. - - - In C99, casts and automatic conversions to '_Bool' or 'bool' are - performed in such a way that every nonzero value gets converted - to 'true', and zero gets converted to 'false'. This doesn't work - with this substitute. With this substitute, only the values 0 and 1 - give the expected result when converted to _Bool' or 'bool'. - - - C99 allows the use of (_Bool)0.0 in constant expressions, but - this substitute cannot always provide this property. - - Also, it is suggested that programs use 'bool' rather than '_Bool'; - this isn't required, but 'bool' is more common. */ - - -/* 7.16. Boolean type and values */ - -/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same - definitions below, but temporarily we have to #undef them. */ -#if defined __BEOS__ && !defined __HAIKU__ -# error #include <OS.h> /* defines bool but not _Bool */ -# undef false -# undef true -#endif - -#ifdef __cplusplus -# define _Bool bool -# define bool bool -#else -# if defined __BEOS__ && !defined __HAIKU__ - /* A compiler known to have 'bool'. */ - /* If the compiler already has both 'bool' and '_Bool', we can assume they - are the same types. */ -# if !0 -typedef bool _Bool; -# endif -# else -# if !defined __GNUC__ - /* If 0: - Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when - the built-in _Bool type is used. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - Similar bugs are likely with other compilers as well; this file - wouldn't be used if <stdbool.h> was working. - So we override the _Bool type. - If !0: - Need to define _Bool ourselves. As 'signed char' or as an enum type? - Use of a typedef, with SunPRO C, leads to a stupid - "warning: _Bool is a keyword in ISO C99". - Use of an enum type, with IRIX cc, leads to a stupid - "warning(1185): enumerated type mixed with another type". - Even the existence of an enum type, without a typedef, - "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. - The only benefit of the enum, debuggability, is not important - with these compilers. So use 'signed char' and no enum. */ -# define _Bool signed char -# else - /* With this compiler, trust the _Bool type if the compiler has it. */ -# if !0 - /* For the sake of symbolic names in gdb, define true and false as - enum constants, not only as macros. - It is tempting to write - typedef enum { false = 0, true = 1 } _Bool; - so that gdb prints values of type 'bool' symbolically. But then - values of type '_Bool' might promote to 'int' or 'unsigned int' - (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' - (see ISO C 99 6.3.1.1.(2)). So add a negative value to the - enum; this ensures that '_Bool' promotes to 'int'. */ -typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; -# endif -# endif -# endif -# define bool _Bool -#endif - -/* The other macros must be usable in preprocessor directives. */ -#ifdef __cplusplus -# define false false -# define true true -#else -# define false 0 -# define true 1 -#endif - -#define __bool_true_false_are_defined 1 - -#endif /* _GL_STDBOOL_H */ diff --git a/contrib/tools/m4/lib/platform/win64/unused-parameter.h b/contrib/tools/m4/lib/platform/win64/unused-parameter.h deleted file mode 100644 index 53474b5754..0000000000 --- a/contrib/tools/m4/lib/platform/win64/unused-parameter.h +++ /dev/null @@ -1,20 +0,0 @@ -/* _GL_UNUSED_PARAMETER is a marker that can be appended to function parameter - declarations for parameters that are not used. This helps to reduce - warnings, such as from GCC -Wunused-parameter. The syntax is as follows: - type param _GL_UNUSED_PARAMETER - or more generally - param_decl _GL_UNUSED_PARAMETER - For example: - int param _GL_UNUSED_PARAMETER - int *(*param)(void) _GL_UNUSED_PARAMETER - Other possible, but obscure and discouraged syntaxes: - int _GL_UNUSED_PARAMETER *(*param)(void) - _GL_UNUSED_PARAMETER int *(*param)(void) - */ -#ifndef _GL_UNUSED_PARAMETER -# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_UNUSED_PARAMETER __attribute__ ((__unused__)) -# else -# define _GL_UNUSED_PARAMETER -# endif -#endif diff --git a/contrib/tools/m4/lib/platform/win64/win_sdk10.h b/contrib/tools/m4/lib/platform/win64/win_sdk10.h deleted file mode 100644 index 76e5c86ccd..0000000000 --- a/contrib/tools/m4/lib/platform/win64/win_sdk10.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#if defined(_MSC_VER) - -#include <ntverp.h> - -// Check for Windows SDK 10+ -#if defined(VER_PRODUCTBUILD) && VER_PRODUCTBUILD >= 9600 -#define WIN_SDK10 1 -#else -#define WIN_SDK10 0 -#endif - -// Since Windows SDK 10 FILE is an internal opaque structure with no backward compatibility. -// This code has been transplanted from Windows SDK -// corecrt_internal_stdio.h - -// __crt_stdio_stream_data -#if WIN_SDK10 -typedef struct { - union { - void* _public_file; - char* _ptr; - }; - - char* _base; - int _cnt; - long _flags; - long _file; - int _charbuf; - int _bufsiz; - char* _tmpfname; - //CRITICAL_SECTION _lock; -} TWinSdk10File; - -enum EWinSdk10ModeBits { - WIN_SDK10_IOREAD = 0x0001, - WIN_SDK10_IOWRITE = 0x0002, - WIN_SDK10_IOUPDATE = 0x0004, - WIN_SDK10_IOEOF = 0x0008, - WIN_SDK10_IOERROR = 0x0010, - WIN_SDK10_IOCTRLZ = 0x0020, - WIN_SDK10_IOBUFFER_CRT = 0x0040, - WIN_SDK10_IOBUFFER_USER = 0x0080, - WIN_SDK10_IOBUFFER_SETVBUF = 0x0100, - WIN_SDK10_IOBUFFER_STBUF = 0x0200, - WIN_SDK10_IOBUFFER_NONE = 0x0400, - WIN_SDK10_IOCOMMIT = 0x0800, - WIN_SDK10_IOSTRING = 0x1000, - WIN_SDK10_IOALLOCATED = 0x2000, -}; -#endif - -#endif - diff --git a/contrib/tools/m4/lib/rawmemchr.c b/contrib/tools/m4/lib/rawmemchr.c deleted file mode 100644 index a0298ce64e..0000000000 --- a/contrib/tools/m4/lib/rawmemchr.c +++ /dev/null @@ -1,136 +0,0 @@ -/* Searching in a string. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <string.h> - -/* Find the first occurrence of C in S. */ -void * -rawmemchr (const void *s, int c_in) -{ - /* On 32-bit hardware, choosing longword to be a 32-bit unsigned - long instead of a 64-bit uintmax_t tends to give better - performance. On 64-bit hardware, unsigned long is generally 64 - bits already. Change this typedef to experiment with - performance. */ - typedef unsigned long int longword; - - const unsigned char *char_ptr; - const longword *longword_ptr; - longword repeated_one; - longword repeated_c; - unsigned char c; - - c = (unsigned char) c_in; - - /* Handle the first few bytes by reading one byte at a time. - Do this until CHAR_PTR is aligned on a longword boundary. */ - for (char_ptr = (const unsigned char *) s; - (size_t) char_ptr % sizeof (longword) != 0; - ++char_ptr) - if (*char_ptr == c) - return (void *) char_ptr; - - longword_ptr = (const longword *) char_ptr; - - /* All these elucidatory comments refer to 4-byte longwords, - but the theory applies equally well to any size longwords. */ - - /* Compute auxiliary longword values: - repeated_one is a value which has a 1 in every byte. - repeated_c has c in every byte. */ - repeated_one = 0x01010101; - repeated_c = c | (c << 8); - repeated_c |= repeated_c << 16; - if (0xffffffffU < (longword) -1) - { - repeated_one |= repeated_one << 31 << 1; - repeated_c |= repeated_c << 31 << 1; - if (8 < sizeof (longword)) - { - size_t i; - - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << i; - } - } - } - - /* Instead of the traditional loop which tests each byte, we will - test a longword at a time. The tricky part is testing if *any of - the four* bytes in the longword in question are equal to NUL or - c. We first use an xor with repeated_c. This reduces the task - to testing whether *any of the four* bytes in longword1 is zero. - - We compute tmp = - ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). - That is, we perform the following operations: - 1. Subtract repeated_one. - 2. & ~longword1. - 3. & a mask consisting of 0x80 in every byte. - Consider what happens in each byte: - - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, - and step 3 transforms it into 0x80. A carry can also be propagated - to more significant bytes. - - If a byte of longword1 is nonzero, let its lowest 1 bit be at - position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, - the byte ends in a single bit of value 0 and k bits of value 1. - After step 2, the result is just k bits of value 1: 2^k - 1. After - step 3, the result is 0. And no carry is produced. - So, if longword1 has only non-zero bytes, tmp is zero. - Whereas if longword1 has a zero byte, call j the position of the least - significant zero byte. Then the result has a zero at positions 0, ..., - j-1 and a 0x80 at position j. We cannot predict the result at the more - significant bytes (positions j+1..3), but it does not matter since we - already have a non-zero bit at position 8*j+7. - - The test whether any byte in longword1 is zero is equivalent - to testing whether tmp is nonzero. - - This test can read beyond the end of a string, depending on where - C_IN is encountered. However, this is considered safe since the - initialization phase ensured that the read will be aligned, - therefore, the read will not cross page boundaries and will not - cause a fault. */ - - while (1) - { - longword longword1 = *longword_ptr ^ repeated_c; - - if ((((longword1 - repeated_one) & ~longword1) - & (repeated_one << 7)) != 0) - break; - longword_ptr++; - } - - char_ptr = (const unsigned char *) longword_ptr; - - /* At this point, we know that one of the sizeof (longword) bytes - starting at char_ptr is == c. On little-endian machines, we - could determine the first such byte without any further memory - accesses, just by looking at the tmp result from the last loop - iteration. But this does not work on big-endian machines. - Choose code that works in both cases. */ - - char_ptr = (unsigned char *) longword_ptr; - while (*char_ptr != c) - char_ptr++; - return (void *) char_ptr; -} diff --git a/contrib/tools/m4/lib/readlink.c b/contrib/tools/m4/lib/readlink.c deleted file mode 100644 index f83a1e0123..0000000000 --- a/contrib/tools/m4/lib/readlink.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Stub for readlink(). - Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <unistd.h> - -#include <errno.h> -#include <string.h> -#include <sys/stat.h> - -#if !HAVE_READLINK - -/* readlink() substitute for systems that don't have a readlink() function, - such as DJGPP 2.03 and mingw32. */ - -ssize_t -readlink (const char *name, char *buf _GL_UNUSED, - size_t bufsize _GL_UNUSED) -{ - struct stat statbuf; - - /* In general we should use lstat() here, not stat(). But on platforms - without symbolic links, lstat() - if it exists - would be equivalent to - stat(), therefore we can use stat(). This saves us a configure check. */ - if (stat (name, &statbuf) >= 0) - errno = EINVAL; - return -1; -} - -#else /* HAVE_READLINK */ - -# undef readlink - -/* readlink() wrapper that uses correct types, for systems like cygwin - 1.5.x where readlink returns int, and which rejects trailing slash, - for Solaris 9. */ - -ssize_t -rpl_readlink (const char *name, char *buf, size_t bufsize) -{ -# if READLINK_TRAILING_SLASH_BUG - size_t len = strlen (name); - if (len && name[len - 1] == '/') - { - /* Even if name without the slash is a symlink to a directory, - both lstat() and stat() must resolve the trailing slash to - the directory rather than the symlink. We can therefore - safely use stat() to distinguish between EINVAL and - ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat(). */ - struct stat st; - if (stat (name, &st) == 0) - errno = EINVAL; - return -1; - } -# endif /* READLINK_TRAILING_SLASH_BUG */ - return readlink (name, buf, bufsize); -} - -#endif /* HAVE_READLINK */ diff --git a/contrib/tools/m4/lib/rename.c b/contrib/tools/m4/lib/rename.c deleted file mode 100644 index 3e463ea86a..0000000000 --- a/contrib/tools/m4/lib/rename.c +++ /dev/null @@ -1,473 +0,0 @@ -/* Work around rename bugs in some systems. - - Copyright (C) 2001-2003, 2005-2006, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -/* Written by Volker Borchert, Eric Blake. */ - -#include <config.h> - -#include <stdio.h> - -#undef rename - -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -/* The mingw rename has problems with trailing slashes; it also - requires use of native Windows calls to allow atomic renames over - existing files. */ - -# include <errno.h> -# include <stdbool.h> -# include <stdlib.h> -# include <sys/stat.h> -# include <unistd.h> - -# define WIN32_LEAN_AND_MEAN -# include <windows.h> - -# include "dirname.h" - -/* Rename the file SRC to DST. This replacement is necessary on - Windows, on which the system rename function will not replace - an existing DST. */ -int -rpl_rename (char const *src, char const *dst) -{ - int error; - size_t src_len = strlen (src); - size_t dst_len = strlen (dst); - char *src_base = last_component (src); - char *dst_base = last_component (dst); - bool src_slash; - bool dst_slash; - bool dst_exists; - struct stat src_st; - struct stat dst_st; - - /* Filter out dot as last component. */ - if (!src_len || !dst_len) - { - errno = ENOENT; - return -1; - } - if (*src_base == '.') - { - size_t len = base_len (src_base); - if (len == 1 || (len == 2 && src_base[1] == '.')) - { - errno = EINVAL; - return -1; - } - } - if (*dst_base == '.') - { - size_t len = base_len (dst_base); - if (len == 1 || (len == 2 && dst_base[1] == '.')) - { - errno = EINVAL; - return -1; - } - } - - /* Presence of a trailing slash requires directory semantics. If - the source does not exist, or if the destination cannot be turned - into a directory, give up now. Otherwise, strip trailing slashes - before calling rename. There are no symlinks on mingw, so stat - works instead of lstat. */ - src_slash = ISSLASH (src[src_len - 1]); - dst_slash = ISSLASH (dst[dst_len - 1]); - if (stat (src, &src_st)) - return -1; - if (stat (dst, &dst_st)) - { - if (errno != ENOENT || (!S_ISDIR (src_st.st_mode) && dst_slash)) - return -1; - dst_exists = false; - } - else - { - if (S_ISDIR (dst_st.st_mode) != S_ISDIR (src_st.st_mode)) - { - errno = S_ISDIR (dst_st.st_mode) ? EISDIR : ENOTDIR; - return -1; - } - dst_exists = true; - } - - /* There are no symlinks, so if a file existed with a trailing - slash, it must be a directory, and we don't have to worry about - stripping strip trailing slash. However, mingw refuses to - replace an existing empty directory, so we have to help it out. - And canonicalize_file_name is not yet ported to mingw; however, - for directories, getcwd works as a viable alternative. Ensure - that we can get back to where we started before using it; later - attempts to return are fatal. Note that we can end up losing a - directory if rename then fails, but it was empty, so not much - damage was done. */ - if (dst_exists && S_ISDIR (dst_st.st_mode)) - { - char *cwd = getcwd (NULL, 0); - char *src_temp; - char *dst_temp; - if (!cwd || chdir (cwd)) - return -1; - if (IS_ABSOLUTE_FILE_NAME (src)) - { - dst_temp = chdir (dst) ? NULL : getcwd (NULL, 0); - src_temp = chdir (src) ? NULL : getcwd (NULL, 0); - } - else - { - src_temp = chdir (src) ? NULL : getcwd (NULL, 0); - if (!IS_ABSOLUTE_FILE_NAME (dst) && chdir (cwd)) - abort (); - dst_temp = chdir (dst) ? NULL : getcwd (NULL, 0); - } - if (chdir (cwd)) - abort (); - free (cwd); - if (!src_temp || !dst_temp) - { - free (src_temp); - free (dst_temp); - errno = ENOMEM; - return -1; - } - src_len = strlen (src_temp); - if (strncmp (src_temp, dst_temp, src_len) == 0 - && (ISSLASH (dst_temp[src_len]) || dst_temp[src_len] == '\0')) - { - error = dst_temp[src_len]; - free (src_temp); - free (dst_temp); - if (error) - { - errno = EINVAL; - return -1; - } - return 0; - } - if (rmdir (dst)) - { - error = errno; - free (src_temp); - free (dst_temp); - errno = error; - return -1; - } - free (src_temp); - free (dst_temp); - } - - /* MoveFileEx works if SRC is a directory without any flags, but - fails with MOVEFILE_REPLACE_EXISTING, so try without flags first. - Thankfully, MoveFileEx handles hard links correctly, even though - rename() does not. */ - if (MoveFileEx (src, dst, 0)) - return 0; - - /* Retry with MOVEFILE_REPLACE_EXISTING if the move failed - due to the destination already existing. */ - error = GetLastError (); - if (error == ERROR_FILE_EXISTS || error == ERROR_ALREADY_EXISTS) - { - if (MoveFileEx (src, dst, MOVEFILE_REPLACE_EXISTING)) - return 0; - - error = GetLastError (); - } - - switch (error) - { - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - case ERROR_BAD_PATHNAME: - case ERROR_DIRECTORY: - errno = ENOENT; - break; - - case ERROR_ACCESS_DENIED: - case ERROR_SHARING_VIOLATION: - errno = EACCES; - break; - - case ERROR_OUTOFMEMORY: - errno = ENOMEM; - break; - - case ERROR_CURRENT_DIRECTORY: - errno = EBUSY; - break; - - case ERROR_NOT_SAME_DEVICE: - errno = EXDEV; - break; - - case ERROR_WRITE_PROTECT: - errno = EROFS; - break; - - case ERROR_WRITE_FAULT: - case ERROR_READ_FAULT: - case ERROR_GEN_FAILURE: - errno = EIO; - break; - - case ERROR_HANDLE_DISK_FULL: - case ERROR_DISK_FULL: - case ERROR_DISK_TOO_FRAGMENTED: - errno = ENOSPC; - break; - - case ERROR_FILE_EXISTS: - case ERROR_ALREADY_EXISTS: - errno = EEXIST; - break; - - case ERROR_BUFFER_OVERFLOW: - case ERROR_FILENAME_EXCED_RANGE: - errno = ENAMETOOLONG; - break; - - case ERROR_INVALID_NAME: - case ERROR_DELETE_PENDING: - errno = EPERM; /* ? */ - break; - -# ifndef ERROR_FILE_TOO_LARGE -/* This value is documented but not defined in all versions of windows.h. */ -# define ERROR_FILE_TOO_LARGE 223 -# endif - case ERROR_FILE_TOO_LARGE: - errno = EFBIG; - break; - - default: - errno = EINVAL; - break; - } - - return -1; -} - -#else /* ! W32 platform */ - -# include <errno.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> -# include <sys/stat.h> -# include <unistd.h> - -# include "dirname.h" -# include "same-inode.h" - -/* Rename the file SRC to DST, fixing any trailing slash bugs. */ - -int -rpl_rename (char const *src, char const *dst) -{ - size_t src_len = strlen (src); - size_t dst_len = strlen (dst); - char *src_temp = (char *) src; - char *dst_temp = (char *) dst; - bool src_slash; - bool dst_slash; - bool dst_exists; - int ret_val = -1; - int rename_errno = ENOTDIR; - struct stat src_st; - struct stat dst_st; - - if (!src_len || !dst_len) - return rename (src, dst); /* Let strace see the ENOENT failure. */ - -# if RENAME_DEST_EXISTS_BUG - { - char *src_base = last_component (src); - char *dst_base = last_component (dst); - if (*src_base == '.') - { - size_t len = base_len (src_base); - if (len == 1 || (len == 2 && src_base[1] == '.')) - { - errno = EINVAL; - return -1; - } - } - if (*dst_base == '.') - { - size_t len = base_len (dst_base); - if (len == 1 || (len == 2 && dst_base[1] == '.')) - { - errno = EINVAL; - return -1; - } - } - } -# endif /* RENAME_DEST_EXISTS_BUG */ - - src_slash = src[src_len - 1] == '/'; - dst_slash = dst[dst_len - 1] == '/'; - -# if !RENAME_HARD_LINK_BUG && !RENAME_DEST_EXISTS_BUG - /* If there are no trailing slashes, then trust the native - implementation unless we also suspect issues with hard link - detection or file/directory conflicts. */ - if (!src_slash && !dst_slash) - return rename (src, dst); -# endif /* !RENAME_HARD_LINK_BUG && !RENAME_DEST_EXISTS_BUG */ - - /* Presence of a trailing slash requires directory semantics. If - the source does not exist, or if the destination cannot be turned - into a directory, give up now. Otherwise, strip trailing slashes - before calling rename. */ - if (lstat (src, &src_st)) - return -1; - if (lstat (dst, &dst_st)) - { - if (errno != ENOENT || (!S_ISDIR (src_st.st_mode) && dst_slash)) - return -1; - dst_exists = false; - } - else - { - if (S_ISDIR (dst_st.st_mode) != S_ISDIR (src_st.st_mode)) - { - errno = S_ISDIR (dst_st.st_mode) ? EISDIR : ENOTDIR; - return -1; - } -# if RENAME_HARD_LINK_BUG - if (SAME_INODE (src_st, dst_st)) - return 0; -# endif /* RENAME_HARD_LINK_BUG */ - dst_exists = true; - } - -# if (RENAME_TRAILING_SLASH_SOURCE_BUG || RENAME_DEST_EXISTS_BUG \ - || RENAME_HARD_LINK_BUG) - /* If the only bug was that a trailing slash was allowed on a - non-existing file destination, as in Solaris 10, then we've - already covered that situation. But if there is any problem with - a trailing slash on an existing source or destination, as in - Solaris 9, or if a directory can overwrite a symlink, as on - Cygwin 1.5, or if directories cannot be created with trailing - slash, as on NetBSD 1.6, then we must strip the offending slash - and check that we have not encountered a symlink instead of a - directory. - - Stripping a trailing slash interferes with POSIX semantics, where - rename behavior on a symlink with a trailing slash operates on - the corresponding target directory. We prefer the GNU semantics - of rejecting any use of a symlink with trailing slash, but do not - enforce them, since Solaris 10 is able to obey POSIX semantics - and there might be clients expecting it, as counter-intuitive as - those semantics are. - - Technically, we could also follow the POSIX behavior by chasing a - readlink trail, but that is harder to implement. */ - if (src_slash) - { - src_temp = strdup (src); - if (!src_temp) - { - /* Rather than rely on strdup-posix, we set errno ourselves. */ - rename_errno = ENOMEM; - goto out; - } - strip_trailing_slashes (src_temp); - if (lstat (src_temp, &src_st)) - { - rename_errno = errno; - goto out; - } - if (S_ISLNK (src_st.st_mode)) - goto out; - } - if (dst_slash) - { - dst_temp = strdup (dst); - if (!dst_temp) - { - rename_errno = ENOMEM; - goto out; - } - strip_trailing_slashes (dst_temp); - if (lstat (dst_temp, &dst_st)) - { - if (errno != ENOENT) - { - rename_errno = errno; - goto out; - } - } - else if (S_ISLNK (dst_st.st_mode)) - goto out; - } -# endif /* RENAME_TRAILING_SLASH_SOURCE_BUG || RENAME_DEST_EXISTS_BUG - || RENAME_HARD_LINK_BUG */ - -# if RENAME_DEST_EXISTS_BUG - /* Cygwin 1.5 sometimes behaves oddly when moving a non-empty - directory on top of an empty one (the old directory name can - reappear if the new directory tree is removed). Work around this - by removing the target first, but don't remove the target if it - is a subdirectory of the source. Note that we can end up losing - a directory if rename then fails, but it was empty, so not much - damage was done. */ - if (dst_exists && S_ISDIR (dst_st.st_mode)) - { - if (src_st.st_dev != dst_st.st_dev) - { - rename_errno = EXDEV; - goto out; - } - if (src_temp != src) - free (src_temp); - src_temp = canonicalize_file_name (src); - if (dst_temp != dst) - free (dst_temp); - dst_temp = canonicalize_file_name (dst); - if (!src_temp || !dst_temp) - { - rename_errno = ENOMEM; - goto out; - } - src_len = strlen (src_temp); - if (strncmp (src_temp, dst_temp, src_len) == 0 - && dst_temp[src_len] == '/') - { - rename_errno = EINVAL; - goto out; - } - if (rmdir (dst)) - { - rename_errno = errno; - goto out; - } - } -# endif /* RENAME_DEST_EXISTS_BUG */ - - ret_val = rename (src_temp, dst_temp); - rename_errno = errno; - out: - if (src_temp != src) - free (src_temp); - if (dst_temp != dst) - free (dst_temp); - errno = rename_errno; - return ret_val; -} -#endif /* ! W32 platform */ diff --git a/contrib/tools/m4/lib/same-inode.h b/contrib/tools/m4/lib/same-inode.h deleted file mode 100644 index 3843b07078..0000000000 --- a/contrib/tools/m4/lib/same-inode.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Determine whether two stat buffers refer to the same file. - - Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#ifndef SAME_INODE_H -# define SAME_INODE_H 1 - -# ifdef __VMS -# define SAME_INODE(a, b) \ - ((a).st_ino[0] == (b).st_ino[0] \ - && (a).st_ino[1] == (b).st_ino[1] \ - && (a).st_ino[2] == (b).st_ino[2] \ - && (a).st_dev == (b).st_dev) -# else -# define SAME_INODE(a, b) \ - ((a).st_ino == (b).st_ino \ - && (a).st_dev == (b).st_dev) -# endif - -#endif diff --git a/contrib/tools/m4/lib/signbitd.c b/contrib/tools/m4/lib/signbitd.c deleted file mode 100644 index 7a434f8eea..0000000000 --- a/contrib/tools/m4/lib/signbitd.c +++ /dev/null @@ -1,64 +0,0 @@ -/* signbit() macro: Determine the sign bit of a floating-point number. - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <math.h> - -#include <string.h> -#include "isnand-nolibm.h" -#include "float+.h" - -#ifdef gl_signbitd_OPTIMIZED_MACRO -# undef gl_signbitd -#endif - -int -gl_signbitd (double arg) -{ -#if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT - /* The use of a union to extract the bits of the representation of a - 'long double' is safe in practice, despite of the "aliasing rules" of - C99, because the GCC docs say - "Even with '-fstrict-aliasing', type-punning is allowed, provided the - memory is accessed through the union type." - and similarly for other compilers. */ -# define NWORDS \ - ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) - union { double value; unsigned int word[NWORDS]; } m; - m.value = arg; - return (m.word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; -#elif HAVE_COPYSIGN_IN_LIBC - return copysign (1.0, arg) < 0; -#else - /* This does not do the right thing for NaN, but this is irrelevant for - most use cases. */ - if (isnand (arg)) - return 0; - if (arg < 0.0) - return 1; - else if (arg == 0.0) - { - /* Distinguish 0.0 and -0.0. */ - static double plus_zero = 0.0; - double arg_mem = arg; - return (memcmp (&plus_zero, &arg_mem, SIZEOF_DBL) != 0); - } - else - return 0; -#endif -} diff --git a/contrib/tools/m4/lib/signbitf.c b/contrib/tools/m4/lib/signbitf.c deleted file mode 100644 index f133be57f5..0000000000 --- a/contrib/tools/m4/lib/signbitf.c +++ /dev/null @@ -1,64 +0,0 @@ -/* signbit() macro: Determine the sign bit of a floating-point number. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <math.h> - -#include <string.h> -#include "isnanf-nolibm.h" -#include "float+.h" - -#ifdef gl_signbitf_OPTIMIZED_MACRO -# undef gl_signbitf -#endif - -int -gl_signbitf (float arg) -{ -#if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT - /* The use of a union to extract the bits of the representation of a - 'long double' is safe in practice, despite of the "aliasing rules" of - C99, because the GCC docs say - "Even with '-fstrict-aliasing', type-punning is allowed, provided the - memory is accessed through the union type." - and similarly for other compilers. */ -# define NWORDS \ - ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) - union { float value; unsigned int word[NWORDS]; } m; - m.value = arg; - return (m.word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; -#elif HAVE_COPYSIGNF_IN_LIBC - return copysignf (1.0f, arg) < 0; -#else - /* This does not do the right thing for NaN, but this is irrelevant for - most use cases. */ - if (isnanf (arg)) - return 0; - if (arg < 0.0f) - return 1; - else if (arg == 0.0f) - { - /* Distinguish 0.0f and -0.0f. */ - static float plus_zero = 0.0f; - float arg_mem = arg; - return (memcmp (&plus_zero, &arg_mem, SIZEOF_FLT) != 0); - } - else - return 0; -#endif -} diff --git a/contrib/tools/m4/lib/signbitl.c b/contrib/tools/m4/lib/signbitl.c deleted file mode 100644 index 9e1e900e16..0000000000 --- a/contrib/tools/m4/lib/signbitl.c +++ /dev/null @@ -1,64 +0,0 @@ -/* signbit() macro: Determine the sign bit of a floating-point number. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <math.h> - -#include <string.h> -#include "isnanl-nolibm.h" -#include "float+.h" - -#ifdef gl_signbitl_OPTIMIZED_MACRO -# undef gl_signbitl -#endif - -int -gl_signbitl (long double arg) -{ -#if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT - /* The use of a union to extract the bits of the representation of a - 'long double' is safe in practice, despite of the "aliasing rules" of - C99, because the GCC docs say - "Even with '-fstrict-aliasing', type-punning is allowed, provided the - memory is accessed through the union type." - and similarly for other compilers. */ -# define NWORDS \ - ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) - union { long double value; unsigned int word[NWORDS]; } m; - m.value = arg; - return (m.word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; -#elif HAVE_COPYSIGNL_IN_LIBC - return copysignl (1.0L, arg) < 0; -#else - /* This does not do the right thing for NaN, but this is irrelevant for - most use cases. */ - if (isnanl (arg)) - return 0; - if (arg < 0.0L) - return 1; - else if (arg == 0.0L) - { - /* Distinguish 0.0L and -0.0L. */ - static long double plus_zero = 0.0L; - long double arg_mem = arg; - return (memcmp (&plus_zero, &arg_mem, SIZEOF_LDBL) != 0); - } - else - return 0; -#endif -} diff --git a/contrib/tools/m4/lib/sigsegv.h b/contrib/tools/m4/lib/sigsegv.h new file mode 100644 index 0000000000..29fc128a3e --- /dev/null +++ b/contrib/tools/m4/lib/sigsegv.h @@ -0,0 +1,243 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Page fault handling library. + Copyright (C) 1998-2021 Bruno Haible <bruno@clisp.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/>. */ + +#ifndef _SIGSEGV_H +#define _SIGSEGV_H + +/* Get size_t. */ +#include <stddef.h> + +/* Define the fault context structure. */ +#if defined __linux__ || defined __ANDROID__ \ + || (defined __FreeBSD__ && (defined __arm__ || defined __armhf__ || defined __arm64__)) \ + || defined __NetBSD__ \ + || defined _AIX || defined __sun \ + || defined __CYGWIN__ +/* Linux, FreeBSD, NetBSD, AIX, Solaris, Cygwin */ +# include <ucontext.h> +#elif (defined __APPLE__ && defined __MACH__) +/* macOS */ +# include <sys/ucontext.h> +#elif defined __HAIKU__ +/* Haiku */ +# include <signal.h> +#endif + +/* Correct the value of SIGSTKSZ on some systems. + glibc >= 2.34: When _GNU_SOURCE is defined, SIGSTKSZ is no longer a + compile-time constant. But most programs need a simple constant. + AIX 64-bit: original value 4096 is too small. + HP-UX: original value 8192 is too small. + Solaris 11/x86_64: original value 8192 is too small. */ +#include <signal.h> +#if __GLIBC__ >= 2 +# undef SIGSTKSZ +# if defined __ia64__ +# define SIGSTKSZ 262144 +# else +# define SIGSTKSZ 65536 +# endif +#endif +#if defined _AIX && defined _ARCH_PPC64 +# undef SIGSTKSZ +# define SIGSTKSZ 8192 +#endif +#if defined __hpux || (defined __sun && (defined __x86_64__ || defined __amd64__)) +# undef SIGSTKSZ +# define SIGSTKSZ 16384 +#endif + +/* HAVE_SIGSEGV_RECOVERY + is defined if the system supports catching SIGSEGV. */ +#if defined __linux__ || defined __ANDROID__ || defined __GNU__ \ + || defined __FreeBSD_kernel__ || (defined __FreeBSD__ && !(defined __sparc__ || defined __sparc64__)) || defined __DragonFly__ \ + || defined __NetBSD__ \ + || defined __OpenBSD__ \ + || (defined __APPLE__ && defined __MACH__) \ + || defined _AIX || defined __sgi || defined __sun \ + || defined __CYGWIN__ || defined __HAIKU__ +/* Linux, Hurd, GNU/kFreeBSD, FreeBSD, NetBSD, OpenBSD, macOS, AIX, IRIX, Solaris, Cygwin, Haiku */ +# define HAVE_SIGSEGV_RECOVERY 1 +#endif + +/* HAVE_STACK_OVERFLOW_RECOVERY + is defined if stack overflow can be caught. */ +#if defined __linux__ || defined __ANDROID__ || defined __GNU__ \ + || defined __FreeBSD_kernel__ || (defined __FreeBSD__ && !(defined __sparc__ || defined __sparc64__)) || defined __DragonFly__ \ + || (defined __NetBSD__ && !(defined __sparc__ || defined __sparc64__)) \ + || defined __OpenBSD__ \ + || (defined __APPLE__ && defined __MACH__) \ + || defined _AIX || defined __sgi || defined __sun \ + || defined __CYGWIN__ || defined __HAIKU__ +/* Linux, Hurd, GNU/kFreeBSD, FreeBSD, NetBSD, OpenBSD, macOS, AIX, IRIX, Solaris, Cygwin, Haiku */ +# define HAVE_STACK_OVERFLOW_RECOVERY 1 +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +#define LIBSIGSEGV_VERSION 0x020D /* version number: (major<<8) + minor */ +extern int libsigsegv_version; /* Likewise */ + +/* -------------------------------------------------------------------------- */ + +#if 1 /* really only HAVE_SIGSEGV_RECOVERY */ + +/* + * The mask of bits that are set to zero in a fault address that gets passed + * to a global SIGSEGV handler. + * On some platforms, the precise fault address is not known, only the memory + * page into which the fault address falls. This is apparently allowed by POSIX: + * <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html> + * says: "For some implementations, the value of si_addr may be inaccurate." + * In this case, the returned fault address is rounded down to a multiple of + * getpagesize() = sysconf(_SC_PAGESIZE). + * On such platforms, we define SIGSEGV_FAULT_ADDRESS_ALIGNMENT to be an upper + * bound for getpagesize() (and, like getpagesize(), also a power of 2). + * On the platforms where the returned fault address is the precise one, we + * define SIGSEGV_FAULT_ADDRESS_ALIGNMENT to 1. + */ +# if defined __NetBSD__ && (defined __sparc__ || defined __sparc64__) + /* getpagesize () is 0x1000 or 0x2000, depending on hardware. */ +# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 0x2000UL +# elif defined __linux__ && (defined __s390__ || defined __s390x__) + /* getpagesize () is 0x1000. */ +# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 0x1000UL +# else +# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 1UL +# endif + +/* + * The type of a global SIGSEGV handler. + * The fault address, with the bits (SIGSEGV_FAULT_ADDRESS_ALIGNMENT - 1) + * cleared, is passed as argument. + * The access type (read access or write access) is not passed; your handler + * has to know itself how to distinguish these two cases. + * The second argument is 0, meaning it could also be a stack overflow, or 1, + * meaning the handler should seriously try to fix the fault. + * The return value should be nonzero if the handler has done its job + * and no other handler should be called, or 0 if the handler declines + * responsibility for the given address. + * + * The handler is run at a moment when nothing about the global state of the + * program is known. Therefore it cannot use facilities that manipulate global + * variables or locks. In particular, it cannot use malloc(); use mmap() + * instead. It cannot use fopen(); use open() instead. Etc. All global + * variables that are accessed by the handler should be marked 'volatile'. + */ +typedef int (*sigsegv_handler_t) (void* fault_address, int serious); + +/* + * Installs a global SIGSEGV handler. + * This should be called once only, and it ignores any previously installed + * SIGSEGV handler. + * Returns 0 on success, or -1 if the system doesn't support catching SIGSEGV. + */ +extern int sigsegv_install_handler (sigsegv_handler_t handler); + +/* + * Deinstalls the global SIGSEGV handler. + * This goes back to the state where no SIGSEGV handler is installed. + */ +extern void sigsegv_deinstall_handler (void); + +/* + * Prepares leaving a SIGSEGV handler (through longjmp or similar means). + * Control is transferred by calling CONTINUATION with CONT_ARG1, CONT_ARG2, + * CONT_ARG3 as arguments. + * CONTINUATION must not return. + * The sigsegv_leave_handler function may return if called from a SIGSEGV + * handler; its return value should be used as the handler's return value. + * The sigsegv_leave_handler function does not return if called from a + * stack overflow handler. + */ +extern int sigsegv_leave_handler (void (*continuation) (void*, void*, void*), void* cont_arg1, void* cont_arg2, void* cont_arg3); + +#endif /* HAVE_SIGSEGV_RECOVERY */ + +#if 1 /* really only HAVE_STACK_OVERFLOW_RECOVERY */ + +/* + * The type of a context passed to a stack overflow handler. + * This type is system dependent; on some platforms it is an 'ucontext_t *', + * on some platforms it is a 'struct sigcontext *', on others merely an + * opaque 'void *'. + */ +# if defined __linux__ || defined __ANDROID__ \ + || (defined __FreeBSD__ && (defined __arm__ || defined __armhf__ || defined __arm64__)) \ + || defined __NetBSD__ \ + || (defined __APPLE__ && defined __MACH__) \ + || defined _AIX || defined __sun \ + || defined __CYGWIN__ || defined __HAIKU__ +typedef ucontext_t *stackoverflow_context_t; +# elif defined __GNU__ \ + || defined __FreeBSD_kernel__ || (defined __FreeBSD__ && !(defined __sparc__ || defined __sparc64__)) \ + || defined __OpenBSD__ || defined __sgi +typedef struct sigcontext *stackoverflow_context_t; +# else +typedef void *stackoverflow_context_t; +# endif + +/* + * The type of a stack overflow handler. + * Such a handler should perform a longjmp call in order to reduce the amount + * of stack needed. It must not return. + * The emergency argument is 0 when the stack could be repared, or 1 if the + * application should better save its state and exit now. + * + * The handler is run at a moment when nothing about the global state of the + * program is known. Therefore it cannot use facilities that manipulate global + * variables or locks. In particular, it cannot use malloc(); use mmap() + * instead. It cannot use fopen(); use open() instead. Etc. All global + * variables that are accessed by the handler should be marked 'volatile'. + */ +typedef void (*stackoverflow_handler_t) (int emergency, stackoverflow_context_t scp); + +/* + * Installs a stack overflow handler. + * The extra_stack argument is a pointer to a pre-allocated area used as a + * stack for executing the handler. It typically comes from a static variable + * or from heap-allocated memoty; placing it on the main stack may fail on + * some operating systems. + * Its size, passed in extra_stack_size, should be sufficiently large. The + * following code determines an appropriate size: + * #include <signal.h> + * #ifndef SIGSTKSZ / * glibc defines SIGSTKSZ for this purpose * / + * # define SIGSTKSZ 16384 / * on most platforms, 16 KB are sufficient * / + * #endif + * Returns 0 on success, or -1 if the system doesn't support catching stack + * overflow. + */ +extern int stackoverflow_install_handler (stackoverflow_handler_t handler, + void* extra_stack, size_t extra_stack_size); + +/* + * Deinstalls the stack overflow handler. + */ +extern void stackoverflow_deinstall_handler (void); + +#endif /* HAVE_STACK_OVERFLOW_RECOVERY */ + +/* -------------------------------------------------------------------------- */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SIGSEGV_H */ diff --git a/contrib/tools/m4/lib/snprintf.c b/contrib/tools/m4/lib/snprintf.c deleted file mode 100644 index 9c34de3bb2..0000000000 --- a/contrib/tools/m4/lib/snprintf.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Formatted output to strings. - Copyright (C) 2004, 2006-2013 Free Software Foundation, Inc. - Written by Simon Josefsson and Paul Eggert. - - 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, 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <stdio.h> - -#include <errno.h> -#include <limits.h> -#include <stdarg.h> -#include <stdlib.h> -#include <string.h> - -#include "vasnprintf.h" - -#if defined(_MSC_VER) && _MSC_VER < 1900 -/* Print formatted output to string STR. Similar to sprintf, but - additional length SIZE limit how much is written into STR. Returns - string length of formatted string (which may be larger than SIZE). - STR may be NULL, in which case nothing will be written. On error, - return a negative value. */ -int -snprintf (char *str, size_t size, const char *format, ...) -{ - char *output; - size_t len; - size_t lenbuf = size; - va_list args; - - va_start (args, format); - output = vasnprintf (str, &lenbuf, format, args); - len = lenbuf; - va_end (args); - - if (!output) - return -1; - - if (output != str) - { - if (size) - { - size_t pruned_len = (len < size ? len : size - 1); - memcpy (str, output, pruned_len); - str[pruned_len] = '\0'; - } - - free (output); - } - - if (INT_MAX < len) - { -#if (defined _MSC_VER) && (MSC_VER < 1800) -#else - errno = EOVERFLOW; -#endif - return -1; - } - - return len; -} -#endif diff --git a/contrib/tools/m4/lib/spawn_faction_addclose.c b/contrib/tools/m4/lib/spawn_faction_addclose.c deleted file mode 100644 index 86a9aba2e7..0000000000 --- a/contrib/tools/m4/lib/spawn_faction_addclose.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -#include <errno.h> -#include <unistd.h> - -#if !_LIBC -# define __sysconf(open_max) getdtablesize () -#endif - -#if !HAVE_WORKING_POSIX_SPAWN -# include "spawn_int.h" -#endif - -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'close' for the given file descriptor during the 'spawn' call. */ -int -posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *file_actions, - int fd) -#undef posix_spawn_file_actions_addclose -{ - int maxfd = __sysconf (_SC_OPEN_MAX); - - /* Test for the validity of the file descriptor. */ - if (fd < 0 || fd >= maxfd) - return EBADF; - -#if HAVE_WORKING_POSIX_SPAWN - return posix_spawn_file_actions_addclose (file_actions, fd); -#else - /* Allocate more memory if needed. */ - if (file_actions->_used == file_actions->_allocated - && __posix_spawn_file_actions_realloc (file_actions) != 0) - /* This can only mean we ran out of memory. */ - return ENOMEM; - - { - struct __spawn_action *rec; - - /* Add the new value. */ - rec = &file_actions->_actions[file_actions->_used]; - rec->tag = spawn_do_close; - rec->action.open_action.fd = fd; - - /* Account for the new entry. */ - ++file_actions->_used; - - return 0; - } -#endif -} diff --git a/contrib/tools/m4/lib/spawn_faction_adddup2.c b/contrib/tools/m4/lib/spawn_faction_adddup2.c deleted file mode 100644 index 56ff1ecc18..0000000000 --- a/contrib/tools/m4/lib/spawn_faction_adddup2.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -#include <errno.h> -#include <unistd.h> - -#if !_LIBC -# define __sysconf(open_max) getdtablesize () -#endif - -#if !HAVE_WORKING_POSIX_SPAWN -# include "spawn_int.h" -#endif - -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'dup2' for the given file descriptors during the 'spawn' call. */ -int -posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *file_actions, - int fd, int newfd) -#undef posix_spawn_file_actions_adddup2 -{ - int maxfd = __sysconf (_SC_OPEN_MAX); - - /* Test for the validity of the file descriptor. */ - if (fd < 0 || newfd < 0 || fd >= maxfd || newfd >= maxfd) - return EBADF; - -#if HAVE_WORKING_POSIX_SPAWN - return posix_spawn_file_actions_adddup2 (file_actions, fd, newfd); -#else - /* Allocate more memory if needed. */ - if (file_actions->_used == file_actions->_allocated - && __posix_spawn_file_actions_realloc (file_actions) != 0) - /* This can only mean we ran out of memory. */ - return ENOMEM; - - { - struct __spawn_action *rec; - - /* Add the new value. */ - rec = &file_actions->_actions[file_actions->_used]; - rec->tag = spawn_do_dup2; - rec->action.dup2_action.fd = fd; - rec->action.dup2_action.newfd = newfd; - - /* Account for the new entry. */ - ++file_actions->_used; - - return 0; - } -#endif -} diff --git a/contrib/tools/m4/lib/spawn_faction_addopen.c b/contrib/tools/m4/lib/spawn_faction_addopen.c deleted file mode 100644 index 8aaeca6a50..0000000000 --- a/contrib/tools/m4/lib/spawn_faction_addopen.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -#include <errno.h> -#include <unistd.h> - -#if !_LIBC -# define __sysconf(open_max) getdtablesize () -#endif - -#if !HAVE_WORKING_POSIX_SPAWN -# include "spawn_int.h" -#endif - -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'open' for the given file during the 'spawn' call. */ -int -posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *file_actions, - int fd, const char *path, int oflag, - mode_t mode) -#undef posix_spawn_file_actions_addopen -{ - int maxfd = __sysconf (_SC_OPEN_MAX); - - /* Test for the validity of the file descriptor. */ - if (fd < 0 || fd >= maxfd) - return EBADF; - -#if HAVE_WORKING_POSIX_SPAWN - return posix_spawn_file_actions_addopen (file_actions, fd, path, oflag, mode); -#else - /* Allocate more memory if needed. */ - if (file_actions->_used == file_actions->_allocated - && __posix_spawn_file_actions_realloc (file_actions) != 0) - /* This can only mean we ran out of memory. */ - return ENOMEM; - - { - struct __spawn_action *rec; - - /* Add the new value. */ - rec = &file_actions->_actions[file_actions->_used]; - rec->tag = spawn_do_open; - rec->action.open_action.fd = fd; - rec->action.open_action.path = path; - rec->action.open_action.oflag = oflag; - rec->action.open_action.mode = mode; - - /* Account for the new entry. */ - ++file_actions->_used; - - return 0; - } -#endif -} diff --git a/contrib/tools/m4/lib/spawn_faction_destroy.c b/contrib/tools/m4/lib/spawn_faction_destroy.c deleted file mode 100644 index 942733dc6b..0000000000 --- a/contrib/tools/m4/lib/spawn_faction_destroy.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -#include <stdlib.h> - -/* Initialize data structure for file attribute for 'spawn' call. */ -int -posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *file_actions) -{ - /* Free the memory allocated. */ - free (file_actions->_actions); - return 0; -} diff --git a/contrib/tools/m4/lib/spawn_faction_init.c b/contrib/tools/m4/lib/spawn_faction_init.c deleted file mode 100644 index cf1d0a6adc..0000000000 --- a/contrib/tools/m4/lib/spawn_faction_init.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -#include "spawn_int.h" - - -/* Function used to increase the size of the allocated array. This - function is called from the 'add'-functions. */ -int -__posix_spawn_file_actions_realloc (posix_spawn_file_actions_t *file_actions) -{ - int newalloc = file_actions->_allocated + 8; - void *newmem = realloc (file_actions->_actions, - newalloc * sizeof (struct __spawn_action)); - - if (newmem == NULL) - /* Not enough memory. */ - return ENOMEM; - - file_actions->_actions = (struct __spawn_action *) newmem; - file_actions->_allocated = newalloc; - - return 0; -} - - -/* Initialize data structure for file attribute for 'spawn' call. */ -int -posix_spawn_file_actions_init (posix_spawn_file_actions_t *file_actions) -{ - /* Simply clear all the elements. */ - memset (file_actions, '\0', sizeof (*file_actions)); - return 0; -} diff --git a/contrib/tools/m4/lib/spawn_int.h b/contrib/tools/m4/lib/spawn_int.h deleted file mode 100644 index f22a659fbe..0000000000 --- a/contrib/tools/m4/lib/spawn_int.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2000, 2008-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <sys/types.h> - -/* Data structure to contain the action information. */ -struct __spawn_action -{ - enum - { - spawn_do_close, - spawn_do_dup2, - spawn_do_open - } tag; - - union - { - struct - { - int fd; - } close_action; - struct - { - int fd; - int newfd; - } dup2_action; - struct - { - int fd; - const char *path; - int oflag; - mode_t mode; - } open_action; - } action; -}; - -#if !_LIBC -# define __posix_spawn_file_actions_realloc gl_posix_spawn_file_actions_realloc -#endif -extern int __posix_spawn_file_actions_realloc (posix_spawn_file_actions_t * - file_actions); - -#if !_LIBC -# define __spawni gl_posix_spawn_internal -#endif -extern int __spawni (pid_t *pid, const char *path, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, char *const argv[], - char *const envp[], int use_path); diff --git a/contrib/tools/m4/lib/spawnattr_destroy.c b/contrib/tools/m4/lib/spawnattr_destroy.c deleted file mode 100644 index ec6c7cf003..0000000000 --- a/contrib/tools/m4/lib/spawnattr_destroy.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -/* Initialize data structure for file attribute for 'spawn' call. */ -int -posix_spawnattr_destroy (posix_spawnattr_t *attr) -{ - /* Nothing to do in the moment. */ - return 0; -} diff --git a/contrib/tools/m4/lib/spawnattr_init.c b/contrib/tools/m4/lib/spawnattr_init.c deleted file mode 100644 index b050fb4ab7..0000000000 --- a/contrib/tools/m4/lib/spawnattr_init.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -#include <string.h> - -/* Initialize data structure for file attribute for 'spawn' call. */ -int -posix_spawnattr_init (posix_spawnattr_t *attr) -{ - /* All elements have to be initialized to the default values which - is generally zero. */ - memset (attr, '\0', sizeof (*attr)); - - return 0; -} diff --git a/contrib/tools/m4/lib/spawnattr_setflags.c b/contrib/tools/m4/lib/spawnattr_setflags.c deleted file mode 100644 index babbb19593..0000000000 --- a/contrib/tools/m4/lib/spawnattr_setflags.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2000, 2004, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -#include <errno.h> -#include <string.h> - -#define ALL_FLAGS (POSIX_SPAWN_RESETIDS \ - | POSIX_SPAWN_SETPGROUP \ - | POSIX_SPAWN_SETSIGDEF \ - | POSIX_SPAWN_SETSIGMASK \ - | POSIX_SPAWN_SETSCHEDPARAM \ - | POSIX_SPAWN_SETSCHEDULER \ - | POSIX_SPAWN_USEVFORK) - -/* Store flags in the attribute structure. */ -int -posix_spawnattr_setflags (posix_spawnattr_t *attr, short int flags) -{ - /* Check no invalid bits are set. */ - if (flags & ~ALL_FLAGS) - return EINVAL; - - /* Store the flag word. */ - attr->_flags = flags; - - return 0; -} diff --git a/contrib/tools/m4/lib/spawnattr_setsigmask.c b/contrib/tools/m4/lib/spawnattr_setsigmask.c deleted file mode 100644 index 8aa6da9437..0000000000 --- a/contrib/tools/m4/lib/spawnattr_setsigmask.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -#include <string.h> - -/* Set signal mask for the new process in ATTR to SIGMASK. */ -int -posix_spawnattr_setsigmask (posix_spawnattr_t *attr, - const sigset_t *sigmask) -{ - /* Copy the sigset_t data to the user buffer. */ - memcpy (&attr->_ss, sigmask, sizeof (sigset_t)); - - return 0; -} diff --git a/contrib/tools/m4/lib/spawni.c b/contrib/tools/m4/lib/spawni.c deleted file mode 100644 index e2f7b45b60..0000000000 --- a/contrib/tools/m4/lib/spawni.c +++ /dev/null @@ -1,374 +0,0 @@ -/* Guts of POSIX spawn interface. Generic POSIX.1 version. - Copyright (C) 2000-2006, 2008-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> -#include "spawn_int.h" - -#include "palloca.h" -#include <errno.h> - -#include <fcntl.h> -#ifndef O_LARGEFILE -# define O_LARGEFILE 0 -#endif - -#if _LIBC || HAVE_PATHS_H -# include <paths.h> -#else -# define _PATH_BSHELL "/bin/sh" -#endif - -#include <signal.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#if _LIBC -# include <not-cancel.h> -#else -# define close_not_cancel close -# define open_not_cancel open -#endif - -#if _LIBC -# include <local-setxid.h> -#else -# if !HAVE_SETEUID -# define seteuid(id) setresuid (-1, id, -1) -# endif -# if !HAVE_SETEGID -# define setegid(id) setresgid (-1, id, -1) -# endif -# define local_seteuid(id) seteuid (id) -# define local_setegid(id) setegid (id) -#endif - -#if _LIBC -# define alloca __alloca -# define execve __execve -# define dup2 __dup2 -# define fork __fork -# define getgid __getgid -# define getuid __getuid -# define sched_setparam __sched_setparam -# define sched_setscheduler __sched_setscheduler -# define setpgid __setpgid -# define sigaction __sigaction -# define sigismember __sigismember -# define sigprocmask __sigprocmask -# define strchrnul __strchrnul -# define vfork __vfork -#else -# undef internal_function -# define internal_function /* empty */ -#endif - - -/* The Unix standard contains a long explanation of the way to signal - an error after the fork() was successful. Since no new wait status - was wanted there is no way to signal an error using one of the - available methods. The committee chose to signal an error by a - normal program exit with the exit code 127. */ -#define SPAWN_ERROR 127 - - -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - -/* Native Windows API. */ -int -__spawni (pid_t *pid, const char *file, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, char *const argv[], - char *const envp[], int use_path) -{ - /* Not yet implemented. */ - return ENOSYS; -} - -#else - - -/* The file is accessible but it is not an executable file. Invoke - the shell to interpret it as a script. */ -static void -internal_function -script_execute (const char *file, char *const argv[], char *const envp[]) -{ - /* Count the arguments. */ - int argc = 0; - while (argv[argc++]) - ; - - /* Construct an argument list for the shell. */ - { - char **new_argv = (char **) alloca ((argc + 1) * sizeof (char *)); - new_argv[0] = (char *) _PATH_BSHELL; - new_argv[1] = (char *) file; - while (argc > 1) - { - new_argv[argc] = argv[argc - 1]; - --argc; - } - - /* Execute the shell. */ - execve (new_argv[0], new_argv, envp); - } -} - - -/* Spawn a new process executing PATH with the attributes describes in *ATTRP. - Before running the process perform the actions described in FILE-ACTIONS. */ -int -__spawni (pid_t *pid, const char *file, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, char *const argv[], - char *const envp[], int use_path) -{ - pid_t new_pid; - char *path, *p, *name; - size_t len; - size_t pathlen; - - /* Do this once. */ - short int flags = attrp == NULL ? 0 : attrp->_flags; - - /* Avoid gcc warning - "variable 'flags' might be clobbered by 'longjmp' or 'vfork'" */ - (void) &flags; - - /* Generate the new process. */ -#if HAVE_VFORK - if ((flags & POSIX_SPAWN_USEVFORK) != 0 - /* If no major work is done, allow using vfork. Note that we - might perform the path searching. But this would be done by - a call to execvp(), too, and such a call must be OK according - to POSIX. */ - || ((flags & (POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF - | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER - | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_RESETIDS)) == 0 - && file_actions == NULL)) - new_pid = vfork (); - else -#endif - new_pid = fork (); - - if (new_pid != 0) - { - if (new_pid < 0) - return errno; - - /* The call was successful. Store the PID if necessary. */ - if (pid != NULL) - *pid = new_pid; - - return 0; - } - - /* Set signal mask. */ - if ((flags & POSIX_SPAWN_SETSIGMASK) != 0 - && sigprocmask (SIG_SETMASK, &attrp->_ss, NULL) != 0) - _exit (SPAWN_ERROR); - - /* Set signal default action. */ - if ((flags & POSIX_SPAWN_SETSIGDEF) != 0) - { - /* We have to iterate over all signals. This could possibly be - done better but it requires system specific solutions since - the sigset_t data type can be very different on different - architectures. */ - int sig; - struct sigaction sa; - - memset (&sa, '\0', sizeof (sa)); - sa.sa_handler = SIG_DFL; - - for (sig = 1; sig <= NSIG; ++sig) - if (sigismember (&attrp->_sd, sig) != 0 - && sigaction (sig, &sa, NULL) != 0) - _exit (SPAWN_ERROR); - - } - -#if (_LIBC ? defined _POSIX_PRIORITY_SCHEDULING : HAVE_SCHED_SETPARAM && HAVE_SCHED_SETSCHEDULER) - /* Set the scheduling algorithm and parameters. */ - if ((flags & (POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER)) - == POSIX_SPAWN_SETSCHEDPARAM) - { - if (sched_setparam (0, &attrp->_sp) == -1) - _exit (SPAWN_ERROR); - } - else if ((flags & POSIX_SPAWN_SETSCHEDULER) != 0) - { - if (sched_setscheduler (0, attrp->_policy, - (flags & POSIX_SPAWN_SETSCHEDPARAM) != 0 - ? &attrp->_sp : NULL) == -1) - _exit (SPAWN_ERROR); - } -#endif - - /* Set the process group ID. */ - if ((flags & POSIX_SPAWN_SETPGROUP) != 0 - && setpgid (0, attrp->_pgrp) != 0) - _exit (SPAWN_ERROR); - - /* Set the effective user and group IDs. */ - if ((flags & POSIX_SPAWN_RESETIDS) != 0 - && (local_seteuid (getuid ()) != 0 - || local_setegid (getgid ()) != 0)) - _exit (SPAWN_ERROR); - - /* Execute the file actions. */ - if (file_actions != NULL) - { - int cnt; - - for (cnt = 0; cnt < file_actions->_used; ++cnt) - { - struct __spawn_action *action = &file_actions->_actions[cnt]; - - switch (action->tag) - { - case spawn_do_close: - if (close_not_cancel (action->action.close_action.fd) != 0) - /* Signal the error. */ - _exit (SPAWN_ERROR); - break; - - case spawn_do_open: - { - int new_fd = open_not_cancel (action->action.open_action.path, - action->action.open_action.oflag - | O_LARGEFILE, - action->action.open_action.mode); - - if (new_fd == -1) - /* The 'open' call failed. */ - _exit (SPAWN_ERROR); - - /* Make sure the desired file descriptor is used. */ - if (new_fd != action->action.open_action.fd) - { - if (dup2 (new_fd, action->action.open_action.fd) - != action->action.open_action.fd) - /* The 'dup2' call failed. */ - _exit (SPAWN_ERROR); - - if (close_not_cancel (new_fd) != 0) - /* The 'close' call failed. */ - _exit (SPAWN_ERROR); - } - } - break; - - case spawn_do_dup2: - if (dup2 (action->action.dup2_action.fd, - action->action.dup2_action.newfd) - != action->action.dup2_action.newfd) - /* The 'dup2' call failed. */ - _exit (SPAWN_ERROR); - break; - } - } - } - - if (! use_path || strchr (file, '/') != NULL) - { - /* The FILE parameter is actually a path. */ - execve (file, argv, envp); - - if (errno == ENOEXEC) - script_execute (file, argv, envp); - - /* Oh, oh. 'execve' returns. This is bad. */ - _exit (SPAWN_ERROR); - } - - /* We have to search for FILE on the path. */ - path = getenv ("PATH"); - if (path == NULL) - { -#if HAVE_CONFSTR - /* There is no 'PATH' in the environment. - The default search path is the current directory - followed by the path 'confstr' returns for '_CS_PATH'. */ - len = confstr (_CS_PATH, (char *) NULL, 0); - path = (char *) alloca (1 + len); - path[0] = ':'; - (void) confstr (_CS_PATH, path + 1, len); -#else - /* Pretend that the PATH contains only the current directory. */ - path = ""; -#endif - } - - len = strlen (file) + 1; - pathlen = strlen (path); - name = alloca (pathlen + len + 1); - /* Copy the file name at the top. */ - name = (char *) memcpy (name + pathlen + 1, file, len); - /* And add the slash. */ - *--name = '/'; - - p = path; - do - { - char *startp; - - path = p; - p = strchrnul (path, ':'); - - if (p == path) - /* Two adjacent colons, or a colon at the beginning or the end - of 'PATH' means to search the current directory. */ - startp = name + 1; - else - startp = (char *) memcpy (name - (p - path), path, p - path); - - /* Try to execute this name. If it works, execv will not return. */ - execve (startp, argv, envp); - - if (errno == ENOEXEC) - script_execute (startp, argv, envp); - - switch (errno) - { - case EACCES: - case ENOENT: - case ESTALE: - case ENOTDIR: - /* Those errors indicate the file is missing or not executable - by us, in which case we want to just try the next path - directory. */ - break; - - default: - /* Some other error means we found an executable file, but - something went wrong executing it; return the error to our - caller. */ - _exit (SPAWN_ERROR); - } - } - while (*p++ != '\0'); - - /* Return with an error. */ - _exit (SPAWN_ERROR); -} - -#endif diff --git a/contrib/tools/m4/lib/spawnp.c b/contrib/tools/m4/lib/spawnp.c deleted file mode 100644 index 8bc5f99aca..0000000000 --- a/contrib/tools/m4/lib/spawnp.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <spawn.h> - -#include "spawn_int.h" - -/* Spawn a new process executing FILE with the attributes describes in *ATTRP. - Before running the process perform the actions described in FILE-ACTIONS. */ -int -posix_spawnp (pid_t *pid, const char *file, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, char *const argv[], - char *const envp[]) -{ - return __spawni (pid, file, file_actions, attrp, argv, envp, 1); -} diff --git a/contrib/tools/m4/lib/stdio-impl.h b/contrib/tools/m4/lib/stdio-impl.h index e510bb8f42..2a5db74f28 100644 --- a/contrib/tools/m4/lib/stdio-impl.h +++ b/contrib/tools/m4/lib/stdio-impl.h @@ -1,5 +1,5 @@ /* Implementation details of FILE streams. - Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2008, 2010-2021 Free Software Foundation, Inc. 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 @@ -12,19 +12,23 @@ 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 <http://www.gnu.org/licenses/>. */ - -/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this - problem by defining it ourselves. FIXME: Do not rely on glibc - internals. */ -#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN -# define _IO_IN_BACKUP 0x100 -#endif + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Many stdio implementations have the same logic and therefore can share the same implementation of stdio extension API, except that some fields have different naming conventions, or their access requires some casts. */ +/* Glibc 2.28 made _IO_UNBUFFERED and _IO_IN_BACKUP private. For now, work + around this problem by defining them ourselves. FIXME: Do not rely on glibc + internals. */ +#if defined _IO_EOF_SEEN +# if !defined _IO_UNBUFFERED +# define _IO_UNBUFFERED 0x2 +# endif +# if !defined _IO_IN_BACKUP +# define _IO_IN_BACKUP 0x100 +# endif +#endif /* BSD stdio derived implementations. */ @@ -35,10 +39,11 @@ #include <errno.h> /* For detecting Plan9. */ -#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ +#if defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ # if defined __DragonFly__ /* DragonFly */ - /* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */ + /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/lib/libc/stdio/priv_stdio.h>. */ # define fp_ ((struct { struct __FILE_public pub; \ struct { unsigned char *_base; int _size; } _bf; \ void *cookie; \ @@ -55,30 +60,89 @@ fpos_t _offset; \ /* More fields, not relevant here. */ \ } *) fp) - /* See <http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */ + /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/include/stdio.h>. */ # define _p pub._p # define _flags pub._flags # define _r pub._r # define _w pub._w +# elif defined __ANDROID__ /* Android */ +# ifdef __LP64__ +# define _gl_flags_file_t int +# else +# define _gl_flags_file_t short +# endif + /* Up to this commit from 2015-10-12 + <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a> + the innards of FILE were public, and fp_ub could be defined like for OpenBSD, + see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h> + and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>. + After this commit, the innards of FILE are hidden. */ +# define fp_ ((struct { unsigned char *_p; \ + int _r; \ + int _w; \ + _gl_flags_file_t _flags; \ + _gl_flags_file_t _file; \ + struct { unsigned char *_base; size_t _size; } _bf; \ + int _lbfsize; \ + void *_cookie; \ + void *_close; \ + void *_read; \ + void *_seek; \ + void *_write; \ + struct { unsigned char *_base; size_t _size; } _ext; \ + unsigned char *_up; \ + int _ur; \ + unsigned char _ubuf[3]; \ + unsigned char _nbuf[1]; \ + struct { unsigned char *_base; size_t _size; } _lb; \ + int _blksize; \ + fpos_t _offset; \ + /* More fields, not relevant here. */ \ + } *) fp) # else # define fp_ fp # endif -# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __ANDROID__ /* NetBSD >= 1.5ZA, OpenBSD, Android */ +# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */ /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> - and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */ + and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> + and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */ struct __sfileext { struct __sbuf _ub; /* ungetc buffer */ /* More fields, not relevant here. */ }; # define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub +# elif defined __ANDROID__ /* Android */ + struct __sfileext + { + struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */ + /* More fields, not relevant here. */ + }; +# define fp_ub ((struct __sfileext *) fp_->_ext._base)->_ub # else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */ # define fp_ub fp_->_ub # endif # define HASUB(fp) (fp_ub._base != NULL) +# if defined __ANDROID__ /* Android */ + /* Needed after this commit from 2016-01-25 + <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */ +# ifndef __SEOF +# define __SLBF 1 +# define __SNBF 2 +# define __SRD 4 +# define __SWR 8 +# define __SRW 0x10 +# define __SEOF 0x20 +# define __SERR 0x40 +# endif +# ifndef __SOFF +# define __SOFF 0x1000 +# endif +# endif + #endif @@ -87,7 +151,7 @@ #ifdef __TANDEM /* NonStop Kernel */ # ifndef _IOERR /* These values were determined by the program 'stdioext-flags' at - <http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>. */ + <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */ # define _IOERR 0x40 # define _IOREAD 0x80 # define _IOWRT 0x4 @@ -105,15 +169,44 @@ int _file; \ unsigned int _flag; \ } *) fp) +# elif defined __VMS /* OpenVMS */ +# define fp_ ((struct _iobuf *) fp) # else # define fp_ fp # endif -# if defined _SCO_DS /* OpenServer */ +# if defined _SCO_DS || (defined __SCO_VERSION__ || defined __sysv5__) /* OpenServer 5, OpenServer 6, UnixWare 7 */ # define _cnt __cnt # define _ptr __ptr # define _base __base # define _flag __flag # endif +#elif defined _WIN32 && ! defined __CYGWIN__ /* newer Windows with MSVC */ + +/* <stdio.h> does not define the innards of FILE any more. */ +# define WINDOWS_OPAQUE_FILE + +struct _gl_real_FILE +{ + /* Note: Compared to older Windows and to mingw, it has the fields + _base and _cnt swapped. */ + unsigned char *_ptr; + unsigned char *_base; + int _cnt; + int _flag; + int _file; + int _charbuf; + int _bufsiz; +}; +# define fp_ ((struct _gl_real_FILE *) fp) + +/* These values were determined by a program similar to the one at + <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */ +# define _IOREAD 0x1 +# define _IOWRT 0x2 +# define _IORW 0x4 +# define _IOEOF 0x8 +# define _IOERR 0x10 + #endif diff --git a/contrib/tools/m4/lib/stdio-write.c b/contrib/tools/m4/lib/stdio-write.c deleted file mode 100644 index 68d54ce93e..0000000000 --- a/contrib/tools/m4/lib/stdio-write.c +++ /dev/null @@ -1,198 +0,0 @@ -/* POSIX compatible FILE stream write function. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2008. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <stdio.h> - -/* Replace these functions only if module 'nonblocking' or module 'sigpipe' is - requested. */ -#if GNULIB_NONBLOCKING || GNULIB_SIGPIPE - -/* On native Windows platforms, SIGPIPE does not exist. When write() is - called on a pipe with no readers, WriteFile() fails with error - GetLastError() = ERROR_NO_DATA, and write() in consequence fails with - error EINVAL. This write() function is at the basis of the function - which flushes the buffer of a FILE stream. */ - -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - -# include <errno.h> -# include <signal.h> -# include <io.h> - -# define WIN32_LEAN_AND_MEAN /* avoid including junk */ -# include <windows.h> - -# include "msvc-nothrow.h" - -# if GNULIB_NONBLOCKING -# define CLEAR_ERRNO \ - errno = 0; -# define HANDLE_ENOSPC \ - if (errno == ENOSPC && ferror (stream)) \ - { \ - int fd = fileno (stream); \ - if (fd >= 0) \ - { \ - HANDLE h = (HANDLE) _get_osfhandle (fd); \ - if (GetFileType (h) == FILE_TYPE_PIPE) \ - { \ - /* h is a pipe or socket. */ \ - DWORD state; \ - if (GetNamedPipeHandleState (h, &state, NULL, NULL, \ - NULL, NULL, 0) \ - && (state & PIPE_NOWAIT) != 0) \ - /* h is a pipe in non-blocking mode. \ - Change errno from ENOSPC to EAGAIN. */ \ - errno = EAGAIN; \ - } \ - } \ - } \ - else -# else -# define CLEAR_ERRNO -# define HANDLE_ENOSPC -# endif - -# if GNULIB_SIGPIPE -# define CLEAR_LastError \ - SetLastError (0); -# define HANDLE_ERROR_NO_DATA \ - if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \ - { \ - int fd = fileno (stream); \ - if (fd >= 0 \ - && GetFileType ((HANDLE) _get_osfhandle (fd)) \ - == FILE_TYPE_PIPE) \ - { \ - /* Try to raise signal SIGPIPE. */ \ - raise (SIGPIPE); \ - /* If it is currently blocked or ignored, change errno from \ - EINVAL to EPIPE. */ \ - errno = EPIPE; \ - } \ - } \ - else -# else -# define CLEAR_LastError -# define HANDLE_ERROR_NO_DATA -# endif - -# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \ - if (ferror (stream)) \ - return (EXPRESSION); \ - else \ - { \ - RETTYPE ret; \ - CLEAR_ERRNO \ - CLEAR_LastError \ - ret = (EXPRESSION); \ - if (FAILED) \ - { \ - HANDLE_ENOSPC \ - HANDLE_ERROR_NO_DATA \ - ; \ - } \ - return ret; \ - } - -# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ -int -printf (const char *format, ...) -{ - int retval; - va_list args; - - va_start (args, format); - retval = vfprintf (stdout, format, args); - va_end (args); - - return retval; -} -# endif - -# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */ -int -fprintf (FILE *stream, const char *format, ...) -{ - int retval; - va_list args; - - va_start (args, format); - retval = vfprintf (stream, format, args); - va_end (args); - - return retval; -} -# endif - -# if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */ -int -vprintf (const char *format, va_list args) -{ - return vfprintf (stdout, format, args); -} -# endif - -# if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */ -int -vfprintf (FILE *stream, const char *format, va_list args) -#undef vfprintf -{ - CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF) -} -# endif - -int -putchar (int c) -{ - return fputc (c, stdout); -} - -int -fputc (int c, FILE *stream) -#undef fputc -{ - CALL_WITH_SIGPIPE_EMULATION (int, fputc (c, stream), ret == EOF) -} - -int -fputs (const char *string, FILE *stream) -#undef fputs -{ - CALL_WITH_SIGPIPE_EMULATION (int, fputs (string, stream), ret == EOF) -} - -int -puts (const char *string) -#undef puts -{ - FILE *stream = stdout; - CALL_WITH_SIGPIPE_EMULATION (int, puts (string), ret == EOF) -} - -size_t -fwrite (const void *ptr, size_t s, size_t n, FILE *stream) -#undef fwrite -{ - CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n) -} - -# endif -#endif diff --git a/contrib/tools/m4/lib/strdup.c b/contrib/tools/m4/lib/strdup.c deleted file mode 100644 index 5826ab02af..0000000000 --- a/contrib/tools/m4/lib/strdup.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2013 Free Software - Foundation, Inc. - - This file is part of the GNU C Library. - - 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, 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 <http://www.gnu.org/licenses/>. */ - -#ifndef _LIBC -# include <config.h> -#endif - -/* Get specification. */ -#include <string.h> - -#include <stdlib.h> - -#undef __strdup -#ifdef _LIBC -# undef strdup -#endif - -#ifndef weak_alias -# define __strdup strdup -#endif - -/* Duplicate S, returning an identical malloc'd string. */ -char * -__strdup (const char *s) -{ - size_t len = strlen (s) + 1; - void *new = malloc (len); - - if (new == NULL) - return NULL; - - return (char *) memcpy (new, s, len); -} -#ifdef libc_hidden_def -libc_hidden_def (__strdup) -#endif -#ifdef weak_alias -weak_alias (__strdup, strdup) -#endif diff --git a/contrib/tools/m4/lib/platform/win64/unitypes.h b/contrib/tools/m4/lib/unitypes.h index 3d7db7510d..3d7db7510d 100644 --- a/contrib/tools/m4/lib/platform/win64/unitypes.h +++ b/contrib/tools/m4/lib/unitypes.h diff --git a/contrib/tools/m4/lib/platform/win64/uniwidth.h b/contrib/tools/m4/lib/uniwidth.h index 2ad29275a5..2ad29275a5 100644 --- a/contrib/tools/m4/lib/platform/win64/uniwidth.h +++ b/contrib/tools/m4/lib/uniwidth.h diff --git a/contrib/tools/m4/lib/platform/posix/unused-parameter.h b/contrib/tools/m4/lib/unused-parameter.h index 53474b5754..53474b5754 100644 --- a/contrib/tools/m4/lib/platform/posix/unused-parameter.h +++ b/contrib/tools/m4/lib/unused-parameter.h diff --git a/contrib/tools/m4/lib/wchar--.h b/contrib/tools/m4/lib/wchar--.h deleted file mode 100644 index 41751e00ac..0000000000 --- a/contrib/tools/m4/lib/wchar--.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include <wchar.h> - -#if defined(_WIN32) -int wcwidth(wchar_t c); -#endif diff --git a/contrib/tools/m4/lib/wcrtomb.c b/contrib/tools/m4/lib/wcrtomb.c deleted file mode 100644 index c3cda35803..0000000000 --- a/contrib/tools/m4/lib/wcrtomb.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Convert wide character to multibyte character. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2008. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <wchar.h> - -#include <errno.h> -#include <stdlib.h> - - -// wcrtomb is defined for msvs 2017 15.7 -#if _MSC_VER < 1914 -size_t -wcrtomb (char *s, wchar_t wc, mbstate_t *ps) -{ - /* This implementation of wcrtomb on top of wctomb() supports only - stateless encodings. ps must be in the initial state. */ - if (ps != NULL && !mbsinit (ps)) - { - errno = EINVAL; - return (size_t)(-1); - } - - if (s == NULL) - /* We know the NUL wide character corresponds to the NUL character. */ - return 1; - else - { - int ret = wctomb (s, wc); - - if (ret >= 0) - return ret; - else - { - errno = EILSEQ; - return (size_t)(-1); - } - } -} -#endif diff --git a/contrib/tools/m4/lib/wcwidth.c b/contrib/tools/m4/lib/wcwidth.c deleted file mode 100644 index 253fcaa656..0000000000 --- a/contrib/tools/m4/lib/wcwidth.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Determine the number of screen columns needed for a character. - Copyright (C) 2006-2007, 2010-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <wchar.h> - -/* Get iswprint. */ -#include <wctype.h> - -#include "localcharset.h" -#include "streq.h" -#include "uniwidth.h" - -int -wcwidth (wchar_t wc) -#undef wcwidth -{ - /* In UTF-8 locales, use a Unicode aware width function. */ - const char *encoding = locale_charset (); - if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0 ,0)) - { - /* We assume that in a UTF-8 locale, a wide character is the same as a - Unicode character. */ - return uc_width (wc, encoding); - } - else - { - /* Otherwise, fall back to the system's wcwidth function. */ -#if HAVE_WCWIDTH - return wcwidth (wc); -#else - return wc == 0 ? 0 : iswprint (wc) ? 1 : -1; -#endif - } -} diff --git a/contrib/tools/m4/lib/xconcat-filename.c b/contrib/tools/m4/lib/xconcat-filename.c deleted file mode 100644 index eb2f8a9fb1..0000000000 --- a/contrib/tools/m4/lib/xconcat-filename.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Construct a full filename from a directory and a relative filename. - Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. - - 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 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 <http://www.gnu.org/licenses/>. */ - -/* Written by Bruno Haible <haible@clisp.cons.org>. */ - -#include <config.h> - -/* Specification. */ -#include "concat-filename.h" - -#include "xalloc.h" - -/* Concatenate a directory filename, a relative filename and an optional - suffix. The directory may end with the directory separator. The second - argument may not start with the directory separator (it is relative). - Return a freshly allocated filename. */ -char * -xconcatenated_filename (const char *directory, const char *filename, - const char *suffix) -{ - char *result; - - result = concatenated_filename (directory, filename, suffix); - if (result == NULL) - xalloc_die (); - - return result; -} diff --git a/contrib/tools/m4/lib/xmemdup0.c b/contrib/tools/m4/lib/xmemdup0.c deleted file mode 100644 index c070fa6343..0000000000 --- a/contrib/tools/m4/lib/xmemdup0.c +++ /dev/null @@ -1,44 +0,0 @@ -/* xmemdup0.c -- copy a block of arbitrary bytes, plus a trailing NUL - - Copyright (C) 2008-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -#include "xmemdup0.h" -#include "xalloc.h" - -#include <string.h> - -/* Clone an arbitrary block of bytes P of size S, with error checking, - and include a terminating NUL byte. P is of type 'void const *', - to make it easier to use this with other mem* functions that return - 'void *', but since appending a NUL byte only makes sense on bytes, - the return type is 'char *'. - - The terminating NUL makes it safe to use strlen or rawmemchr to - check for embedded NUL; it also speeds up algorithms such as escape - sequence processing on arbitrary memory, by making it always safe - to read the byte after the escape character rather than having to - check if each escape character is the last byte in the object. */ - -char * -xmemdup0 (void const *p, size_t s) -{ - char *result = xcharalloc (s + 1); - memcpy (result, p, s); - result[s] = 0; - return result; -} diff --git a/contrib/tools/m4/lib/xmemdup0.h b/contrib/tools/m4/lib/xmemdup0.h deleted file mode 100644 index 9ec827107a..0000000000 --- a/contrib/tools/m4/lib/xmemdup0.h +++ /dev/null @@ -1,41 +0,0 @@ -/* xmemdup0.h -- copy a block of arbitrary bytes, plus a trailing NUL - - Copyright (C) 2008-2013 Free Software Foundation, Inc. - - 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 <http://www.gnu.org/licenses/>. */ - -#ifndef XMEMDUP_H_ -# define XMEMDUP_H_ - -# include <stddef.h> - - -# ifdef __cplusplus -extern "C" { -# endif - -/* This function is always triggered when memory is exhausted. - It must be defined by the application, either explicitly - or by using gnulib's xalloc-die module. This is the - function to call when one wants the program to die because of a - memory allocation failure. */ -extern _Noreturn void xalloc_die (void); - -char *xmemdup0 (void const *p, size_t s); - -# ifdef __cplusplus -} -# endif - -#endif /* !XMEMDUP0_H_ */ diff --git a/contrib/tools/m4/lib/ya.make b/contrib/tools/m4/lib/ya.make index 21b3b59c56..4304d890d5 100644 --- a/contrib/tools/m4/lib/ya.make +++ b/contrib/tools/m4/lib/ya.make @@ -24,10 +24,6 @@ IF (OS_WINDOWS) ADDINCL( GLOBAL contrib/tools/m4/lib/platform/win64 ) -ELSE() - ADDINCL( - GLOBAL contrib/tools/m4/lib/platform/posix - ) ENDIF() IF (OS_DARWIN) @@ -55,7 +51,6 @@ SRCS( c-stack.c c-strcasecmp.c c-strncasecmp.c - calloc.c clean-temp.c cloexec.c close-stream.c @@ -80,15 +75,11 @@ SRCS( fflush.c filenamecat-lgpl.c filenamecat.c - float.c fopen-safer.c fpurge.c freading.c fstat.c - get-errno.c getdtablesize.c - getopt.c - getopt1.c gl_avltree_oset.c gl_linkedhash_list.c gl_list.c @@ -97,16 +88,12 @@ SRCS( gl_xoset.c hash.c isnand.c - isnanf.c isnanl.c - itold.c + isnanf.c localcharset.c lseek.c - lstat.c - malloc.c malloca.c mbrtowc.c - mbswidth.c memchr2.c mkstemp-safer.c nl_langinfo.c @@ -119,21 +106,14 @@ SRCS( progname.c quotearg.c raise.c - rawmemchr.c - readlink.c realloc.c regex.c - rename.c rmdir.c secure_getenv.c sig-handler.c - signbitd.c - signbitf.c - signbitl.c spawn-pipe.c stat.c stpcpy.c - strdup.c stripslash.c tempname.c tmpdir.c @@ -147,10 +127,8 @@ SRCS( wctype-h.c xalloc-die.c xasprintf.c - xconcat-filename.c xmalloc.c xmalloca.c - xmemdup0.c xprintf.c xsize.c xstrndup.c @@ -160,8 +138,6 @@ SRCS( IF (NOT MUSL) SRCS( freadahead.c - fseterr.c - # fseek.c ) ENDIF() @@ -171,24 +147,14 @@ IF (NOT OS_LINUX) ) ENDIF() -IF (NOT OS_WINDOWS) - SRCS( - stdio-write.c - ) -ENDIF() - IF (OS_WINDOWS) SRCS( - frexp.c - wcrtomb.c - perror.c - mkstemp.c vasprintf.c strsignal.c mkdtemp.c fseeko.c - fopen.c - ftello.c + getopt.c + getopt1.c gettimeofday.c localeconv.c msvc-inval.c @@ -196,20 +162,7 @@ IF (OS_WINDOWS) open.c sigaction.c sigprocmask.c - snprintf.c - spawn_faction_addclose.c - spawn_faction_adddup2.c - spawn_faction_addopen.c - spawn_faction_destroy.c - spawn_faction_init.c - spawnattr_destroy.c - spawnattr_init.c - spawnattr_setflags.c - spawnattr_setsigmask.c - spawni.c - spawnp.c waitpid.c - wcwidth.c uniwidth/width.c ) ENDIF() diff --git a/contrib/tools/python3/Include/README.rst b/contrib/tools/python3/Include/README.rst new file mode 100644 index 0000000000..531f09692f --- /dev/null +++ b/contrib/tools/python3/Include/README.rst @@ -0,0 +1,14 @@ +The Python C API +================ + +The C API is divided into these sections: + +1. ``Include/``: Limited API +2. ``Include/cpython/``: CPython implementation details +3. ``Include/cpython/``, names with the ``PyUnstable_`` prefix: API that can + change between minor releases +4. ``Include/internal/``, and any name with ``_`` prefix: The internal API + +Information on changing the C API is available `in the developer guide`_ + +.. _in the developer guide: https://devguide.python.org/c-api/ diff --git a/contrib/tools/python3/Objects/stringlib/README.txt b/contrib/tools/python3/Objects/stringlib/README.txt new file mode 100644 index 0000000000..e1e329290a --- /dev/null +++ b/contrib/tools/python3/Objects/stringlib/README.txt @@ -0,0 +1,40 @@ +bits shared by the bytesobject and unicodeobject implementations (and +possibly other modules, in a not too distant future). + +the stuff in here is included into relevant places; see the individual +source files for details. + +-------------------------------------------------------------------- +the following defines used by the different modules: + +STRINGLIB_CHAR + + the type used to hold a character (char or Py_UNICODE) + +STRINGLIB_GET_EMPTY() + + returns a PyObject representing the empty string, only to be used if + STRINGLIB_MUTABLE is 0. It must not be NULL. + +Py_ssize_t STRINGLIB_LEN(PyObject*) + + returns the length of the given string object (which must be of the + right type) + +PyObject* STRINGLIB_NEW(STRINGLIB_CHAR*, Py_ssize_t) + + creates a new string object + +STRINGLIB_CHAR* STRINGLIB_STR(PyObject*) + + returns the pointer to the character data for the given string + object (which must be of the right type) + +int STRINGLIB_CHECK_EXACT(PyObject *) + + returns true if the object is an instance of our type, not a subclass + +STRINGLIB_MUTABLE + + must be 0 or 1 to tell the cpp macros in stringlib code if the object + being operated on is mutable or not diff --git a/contrib/tools/python3/Programs/README b/contrib/tools/python3/Programs/README new file mode 100644 index 0000000000..c24578bc08 --- /dev/null +++ b/contrib/tools/python3/Programs/README @@ -0,0 +1 @@ +Source files for binary executables (as opposed to shared modules) diff --git a/library/cpp/tld/tlds-alpha-by-domain.txt b/library/cpp/tld/tlds-alpha-by-domain.txt index 21df2a6307..4b8b40363b 100644 --- a/library/cpp/tld/tlds-alpha-by-domain.txt +++ b/library/cpp/tld/tlds-alpha-by-domain.txt @@ -1,4 +1,4 @@ -# Version 2024093002, Last Updated Tue Oct 1 07:07:01 2024 UTC +# Version 2024100400, Last Updated Fri Oct 4 07:07:01 2024 UTC AAA AARP ABB diff --git a/library/python/symbols/libc/syms.cpp b/library/python/symbols/libc/syms.cpp index 6c04a7ef6e..56a89ecfbd 100644 --- a/library/python/symbols/libc/syms.cpp +++ b/library/python/symbols/libc/syms.cpp @@ -138,6 +138,8 @@ SYM(inotify_init) SYM(inotify_add_watch) SYM(inotify_rm_watch) SYM(mlockall) +SYM(malloc) +SYM(free) #endif #if defined(_darwin_) diff --git a/util/generic/string.h b/util/generic/string.h index 5fe507200d..b73c73e625 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -325,14 +325,36 @@ public: return reverse_iterator(begin()); } - using TBase::begin; //!< const_iterator TStringBase::begin() const - using TBase::cbegin; //!< const_iterator TStringBase::cbegin() const - using TBase::cend; //!< const_iterator TStringBase::cend() const - using TBase::crbegin; //!< const_reverse_iterator TStringBase::crbegin() const - using TBase::crend; //!< const_reverse_iterator TStringBase::crend() const - using TBase::end; //!< const_iterator TStringBase::end() const - using TBase::rbegin; //!< const_reverse_iterator TStringBase::rbegin() const - using TBase::rend; //!< const_reverse_iterator TStringBase::rend() const + const_iterator begin() const noexcept Y_LIFETIME_BOUND { + return TBase::begin(); + } + const_iterator cbegin() const noexcept Y_LIFETIME_BOUND { + return TBase::cbegin(); + } + + const_iterator cend() const noexcept Y_LIFETIME_BOUND { + return TBase::cend(); + } + + const_reverse_iterator crbegin() const noexcept Y_LIFETIME_BOUND { + return TBase::crbegin(); + } + + const_reverse_iterator crend() const noexcept Y_LIFETIME_BOUND { + return TBase::crend(); + } + + const_iterator end() const noexcept Y_LIFETIME_BOUND { + return TBase::end(); + } + + const_reverse_iterator rbegin() const noexcept Y_LIFETIME_BOUND { + return TBase::rbegin(); + } + + const_reverse_iterator rend() const noexcept Y_LIFETIME_BOUND { + return TBase::rend(); + } inline size_t capacity() const noexcept { #ifdef TSTRING_IS_STD_STRING @@ -39,33 +39,33 @@ REGISTRY_ENDPOINT = os.environ.get("YA_REGISTRY_ENDPOINT", "https://devtools-reg PLATFORM_MAP = { "data": { "darwin": { - "md5": "b9a6b9b51583d6e8e8e3430b5889b936", + "md5": "05d5993f3773b34ad0d0fa2920e11823", "urls": [ - f"{REGISTRY_ENDPOINT}/7203792711" + f"{REGISTRY_ENDPOINT}/7214841619" ] }, "darwin-arm64": { - "md5": "157d04aa112f24b5b5deecf22fdf2408", + "md5": "a6011d41fcb2b51518690d344069c5f9", "urls": [ - f"{REGISTRY_ENDPOINT}/7203791602" + f"{REGISTRY_ENDPOINT}/7214841335" ] }, "linux-aarch64": { - "md5": "dac91d702f5cb1d51b8590f58cb5fae3", + "md5": "78d25222fa5107948c84b20c5d725896", "urls": [ - f"{REGISTRY_ENDPOINT}/7203790464" + f"{REGISTRY_ENDPOINT}/7214841001" ] }, "win32-clang-cl": { - "md5": "39dcf1a1ccd79baeead3f64644008615", + "md5": "d97df327b5cc5189e04197bf702694e7", "urls": [ - f"{REGISTRY_ENDPOINT}/7203794121" + f"{REGISTRY_ENDPOINT}/7214842090" ] }, "linux": { - "md5": "1ce6223b1da674d6a72b0309caa5c0df", + "md5": "4778605f0a783b6c46e162a59f4e5a62", "urls": [ - f"{REGISTRY_ENDPOINT}/7203795248" + f"{REGISTRY_ENDPOINT}/7214842433" ] } } diff --git a/yt/yt/core/net/address.cpp b/yt/yt/core/net/address.cpp index 40107c3278..c08fb94226 100644 --- a/yt/yt/core/net/address.cpp +++ b/yt/yt/core/net/address.cpp @@ -709,6 +709,13 @@ bool TIP6Address::FromString(TStringBuf str, TIP6Address* address) return true; } +bool TIP6Address::IsMtn() const +{ + static const auto BackboneNetwork = TIP6Network::FromString("2a02:6b8:c00::/40"); + static const auto FastboneNetwork = TIP6Network::FromString("2a02:6b8:fc00::/40"); + return BackboneNetwork.Contains(*this) || FastboneNetwork.Contains(*this); +} + void FormatValue(TStringBuilderBase* builder, const TIP6Address& address, TStringBuf /*spec*/) { const auto* parts = reinterpret_cast<const ui16*>(address.GetRawBytes()); @@ -1187,7 +1194,7 @@ TMtnAddress& TMtnAddress::SetHost(ui64 host) return *this; } -const TIP6Address& TMtnAddress::ToIP6Address() const +TIP6Address TMtnAddress::ToIP6Address() const { return Address_; } diff --git a/yt/yt/core/net/address.h b/yt/yt/core/net/address.h index 6f77b1b65f..6f507b2900 100644 --- a/yt/yt/core/net/address.h +++ b/yt/yt/core/net/address.h @@ -123,6 +123,8 @@ public: const ui32* GetRawDWords() const; ui32* GetRawDWords(); + bool IsMtn() const; + private: std::array<ui8, ByteSize> Raw_ = {}; }; @@ -226,7 +228,6 @@ class TMtnAddress { public: TMtnAddress() = default; - TMtnAddress(TIP6Address address); ui64 GetPrefix() const; @@ -241,11 +242,10 @@ public: ui64 GetHost() const; TMtnAddress& SetHost(ui64 host); - const TIP6Address& ToIP6Address() const; + TIP6Address ToIP6Address() const; private: ui64 GetBytesRangeValue(int leftIndex, int rightIndex) const; - void SetBytesRangeValue(int leftIndex, int rightIndex, ui64 value); static constexpr int HostOffsetInBytes = 0; diff --git a/yt/yt/core/net/unittests/network_address_ut.cpp b/yt/yt/core/net/unittests/network_address_ut.cpp index 0c2e463516..10ae29d1f1 100644 --- a/yt/yt/core/net/unittests/network_address_ut.cpp +++ b/yt/yt/core/net/unittests/network_address_ut.cpp @@ -325,7 +325,16 @@ TEST(TIP6AddressTest, ToStringFromStringRandom) } } -TEST(TMtnAddressTest, SimpleTest) +TEST(TIP6AddressTest, IsMtn) +{ + EXPECT_TRUE(TIP6Address::FromString("2a02:6b8:c23:130:0:4397:571f:0").IsMtn()); + EXPECT_TRUE(TIP6Address::FromString("2a02:6b8:fc00:c21b:0:4397:ead:0").IsMtn()); + EXPECT_FALSE(TIP6Address::FromString("fe80::5054:ff:fe12:3456").IsMtn()); +} + +//////////////////////////////////////////////////////////////////////////////// + +TEST(TMtnAddressTest, Simple) { TMtnAddress address(TIP6Address::FromString("1361:24ad:4326:bda1:8432:a3fe:3f6c:4b38")); EXPECT_EQ(address.GetPrefix(), 0x136124ad43u); @@ -353,7 +362,7 @@ TEST(TMtnAddressTest, SimpleTest) //////////////////////////////////////////////////////////////////////////////// -TEST(InferYPCluster, ValidFqdns) +TEST(TInferYPClusterTest, ValidFqdns) { TString gencfgHostName = "sas1-5535-9d7.sas-test.yp.gencfg-c.yandex.net"; TString ypHostName = "noqpmfiudzbb4hvs.man.yp-c.yandex.net"; @@ -362,7 +371,7 @@ TEST(InferYPCluster, ValidFqdns) EXPECT_EQ(InferYPClusterFromHostName(ypHostName), "man"); } -TEST(InferYPCluster, InvalidFqdn) +TEST(TInferYPClusterTest, InvalidFqdn) { TString hostName = "noqpmfiudzbb4hvs..yp-c.yandex.net"; @@ -372,9 +381,7 @@ TEST(InferYPCluster, InvalidFqdn) EXPECT_EQ(InferYPClusterFromHostName("yandex.net"), std::nullopt); } -//////////////////////////////////////////////////////////////////////////////// - -TEST(InferYTCluster, ClusterUrls) +TEST(TInferYPClusterTest, ClusterUrls) { EXPECT_EQ(InferYTClusterFromClusterUrl("hume"), "hume"); EXPECT_EQ(InferYTClusterFromClusterUrl("http://yp-sas.yt.yandex.net"), "yp-sas"); diff --git a/yt/yt/core/rpc/response_keeper.cpp b/yt/yt/core/rpc/response_keeper.cpp index 2ebb194ab9..2e1891bea4 100644 --- a/yt/yt/core/rpc/response_keeper.cpp +++ b/yt/yt/core/rpc/response_keeper.cpp @@ -4,7 +4,6 @@ #include "helpers.h" #include "service.h" -#include <atomic> #include <yt/yt/core/concurrency/thread_affinity.h> #include <yt/yt/core/concurrency/periodic_executor.h> @@ -241,9 +240,7 @@ public: const auto& responseMessage = responseMessageOrError.Value(); - NProto::TResponseHeader header; - YT_VERIFY(TryParseResponseHeader(responseMessage, &header)); - bool remember = FromProto<NRpc::EErrorCode>(header.error().code()) != NRpc::EErrorCode::Unavailable; + auto remember = ValidateHeaderAndParseRememberOption(responseMessage); if (auto setResponseKeeperPromise = EndRequest(mutationId, responseMessage, remember)) { setResponseKeeperPromise(); @@ -313,20 +310,16 @@ private: auto pendingIt = PendingResponses_.find(id); if (pendingIt != PendingResponses_.end()) { - if (!isRetry) { - THROW_ERROR_EXCEPTION("Duplicate request is not marked as \"retry\"") - << TErrorAttribute("mutation_id", id); - } + ValidateRetry(id, isRetry); + YT_LOG_DEBUG("Replying with pending response (MutationId: %v)", id); return pendingIt->second; } auto finishedIt = FinishedResponses_.find(id); if (finishedIt != FinishedResponses_.end()) { - if (!isRetry) { - THROW_ERROR_EXCEPTION("Duplicate request is not marked as \"retry\"") - << TErrorAttribute("mutation_id", id); - } + ValidateRetry(id, isRetry); + YT_LOG_DEBUG("Replying with finished response (MutationId: %v)", id); return MakeFuture(finishedIt->second); } @@ -383,6 +376,23 @@ private: //////////////////////////////////////////////////////////////////////////////// +bool ValidateHeaderAndParseRememberOption(const TSharedRefArray& responseMessage) +{ + NProto::TResponseHeader header; + YT_VERIFY(TryParseResponseHeader(responseMessage, &header)); + return FromProto<EErrorCode>(header.error().code()) != EErrorCode::Unavailable; +} + +void ValidateRetry(TMutationId mutationId, bool isRetry) +{ + if (!isRetry) { + THROW_ERROR_EXCEPTION("Duplicate request is not marked as \"retry\"") + << TErrorAttribute("mutation_id", mutationId); + } +} + +//////////////////////////////////////////////////////////////////////////////// + IResponseKeeperPtr CreateResponseKeeper( TResponseKeeperConfigPtr config, IInvokerPtr invoker, diff --git a/yt/yt/core/rpc/response_keeper.h b/yt/yt/core/rpc/response_keeper.h index 70b15a89f5..9a4edbc262 100644 --- a/yt/yt/core/rpc/response_keeper.h +++ b/yt/yt/core/rpc/response_keeper.h @@ -106,6 +106,12 @@ DEFINE_REFCOUNTED_TYPE(IResponseKeeper) //////////////////////////////////////////////////////////////////////////////// +bool ValidateHeaderAndParseRememberOption(const TSharedRefArray& responseMessage); + +void ValidateRetry(TMutationId mutationId, bool isRetry); + +//////////////////////////////////////////////////////////////////////////////// + IResponseKeeperPtr CreateResponseKeeper( TResponseKeeperConfigPtr config, IInvokerPtr invoker, diff --git a/yt/yt/core/rpc/service_detail.h b/yt/yt/core/rpc/service_detail.h index 02ce7ae78d..ab32bce755 100644 --- a/yt/yt/core/rpc/service_detail.h +++ b/yt/yt/core/rpc/service_detail.h @@ -295,7 +295,6 @@ public: return *Response_; } - using IServiceContext::Reply; void Reply() @@ -315,7 +314,6 @@ public: } } - const THandlerInvocationOptions& GetOptions() const { return Options_; diff --git a/yt/yt/library/process/process.cpp b/yt/yt/library/process/process.cpp index 498503d857..4d6680825b 100644 --- a/yt/yt/library/process/process.cpp +++ b/yt/yt/library/process/process.cpp @@ -720,6 +720,10 @@ IConnectionWriterPtr TSimpleProcess::GetStdInWriter() TFuture<void> TProcessBase::Spawn() { + auto finally = Finally([&] { + CleanUpParent(); + }); + try { // Resolve binary path. std::vector<TError> innerErrors; @@ -753,13 +757,6 @@ TFuture<void> TProcessBase::Spawn() void TSimpleProcess::DoSpawn() { #ifdef _unix_ - auto finally = Finally([&] { - StdPipes_[STDIN_FILENO].CloseReadFD(); - StdPipes_[STDOUT_FILENO].CloseWriteFD(); - StdPipes_[STDERR_FILENO].CloseWriteFD(); - PipeFactory_.Clear(); - }); - YT_VERIFY(ProcessId_ == InvalidProcessId && !Finished_); // Make sure no spawn action closes Pipe_.WriteFD @@ -811,6 +808,14 @@ void TSimpleProcess::DoSpawn() #endif } +void TSimpleProcess::CleanUpParent() +{ + StdPipes_[STDIN_FILENO].CloseReadFD(); + StdPipes_[STDOUT_FILENO].CloseWriteFD(); + StdPipes_[STDERR_FILENO].CloseWriteFD(); + PipeFactory_.Clear(); +} + void TSimpleProcess::PrepareErrorPipe() { #if defined(YT_USE_POSIX_SPAWN_API) diff --git a/yt/yt/library/process/process.h b/yt/yt/library/process/process.h index e642515092..b88defec45 100644 --- a/yt/yt/library/process/process.h +++ b/yt/yt/library/process/process.h @@ -73,6 +73,8 @@ protected: virtual void DoSpawn() = 0; const char* Capture(TStringBuf arg); + virtual void CleanUpParent() = 0; + private: void SpawnChild(); void ValidateSpawnResult(); @@ -128,6 +130,8 @@ private: void AsyncPeriodicTryWait(); void ValidateSpawnResult(); + + void CleanUpParent() override; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/library/process/unittests/subprocess_ut.cpp b/yt/yt/library/process/unittests/subprocess_ut.cpp index 32120a89a6..ff7cf7aa08 100644 --- a/yt/yt/library/process/unittests/subprocess_ut.cpp +++ b/yt/yt/library/process/unittests/subprocess_ut.cpp @@ -26,7 +26,6 @@ TEST(TSubprocessTest, Basic) EXPECT_TRUE(result.Status.IsOK()); } - TEST(TSubprocessTest, PipeOutput) { TSubprocess subprocess("/bin/echo"); @@ -74,7 +73,6 @@ TEST(TSubprocessTest, PipeBigOutput) EXPECT_TRUE(result); } - TEST(TSubprocessTest, PipeBigError) { auto queue = New<TActionQueue>(); @@ -93,6 +91,18 @@ TEST(TSubprocessTest, PipeBigError) EXPECT_EQ(6*100000, std::ssize(result.Error)); } +TEST(TSubprocessTest, BinaryNotFound) +{ + auto queue = New<TActionQueue>(); + + auto result = BIND([] { + TSubprocess subprocess("does-not-exist"); + return subprocess.Execute(); + }).AsyncVia(queue->GetInvoker()).Run().Get().Value(); + + EXPECT_FALSE(result.Status.IsOK()); +} + #endif //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/library/profiling/histogram_snapshot.h b/yt/yt/library/profiling/histogram_snapshot.h index 8fd0296942..0724c9f8d6 100644 --- a/yt/yt/library/profiling/histogram_snapshot.h +++ b/yt/yt/library/profiling/histogram_snapshot.h @@ -11,7 +11,7 @@ namespace NYT::NProfiling { struct THistogramSnapshot { // When Values.size() == Bounds.size() + 1, Values.back() stores "Inf" bucket. - std::vector<int> Values; + std::vector<i64> Values; std::vector<double> Bounds; THistogramSnapshot& operator += (const THistogramSnapshot& other); diff --git a/yt/yt/library/profiling/solomon/cube.cpp b/yt/yt/library/profiling/solomon/cube.cpp index 2dc4d93438..93b54496b2 100644 --- a/yt/yt/library/profiling/solomon/cube.cpp +++ b/yt/yt/library/profiling/solomon/cube.cpp @@ -514,7 +514,7 @@ int TCube<T>::ReadSensors( } for (size_t i = 0; i < n; ++i) { - int bucketValue = i < value.Values.size() ? value.Values[i] : 0u; + auto bucketValue = i < value.Values.size() ? value.Values[i] : 0u; (*hist)[i] = {value.Bounds[i], bucketValue / options.RateDenominator}; } @@ -525,7 +525,7 @@ int TCube<T>::ReadSensors( auto rollup = Rollup(*window, indices.back()); for (size_t i = 0; i < n; ++i) { - int bucketValue = i < rollup.Values.size() ? rollup.Values[i] : 0u; + auto bucketValue = i < rollup.Values.size() ? rollup.Values[i] : 0u; (*hist)[i] = {rollup.Bounds[i], bucketValue}; } @@ -549,7 +549,7 @@ int TCube<T>::ReadSensors( auto hist = NMonitoring::TExplicitHistogramSnapshot::New(n + 1); for (size_t i = 0; i < n; ++i) { - int bucketValue = i < value.Values.size() ? value.Values[i] : 0u; + auto bucketValue = i < value.Values.size() ? value.Values[i] : 0u; (*hist)[i] = {value.Bounds[i], bucketValue}; } @@ -576,7 +576,7 @@ int TCube<T>::ReadSensors( } for (size_t i = 0; i < n; ++i) { - int bucketValue = i < value.Values.size() ? value.Values[i] : 0u; + auto bucketValue = i < value.Values.size() ? value.Values[i] : 0u; (*hist)[i] = {value.Bounds[i], bucketValue / options.RateDenominator}; } @@ -669,11 +669,11 @@ int TCube<T>::ReadSensorValues( } ++valuesRead; } else if constexpr (std::is_same_v<T, TTimeHistogramSnapshot> || std::is_same_v<T, TGaugeHistogramSnapshot> || std::is_same_v<T, TRateHistogramSnapshot>) { - std::vector<std::pair<double, int>> hist; + std::vector<std::pair<double, i64>> hist; size_t n = value.Bounds.size(); hist.reserve(n + 1); for (size_t i = 0; i != n; ++i) { - int bucketValue = i < value.Values.size() ? value.Values[i] : 0; + auto bucketValue = i < value.Values.size() ? value.Values[i] : 0; hist.emplace_back(value.Bounds[i], bucketValue); } hist.emplace_back(Max<double>(), n < value.Values.size() ? value.Values[n] : 0u); diff --git a/yt/yt/library/profiling/solomon/sensor.h b/yt/yt/library/profiling/solomon/sensor.h index c81055ea14..391a9dbc59 100644 --- a/yt/yt/library/profiling/solomon/sensor.h +++ b/yt/yt/library/profiling/solomon/sensor.h @@ -121,7 +121,7 @@ public: private: std::vector<double> Bounds_; - std::vector<std::atomic<int>> Buckets_; + std::vector<std::atomic<i64>> Buckets_; // These two methods are not used. TSummarySnapshot<TDuration> GetSummary() override; diff --git a/yt/yt/library/profiling/unittests/solomon_ut.cpp b/yt/yt/library/profiling/unittests/solomon_ut.cpp index 62b871646a..c26d478234 100644 --- a/yt/yt/library/profiling/unittests/solomon_ut.cpp +++ b/yt/yt/library/profiling/unittests/solomon_ut.cpp @@ -371,6 +371,22 @@ TEST(TSolomonRegistry, SparseHistogram) CollectSensors(impl, 3); } +TEST(TSolomonRegistry, HistogramWithBigCounterValues) +{ + auto impl = New<TSolomonRegistry>(); + TProfiler profiler(impl, "/d"); + + auto h0 = profiler.GaugeHistogram("/histogram", {1.0}); + + h0.Add(0, 2e9); + h0.Add(0, 2e9); + + auto result = h0.GetSnapshot().Values; + + ASSERT_FALSE(result.empty()); + ASSERT_EQ(result.front(), 4e9); +} + TEST(TSolomonRegistry, SparseCounters) { auto impl = New<TSolomonRegistry>(); |