Re: printf logs are not getting printed properly on system.log
Re: printf logs are not getting printed properly on system.log
- Subject: Re: printf logs are not getting printed properly on system.log
- From: Jeremy Pereira <email@hidden>
- Date: Fri, 24 Aug 2007 12:18:17 +0100
On 23 Aug 2007, at 20:04, Draichis wrote:
Amazing.
One of the most common problems faced when programming in the
kernel is use of “standard” functions—things like printf or bcopy.
Many commonly used standard C library functions are implemented in
the kernel. In order to use them, however, you need to include the
appropriate prototypes, which may be different from the user space
prototypes for those functions, and which generally have different
names when included from kernel code.
In general, any non–I/O Kit header that you can safely include in
the kernel is located in xnu/bsd/sys or xnu/osfmk/mach, although
there are a few specialized headers in other places like libkern
and libsa. Normal headers (those in /usr/include) cannot be used in
the kernel (or rather, cannot be used 'properly').
If the standard C function you are trying to use is not in one of
the following files, chances are the function is not supported for
use within the kernel, and you need to implement your code in
another way:
<sys/systm.h> (printf can be used with this)
<sys/buf.h> (buffer cache functions like bread)
<sys/dirent.h> (directory entries)
<sys/errno.h> (Error numbers)
<sys.kernel.h> (kernel special variables)
<sys/lock.h> (spinlocks)
<sys/malloc.h> (malloc)
<sys/queue.h> (queues)
<sys/rand.h> (random generation numbers)
<sys/systm.h> (bzero, bcopy.. etc)
<sys/system.h> (timeout, untimeout)
<sys/time.h> (time functions)
<sys/types.h> <mach/mach_types.h> (standard type declarations)
<sys/ucred.h> (user credentials)
<sys/utsname.h> (os and system information)
For developing kernel extensions, surely it is better to be guided by
the header files that are in Kernel.framework in the SDK which are
also the ones that should be used - at least they are the ones that
XCode uses when it creates a new kext project.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden