mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-25 06:12:47 -06:00
Improved POSIX compatibility (OpenBSD, NetBSD support)
git-svn-id: svn://ultimatepp.org/upp/trunk@1095 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
4f33d6f280
commit
107b0a4952
16 changed files with 70 additions and 29 deletions
|
|
@ -39,7 +39,7 @@ const char *procexepath_() {
|
|||
static char h[_MAX_PATH + 1];
|
||||
ONCELOCK {
|
||||
char link[100];
|
||||
#ifdef PLATFORM_FREEBSD
|
||||
#ifdef PLATFORM_BSD
|
||||
sprintf(link, "/proc/%d/file", getpid());
|
||||
#else
|
||||
sprintf(link, "/proc/%d/exe", getpid());
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ library(WIN32 !GUI !GNU !GCC) "ole32 oleaut32 oldnames";
|
|||
|
||||
library(LINUX) "pthread dl";
|
||||
|
||||
library(FREEBSD) pthread;
|
||||
library(BSD) pthread;
|
||||
|
||||
library(WIN32 !MSC8ARM) "advapi32 shell32 winmm mpr";
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,9 @@ bool CpuSSE2() { sCheckCPU(); return sHasSSE2; }
|
|||
bool CpuSSE3() { sCheckCPU(); return sHasSSE3; }
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
#ifdef PLATFORM_FREEBSD
|
||||
#include <unistd.h>
|
||||
#ifdef PLATFORM_BSD
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#else
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
|
@ -81,7 +82,14 @@ int CPU_Cores()
|
|||
n += !!(sa & (1 << i));
|
||||
#endif
|
||||
#elif defined(PLATFORM_POSIX)
|
||||
#if defined(PLATFORM_FREEBSD) || defined(PLATFORM_SOLARIS)
|
||||
#ifdef PLATFORM_BSD
|
||||
int mib[2];
|
||||
size_t len = sizeof(n);
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_NCPU;
|
||||
sysctl(mib, 2, &n, &len, NULL, 0);
|
||||
n = minmax(n, 1, 256);
|
||||
#elif defined(PLATFORM_SOLARIS)
|
||||
n = minmax((int)sysconf(_SC_NPROCESSORS_ONLN), 1, 256);
|
||||
#else
|
||||
n = minmax(get_nprocs(), 1, 256);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ static void sLogFile(char *fn, const char *app = ".log")
|
|||
const char *q = strrchr(exe, '/');
|
||||
if(q)
|
||||
exe = q + 1;
|
||||
if(!exe)
|
||||
if(!*exe)
|
||||
exe = "upp";
|
||||
strcat(path, exe);
|
||||
mkdir(path, 0755);
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ SIGDEF(SIGFPE) SIGDEF(SIGKILL) SIGDEF(SIGSEGV) SIGDEF(SIGPIPE) SIGDEF(SIGALRM)
|
|||
SIGDEF(SIGPIPE) SIGDEF(SIGTERM) SIGDEF(SIGUSR1) SIGDEF(SIGUSR2) SIGDEF(SIGTRAP)
|
||||
SIGDEF(SIGURG) SIGDEF(SIGVTALRM) SIGDEF(SIGXCPU) SIGDEF(SIGXFSZ) SIGDEF(SIGIOT)
|
||||
SIGDEF(SIGIO) SIGDEF(SIGWINCH)
|
||||
#ifndef PLATFORM_FREEBSD
|
||||
#ifndef PLATFORM_BSD
|
||||
//SIGDEF(SIGCLD) SIGDEF(SIGPWR)
|
||||
#endif
|
||||
//SIGDEF(SIGSTKFLT) SIGDEF(SIGUNUSED) // not in Solaris, make conditional if needed
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ void Thread::Sleep(int msec)
|
|||
::Sleep(msec);
|
||||
#endif
|
||||
#ifdef PLATFORM_POSIX
|
||||
timespec tval;
|
||||
::timespec tval;
|
||||
tval.tv_sec = msec / 1000;
|
||||
tval.tv_nsec = (msec % 1000) * 1000000;
|
||||
nanosleep(&tval, NULL);
|
||||
|
|
|
|||
|
|
@ -1331,7 +1331,7 @@ bool FileMapping::Map(int64 mapoffset, dword maplen)
|
|||
(dword)(rawoffset >> 32), (dword)(rawoffset >> 0), rawsize);
|
||||
#else
|
||||
rawbase = (byte *)mmap(0, rawsize, PROT_READ | PROT_WRITE,
|
||||
#ifdef PLATFORM_FREEBSD
|
||||
#ifdef PLATFORM_BSD
|
||||
MAP_NOSYNC,
|
||||
#else
|
||||
MAP_SHARED,
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ char *PermanentCopy(const char *s)
|
|||
#ifndef PLATFORM_WIN32
|
||||
void Sleep(int msec)
|
||||
{
|
||||
timespec tval;
|
||||
::timespec tval;
|
||||
tval.tv_sec = msec / 1000;
|
||||
tval.tv_nsec = (msec % 1000) * 1000000;
|
||||
nanosleep(&tval, NULL);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#define PLATFORM_WIN32
|
||||
#endif
|
||||
|
||||
#if __unix
|
||||
#if __unix || __unix__
|
||||
#define PLATFORM_POSIX 1
|
||||
|
||||
#ifdef flagGUI
|
||||
|
|
@ -16,9 +16,23 @@
|
|||
|
||||
#if __linux
|
||||
#define PLATFORM_LINUX 1
|
||||
#else // ToDo
|
||||
#define PLATFORM_BSD 1
|
||||
#define PLATFORM_FREEBSD 1
|
||||
#else
|
||||
#if __FreeBSD__ || __OpenBSD__ || __NetBSD__
|
||||
#define PLATFORM_BSD 1
|
||||
#if __FreeBSD__
|
||||
#define PLATFORM_BSD 1
|
||||
#endif
|
||||
#if __OpenBSD__
|
||||
#define PLATFORM_OPENBSD 1
|
||||
#endif
|
||||
#if __NetBSD__
|
||||
#define PLATFORM_NETBSD 1
|
||||
#endif
|
||||
#elif __sun
|
||||
#define PLATFORM_SOLARIS 1
|
||||
#else
|
||||
#error Unknown OS
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,7 @@ uses
|
|||
CtrlCore,
|
||||
RichText;
|
||||
|
||||
uses(LINUX) PdfDraw;
|
||||
|
||||
uses(FREEBSD) PdfDraw;
|
||||
|
||||
uses(OSX11) PdfDraw;
|
||||
uses(POSIX) PdfDraw;
|
||||
|
||||
file
|
||||
CtrlLib.h,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "CtrlCore/init"
|
||||
#include "RichText/init"
|
||||
#include "PdfDraw/init"
|
||||
#define BLITZ_INDEX__ FC405953C5744B97C1D3FC16A15582A05
|
||||
#define BLITZ_INDEX__ F8AE2F5C10EDF2AF9715E3BDBF11A5948
|
||||
#include "CtrlLib.icpp"
|
||||
#undef BLITZ_INDEX__
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ acceptflags
|
|||
uses
|
||||
Core;
|
||||
|
||||
library((LINUX | FREEBSD) & !NOGTK) "gtk-x11-2.0 gdk-x11-2.0 atk-1.0 gdk_pixbuf-2.0 m pangocairo-1.0 fontconfig Xext Xrender Xinerama Xi Xrandr Xcursor Xfixes pango-1.0 cairo X11 gobject-2.0 gmodule-2.0 glib-2.0";
|
||||
library((LINUX | BSD) & !NOGTK) "gtk-x11-2.0 gdk-x11-2.0 atk-1.0 gdk_pixbuf-2.0 m pangocairo-1.0 fontconfig Xext Xrender Xinerama Xi Xrandr Xcursor Xfixes pango-1.0 cairo X11 gobject-2.0 gmodule-2.0 glib-2.0";
|
||||
|
||||
library(WIN32 !MSC8ARM) "user32 gdi32";
|
||||
|
||||
|
|
@ -16,9 +16,9 @@ library(LINUX) dl;
|
|||
|
||||
library(LINUX !XLFD) Xft;
|
||||
|
||||
library(FREEBSD) X11;
|
||||
library(BSD) X11;
|
||||
|
||||
library(FREEBSD !XLFD) "Xft fontconfig Xrender freetype expat";
|
||||
library(BSD !XLFD) "Xft fontconfig Xrender freetype expat";
|
||||
|
||||
library(LINUX !XLFD !SHARED) "fontconfig Xrender freetype expat";
|
||||
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ SIGDEF(SIGFPE) SIGDEF(SIGKILL) SIGDEF(SIGSEGV) SIGDEF(SIGPIPE) SIGDEF(SIGALRM)
|
|||
SIGDEF(SIGPIPE) SIGDEF(SIGTERM) SIGDEF(SIGUSR1) SIGDEF(SIGUSR2) SIGDEF(SIGTRAP)
|
||||
SIGDEF(SIGURG) SIGDEF(SIGVTALRM) SIGDEF(SIGXCPU) SIGDEF(SIGXFSZ) SIGDEF(SIGIOT)
|
||||
SIGDEF(SIGIO) SIGDEF(SIGWINCH)
|
||||
#ifndef PLATFORM_FREEBSD
|
||||
#ifndef PLATFORM_BSD
|
||||
//SIGDEF(SIGCLD) SIGDEF(SIGPWR)
|
||||
#endif
|
||||
//SIGDEF(SIGSTKFLT) SIGDEF(SIGUNUSED) // not in Solaris, make conditional if needed
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#undef __offsetof
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_FREEBSD
|
||||
#ifdef PLATFORM_BSD
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -289,13 +289,36 @@ void LocalHost::AddFlags(Index<String>& cfg)
|
|||
#if defined(PLATFORM_WIN32)
|
||||
cfg.Add("WIN32");
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_LINUX
|
||||
cfg.Add("LINUX");
|
||||
#elif defined(PLATFORM_FREEBSD)
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
cfg.Add("POSIX");
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_BSD
|
||||
cfg.Add("BSD");
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_BSD
|
||||
cfg.Add("FREEBSD");
|
||||
#elif defined(PLATFORM_SOLARIS)
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_OPENBSD
|
||||
cfg.Add("OPENBSD");
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_NETBSD
|
||||
cfg.Add("NETBSD");
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_SOLARIS
|
||||
cfg.Add("SOLARIS");
|
||||
#elif defined(PLATFORM_OSX11)
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_OSX11
|
||||
cfg.Add("OSX11");
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ BuildMethods::BuildMethods()
|
|||
remote_os.Add("WINCE");
|
||||
remote_os.Add("UNIX");
|
||||
remote_os.Add("SOLARIS");
|
||||
remote_os.Add("FREEBSD");
|
||||
remote_os.Add("BSD");
|
||||
method.AddCtrl("REMOTE_TRANSFER", remote_file_access);
|
||||
remote_file_access.Add("0", "direct (SAMBA)");
|
||||
remote_file_access.Add("1", "indirect (transfer)");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue