mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 19:21:35 +01:00
infinite_loop.c: document better, allow 0 magic value to not print
Enable test by passing arguments to the test to limit loops. gem5 arm LSE: still skipped, but add a link to the master patch that was merged.
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
/* https://cirosantilli.com/linux-kernel-module-cheat#c
|
||||
*
|
||||
* Loop infinitely. Print an integer whenever a period is reached:
|
||||
* Loop and print an integer whenever a period is reached:
|
||||
*
|
||||
* ....
|
||||
* ./infinite_loop [period]
|
||||
* ./infinite_loop [period=100000000 [max=0]]
|
||||
* ....
|
||||
*
|
||||
* * period: period for printing integers to stdout
|
||||
* 0 means disable printing.
|
||||
* * max: Stop counting when max is reached.
|
||||
* 0 means count to infinity.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
@@ -30,7 +35,7 @@ int main(int argc, char **argv) {
|
||||
j = 0;
|
||||
while (1) {
|
||||
i++;
|
||||
if (i % period == 0) {
|
||||
if (period != 0 && i % period == 0) {
|
||||
printf("%ju\n", j);
|
||||
j++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user