Last active
December 15, 2019 04:07
-
-
Save wataash/b34eb1436e2c37829eb9d52b242dfe39 to your computer and use it in GitHub Desktop.
loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define loop() do { \ | |
fprintf(stderr, "\x1b[36m %s loop \x1b[0m\n", __func__); \ | |
_loop(); \ | |
fprintf(stderr, "\x1b[36m %s exit loop \x1b[0m\n", __func__); \ | |
} while (0) | |
void _loop(void); | |
void | |
_loop(void) | |
{ | |
static volatile int not_loop = 0; // set me to 1 with gdb | |
if (not_loop) | |
return; | |
volatile long break_ = 1; | |
while (break_ != 0) { | |
// to quit: wait ~1s or `break_ = 0` with gdb | |
break_++; | |
// if (break_ == (long)1e9) { // tune me | |
if (break_ == (long)5e8) { | |
break; | |
} | |
} | |
return; // breakpoint | |
} | |
int | |
main(int argc, char const *argv[]) | |
{ | |
loop(); | |
printf("hello\n"); | |
return 0; | |
} |
Author
wataash
commented
Sep 30, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment