Переглянути джерело

fix: 去除quick_exit

quick_exit的宏可能导致msvc编译不过
SongZihuan 3 роки тому
батько
коміт
f9dc464386
4 змінених файлів з 6 додано та 13 видалено
  1. 0 7
      CMakeLists.txt
  2. 1 1
      include/tool/log.h
  3. 1 4
      src/tool/log.c
  4. 4 1
      test/src/run_code.c

+ 0 - 7
CMakeLists.txt

@@ -26,9 +26,6 @@ if (fpic_work)
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
 endif()
 
-include(CheckSymbolExists)
-check_symbol_exists(quick_exit "stdlib.h" HAVE_QUICK_EXIT)  # base_compile_definitions 时使用
-
 if (MSVC)
     set(CMAKE_GNUtoMS TRUE)
     check_c_compiler_flag("/utf-8" utf8_work)
@@ -91,10 +88,6 @@ if (CYGWIN)
     list(APPEND base_compile_definitions aFunCYGWIN=1)
 endif()
 
-if (NOT HAVE_QUICK_EXIT)
-    list(APPEND base_compile_definitions quick_exit=exit "at_quick_exit=(void)")
-endif()
-
 add_compile_definitions(${base_compile_definitions})
 
 include(${CMAKE_CURRENT_LIST_DIR}/deps/deps.cmake)  # 安装依赖

+ 1 - 1
include/tool/log.h

@@ -35,7 +35,7 @@ struct Logger {
     bool process_send_error;  // 若为false则send_error转换为error
     bool process_fatal_error;  // 若为false则fatal_error转换为error
     jmp_buf *buf;
-    int exit_type;  // 0-quick_exit 1-abort 其他值则为exit
+    int exit_type;    // 0-abort 其他值则为exit
 };
 typedef struct Logger Logger;
 

+ 1 - 4
src/tool/log.c

@@ -92,7 +92,6 @@ int initLogSystem(FilePath path, LogFactoryPrintConsole print_console) {
     log_factory.print_console = print_console;
     log_factory.init = true;
     atexit(destructLogSystem_at_exit);
-    at_quick_exit(destructLogSystem_at_exit);
 
     initLogger(&(log_factory.sys_log), "SYSTEM", log_debug);  // 设置为 debug, 记录 success 信息
     log_factory.sys_log.process_fatal_error = true;
@@ -282,10 +281,8 @@ int writeFatalErrorLog_(Logger *logger, LogLoggerPrintConsole pc, char *file, in
     va_start(ap, format);
     int re = writeLog_(logger, pc, log_fatal_error, file, line, func, format, ap);
     if (logger->process_fatal_error) {
-        if (logger->exit_type == 1)
+        if (logger->exit_type == 0)
             abort();
-        else if (logger->exit_type == 0)
-            quick_exit(exit_code);
         else
             exit(exit_code);
     }

+ 4 - 1
test/src/run_code.c

@@ -373,12 +373,15 @@ int main(int argc, char **argv) {
     char *base_name_ = getExedir(*argv, 1);
 
     char *log = strJoin(base_name_, SEP aFunLogDir SEP, false, false);
+    printf("log = %s\n", log);
     bool re = aFunInit(log, log_pc_all, NULL, log_debug);
     free(log);
     free(base_name_);
 
-    if (!re)
+    if (!re) {
+        printf("re = %d\n", re);
         exit(EXIT_FAILURE);
+    }
 
     af_Environment *env = creatAFunEnvironment(0, NULL);
     if(!pushLiteralRegex("data.*", "func", true, env)) {