Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > 2c51d8eb79f8810ada971ee8c30ce1e5 > files > 2185

kernel-doc-2.6.32-71.14.1.el6.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Chapter&#160;12.&#160;Kernel Cantrips</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="Unreliable Guide To Hacking The Linux Kernel" /><link rel="up" href="index.html" title="Unreliable Guide To Hacking The Linux Kernel" /><link rel="prev" href="ch11.html" title="Chapter&#160;11.&#160;Putting Your Stuff in the Kernel" /><link rel="next" href="ch13.html" title="Chapter&#160;13.&#160;Thanks" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&#160;12.&#160;Kernel Cantrips</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch11.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch13.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter&#160;12.&#160;Kernel Cantrips"><div class="titlepage"><div><div><h2 class="title"><a id="cantrips"></a>Chapter&#160;12.&#160;Kernel Cantrips</h2></div></div></div><p>
   Some favorites from browsing the source.  Feel free to add to this
   list.
  </p><p>
   <code class="filename">arch/x86/include/asm/delay.h:</code>
  </p><pre class="programlisting">
#define ndelay(n) (__builtin_constant_p(n) ? \
        ((n) &gt; 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
        __ndelay(n))
  </pre><p>
   <code class="filename">include/linux/fs.h</code>:
  </p><pre class="programlisting">
/*
 * Kernel pointers have redundant information, so we can use a
 * scheme where we can return either an error code or a dentry
 * pointer with the same return value.
 *
 * This should be a per-architecture thing, to allow different
 * error and pointer decisions.
 */
 #define ERR_PTR(err)    ((void *)((long)(err)))
 #define PTR_ERR(ptr)    ((long)(ptr))
 #define IS_ERR(ptr)     ((unsigned long)(ptr) &gt; (unsigned long)(-1000))
</pre><p>
   <code class="filename">arch/x86/include/asm/uaccess_32.h:</code>
  </p><pre class="programlisting">
#define copy_to_user(to,from,n)                         \
        (__builtin_constant_p(n) ?                      \
         __constant_copy_to_user((to),(from),(n)) :     \
         __generic_copy_to_user((to),(from),(n)))
  </pre><p>
   <code class="filename">arch/sparc/kernel/head.S:</code>
  </p><pre class="programlisting">
/*
 * Sun people can't spell worth damn. "compatability" indeed.
 * At least we *know* we can't spell, and use a spell-checker.
 */

/* Uh, actually Linus it is I who cannot spell. Too much murky
 * Sparc assembly will do this to ya.
 */
C_LABEL(cputypvar):
        .asciz "compatability"

/* Tested on SS-5, SS-10. Probably someone at Sun applied a spell-checker. */
        .align 4
C_LABEL(cputypvar_sun4m):
        .asciz "compatible"
  </pre><p>
   <code class="filename">arch/sparc/lib/checksum.S:</code>
  </p><pre class="programlisting">
        /* Sun, you just can't beat me, you just can't.  Stop trying,
         * give up.  I'm serious, I am going to kick the living shit
         * out of you, game over, lights out.
         */
  </pre></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch11.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="ch13.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&#160;11.&#160;Putting Your Stuff in the Kernel&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Chapter&#160;13.&#160;Thanks</td></tr></table></div></body></html>