1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>GNU Extensions</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Unreliable Guide To Hacking The Linux Kernel"><link rel="up" href="conventions.html" title="Chapter&#160;10.&#160;Routines and Conventions"><link rel="prev" href="conventions-initialising.html" title="Initializing structure members"><link rel="next" href="conventions-cplusplus.html" title="C++"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">GNU Extensions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="conventions-initialising.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;10.&#160;Routines and Conventions</th><td width="20%" align="right">&#160;<a accesskey="n" href="conventions-cplusplus.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="conventions-gnu-extns"></a>GNU Extensions</h2></div></div></div><p>
2    GNU Extensions are explicitly allowed in the Linux kernel.
3    Note that some of the more complex ones are not very well
4    supported, due to lack of general use, but the following are
5    considered standard (see the GCC info page section "C
6    Extensions" for more details - Yes, really the info page, the
7    man page is only a short summary of the stuff in info).
8   </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
9      Inline functions
10     </p></li><li class="listitem"><p>
11      Statement expressions (ie. the ({ and }) constructs).
12     </p></li><li class="listitem"><p>
13      Declaring attributes of a function / variable / type
14      (__attribute__)
15     </p></li><li class="listitem"><p>
16      typeof
17     </p></li><li class="listitem"><p>
18      Zero length arrays
19     </p></li><li class="listitem"><p>
20      Macro varargs
21     </p></li><li class="listitem"><p>
22      Arithmetic on void pointers
23     </p></li><li class="listitem"><p>
24      Non-Constant initializers
25     </p></li><li class="listitem"><p>
26      Assembler Instructions (not outside arch/ and include/asm/)
27     </p></li><li class="listitem"><p>
28      Function names as strings (__func__).
29     </p></li><li class="listitem"><p>
30      __builtin_constant_p()
31     </p></li></ul></div><p>
32    Be wary when using long long in the kernel, the code gcc generates for
33    it is horrible and worse: division and multiplication does not work
34    on i386 because the GCC runtime functions for it are missing from
35    the kernel environment.
36   </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="conventions-initialising.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="conventions.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="conventions-cplusplus.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Initializing structure members&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;C++</td></tr></table></div></body></html>
37