gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

rawhelpers.go (1273B)


      1 // Copyright The OpenTelemetry Authors
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 package internal // import "go.opentelemetry.io/otel/internal"
     16 
     17 import (
     18 	"math"
     19 	"unsafe"
     20 )
     21 
     22 func BoolToRaw(b bool) uint64 { // nolint:revive  // b is not a control flag.
     23 	if b {
     24 		return 1
     25 	}
     26 	return 0
     27 }
     28 
     29 func RawToBool(r uint64) bool {
     30 	return r != 0
     31 }
     32 
     33 func Int64ToRaw(i int64) uint64 {
     34 	return uint64(i)
     35 }
     36 
     37 func RawToInt64(r uint64) int64 {
     38 	return int64(r)
     39 }
     40 
     41 func Float64ToRaw(f float64) uint64 {
     42 	return math.Float64bits(f)
     43 }
     44 
     45 func RawToFloat64(r uint64) float64 {
     46 	return math.Float64frombits(r)
     47 }
     48 
     49 func RawPtrToFloat64Ptr(r *uint64) *float64 {
     50 	return (*float64)(unsafe.Pointer(r))
     51 }
     52 
     53 func RawPtrToInt64Ptr(r *uint64) *int64 {
     54 	return (*int64)(unsafe.Pointer(r))
     55 }