Merge branch 'master' of https://github.com/86Box/86Box
This commit is contained in:
@@ -429,7 +429,7 @@ viso_fill_time(uint8_t *data, time_t time, int format, int longform)
|
||||
or way too far into 64-bit space (Linux). Fall back to epoch. */
|
||||
time_t epoch = 0;
|
||||
time_s = localtime(&epoch);
|
||||
if (!time_s)
|
||||
if (UNLIKELY(!time_s))
|
||||
fatal("VISO: localtime(0) = NULL\n");
|
||||
|
||||
/* Force year clamping if the timestamp is known to be outside the supported ranges. */
|
||||
@@ -636,12 +636,8 @@ pad_susp:
|
||||
break;
|
||||
}
|
||||
|
||||
if ((p - data) > 255)
|
||||
#if (defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)
|
||||
fatal("VISO: Directory record overflow (%d) on entry %016" PRIX64 "\n", (uint32_t) (uintptr_t) (p - data), (uint64_t) (uintptr_t) entry);
|
||||
#else
|
||||
fatal("VISO: Directory record overflow (%d) on entry %08X\n", (uint32_t) (uintptr_t) (p - data), (uint32_t) (uintptr_t) entry);
|
||||
#endif
|
||||
if (UNLIKELY((p - data) > 255))
|
||||
fatal("VISO: Directory record overflow (%" PRIuPTR ") on entry %08" PRIXPTR "\n", (uintptr_t) (p - data), (uintptr_t) entry);
|
||||
|
||||
data[0] = p - data; /* length */
|
||||
return data[0];
|
||||
|
@@ -35,7 +35,7 @@
|
||||
}
|
||||
|
||||
#define CHECK_CURRENT_CARD() \
|
||||
if (1) { \
|
||||
do { \
|
||||
card = dev->first_card; \
|
||||
while (card) { \
|
||||
if (card->enable && (card->state == PNP_STATE_CONFIG)) \
|
||||
@@ -46,7 +46,7 @@
|
||||
isapnp_log("ISAPnP: No card in CONFIG state\n"); \
|
||||
break; \
|
||||
} \
|
||||
}
|
||||
} while (0);
|
||||
|
||||
static const uint8_t pnp_init_key[32] = { 0x6A, 0xB5, 0xDA, 0xED, 0xF6, 0xFB, 0x7D, 0xBE,
|
||||
0xDF, 0x6F, 0x37, 0x1B, 0x0D, 0x86, 0xC3, 0x61,
|
||||
|
@@ -1015,13 +1015,8 @@ e14:
|
||||
|
||||
/* Add our supported features to the end. */
|
||||
if (client->response_pos < (sizeof(client->response) - 1))
|
||||
#if (defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)
|
||||
client->response_pos += snprintf(&client->response[client->response_pos], sizeof(client->response) - client->response_pos,
|
||||
"PacketSize=%lX;swbreak+;hwbreak+;qXfer:features:read+", sizeof(client->packet) - 1);
|
||||
#else
|
||||
client->response_pos += snprintf(&client->response[client->response_pos], sizeof(client->response) - client->response_pos,
|
||||
"PacketSize=%X;swbreak+;hwbreak+;qXfer:features:read+", sizeof(client->packet) - 1);
|
||||
#endif
|
||||
"PacketSize=%X;swbreak+;hwbreak+;qXfer:features:read+", (int) (sizeof(client->packet) - 1));
|
||||
break;
|
||||
} else if (!strcmp(client->response, "Xfer")) {
|
||||
/* Read the transfer object. */
|
||||
|
@@ -137,6 +137,7 @@ extern void plat_vidapi_reload(void);
|
||||
extern void plat_vid_reload_options(void);
|
||||
extern uint32_t plat_language_code(char *langcode);
|
||||
extern void plat_language_code_r(uint32_t lcid, char *outbuf, int len);
|
||||
extern void plat_get_cpu_string(char *outbuf, uint8_t len);
|
||||
|
||||
/* Resource management. */
|
||||
extern void set_language(uint32_t id);
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QLocalSocket>
|
||||
#include <QTimer>
|
||||
#include <QProcess>
|
||||
|
||||
#include <QLibrary>
|
||||
#include <QElapsedTimer>
|
||||
@@ -660,3 +661,69 @@ plat_init_rom_paths()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
plat_get_cpu_string(char *outbuf, uint8_t len) {
|
||||
auto cpu_string = QString("Unknown");
|
||||
/* Write the default string now in case we have to exit early from an error */
|
||||
qstrncpy(outbuf, cpu_string.toUtf8().constData(), len);
|
||||
|
||||
#if defined(Q_OS_MACOS)
|
||||
auto *process = new QProcess(nullptr);
|
||||
QStringList arguments;
|
||||
QString program = "/usr/sbin/sysctl";
|
||||
arguments << "machdep.cpu.brand_string";
|
||||
process->start(program, arguments);
|
||||
if (!process->waitForStarted()) {
|
||||
return;
|
||||
}
|
||||
if (!process->waitForFinished()) {
|
||||
return;
|
||||
}
|
||||
QByteArray result = process->readAll();
|
||||
auto command_result = QString(result).split(": ").last();
|
||||
if(!command_result.isEmpty()) {
|
||||
cpu_string = command_result;
|
||||
}
|
||||
#elif defined(Q_OS_WINDOWS)
|
||||
const LPCSTR keyName = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
|
||||
const LPCSTR valueName = "ProcessorNameString";
|
||||
unsigned char buf[32768];
|
||||
DWORD bufSize;
|
||||
HKEY hKey;
|
||||
bufSize = 32768;
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyName, 0, 1, &hKey) == ERROR_SUCCESS) {
|
||||
if (RegQueryValueExA(hKey, valueName, NULL, NULL, buf, &bufSize) == ERROR_SUCCESS) {
|
||||
cpu_string = reinterpret_cast<const char*>(buf);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
auto cpuinfo = QString("/proc/cpuinfo");
|
||||
auto cpuinfo_fi = QFileInfo(cpuinfo);
|
||||
if(!cpuinfo_fi.isReadable()) {
|
||||
return;
|
||||
}
|
||||
QFile file(cpuinfo);
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream textStream(&file);
|
||||
while(true) {
|
||||
QString line = textStream.readLine();
|
||||
if (line.isNull()) {
|
||||
break;
|
||||
}
|
||||
if(line.contains(QRegExp("model name.*:"))) {
|
||||
auto list = line.split(": ");
|
||||
if(!list.last().isEmpty()) {
|
||||
cpu_string = list.last();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
qstrncpy(outbuf, cpu_string.toUtf8().constData(), len);
|
||||
|
||||
}
|
@@ -1309,6 +1309,12 @@ plat_language_code(char *langcode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
plat_get_cpu_string(char *outbuf, uint8_t len) {
|
||||
char cpu_string[] = "Unknown";
|
||||
strncpy(outbuf, cpu_string, len);
|
||||
}
|
||||
|
||||
/* Converts back the language code to LCID */
|
||||
void
|
||||
plat_language_code_r(uint32_t lcid, char *outbuf, int len)
|
||||
|
@@ -1250,6 +1250,12 @@ plat_language_code_r(uint32_t lcid, char *outbuf, int len)
|
||||
c16stombs(outbuf, buffer, len);
|
||||
}
|
||||
|
||||
void
|
||||
plat_get_cpu_string(char *outbuf, uint8_t len) {
|
||||
char cpu_string[] = "Unknown";
|
||||
strncpy(outbuf, cpu_string, len);
|
||||
}
|
||||
|
||||
void
|
||||
take_screenshot(void)
|
||||
{
|
||||
|
Reference in New Issue
Block a user