Refactor push_to_stack helper to match style of other helper functions

This commit is contained in:
Themis Demetriades
2024-11-08 16:53:30 +00:00
parent a19f02fad7
commit 5ed999bc9c

View File

@@ -60,16 +60,9 @@ process_execute (const char *file_name)
return tid; return tid;
} }
static void *
push_to_stack (void **esp, void *data, size_t data_size)
{
*esp -= data_size;
memcpy (*esp, data, data_size);
return *esp;
}
static void process_init_stack (void *file_name_, char *saveptr, void **esp, static void process_init_stack (void *file_name_, char *saveptr, void **esp,
char *file_name); char *file_name);
static void *push_to_stack (void **esp, void *data, size_t data_size);
/* A thread function that loads a user process and starts it /* A thread function that loads a user process and starts it
running. */ running. */
@@ -205,6 +198,17 @@ process_init_stack (void *file_name_, char *saveptr, void **esp,
*(char *) *esp = 0; *(char *) *esp = 0;
} }
/* Helper function that pushes the first 'data_size' bytes stored in the
address '*data' into the stack given a pointer to the stack pointer
'**esp'. */
static void *
push_to_stack (void **esp, void *data, size_t data_size)
{
*esp -= data_size;
memcpy (*esp, data, data_size);
return *esp;
}
/* Waits for thread TID to die and returns its exit status. /* Waits for thread TID to die and returns its exit status.
* If it was terminated by the kernel (i.e. killed due to an exception), * If it was terminated by the kernel (i.e. killed due to an exception),
* returns -1. * returns -1.