Skip to content

Commit 38dc5d8

Browse files
authored
Improved webOS CPU info and fix version number in IPK (#18381)
* Fix version parsing in Makefile.webos * webOS: add output of lscpu, as some boards will give less than helpful /proc/cpuinfo
1 parent c0be192 commit 38dc5d8

2 files changed

Lines changed: 70 additions & 3 deletions

File tree

Makefile.webos

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SDL2_PREBUILT_ARCHIVE ?= https://github.com/webosbrew/SDL-webOS/releases/downloa
2424
#########################
2525

2626
APP_PACKAGE_NAME ?= com.retroarch.webos
27-
PACKAGE_VERSION := $(patsubst "%",%,$(RARCH_VERSION))
27+
IPK_VERSION := $(shell grep '#define PACKAGE_VERSION' version.all | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/')
2828

2929
DEBUG ?= 0
3030

@@ -217,7 +217,7 @@ RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
217217
define APPINFO
218218
{
219219
"id": "$(APP_PACKAGE_NAME)",
220-
"version": "$(PACKAGE_VERSION)",
220+
"version": "$(IPK_VERSION)",
221221
"vendor": "webosbrew.org",
222222
"title": "RetroArch",
223223
"icon": "icon160.png",
@@ -313,7 +313,7 @@ endif
313313
cd webos && ares-package dist
314314

315315
install: ipk
316-
ares-install webos/$(APP_PACKAGE_NAME)_$(PACKAGE_VERSION)_$(ARCH).ipk
316+
ares-install webos/$(APP_PACKAGE_NAME)_$(IPK_VERSION)_$(ARCH).ipk
317317

318318
launch: install
319319
ares-launch $(APP_PACKAGE_NAME)

libretro-common/features/features_cpu.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
#include <3ds/services/cfgu.h>
109109
#endif
110110

111+
#if defined(WEBOS)
112+
#include <sys/stat.h>
113+
#endif
114+
111115
/* iOS/OSX specific. Lacks clock_gettime(), so implement it. */
112116
#ifdef __MACH__
113117
#include <sys/time.h>
@@ -858,6 +862,69 @@ void cpu_features_get_model_name(char *s, int len)
858862
}
859863

860864
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
861928
}
862929
#endif
863930
}

0 commit comments

Comments
 (0)