Linked lists for userspace programs in Linux
Valdis.Kletnieks at vt.edu
Valdis.Kletnieks at vt.edu
Sun Jun 15 23:24:17 EDT 2014
On Sat, 14 Jun 2014 02:38:19 +0800, Chandrasekaran Sivakumar said:
> I wanted to use linked lists in one of my userspace programs in Linux.
Userspace. Remember that word.
> 1. I used the modified version of list implementation given in
> http://isis.poly.edu/kulesh/stuff/src/klist/list.h for my userspace
> program. But when I compiled the kernel, there were errors showing
> 'redefinition of struct', 'conflicting types' etc.
You're recompiling the kernel for what reason? You seem to be confused
regarding kernel space versus userspace programming...
> 2. When I tried to use list.h as such without any modifications, linked
> list functions in my userspace program were not identified by the compiler
> and displayed as undefined.
This sounds like you need an introductory C class.
Did you remember to #include them?
Oh, by the way, keep in mind that the Linux kernel "linked list"
is actually a circularly linked list - as a result, treating it as a
normal linked list (particularly when checking for empty list or end-of-list)
is likely to result in hilarity and hijinks for all...
> Would it be okay to modify the variable/function names in a copy of list.h
> and use it in the userspace program ?
You'd probably be better off learning basic data structures well enough
to write your own implementation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140615/ef9bf990/attachment.bin
More information about the Kernelnewbies
mailing list