diff options
author | Morgan Deters <mdeters@gmail.com> | 2010-10-01 21:35:31 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2010-10-01 21:35:31 +0000 |
commit | 96d1c3daff7efdd2d853864fb820bc7cf413624e (patch) | |
tree | b995c98a2be18182d6cb52e81de5bf712b475f06 /src/main | |
parent | d0b49d588033ab8140bdf297c9cdf73b1088fe68 (diff) |
replacement implementation for clock_gettime() on mac os x, build portability (resolving mac os x issues), code cleanup, fix compiler warnings
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/Makefile.am | 4 | ||||
-rw-r--r-- | src/main/util.cpp | 37 |
2 files changed, 37 insertions, 4 deletions
diff --git a/src/main/Makefile.am b/src/main/Makefile.am index 82ff00a60..3cd062158 100644 --- a/src/main/Makefile.am +++ b/src/main/Makefile.am @@ -1,4 +1,5 @@ AM_CPPFLAGS = \ + -D__BUILDING_CVC4DRIVER \ -I@srcdir@/../include -I@srcdir@/.. -I@builddir@/.. $(ANTLR_INCLUDES) AM_CXXFLAGS = -Wall -Wno-unknown-pragmas @@ -13,7 +14,8 @@ cvc4_SOURCES = \ cvc4_LDADD = \ ../parser/libcvc4parser.la \ - ../libcvc4.la + ../libcvc4.la \ + ../lib/libreplacements.la if STATIC_BINARY cvc4_LINK = $(CXXLINK) -all-static diff --git a/src/main/util.cpp b/src/main/util.cpp index ddb9f84c8..e91e80c3f 100644 --- a/src/main/util.cpp +++ b/src/main/util.cpp @@ -82,6 +82,26 @@ void segv_handler(int sig, siginfo_t* info, void*) { #endif /* CVC4_DEBUG */ } +/** Handler for SIGILL (illegal instruction). */ +void ill_handler(int sig, siginfo_t* info, void*) { +#ifdef CVC4_DEBUG + fprintf(stderr, "CVC4 executed an illegal instruction in DEBUG mode.\n"); + if(segvNoSpin) { + fprintf(stderr, "No-spin requested, aborting...\n"); + abort(); + } else { + fprintf(stderr, "Spinning so that a debugger can be connected.\n"); + fprintf(stderr, "Try: gdb %s %u\n", progName, getpid()); + for(;;) { + sleep(60); + } + } +#else /* CVC4_DEBUG */ + fprintf(stderr, "CVC4 executed an illegal instruction.\n"); + abort(); +#endif /* CVC4_DEBUG */ +} + static terminate_handler default_terminator; void cvc4unexpected() { @@ -134,22 +154,33 @@ void cvc4_init() throw() { act1.sa_sigaction = sigint_handler; act1.sa_flags = SA_SIGINFO; sigemptyset(&act1.sa_mask); - if(sigaction(SIGINT, &act1, NULL)) + if(sigaction(SIGINT, &act1, NULL)) { throw Exception(string("sigaction(SIGINT) failure: ") + strerror(errno)); + } struct sigaction act2; act2.sa_sigaction = timeout_handler; act2.sa_flags = SA_SIGINFO; sigemptyset(&act2.sa_mask); - if(sigaction(SIGXCPU, &act2, NULL)) + if(sigaction(SIGXCPU, &act2, NULL)) { throw Exception(string("sigaction(SIGXCPU) failure: ") + strerror(errno)); + } struct sigaction act3; act3.sa_sigaction = segv_handler; act3.sa_flags = SA_SIGINFO; sigemptyset(&act3.sa_mask); - if(sigaction(SIGSEGV, &act3, NULL)) + if(sigaction(SIGSEGV, &act3, NULL)) { throw Exception(string("sigaction(SIGSEGV) failure: ") + strerror(errno)); + } + + struct sigaction act4; + act4.sa_sigaction = segv_handler; + act4.sa_flags = SA_SIGINFO; + sigemptyset(&act4.sa_mask); + if(sigaction(SIGILL, &act4, NULL)) { + throw Exception(string("sigaction(SIGILL) failure: ") + strerror(errno)); + } set_unexpected(cvc4unexpected); default_terminator = set_terminate(cvc4terminate); |