Update stack initialization alignment calculation to use WORD_SIZE constant for clarity
This commit is contained in:
@@ -22,6 +22,10 @@
|
|||||||
#include "threads/synch.h"
|
#include "threads/synch.h"
|
||||||
#include "devices/timer.h"
|
#include "devices/timer.h"
|
||||||
|
|
||||||
|
/* Defines the native number of bytes processed by the processor
|
||||||
|
(for the purposes of alignment). */
|
||||||
|
#define WORD_SIZE 4
|
||||||
|
|
||||||
/* Keeps track of the position of pointers to user program arguments
|
/* Keeps track of the position of pointers to user program arguments
|
||||||
within a linked list. */
|
within a linked list. */
|
||||||
struct arg_elem
|
struct arg_elem
|
||||||
@@ -153,7 +157,7 @@ process_init_stack (char *saveptr, void **esp, char *file_name)
|
|||||||
|
|
||||||
/* Calculate the remaining number of bytes that need to be written
|
/* Calculate the remaining number of bytes that need to be written
|
||||||
to the user process stack in order to check for possible overflow. */
|
to the user process stack in order to check for possible overflow. */
|
||||||
size_t align_size = ((unsigned int) *esp % 4) * sizeof (uint8_t);
|
size_t align_size = ((unsigned int) *esp % WORD_SIZE) * sizeof (uint8_t);
|
||||||
size_t argv_data_size = (arg_count + 1) * sizeof (char *);
|
size_t argv_data_size = (arg_count + 1) * sizeof (char *);
|
||||||
size_t argv_size = sizeof (char **);
|
size_t argv_size = sizeof (char **);
|
||||||
size_t argc_size = sizeof (int);
|
size_t argc_size = sizeof (int);
|
||||||
|
|||||||
Reference in New Issue
Block a user