2021-08-09 07:19:24 +00:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2024-08-19 08:01:33 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2021-08-09 07:19:24 +00:00
|
|
|
|
2023-02-01 17:06:36 +00:00
|
|
|
package internal // import "go.opentelemetry.io/otel/internal"
|
2021-08-09 07:19:24 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2023-02-01 17:06:36 +00:00
|
|
|
func BoolToRaw(b bool) uint64 { // nolint:revive // b is not a control flag.
|
2021-08-09 07:19:24 +00:00
|
|
|
if b {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func RawToBool(r uint64) bool {
|
|
|
|
return r != 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func Int64ToRaw(i int64) uint64 {
|
|
|
|
return uint64(i)
|
|
|
|
}
|
|
|
|
|
|
|
|
func RawToInt64(r uint64) int64 {
|
|
|
|
return int64(r)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Float64ToRaw(f float64) uint64 {
|
|
|
|
return math.Float64bits(f)
|
|
|
|
}
|
|
|
|
|
|
|
|
func RawToFloat64(r uint64) float64 {
|
|
|
|
return math.Float64frombits(r)
|
|
|
|
}
|
|
|
|
|
|
|
|
func RawPtrToFloat64Ptr(r *uint64) *float64 {
|
|
|
|
return (*float64)(unsafe.Pointer(r))
|
|
|
|
}
|
|
|
|
|
|
|
|
func RawPtrToInt64Ptr(r *uint64) *int64 {
|
|
|
|
return (*int64)(unsafe.Pointer(r))
|
|
|
|
}
|