From aa9c6e7d304847c1e1ccdaa812310d2569fea3b0 Mon Sep 17 00:00:00 2001 From: olsner Date: Mon, 12 Jul 2004 22:05:49 +0000 Subject: [PATCH] Created a Unix sysdep/ folder, and implemented a unix debug_break function This was SVN commit r735. --- source/lib/sysdep/sysdep.cpp | 2 ++ source/lib/sysdep/sysdep.h | 6 ++++-- source/lib/sysdep/unix/unix.cpp | 12 ++++++++++++ source/lib/sysdep/unix/unix.h | 10 ++++++++++ source/lib/sysdep/{ => unix}/x.cpp | 14 ++++++++++++-- 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100755 source/lib/sysdep/unix/unix.cpp create mode 100755 source/lib/sysdep/unix/unix.h rename source/lib/sysdep/{ => unix}/x.cpp (84%) diff --git a/source/lib/sysdep/sysdep.cpp b/source/lib/sysdep/sysdep.cpp index 7115931a2d..aed9e4ff5d 100755 --- a/source/lib/sysdep/sysdep.cpp +++ b/source/lib/sysdep/sysdep.cpp @@ -49,6 +49,8 @@ void debug_break() win_debug_break(); # elif defined(_M_IX86) ia32_debug_break(); +# elif defined(OS_UNIX) + unix_debug_break(); # else # error "port" # endif diff --git a/source/lib/sysdep/sysdep.h b/source/lib/sysdep/sysdep.h index 30bf840286..c6ae4f75f1 100755 --- a/source/lib/sysdep/sysdep.h +++ b/source/lib/sysdep/sysdep.h @@ -1,13 +1,15 @@ #ifndef SYSDEP_H__ #define SYSDEP_H__ +#include "config.h" + #ifdef _WIN32 #include "win/win.h" #include "win/wdbg.h" +#elif defined(OS_UNIX) +#include "unix/unix.h" #endif -#include "config.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/source/lib/sysdep/unix/unix.cpp b/source/lib/sysdep/unix/unix.cpp new file mode 100755 index 0000000000..cd8c7bca12 --- /dev/null +++ b/source/lib/sysdep/unix/unix.cpp @@ -0,0 +1,12 @@ +#include "precompiled.h" + +#include "sysdep/sysdep.h" + +#include +#include +#include + +void unix_debug_break() +{ + kill(getpid(), SIGTRAP); +} diff --git a/source/lib/sysdep/unix/unix.h b/source/lib/sysdep/unix/unix.h new file mode 100755 index 0000000000..4f9f202683 --- /dev/null +++ b/source/lib/sysdep/unix/unix.h @@ -0,0 +1,10 @@ +#ifndef _sysdep_unix_H +#define _sysdep_unix_H + +/* +This implementation raises the SIGTRAP signal which should be caught by your +debugger +*/ +extern void unix_debug_break(); + +#endif diff --git a/source/lib/sysdep/x.cpp b/source/lib/sysdep/unix/x.cpp similarity index 84% rename from source/lib/sysdep/x.cpp rename to source/lib/sysdep/unix/x.cpp index 76250451f0..0bfd3f6365 100755 --- a/source/lib/sysdep/x.cpp +++ b/source/lib/sysdep/unix/x.cpp @@ -36,7 +36,7 @@ int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq) if(yres) *yres = XDisplayHeight(disp, screen); if(bpp) - *bpp = 0; + *bpp = XDefaultDepth(disp, screen); if(freq) *freq = 0; XCloseDisplay(disp); @@ -48,7 +48,17 @@ int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq) // if we fail, outputs are unchanged (assumed initialized to defaults) int get_monitor_size(int& width_mm, int& height_mm) { - return -1; + Display* disp = XOpenDisplay(0); + if(!disp) + return -1; + + int screen = XDefaultScreen(disp); + + width_mm=XDisplayWidthMM(disp, screen); + height_mm=XDisplayHeightMM(disp, screen); + + XCloseDisplay(disp); + return 0; }