/[qemu]/qemu/tests/test-i386.c
ViewVC logotype

Diff of /qemu/tests/test-i386.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by bellard, Fri May 16 13:43:31 2003 UTC revision 1.17 by bellard, Sun May 25 16:47:16 2003 UTC
# Line 1218  uint8_t code[] = { Line 1218  uint8_t code[] = {
1218      0xc3, /* ret */      0xc3, /* ret */
1219  };  };
1220    
1221    typedef int FuncType(void);
1222    
1223  void test_self_modifying_code(void)  void test_self_modifying_code(void)
1224  {  {
1225      int (*func)(void);      int i;
1226    
     func = (void *)code;  
1227      printf("self modifying code:\n");      printf("self modifying code:\n");
1228      printf("func1 = 0x%x\n", func());      printf("func1 = 0x%x\n", ((FuncType *)code)());
1229      code[1] = 0x2;      for(i = 2; i <= 4; i++) {
1230      printf("func1 = 0x%x\n", func());          code[1] = i;
1231            printf("func%d = 0x%x\n", i, ((FuncType *)code)());
1232        }
1233  }  }
1234            
1235  static void *call_end __init_call = NULL;  static void *call_end __init_call = NULL;

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26