fork download
  1. void ShareRangeWithPermissions(char** arguments)
  2. {
  3. //TODO: Assignment3.Q2
  4. //put your logic here
  5. //...
  6. int size = (strtol(arguments[3], NULL, 10) * 1024)/4;
  7. uint32 *va1 = (uint32 *)strtol(arguments[1], NULL, 16), *va2 = (uint32 *)strtol(arguments[2], NULL, 16), *t, *tt;
  8. char permission = arguments[4][0];
  9. for (int i = 0; i < size; i++, va1 += PAGE_SIZE, va2 += PAGE_SIZE)
  10. {
  11. get_page_table(ptr_page_directory, (void *)va1, 0, &t);
  12. if (t && (t[PTX(va1)] & PERM_PRESENT))
  13. {
  14. get_page_table(ptr_page_directory, (void *)va2, 1, &tt);
  15. tt[PTX(va2)] = t[PTX(va1)];
  16. permission == 'r'? tt[PTX(va2)] &= (~PERM_WRITEABLE) : (tt[PTX(va2)] |= PERM_WRITEABLE);
  17. }
  18. }
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘ShareRangeWithPermissions’:
prog.c:6:14: warning: implicit declaration of function ‘strtol’ [-Wimplicit-function-declaration]
  int size = (strtol(arguments[3], NULL, 10) * 1024)/4;
              ^~~~~~
prog.c:6:35: error: ‘NULL’ undeclared (first use in this function)
  int size = (strtol(arguments[3], NULL, 10) * 1024)/4;
                                   ^~~~
prog.c:6:35: note: each undeclared identifier is reported only once for each function it appears in
prog.c:7:2: error: unknown type name ‘uint32’
  uint32 *va1 = (uint32 *)strtol(arguments[1], NULL, 16), *va2 = (uint32 *)strtol(arguments[2], NULL, 16), *t, *tt;
  ^~~~~~
prog.c:7:17: error: ‘uint32’ undeclared (first use in this function)
  uint32 *va1 = (uint32 *)strtol(arguments[1], NULL, 16), *va2 = (uint32 *)strtol(arguments[2], NULL, 16), *t, *tt;
                 ^~~~~~
prog.c:7:25: error: expected expression before ‘)’ token
  uint32 *va1 = (uint32 *)strtol(arguments[1], NULL, 16), *va2 = (uint32 *)strtol(arguments[2], NULL, 16), *t, *tt;
                         ^
prog.c:9:40: error: ‘PAGE_SIZE’ undeclared (first use in this function)
  for (int i = 0; i < size; i++, va1 += PAGE_SIZE, va2 += PAGE_SIZE)
                                        ^~~~~~~~~
prog.c:9:51: error: ‘va2’ undeclared (first use in this function)
  for (int i = 0; i < size; i++, va1 += PAGE_SIZE, va2 += PAGE_SIZE)
                                                   ^~~
prog.c:9:49: warning: left-hand operand of comma expression has no effect [-Wunused-value]
  for (int i = 0; i < size; i++, va1 += PAGE_SIZE, va2 += PAGE_SIZE)
                                                 ^
prog.c:11:3: warning: implicit declaration of function ‘get_page_table’ [-Wimplicit-function-declaration]
   get_page_table(ptr_page_directory, (void *)va1, 0, &t);
   ^~~~~~~~~~~~~~
prog.c:11:18: error: ‘ptr_page_directory’ undeclared (first use in this function)
   get_page_table(ptr_page_directory, (void *)va1, 0, &t);
                  ^~~~~~~~~~~~~~~~~~
prog.c:11:55: error: ‘t’ undeclared (first use in this function)
   get_page_table(ptr_page_directory, (void *)va1, 0, &t);
                                                       ^
prog.c:12:15: warning: implicit declaration of function ‘PTX’ [-Wimplicit-function-declaration]
   if (t && (t[PTX(va1)] & PERM_PRESENT))
               ^~~
prog.c:12:27: error: ‘PERM_PRESENT’ undeclared (first use in this function)
   if (t && (t[PTX(va1)] & PERM_PRESENT))
                           ^~~~~~~~~~~~
prog.c:14:56: error: ‘tt’ undeclared (first use in this function)
    get_page_table(ptr_page_directory, (void *)va2, 1, &tt);
                                                        ^~
prog.c:16:41: error: ‘PERM_WRITEABLE’ undeclared (first use in this function)
    permission == 'r'? tt[PTX(va2)] &= (~PERM_WRITEABLE) : (tt[PTX(va2)] |= PERM_WRITEABLE);
                                         ^~~~~~~~~~~~~~
stdout
Standard output is empty