Update stack initialization alignment calculation to use WORD_SIZE constant for clarity

This commit is contained in:
Themis Demetriades
2024-11-10 11:24:51 +00:00
parent a165107f5f
commit f0dae74cf3

View File

@@ -22,6 +22,10 @@
#include "threads/synch.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
within a linked list. */
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
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_size = sizeof (char **);
size_t argc_size = sizeof (int);