Find the answer to your Linux question:
Results 1 to 5 of 5
Hello, I got quite an easy question I guess. Does unistd.h declare functions in the kernel or in the stdclib? Or in any other C file. I need to know ...
  1. #1
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422

    unistd.h

    Hello,

    I got quite an easy question I guess.

    Does unistd.h declare functions in the kernel or in the stdclib? Or in any other C file.
    I need to know from the inside how some of the functions work.

    So where does unistd redirect to?

    Thanks

    Cheers,
    Robin
    New Users, please read this..
    Google first, then ask..

  2. #2
    Linux Newbie
    Join Date
    Apr 2010
    Location
    Novosibirsk, Russia
    Posts
    136
    Quote Originally Posted by RobinVossen View Post
    Hello,

    I got quite an easy question I guess.

    Does unistd.h declare functions in the kernel or in the stdclib? Or in any other C file.
    I need to know from the inside how some of the functions work.

    So where does unistd redirect to?

    Thanks

    Cheers,
    Robin
    as I remember, linux kernel uses libc itself...) but in any case, if you want to know how a function works, you can search it in kernel source, or just compile kernel in debug mode and use gcc by your hands I think it could be useful to read kernel docs too (something about unistd... Or just try 'man unistd' command ).

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I don't fully understand your question.

    unistd.h is a part of glibc, which is the GNU implementation of the C library. glibc is an external library loaded into pretty much every executable (ones compiled from C, at least), but it is not included in the kernel. Kernel programming uses a separate set of libraries that are kernel-specific, and kernel programming cannot use normal libc functions.
    DISTRO=Arch
    Registered Linux User #388732

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by Cabhan View Post
    I don't fully understand your question.

    unistd.h is a part of glibc, which is the GNU implementation of the C library. glibc is an external library loaded into pretty much every executable (ones compiled from C, at least), but it is not included in the kernel. Kernel programming uses a separate set of libraries that are kernel-specific, and kernel programming cannot use normal libc functions.
    While true that glibc and libc are not used directly by the kernel, the kernel has it's own version of unistd.h and other common headers in linux-src-dir/include/linux, so in kernel code you would #include <linux/unistd.h> in order to get unistd.h functions. In any case, do read the docs.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Thanks all,
    I managed to override a default function from unistd.h

    Thanks all real great =)
    New Users, please read this..
    Google first, then ask..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...