github.com/iDigitalFlame/xmt@v0.5.4/device/local/z_arch_nix.go (about)

     1  //go:build !windows && !js && !plan9 && (386 || arm)
     2  // +build !windows
     3  // +build !js
     4  // +build !plan9
     5  // +build 386 arm
     6  
     7  // Copyright (C) 2020 - 2023 iDigitalFlame
     8  //
     9  // This program is free software: you can redistribute it and/or modify
    10  // it under the terms of the GNU General Public License as published by
    11  // the Free Software Foundation, either version 3 of the License, or
    12  // any later version.
    13  //
    14  // This program is distributed in the hope that it will be useful,
    15  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  // GNU General Public License for more details.
    18  //
    19  // You should have received a copy of the GNU General Public License
    20  // along with this program.  If not, see <https://www.gnu.org/licenses/>.
    21  //
    22  
    23  package local
    24  
    25  import (
    26  	"github.com/iDigitalFlame/xmt/device"
    27  	"github.com/iDigitalFlame/xmt/device/arch"
    28  	"github.com/iDigitalFlame/xmt/device/unix"
    29  )
    30  
    31  func systemType() uint8 {
    32  	if arch.Current != arch.ARM && arch.Current != arch.X86 {
    33  		return uint8(uint8(device.OS)<<4 | uint8(arch.Current))
    34  	}
    35  	// NOTE(dij): Check if we're running under a 64bit kernel and report the /actual/
    36  	//            system arch, since we only know what we've been built as.
    37  	switch {
    38  	case !unix.IsMachine64():
    39  	case arch.Current == arch.ARM:
    40  		return uint8(uint8(device.OS)<<4 | uint8(arch.ARMOnARM64))
    41  	case arch.Current == arch.X86:
    42  		return uint8(uint8(device.OS)<<4 | uint8(arch.X86OnX64))
    43  	}
    44  	return uint8(uint8(device.OS)<<4 | uint8(arch.Current))
    45  }