Jump to content
Nytro

GCC hacks in the Linux kernel

Recommended Posts

Posted

GCC hacks in the Linux kernel

Discover GCC extensions for the C language

Skill Level: Intermediate

M. Tim Jones

Consultant Engineer

Emulex Corp

18 Nov 2008

The Linux® kernel uses several special capabilities of the GNU Compiler Collection
(GCC) suite. These capabilities range from giving you shortcuts and simplifications to
providing the compiler with hints for optimization. Discover some of these special
GCC features and learn how to use them in the Linux kernel.
GCC and Linux are a great pair. Although they are independent pieces of software,
Linux is totally dependent on GCC to enable it on new architectures. Linux further
exploits features in GCC, called extensions, for greater functionality and
optimization. This article explores many of these important extensions and shows
you how they're used within the Linux kernel.
GCC in its current stable version (version 4.3.2) supports three versions of the C
standard:
• The original International Organization for Standardization (ISO) standard
of the C language (ISO C89 or C90)
• ISO C90 with amendment 1
• The current ISO C99 (the default standard that GCC uses and that this
article assumes)

Note: This article assumes that you are using the ISO C99 standard. If you specify a
standard older than the ISO C99 version, some of the extensions described in this
article may be disabled. To specify the actual standard that GCC uses, you can use
the -std option from the command line. Use the GCC manual to verify which
extensions are supported in which versions of the standard (see Resources for a
link).
Applicable versions
This article focuses on the use of GCC extensions in the 2.6.27.1
Linux kernel and version 4.3.2 of GCC. Each C extension refers to
the file in the Linux kernel source where the example can be found.
The available C extensions can be classified in several ways. This article puts them
in two broad categories:
• Functionality extensions bring new capabilities from GCC.
• Optimization extensions help you generate more efficient code.

Download:

http://download.boulder.ibm.com/ibmdl/pub/software/dw/linux/l-gcc-hacks/l-gcc-hacks-pdf.pdf

Online:

http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/index.html

Posted

Niciuna. Sunt prezentate niste extensii ale compilatorului GCC care fac viata mai usoara. Citeste macar o parte din articol. De exemplu sa definesti "1 ... 10" care sa reprezinte orice numar de la 1 la 10. Asta nu se poate in Visual C++ de exemplu si NU face parte din standardul C!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...