Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <linux/module.h>
- #include <linux/init.h>
- #include <linux/string.h>
- #include <linux/slab.h>
- struct stack_node{
- int data;
- struct stack_node *nastepny;
- } *top = NULL;
- struct stack_node *push(struct stack_node *top,int data)
- { struct stack_node *new_node = (struct stack_node *)kmalloc(sizeof(struct stack_node),GFP_KERNEL);
- if(new_node){
- new_node->data=data;
- new_node->nastepny=top;
- top=new_node;}
- return top;}
- int pop(struct stack_node **top){
- int temp = -1;
- if(top){
- temp =(*top)->data;
- struct stack_node *tmp=(*top)->nastepny;
- kfree(*top);
- *top = tmp;}
- return temp;}
- static int __init stack_init(void){
- int i = 0;
- for(i=0;i<15;i++){
- top = push(top,i);}
- return 0;}
- static void __exit stack_exit(void){
- while (top != NULL){
- printk(KERN_INFO "%d\n\n",pop(&top));}}
- module_init(stack_init);
- module_exit(stack_exit);
- MODULE_LICENSE("GPL");
- MODULE_AUTHOR("Mateusz Nachyla Mateusz Orlowski");
- MODULE_VERSION("1.0");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement