Update to 1.10.0-beta1

This commit is contained in:
dP
2019-10-31 22:24:28 +03:00
parent b84a475e14
commit 599ccf0c2b
1470 changed files with 354219 additions and 16795 deletions
+27 -104
View File
@@ -17,6 +17,7 @@
#include "../../debug.h"
#include "../../string_func.h"
#include "../../fios.h"
#include "../../thread.h"
#include <dirent.h>
@@ -43,39 +44,24 @@
#include <sys/sysctl.h>
#endif
#ifdef __MORPHOS__
#include <exec/types.h>
ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;)
/* The system supplied definition of SIG_IGN does not match */
#undef SIG_IGN
#define SIG_IGN (void (*)(int))1
#endif /* __MORPHOS__ */
#ifdef __AMIGA__
#warning add stack symbol to avoid that user needs to set stack manually (tokai)
// ULONG __stack =
#ifndef NO_THREADS
#include <pthread.h>
#endif
#if defined(__APPLE__)
#if defined(WITH_SDL)
# if defined(WITH_SDL)
/* the mac implementation needs this file included in the same file as main() */
#include <SDL.h>
#endif
# include <SDL.h>
# endif
# include "../macosx/macos.h"
#endif
#include "../../safeguards.h"
bool FiosIsRoot(const char *path)
{
#if !defined(__MORPHOS__) && !defined(__AMIGAOS__)
return path[1] == '\0';
#else
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
const char *s = strchr(path, ':');
return s != NULL && s[1] == '\0';
#endif
}
void FiosGetDrives(FileList &file_list)
@@ -98,7 +84,7 @@ bool FiosGetDiskFreeSpace(const char *path, uint64 *tot)
if (statvfs(path, &s) != 0) return false;
free = (uint64)s.f_frsize * s.f_bavail;
#endif
if (tot != NULL) *tot = free;
if (tot != nullptr) *tot = free;
return true;
}
@@ -106,15 +92,8 @@ bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb
{
char filename[MAX_PATH];
int res;
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
if (FiosIsRoot(path)) {
res = seprintf(filename, lastof(filename), "%s:%s", path, ent->d_name);
} else // XXX - only next line!
#else
assert(path[strlen(path) - 1] == PATHSEPCHAR);
if (strlen(path) > 2) assert(path[strlen(path) - 2] != PATHSEPCHAR);
#endif
res = seprintf(filename, lastof(filename), "%s%s", path, ent->d_name);
/* Could we fully concatenate the path and filename? */
@@ -151,9 +130,9 @@ static const char *GetLocalCode()
#else
/* Strip locale (eg en_US.UTF-8) to only have UTF-8 */
const char *locale = GetCurrentLocale("LC_CTYPE");
if (locale != NULL) locale = strchr(locale, '.');
if (locale != nullptr) locale = strchr(locale, '.');
return (locale == NULL) ? "" : locale + 1;
return (locale == nullptr) ? "" : locale + 1;
#endif
}
@@ -179,7 +158,7 @@ static const char *convert_tofrom_fs(iconv_t convd, const char *name)
strecpy(outbuf, name, outbuf + outlen);
iconv(convd, NULL, NULL, NULL, NULL);
iconv(convd, nullptr, nullptr, nullptr, nullptr);
if (iconv(convd, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1)) {
DEBUG(misc, 0, "[iconv] error converting '%s'. Errno %d", name, errno);
}
@@ -267,13 +246,13 @@ int CDECL main(int argc, char *argv[])
cocoaSetupAutoreleasePool();
/* This is passed if we are launched by double-clicking */
if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
argv[1] = NULL;
argv[1] = nullptr;
argc = 1;
}
#endif
CrashLog::InitialiseCrashLog();
SetRandomSeed(time(NULL));
SetRandomSeed(time(nullptr));
signal(SIGPIPE, SIG_IGN);
@@ -294,74 +273,7 @@ bool GetClipboardContents(char *buffer, const char *last)
#endif
/* multi os compatible sleep function */
#ifdef __AMIGA__
/* usleep() implementation */
# include <devices/timer.h>
# include <dos/dos.h>
extern struct Device *TimerBase = NULL;
extern struct MsgPort *TimerPort = NULL;
extern struct timerequest *TimerRequest = NULL;
#endif /* __AMIGA__ */
void CSleep(int milliseconds)
{
#if defined(__BEOS__)
snooze(milliseconds * 1000);
#elif defined(__AMIGA__)
{
ULONG signals;
ULONG TimerSigBit = 1 << TimerPort->mp_SigBit;
/* send IORequest */
TimerRequest->tr_node.io_Command = TR_ADDREQUEST;
TimerRequest->tr_time.tv_secs = (milliseconds * 1000) / 1000000;
TimerRequest->tr_time.tv_micro = (milliseconds * 1000) % 1000000;
SendIO((struct IORequest *)TimerRequest);
if (!((signals = Wait(TimerSigBit | SIGBREAKF_CTRL_C)) & TimerSigBit) ) {
AbortIO((struct IORequest *)TimerRequest);
}
WaitIO((struct IORequest *)TimerRequest);
}
#else
usleep(milliseconds * 1000);
#endif
}
#ifndef __APPLE__
uint GetCPUCoreCount()
{
uint count = 1;
#ifdef HAS_SYSCTL
int ncpu = 0;
size_t len = sizeof(ncpu);
#ifdef OPENBSD
int name[2];
name[0] = CTL_HW;
name[1] = HW_NCPU;
if (sysctl(name, 2, &ncpu, &len, NULL, 0) < 0) {
ncpu = 0;
}
#else
if (sysctlbyname("hw.availcpu", &ncpu, &len, NULL, 0) < 0) {
sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0);
}
#endif /* #ifdef OPENBSD */
if (ncpu > 0) count = ncpu;
#elif defined(_SC_NPROCESSORS_ONLN)
long res = sysconf(_SC_NPROCESSORS_ONLN);
if (res > 0) count = res;
#endif
return count;
}
void OSOpenBrowser(const char *url)
{
pid_t child_pid = fork();
@@ -370,9 +282,20 @@ void OSOpenBrowser(const char *url)
const char *args[3];
args[0] = "xdg-open";
args[1] = url;
args[2] = NULL;
args[2] = nullptr;
execvp(args[0], const_cast<char * const *>(args));
DEBUG(misc, 0, "Failed to open url: %s", url);
exit(0);
}
#endif
#endif /* __APPLE__ */
void SetCurrentThreadName(const char *threadName) {
#if !defined(NO_THREADS) && defined(__GLIBC__)
#if __GLIBC_PREREQ(2, 12)
if (threadName) pthread_setname_np(pthread_self(), threadName);
#endif /* __GLIBC_PREREQ(2, 12) */
#endif /* !defined(NO_THREADS) && defined(__GLIBC__) */
#if defined(__APPLE__)
MacOSSetThreadName(threadName);
#endif /* defined(__APPLE__) */
}