Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  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_3(void)
  31. {
  32.     unsigned long timeout = 2;
  33.     do {
  34.         (1 ?
  35.             printf("timeout=%ld\n", timeout) :
  36.             ({
  37.                 int i = 1;
  38.                 goto label;
  39.                 i = i + 2;
  40.             label:
  41.                 i = i + 3;
  42.             })
  43.         );
  44.         timeout--;
  45.     } while (timeout);
  46. }
  47. static void kb_wait_4(void)
  48. {
  49.     unsigned long timeout = 2;
  50.     do {
  51.         (1 ?
  52.             printf("timeout=%ld\n", timeout) :
  53.             ({
  54.                 switch(timeout) {
  55.                     case 2:
  56.                         printf("timeout is 2");
  57.                         break;
  58.                     case 1:
  59.                         printf("timeout is 1");
  60.                         break;
  61.                     default:
  62.                         printf("timeout is 0?");
  63.                         break;
  64.                 };
  65.                 // return;
  66.             })
  67.         );
  68.         timeout--;
  69.     } while (timeout);
  70. }
  71. int main()
  72. {
  73.     printf("begin\n");
  74.     kb_wait_1();
  75.     kb_wait_2();
  76.     kb_wait_3();
  77.     kb_wait_4();
  78.     printf("end\n");
  79.     return 0;
  80. }
  81.