mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-23 22:52:34 +01:00
byuu says: Lots of changes this time around. FreeBSD stability and compilation is still a work in progress. FreeBSD 10 + Clang 3.3 = 108fps FreeBSD 10 + GCC 4.7 = 130fps Errata 1: I've been fighting that god-damned endian.h header for the past nine WIPs now. The above WIP isn't building now because FreeBSD isn't including headers before using certain types, and you end up with a trillion error messages. So just delete all the endian.h includes from nall/intrinsics.hpp to build. Errata 2: I was trying to match g++ and g++47, so I used $(findstring g++,$(compiler)), which ends up also matching clang++. Oops. Easy fix, put Clang first and then else if g++ next. Not ideal, but oh well. All it's doing for now is declaring -fwrapv twice, so you don't have to fix it just yet. Probably just going to alias g++="g++47" and do exact matching instead. Errata 3: both OpenGL::term and VideoGLX::term are causing a core dump on BSD. No idea why. The resources are initialized and valid, but releasing them crashes the application. Changelog: - nall/Makefile is more flexible with overriding $(compiler), so you can build with GCC or Clang on BSD (defaults to GCC now) - PLATFORM_X was renamed to PLATFORM_XORG, and it's also declared with PLATFORM_LINUX or PLATFORM_BSD - PLATFORM_XORG probably isn't the best name ... still thinking about what best to call LINUX|BSD|SOLARIS or ^(WINDOWS|MACOSX) - fixed a few legitimate Clang warning messages in nall - Compiler::VisualCPP is ugly as hell, renamed to Compiler::CL - nall/platform includes nall/intrinsics first. Trying to move away from testing for _WIN32, etc directly in all files. Work in progress. - nall turns off Clang warnings that I won't "fix", because they aren't broken. It's much less noisy to compile with warnings on now. - phoenix gains the ability to set background and foreground colors on various text container widgets (GTK only for now.) - rewrote a lot of the MSU1 code to try and simplify it. Really hope I didn't break anything ... I don't have any MSU1 test ROMs handy - SNES coprocessor audio is now mixed as sclamp<16>(system_sample + coprocessor_sample) instead of sclamp<16>((sys + cop) / 2) - allows for greater chance of aliasing (still low, SNES audio is quiet), but doesn't cut base system volume in half anymore - fixed Super Scope and Justifier cursor colors - use input.xlib instead of input.x ... allows Xlib input driver to be visible on Linux and BSD once again - make install and make uninstall must be run as root again; no longer using install but cp instead for BSD compatibility - killed $(DESTDIR) ... use make prefix=$DESTDIR$prefix instead - you can now set text/background colors for the loki console via (eg): - settings.terminal.background-color 0x000000 - settings.terminal.foreground-color 0xffffff
82 lines
2.4 KiB
C++
82 lines
2.4 KiB
C++
#ifndef NALL_PLATFORM_HPP
|
|
#define NALL_PLATFORM_HPP
|
|
|
|
#include <nall/intrinsics.hpp>
|
|
|
|
namespace Math {
|
|
static const long double e = 2.71828182845904523536;
|
|
static const long double Pi = 3.14159265358979323846;
|
|
}
|
|
|
|
#if defined(PLATFORM_WINDOWS)
|
|
//minimum version needed for _wstat64, etc
|
|
#undef __MSVCRT_VERSION__
|
|
#define __MSVCRT_VERSION__ 0x0601
|
|
#include <nall/windows/utf8.hpp>
|
|
#endif
|
|
|
|
#include <limits>
|
|
#include <utility>
|
|
|
|
#include <assert.h>
|
|
#include <errno.h>
|
|
#include <limits.h>
|
|
#include <math.h>
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
|
|
#if defined(PLATFORM_WINDOWS)
|
|
#include <io.h>
|
|
#include <direct.h>
|
|
#include <shlobj.h>
|
|
#include <wchar.h>
|
|
#undef interface
|
|
#define dllexport __declspec(dllexport)
|
|
#else
|
|
#include <dlfcn.h>
|
|
#include <unistd.h>
|
|
#include <pwd.h>
|
|
#define dllexport
|
|
#endif
|
|
|
|
#if defined(COMPILER_CL)
|
|
#define va_copy(dest, src) ((dest) = (src))
|
|
#endif
|
|
|
|
#if defined(PLATFORM_WINDOWS)
|
|
__declspec(dllimport) int _fileno(FILE*);
|
|
|
|
inline int access(const char* path, int amode) { return _waccess(nall::utf16_t(path), amode); }
|
|
inline int fileno(FILE* stream) { return _fileno(stream); }
|
|
inline char* getcwd(char* buf, size_t size) { wchar_t wpath[PATH_MAX] = L""; if(!_wgetcwd(wpath, size)) return nullptr; strcpy(buf, nall::utf8_t(wpath)); return buf; }
|
|
inline int putenv(char* string) { return _wputenv(nall::utf16_t(string)); }
|
|
inline char* realpath(const char* file_name, char* resolved_name) { wchar_t wfile_name[PATH_MAX] = L""; if(!_wfullpath(wfile_name, nall::utf16_t(file_name), PATH_MAX)) return nullptr; strcpy(resolved_name, nall::utf8_t(wfile_name)); return resolved_name; }
|
|
inline int rename(const char* oldname, const char* newname) { return _wrename(nall::utf16_t(oldname), nall::utf16_t(newname)); }
|
|
inline void usleep(unsigned milliseconds) { Sleep(milliseconds / 1000); }
|
|
#endif
|
|
|
|
#if defined(COMPILER_CLANG) || defined(COMPILER_GCC)
|
|
#define neverinline __attribute__((noinline))
|
|
#define alwaysinline inline __attribute__((always_inline))
|
|
#elif defined(COMPILER_CL)
|
|
#define neverinline __declspec(noinline)
|
|
#define alwaysinline inline __forceinline
|
|
#else
|
|
#define neverinline
|
|
#define alwaysinline inline
|
|
#endif
|
|
|
|
#if defined(COMPILER_CLANG) || defined(COMPILER_GCC)
|
|
#define unreachable __builtin_unreachable()
|
|
#else
|
|
#define unreachable throw
|
|
#endif
|
|
|
|
#endif
|