Ashok Thirumurthi | 0b009ee | 2013-07-15 15:05:33 +0000 | [diff] [blame] | 1 | //===-- main.c --------------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | #include <setjmp.h> |
| 10 | #include <stdio.h> |
Ashok Thirumurthi | 23bb947 | 2013-08-01 18:52:01 +0000 | [diff] [blame^] | 11 | #include <time.h> |
Ashok Thirumurthi | 0b009ee | 2013-07-15 15:05:33 +0000 | [diff] [blame] | 12 | |
| 13 | jmp_buf j; |
| 14 | |
| 15 | void do_jump(void) |
| 16 | { |
Ashok Thirumurthi | 23bb947 | 2013-08-01 18:52:01 +0000 | [diff] [blame^] | 17 | // We can't let the compiler know this will always happen or it might make |
| 18 | // optimizations that break our test. |
| 19 | if (!clock()) |
| 20 | longjmp(j, 1); // non-local goto |
Ashok Thirumurthi | 0b009ee | 2013-07-15 15:05:33 +0000 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | int main (void) |
| 24 | { |
| 25 | if (setjmp(j) == 0) |
| 26 | do_jump(); |
| 27 | else |
| 28 | return 0; // destination of longjmp |
| 29 | |
| 30 | return 1; |
| 31 | } |