forked from eabatalov/au-linux-kernel-autumn-2016
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba3b32d
commit 1f899f8
Showing
3 changed files
with
76 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,38 @@ | ||
#include "stack.h" | ||
|
||
#include "assert.h" | ||
#include <linux/slab.h> | ||
#include <linux/gfp.h> | ||
|
||
stack_entry_t* create_stack_entry(void *data) | ||
{ | ||
// TODO | ||
(void)data; | ||
return NULL; | ||
stack_entry_t* result = kmalloc(sizeof(stack_entry_t), GFP_KERNEL); | ||
if (!result) { | ||
printk(KERN_ALERT "FAILED TO ALLOCATE MEMORY"); | ||
return result; | ||
} | ||
INIT_LIST_HEAD(&(result->lh)); | ||
result->data = data; | ||
printk(KERN_ALERT "created node: %p\n", result); | ||
return result; | ||
} | ||
|
||
void delete_stack_entry(stack_entry_t *entry) | ||
{ | ||
// TODO | ||
(void)entry; | ||
// if I understand correctly, taking care of *data | ||
// is not our responsibility, since we didn't create it | ||
printk(KERN_ALERT "deleting node: %p\n", entry); | ||
kfree(entry); | ||
} | ||
|
||
void stack_push(struct list_head *stack, stack_entry_t *entry) | ||
{ | ||
// TODO | ||
(void)stack; | ||
(void)entry; | ||
list_add(&(entry->lh), stack); | ||
} | ||
|
||
stack_entry_t* stack_pop(struct list_head *stack) | ||
{ | ||
// TODO | ||
(void)stack; | ||
return NULL; | ||
stack_entry_t* result = list_entry(stack->next, stack_entry_t, lh); | ||
list_del(stack->next); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters