473,414 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

C Inlining

What is C inlinging? Or inlining. Does it have something to do with using C
and assembly language together? I know some of the linux kernel is inlined
and it's written in C with a little assembly.

Bill

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 13 '05 #1
4 1817
Bill Cunningham <no****@net.net> wrote:
What is C inlinging? Or inlining. Does it have something to do with using C
and assembly language together? I know some of the linux kernel is inlined
and it's written in C with a little assembly.


Inlining means that a function declared as 'inline' (which has become
an offical C feature only with C99 but was supported by many compilers
before as an extension) will not be really created but instead the code
for the function is placed everywhere where the function is called.
Lets say you have an inlined function my_abs():

inline double my_abs( double val )
{
return val >= 0 ? val : - val;
}

and you call it as

x = my_abs( y );

then the compiler won't create a call to the function but instead will
replace it with the functions code, resulting in something similar to

x = y >= 0 ? y : - y;

This can increase execution speed a bit because the overhead for calling
a function is eliminated.
Regards, Jens
--
_ _____ _____
| ||_ _||_ _| Je***********@physik.fu-berlin.de
_ | | | | | |
| |_| | | | | | http://www.physik.fu-berlin.de/~toerring
\___/ens|_|homs|_|oerring
Nov 13 '05 #2
Greetings.

In article <3f********@corp.newsgroups.com>, Bill Cunningham wrote:
What is C inlinging? Or inlining. Does it have something to do with using
C and assembly language together? I know some of the linux kernel is
inlined and it's written in C with a little assembly.


The term 'inlining' can have different meanings. In standard C, it refers
to declaring a function with the 'inline' keyword, which is a suggestion to
the compiler that it insert the function's code verbatim wherever it is
called, rather than only producing the code for the function once and
calling it as a subroutine. Obviously there's a time-space tradeoff
involved.

The meaning of 'inline' you refer to deals with inserting code from another
programming language, such as SQL or assembly, into a C program. Support
for this type of inlining is compiler-specific; ISO/ANSI C does not provide
for a standard method. If you want to know how to inline assembly in C or
have questions about the Linux kernel, you need to ask on a Linux- or
compiler-specific newsgroup.

Regards,
Tristan

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 13 '05 #3

"Bill Cunningham" <no****@net.net> wrote in message
What is C inlinging? Or inlining. Does it have something to do with
using C and assembly language together? I know some of the linux
kernel is inlined and it's written in C with a little assembly.

Most compilers allow you to add assembly statements to C code, typically
using "asm" as a keyword.
Needless to say, the details are very platform-specific, and such code is
not portable.
Nov 13 '05 #4
"Malcolm" <ma*****@55bank.freeserve.co.uk> wrote in message
news:bl**********@news7.svr.pol.co.uk...

"Bill Cunningham" <no****@net.net> wrote in message
What is C inlinging? Or inlining. Does it have something to do with
using C and assembly language together? I know some of the linux
kernel is inlined and it's written in C with a little assembly.

Most compilers allow you to add assembly statements to C code, typically
using "asm" as a keyword.
Needless to say, the details are very platform-specific, and such code is
not portable.


OTOH, inlining may have nothing to do with asm. The C99 keyword inline,
supported by many pre-C99 compilers as a common extension, means basically
that the function body is expanded whenever the function declared as
inline is called. This saves a function call overhead and allows for
better optimization, but tends to bloat the code if the inline function
is used in more than one place.

Sorry if this has been mentioned in the thread already, I have joined only
now and have not seen any other reply than Malcolm's.
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Tony Vitonis | last post by:
From what I can tell, VB.NET doesn't allow programmers to say explicitly that they want a function to be inlined. Now, I'm a big fan of factoring out duplicate code, but I don't want to do too...
6
by: glen_stark | last post by:
Hi. I'm just curious if there any warnings or caveats or whatever to be aware of when inlining function object calls? If the answer is no, they inline just like everything else, that's good...
10
by: gianguz | last post by:
The question is about the possible use of inlining to improve performance in a heavy multithreading environment (200+ threads). If we have to work with applications in which threads aren't I/O...
5
by: Raphael | last post by:
Hello, I have 2 files A.c : Defining a bunch of usefull functions B.c : Defining a main that uses these ones. I need to improve perfs : I know that, if the caller and the functions called...
11
by: Elpoca | last post by:
Hi: What rules govern the inlining of templated functions and templated class methods? It has always been my understanding that both templated functions and templated class methods were...
21
by: LuB | last post by:
How judicious ought one be when inlining small methods. I once read that in general, most compiles will only inline 'one' level. IE: if all the following methods were declared/defined as...
15
by: Lloyd Dupont | last post by:
I have some code which looks like that: public CornerStyle RectCornerMode { get { return this.GetValue<CornerStyle>(); } set { this.SetValue<CornerStyle>(value); } }
21
by: Michael Hull | last post by:
Hi, I remember from somewhere reading that inlining constructors is a 'BadThing', but now can't seem to find the original source. I can't however thing of a reason why it would be for simple...
8
by: Yakov | last post by:
I'd like a tool that performed inlining of function bodies of which do not appear in the .h file. Really. gcc on Linux. Yakov
58
by: sh.vipin | last post by:
is there any way to find out number of bytes freed on a particular free() call in C
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.