| 862 | } |
| 863 | |
| 864 | bool AndroidPlatform::Init() |
| 865 | { |
| 866 | if (UnixPlatform::Init()) |
| 867 | return true; |
| 868 | |
| 869 | // Init timing |
| 870 | struct timespec ts; |
| 871 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) |
| 872 | { |
| 873 | ClockSource = CLOCK_REALTIME; |
| 874 | } |
| 875 | else |
| 876 | { |
| 877 | ClockSource = CLOCK_MONOTONIC; |
| 878 | } |
| 879 | |
| 880 | // Estimate program size by checking physical memory usage on start |
| 881 | ProgramSizeMemory = Platform::GetProcessMemoryStats().UsedPhysicalMemory; |
| 882 | |
| 883 | // Set info about the CPU |
| 884 | cpu_set_t cpus; |
| 885 | CPU_ZERO(&cpus); |
| 886 | if (sched_getaffinity(0, sizeof(cpus), &cpus) == 0) |
| 887 | { |
| 888 | AndroidCpu.ProcessorCoreCount = AndroidCpu.LogicalProcessorCount = CPU_COUNT(&cpus); |
| 889 | } |
| 890 | else |
| 891 | { |
| 892 | AndroidCpu.ProcessorCoreCount = AndroidCpu.LogicalProcessorCount = 1; |
| 893 | } |
| 894 | AndroidCpu.ProcessorPackageCount = 1; |
| 895 | AndroidCpu.L1CacheSize = 0; |
| 896 | AndroidCpu.L2CacheSize = 0; |
| 897 | AndroidCpu.L3CacheSize = 0; |
| 898 | AndroidCpu.PageSize = sysconf(_SC_PAGESIZE); |
| 899 | AndroidCpu.ClockSpeed = GetClockFrequency(); |
| 900 | AndroidCpu.CacheLineSize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); |
| 901 | if (!AndroidCpu.CacheLineSize) |
| 902 | { |
| 903 | AndroidCpu.CacheLineSize = PLATFORM_CACHE_LINE_SIZE; |
| 904 | } |
| 905 | |
| 906 | UnixGetMacAddress(MacAddress); |
| 907 | |
| 908 | // Generate unique device ID |
| 909 | { |
| 910 | DeviceId = Guid::Empty; |
| 911 | |
| 912 | // A - Computer Name and User Name |
| 913 | uint32 hash = GetHash(Platform::GetComputerName()); |
| 914 | CombineHash(hash, GetHash(Platform::GetUserName())); |
| 915 | DeviceId.A = hash; |
| 916 | |
| 917 | // B - MAC address |
| 918 | hash = MacAddress[0]; |
| 919 | for (uint32 i = 0; i < 6; i++) |
| 920 | CombineHash(hash, MacAddress[i]); |
| 921 | DeviceId.B = hash; |
nothing calls this directly
no test coverage detected