From 6d633a935232de1f4e19467ce331b6e5290a378e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 22 Nov 2010 13:24:45 +0000 Subject: [PATCH] Abstract process termination. --- base.py | 2 +- dl.py | 5 ++--- glx.py | 3 --- log.cpp | 5 +++++ log.hpp | 2 ++ os.hpp | 2 ++ os_posix.cpp | 8 ++++++++ os_win32.cpp | 7 +++++++ 8 files changed, 27 insertions(+), 7 deletions(-) diff --git a/base.py b/base.py index c7d18af..4afcb57 100644 --- a/base.py +++ b/base.py @@ -444,7 +444,7 @@ class Function: raise NotImplementedError def exit_impl(self): - print ' ExitProcess(0);' + print ' Log::Abort();' def fail_impl(self): if self.fail is not None: diff --git a/dl.py b/dl.py index 14b8b9f..acf328b 100644 --- a/dl.py +++ b/dl.py @@ -25,16 +25,15 @@ """dl""" + from base import * + class DllFunction(Function): def __init__(self, type, name, args, call = '', fail = None): Function.__init__(self, type, name, args, call=call, fail=fail) - def exit_impl(self): - print ' exit(0);' - def get_true_pointer(self): ptype = self.pointer_type() pvalue = self.pointer_value() diff --git a/glx.py b/glx.py index 99d07f4..79f39f2 100644 --- a/glx.py +++ b/glx.py @@ -477,9 +477,6 @@ class GlxFunction(Function): def __init__(self, type, name, args, call = '', fail = None): Function.__init__(self, type, name, args, call=call, fail=fail) - def exit_impl(self): - print ' exit(0);' - def get_true_pointer(self): ptype = self.pointer_type() pvalue = self.pointer_value() diff --git a/log.cpp b/log.cpp index 4762db9..ea306de 100644 --- a/log.cpp +++ b/log.cpp @@ -281,4 +281,9 @@ void LiteralOpaque(const void *addr) { WriteUInt((size_t)addr); } +void Abort(void) { + Close(); + OS::Abort(); +} + } /* namespace Log */ diff --git a/log.hpp b/log.hpp index c82de5d..33fe477 100644 --- a/log.hpp +++ b/log.hpp @@ -69,6 +69,8 @@ namespace Log { void LiteralNamedConstant(const char *name, long long value); void LiteralNull(void); void LiteralOpaque(const void *ptr); + + void Abort(void); } #endif /* _LOG_HPP_ */ diff --git a/os.hpp b/os.hpp index 8e1c295..3c24462 100644 --- a/os.hpp +++ b/os.hpp @@ -47,6 +47,8 @@ void ReleaseMutex(void); bool GetProcessName(char *str, size_t size); +void Abort(void); + } /* namespace OS */ #endif /* _OS_HPP_ */ diff --git a/os_posix.cpp b/os_posix.cpp index b13646f..a5be47d 100644 --- a/os_posix.cpp +++ b/os_posix.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include "os.hpp" @@ -76,4 +77,11 @@ GetProcessName(char *str, size_t size) } +void +Abort(void) +{ + exit(0); +} + + } /* namespace OS */ diff --git a/os_win32.cpp b/os_win32.cpp index 98e397b..04c0343 100755 --- a/os_win32.cpp +++ b/os_win32.cpp @@ -78,4 +78,11 @@ GetProcessName(char *str, size_t size) } +void +Abort(void) +{ + ExitProcess(0); +} + + } /* namespace OS */ -- 2.45.2