Fixes of mimalloc warnings (#3765)

This commit is contained in:
LepilkinaElena
2020-01-21 14:15:18 +03:00
committed by GitHub
parent 6bca6d05c6
commit 9e558ca32c
4 changed files with 21 additions and 10 deletions
@@ -70,7 +70,7 @@ open class CommonInteropArguments(val argParser: ArgParser) {
class CInteropArguments(argParser: ArgParser = class CInteropArguments(argParser: ArgParser =
ArgParser("cinterop", ArgParser("cinterop",
prefixStyle = ArgParser.OPTION_PREFIX_STYLE.JVM)): CommonInteropArguments(argParser) { prefixStyle = ArgParser.OptionPrefixStyle.JVM)): CommonInteropArguments(argParser) {
val target by argParser.option(ArgType.String, description = "native target to compile to").default("host") val target by argParser.option(ArgType.String, description = "native target to compile to").default("host")
val def by argParser.option(ArgType.String, description = "the library definition file") val def by argParser.option(ArgType.String, description = "the library definition file")
val header by argParser.option(ArgType.String, description = "header file to produce kotlin bindings for") val header by argParser.option(ArgType.String, description = "header file to produce kotlin bindings for")
@@ -99,7 +99,7 @@ class CInteropArguments(argParser: ArgParser =
} }
class JSInteropArguments(argParser: ArgParser = ArgParser("jsinterop", class JSInteropArguments(argParser: ArgParser = ArgParser("jsinterop",
prefixStyle = ArgParser.OPTION_PREFIX_STYLE.JVM)): CommonInteropArguments(argParser) { prefixStyle = ArgParser.OptionPrefixStyle.JVM)): CommonInteropArguments(argParser) {
val target by argParser.option(ArgType.Choice(listOf("wasm32")), val target by argParser.option(ArgType.Choice(listOf("wasm32")),
description = "wasm target to compile to").default("wasm32") description = "wasm target to compile to").default("wasm32")
} }
@@ -65,7 +65,7 @@ open class CompileToBitcode @Inject constructor(@InputDirectory val srcRoot: Fil
Language.C -> Triple("clang", Language.C -> Triple("clang",
// Used flags provided by original build of allocator C code. // Used flags provided by original build of allocator C code.
commonFlags + listOf("-std=gnu11", "-O3", "-Wall", "-Wextra", "-Wno-unknown-pragmas", commonFlags + listOf("-std=gnu11", "-O3", "-Wall", "-Wextra", "-Wno-unknown-pragmas",
"-ftls-model=initial-exec"), "-Werror", "-ftls-model=initial-exec", "-Wno-unused-function"),
listOf("**/*.c")) listOf("**/*.c"))
Language.CPP -> Triple("clang++", Language.CPP -> Triple("clang++",
commonFlags + listOfNotNull("-std=c++14", "-Werror", "-O2", commonFlags + listOfNotNull("-std=c++14", "-Werror", "-O2",
@@ -163,12 +163,23 @@ bool _mi_page_is_valid(mi_page_t* page);
static inline bool mi_mul_overflow(size_t count, size_t size, size_t* total) { static inline bool mi_mul_overflow(size_t count, size_t size, size_t* total) {
#if __has_builtin(__builtin_umul_overflow) || __GNUC__ >= 5 #if __has_builtin(__builtin_umul_overflow) || __GNUC__ >= 5
#include <limits.h> // UINT_MAX, ULONG_MAX #include <limits.h> // UINT_MAX, ULONG_MAX
#if (SIZE_MAX == UINT_MAX) // Changed order for armv7 (ULONG_MAX == UINT_MAX, but size_t = unsigned long)
return __builtin_umul_overflow(count, size, total); #if defined(__MACH__) && KONAN_MI_MALLOC
#elif (SIZE_MAX == ULONG_MAX) #if (SIZE_MAX == ULONG_MAX)
return __builtin_umull_overflow(count, size, total); return __builtin_umull_overflow(count, size, total);
#elif (SIZE_MAX == UINT_MAX)
return __builtin_umul_overflow(count, size, total);
#else
return __builtin_umulll_overflow(count, size, total);
#endif
#else #else
return __builtin_umulll_overflow(count, size, total); #if (SIZE_MAX == UINT_MAX)
return __builtin_umul_overflow(count, size, total);
#elif (SIZE_MAX == ULONG_MAX)
return __builtin_umull_overflow(count, size, total);
#else
return __builtin_umulll_overflow(count, size, total);
#endif
#endif #endif
#else /* __builtin_umul_overflow is unavailable */ #else /* __builtin_umul_overflow is unavailable */
*total = count * size; *total = count * size;
@@ -471,7 +482,7 @@ static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
#if KONAN_MI_MALLOC #if KONAN_MI_MALLOC
#include <TargetConditionals.h> #include <TargetConditionals.h>
#if TARGET_OS_EMBEDDED // iOS/tvOS/watchOS devices. #if TARGET_OS_EMBEDDED // iOS/tvOS/watchOS devices.
tid = pthread_self(); tid = pthread_mach_thread_np(pthread_self());
#else #else
__asm__("movq %%gs:0, %0" : "=r" (tid) : : ); // x86_64 macOS uses GS __asm__("movq %%gs:0, %0" : "=r" (tid) : : ); // x86_64 macOS uses GS
#endif #endif
@@ -11,7 +11,7 @@ import java.util.concurrent.*
import kotlinx.cli.* import kotlinx.cli.*
fun generatePlatformLibraries(args: Array<String>) { fun generatePlatformLibraries(args: Array<String>) {
val argParser = ArgParser("generate-platform", prefixStyle = ArgParser.OPTION_PREFIX_STYLE.JVM) val argParser = ArgParser("generate-platform", prefixStyle = ArgParser.OptionPrefixStyle.JVM)
val inputDirectoryPath by argParser.option( val inputDirectoryPath by argParser.option(
ArgType.String, "input-directory", "i", "Input directory").required() ArgType.String, "input-directory", "i", "Input directory").required()
val outputDirectoryPath by argParser.option( val outputDirectoryPath by argParser.option(