89_nocode_wanted.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. extern int printf(const char *format, ...);
  2. static void kb_wait_1(void)
  3. {
  4. unsigned long timeout = 2;
  5. do {
  6. (1 ?
  7. printf("timeout=%ld\n", timeout) :
  8. ({
  9. while (1)
  10. printf("error\n");
  11. })
  12. );
  13. timeout--;
  14. } while (timeout);
  15. }
  16. static void kb_wait_2(void)
  17. {
  18. unsigned long timeout = 2;
  19. do {
  20. (1 ?
  21. printf("timeout=%ld\n", timeout) :
  22. ({
  23. for (;;)
  24. printf("error\n");
  25. })
  26. );
  27. timeout--;
  28. } while (timeout);
  29. }
  30. static void kb_wait_2_1(void)
  31. {
  32. unsigned long timeout = 2;
  33. do {
  34. (1 ?
  35. printf("timeout=%ld\n", timeout) :
  36. ({
  37. do {
  38. printf("error\n");
  39. } while (1);
  40. })
  41. );
  42. timeout--;
  43. } while (timeout);
  44. }
  45. static void kb_wait_2_2(void)
  46. {
  47. unsigned long timeout = 2;
  48. do {
  49. (1 ?
  50. printf("timeout=%ld\n", timeout) :
  51. ({
  52. label:
  53. printf("error\n");
  54. goto label;
  55. })
  56. );
  57. timeout--;
  58. } while (timeout);
  59. }
  60. static void kb_wait_3(void)
  61. {
  62. unsigned long timeout = 2;
  63. do {
  64. (1 ?
  65. printf("timeout=%ld\n", timeout) :
  66. ({
  67. int i = 1;
  68. goto label;
  69. i = i + 2;
  70. label:
  71. i = i + 3;
  72. })
  73. );
  74. timeout--;
  75. } while (timeout);
  76. }
  77. static void kb_wait_4(void)
  78. {
  79. unsigned long timeout = 2;
  80. do {
  81. (1 ?
  82. printf("timeout=%ld\n", timeout) :
  83. ({
  84. switch(timeout) {
  85. case 2:
  86. printf("timeout is 2");
  87. break;
  88. case 1:
  89. printf("timeout is 1");
  90. break;
  91. default:
  92. printf("timeout is 0?");
  93. break;
  94. };
  95. // return;
  96. })
  97. );
  98. timeout--;
  99. } while (timeout);
  100. }
  101. int main()
  102. {
  103. printf("begin\n");
  104. kb_wait_1();
  105. kb_wait_2();
  106. kb_wait_2_1();
  107. kb_wait_2_2();
  108. kb_wait_3();
  109. kb_wait_4();
  110. printf("end\n");
  111. return 0;
  112. }