Skip to content

Instantly share code, notes, and snippets.

@wataash
Last active December 15, 2019 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wataash/b34eb1436e2c37829eb9d52b242dfe39 to your computer and use it in GitHub Desktop.
Save wataash/b34eb1436e2c37829eb9d52b242dfe39 to your computer and use it in GitHub Desktop.
loop
#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;
}
@wataash
Copy link
Author

wataash commented Sep 30, 2019

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment