|
108 | 108 | #include <3ds/services/cfgu.h> |
109 | 109 | #endif |
110 | 110 |
|
| 111 | +#if defined(WEBOS) |
| 112 | +#include <sys/stat.h> |
| 113 | +#endif |
| 114 | + |
111 | 115 | /* iOS/OSX specific. Lacks clock_gettime(), so implement it. */ |
112 | 116 | #ifdef __MACH__ |
113 | 117 | #include <sys/time.h> |
@@ -858,6 +862,69 @@ void cpu_features_get_model_name(char *s, int len) |
858 | 862 | } |
859 | 863 |
|
860 | 864 | filestream_close(fp); |
| 865 | + |
| 866 | +#if defined(WEBOS) |
| 867 | + struct stat st; |
| 868 | + if (stat("/usr/bin/lscpu", &st) == 0) |
| 869 | + { |
| 870 | + FILE *pipe = popen("/usr/bin/lscpu", "r"); |
| 871 | + if (pipe) |
| 872 | + { |
| 873 | + char buf[256]; |
| 874 | + while (fgets(buf, sizeof(buf), pipe)) |
| 875 | + { |
| 876 | + if (strncmp(buf, "Model name:", 11) == 0) |
| 877 | + { |
| 878 | + const char *p = strchr(buf, ':'); |
| 879 | + if (p) |
| 880 | + { |
| 881 | + p++; // skip ':' |
| 882 | + while (*p == ' ' || *p == '\t') p++; |
| 883 | + size_t len2 = strcspn(p, "\r\n"); |
| 884 | + |
| 885 | + char *tmp = (char *)malloc(len2 + 1); |
| 886 | + if (tmp) |
| 887 | + { |
| 888 | + memcpy(tmp, p, len2); |
| 889 | + tmp[len2] = '\0'; |
| 890 | + |
| 891 | + if (model_name && *model_name) |
| 892 | + { |
| 893 | + size_t oldlen = strlen(model_name); |
| 894 | + char *combined = (char *)malloc(oldlen + len2 + 4); |
| 895 | + if (combined) |
| 896 | + { |
| 897 | + memcpy(combined, model_name, oldlen); |
| 898 | + combined[oldlen] = ' '; |
| 899 | + combined[oldlen + 1] = '('; |
| 900 | + memcpy(combined + oldlen + 2, tmp, len2); |
| 901 | + combined[oldlen + 2 + len2] = ')'; |
| 902 | + combined[oldlen + 2 + len2 + 1] = '\0'; |
| 903 | + free(model_name); |
| 904 | + model_name = combined; |
| 905 | + } |
| 906 | + free(tmp); |
| 907 | + } |
| 908 | + else |
| 909 | + { |
| 910 | + free(model_name); |
| 911 | + model_name = tmp; |
| 912 | + } |
| 913 | + } |
| 914 | + } |
| 915 | + break; |
| 916 | + } |
| 917 | + } |
| 918 | + pclose(pipe); |
| 919 | + } |
| 920 | + |
| 921 | + if (model_name) |
| 922 | + { |
| 923 | + strncpy(s, model_name, len); |
| 924 | + s[len - 1] = '\0'; |
| 925 | + } |
| 926 | + } |
| 927 | +#endif |
861 | 928 | } |
862 | 929 | #endif |
863 | 930 | } |
0 commit comments