boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

00210.c (905B)


      1 typedef unsigned short uint16_t;
      2 typedef unsigned char uint8_t;
      3 
      4 typedef union Unaligned16a {
      5   uint16_t u;
      6   uint8_t b[2];
      7 } __attribute__((packed)) Unaligned16a;
      8 
      9 typedef union __attribute__((packed)) Unaligned16b {
     10   uint16_t u;
     11   uint8_t b[2];
     12 } Unaligned16b;
     13 
     14 extern void foo (void) __attribute__((stdcall));
     15 void __attribute__((stdcall)) foo (void)
     16 {
     17 }
     18 
     19 /* The actual attribute isn't important, must just be
     20    parsable.  */
     21 #define ATTR __attribute__((__noinline__))
     22 int ATTR actual_function() {
     23   return 42;
     24 }
     25 
     26 extern int printf (const char *, ...);
     27 int main()
     28 {
     29     void *function_pointer = &actual_function;
     30 
     31     int a = ((ATTR int(*) (void)) function_pointer)();
     32     printf("%i\n", a);
     33 
     34     /* In the following we once misparsed 'ATTR *' is a btype
     35        and hence the whole type was garbled.  */
     36     int b = ( (int(ATTR *)(void))  function_pointer)();
     37     printf("%i\n", b);
     38 
     39     return 0;
     40 }