github.com/insolar/vanilla@v0.0.0-20201023172447-248fdf805322/unsafekit/memarch.go (about) 1 // Copyright 2020 Insolar Network Ltd. 2 // All rights reserved. 3 // This material is licensed under the Insolar License version 1.0, 4 // available at https://github.com/insolar/assured-ledger/blob/master/LICENSE.md. 5 6 package unsafekit 7 8 const PtrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const 9 10 type MemoryModelSupported uint8 11 12 const ( 13 _ MemoryModelSupported = iota 14 LittleEndianSupported 15 BigEndianSupported 16 EndianIndependent // LittleEndianSupported | BigEndianSupported 17 ) 18 19 func IsCompatibleMemoryModel(v MemoryModelSupported) bool { 20 switch v { 21 case EndianIndependent: 22 return true 23 case LittleEndianSupported: 24 return !BigEndian 25 case BigEndianSupported: 26 return BigEndian 27 default: 28 panic("illegal value") 29 } 30 }