From 17d242429944858cfed0ae4bf1438d9667c089b2 Mon Sep 17 00:00:00 2001 From: SYC_ Date: Mon, 18 Sep 2023 07:40:43 +0000 Subject: [PATCH] feat: support go1.21 Change-Id: I2140c815e893f2f44684f73d8e8cdf46eeb773b1 --- .github/workflows/tests.yml | 13 ++++++- internal/monkey/common/runtime_above_1_21.go | 35 +++++++++++++++++++ .../{runtime.go => runtime_below_1_21.go} | 11 ++++-- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 internal/monkey/common/runtime_above_1_21.go rename internal/monkey/common/{runtime.go => runtime_below_1_21.go} (80%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9256248..2578f71 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,18 @@ jobs: unit-benchmark-test: strategy: matrix: - go: ["1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.20"] + go: + [ + "1.13", + "1.14", + "1.15", + "1.16", + "1.17", + "1.18", + "1.19", + "1.20", + "1.21", + ] os: [linux] # should be [ macOS, linux, windows ], but currently we don't have macOS and windows runners arch: [X64, ARM64] exclude: diff --git a/internal/monkey/common/runtime_above_1_21.go b/internal/monkey/common/runtime_above_1_21.go new file mode 100644 index 0000000..78a0278 --- /dev/null +++ b/internal/monkey/common/runtime_above_1_21.go @@ -0,0 +1,35 @@ +//go:build go1.21 +// +build go1.21 + +/* + * Copyright 2022 ByteDance Inc. + * + * 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. + */ + +package common + +import ( + _ "unsafe" +) + +func StopTheWorld() { + const stwForTestResetDebugLog = 16 + stopTheWorld(stwForTestResetDebugLog) +} + +//go:linkname stopTheWorld runtime.stopTheWorld +func stopTheWorld(reason uint8) + +//go:linkname StartTheWorld runtime.startTheWorld +func StartTheWorld() diff --git a/internal/monkey/common/runtime.go b/internal/monkey/common/runtime_below_1_21.go similarity index 80% rename from internal/monkey/common/runtime.go rename to internal/monkey/common/runtime_below_1_21.go index 6bfd145..fd6f2d7 100644 --- a/internal/monkey/common/runtime.go +++ b/internal/monkey/common/runtime_below_1_21.go @@ -1,3 +1,6 @@ +//go:build !go1.21 +// +build !go1.21 + /* * Copyright 2022 ByteDance Inc. * @@ -20,8 +23,12 @@ import ( _ "unsafe" ) -//go:linkname StopTheWorld runtime.stopTheWorld -func StopTheWorld() +func StopTheWorld() { + stopTheWorld("mockey") +} + +//go:linkname stopTheWorld runtime.stopTheWorld +func stopTheWorld(reason string) //go:linkname StartTheWorld runtime.startTheWorld func StartTheWorld()