mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Merge pull request #2787 from lubinszARM:pr_race_time
PiperOrigin-RevId: 315734425
This commit is contained in:
@@ -12,12 +12,15 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "funcdata.h"
|
||||
#include "textflag.h"
|
||||
|
||||
// Documentation is available in parameters.go.
|
||||
//
|
||||
// func muldiv64(value, multiplier, divisor uint64) (uint64, bool)
|
||||
TEXT ·muldiv64(SB),NOSPLIT,$40-33
|
||||
GO_ARGS
|
||||
NO_LOCAL_POINTERS
|
||||
MOVD value+0(FP), R0
|
||||
MOVD multiplier+8(FP), R1
|
||||
MOVD divisor+16(FP), R2
|
||||
|
||||
@@ -484,3 +484,18 @@ func TestMulDivOverflow(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkMuldiv64(b *testing.B) {
|
||||
var v uint64 = math.MaxUint64
|
||||
for i := uint64(1); i <= 1000000; i++ {
|
||||
mult := uint64(1000000000)
|
||||
div := i * mult
|
||||
res, ok := muldiv64(v, mult, div)
|
||||
if !ok {
|
||||
b.Errorf("Result of %v * %v / %v ok got false want true", v, mult, div)
|
||||
}
|
||||
if want := v / i; res != want {
|
||||
b.Errorf("Bad result of %v * %v / %v: got %v, want %v", v, mult, div, res, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user