Fix problems with programs that prototype printf to something unusual
authorChris Lattner <sabre@nondot.org>
Mon, 15 Sep 2003 16:47:12 +0000 (16:47 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 15 Sep 2003 16:47:12 +0000 (16:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8538 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index 6d1fd14dae9df60871a121312b8cb9ae655bb16c..65919e8c48d9cc6423f9dff589312003c6410ff1 100644 (file)
@@ -987,8 +987,10 @@ void CWriter::visitUnwindInst(UnwindInst &I) {
   // instruction is found.  In this context, we code generated the invoke
   // instruction to add an entry to the top of the jmpbuf_list.  Thus, here we
   // just have to longjmp to the specified handler.
-  Out << "  if (__llvm_jmpbuf_list == 0) {  /* llvm.unwind */\n"
-      << "    printf(\"throw found with no handler!\\n\"); abort();\n"
+  Out << "  if (__llvm_jmpbuf_list == 0) {  /* unwind */\n"
+      << "    extern write();\n"
+      << "    ((void (*)(int, void*, unsigned))write)(2,\n"
+      << "           \"throw found with no handler!\\n\", 31); abort();\n"
       << "  }\n"
       << "  longjmp(__llvm_jmpbuf_list->buf, 1);\n";
   emittedInvoke = true;
index 6d1fd14dae9df60871a121312b8cb9ae655bb16c..65919e8c48d9cc6423f9dff589312003c6410ff1 100644 (file)
@@ -987,8 +987,10 @@ void CWriter::visitUnwindInst(UnwindInst &I) {
   // instruction is found.  In this context, we code generated the invoke
   // instruction to add an entry to the top of the jmpbuf_list.  Thus, here we
   // just have to longjmp to the specified handler.
-  Out << "  if (__llvm_jmpbuf_list == 0) {  /* llvm.unwind */\n"
-      << "    printf(\"throw found with no handler!\\n\"); abort();\n"
+  Out << "  if (__llvm_jmpbuf_list == 0) {  /* unwind */\n"
+      << "    extern write();\n"
+      << "    ((void (*)(int, void*, unsigned))write)(2,\n"
+      << "           \"throw found with no handler!\\n\", 31); abort();\n"
       << "  }\n"
       << "  longjmp(__llvm_jmpbuf_list->buf, 1);\n";
   emittedInvoke = true;