kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

sw_char.c (549B)


      1 /* A switch on a char-typed selector. The selector is narrowed to 8 bits, so
      2  * the dispatch compares byte values; this exercises the sub-register compare
      3  * path feeding the switch. volatile char defeats folding. The character 'B'
      4  * (0x42) selects the case returning 42. Exit code 42. */
      5 int sel(char c) {
      6   switch (c) {
      7     case 'A':
      8       return 10;
      9     case 'B':
     10       return 42;
     11     case 'C':
     12       return 12;
     13     case 'D':
     14       return 13;
     15     default:
     16       return 99;
     17   }
     18 }
     19 int test_main(void) {
     20   volatile char c = 'B';
     21   return sel(c);
     22 }