about summary refs log tree commit diff
path: root/src/debug.h
diff options
context:
space:
mode:
authorPjotr Prins2017-10-20 08:10:39 +0000
committerPjotr Prins2017-10-23 13:54:05 +0000
commitb42a02d02b3d9384b1da55bd091f0f89c808b626 (patch)
tree4fd66b70ce7eb660dcb98c38a7f5309ac43195e8 /src/debug.h
parent12558c358150bfed99874b791932bbe06a107263 (diff)
downloadpangemma-b42a02d02b3d9384b1da55bd091f0f89c808b626.tar.gz
Travis-ci:
- Disabled gcc-6 since we develop with later tools anyway
- Turned the release test into a simple integration test
- Adding MacOSX on Travis-ci

Tests: Adding tests for Plink w. LOCO

Safety: Introduce strtok_safe to get rid of segfaults
Diffstat (limited to 'src/debug.h')
-rw-r--r--src/debug.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/debug.h b/src/debug.h
index c127630..b3ec17b 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -28,6 +28,9 @@ bool is_legacy_mode();
 gsl_matrix *gsl_matrix_safe_alloc(size_t rows,size_t cols);
 gsl_vector *gsl_vector_safe_alloc(size_t n);
 
+char *do_strtok_safe(char *tokenize, const char *delimiters, const char *__pretty_function, const char *__file, int __line);
+#define strtok_safe(string,delimiters) do_strtok_safe(string,delimiters,__PRETTY_FUNCTION__,__FILE__,__LINE__)
+
 // Validation routines
 void do_validate_K(const gsl_matrix *K, const char *__file, int __line);
 
@@ -36,7 +39,7 @@ void do_validate_K(const gsl_matrix *K, const char *__file, int __line);
 
 #define warning_at_msg(__file,__line,msg) cerr << "**** WARNING: " << msg << " in " << __file << " at line " << __line << endl;
 
-inline void fail_at_msg(bool strict, const char *__file, int __line, const char *msg) {
+inline void warnfail_at_msg(bool strict, const char *__file, int __line, const char *msg) {
   if (strict)
     std::cerr << "**** STRICT FAIL: ";
   else
@@ -46,6 +49,11 @@ inline void fail_at_msg(bool strict, const char *__file, int __line, const char
     exit(1);
 }
 
+inline void fail_at_msg(const char *__file, int __line, std::string msg) {
+  std::cerr << msg << " in " << __file << " at line " << __line << std::endl;
+  exit(1);
+}
+
 # ifndef __ASSERT_VOID_CAST
 # define __ASSERT_VOID_CAST (void)
 # endif
@@ -55,6 +63,11 @@ inline void fail_msg(const char *msg) {
   exit(5);
 }
 
+inline void fail_msg(std::string msg) {
+  std::cerr << "**** FAILED: " << msg << std::endl;
+  exit(5);
+}
+
 #if defined NDEBUG
 
 #define warning_msg(msg) cerr << "**** WARNING: " << msg << endl;