Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/sentencepiece.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaku Kudo <taku@google.com>2018-07-31 04:03:50 +0300
committerTaku Kudo <taku@google.com>2018-07-31 04:03:50 +0300
commitd6835b69a8980d0ea5f56252002a7297fcdc6346 (patch)
tree2dd20afecc836ed20e51e95a29230d3b67069c6f /src/error.cc
parent510ba80638268104811f89f6a8f702c4d6047a5f (diff)
Remove setjmp/longjmp
Diffstat (limited to 'src/error.cc')
-rw-r--r--src/error.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/error.cc b/src/error.cc
index 93baced..af1147d 100644
--- a/src/error.cc
+++ b/src/error.cc
@@ -18,8 +18,27 @@
namespace sentencepiece {
namespace error {
-jmp_buf gTestJmp;
-bool gTestMode = false;
+int gTestCounter = 0;
+
+void Abort() {
+ if (GetTestCounter() == 1) {
+ SetTestCounter(2);
+ } else {
+ std::cerr << "Program terminated with an unrecoverable error." << std::endl;
+ exit(-1);
+ }
+}
+
+void Exit(int code) {
+ if (GetTestCounter() == 1) {
+ SetTestCounter(2);
+ } else {
+ exit(code);
+ }
+}
+
+void SetTestCounter(int c) { gTestCounter = c; }
+bool GetTestCounter() { return gTestCounter; }
} // namespace error
namespace util {