LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 09-09-2009, 03:59 AM   #1
MahendraL
LQ Newbie
 
Registered: Jul 2009
Posts: 10

Rep: Reputation: 0
Integer division operation in Linux kernel


Hi,
is integer (int or unsigned int) division operation in a
Linux kernel module always guaranteed to compile and work on all CPUs ?

Thanks,
Mahendra
 
Old 09-09-2009, 08:10 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,368
Blog Entries: 52

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Assuming you are writing in C (or some other high level language), it is up to the compiler to create valid assembly code for the division operation, no matter what the CPU is.

Of course, you will have to precheck the dividend to make sure that you don't get divide by zero errors in the kernel.

There are some math operations that are strongly discouraged in the kernel, such as floating point (because the floating point state is not saved during system calls). There could also be some routines (such as the longlong division) missing, since kernel code wouldn't normally use the standard C library.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
porting linux kernel list operation to user space? soararing Programming 2 11-24-2007 07:49 AM
LXer: Title: Linux Kernel "get_fdb_entries()" Integer Overflow ... LXer Syndicated Linux News 0 11-30-2006 04:03 PM
LXer: Interview: Guy Martin of Motorola's Linux Division LXer Syndicated Linux News 0 08-30-2006 03:03 AM
Error upgrading kernel, /sbin/mkinitrdi integer expression expected amp2000 Linux - General 2 12-05-2003 06:38 AM
Kernel Panic during tar operation ryanz Linux - Newbie 1 10-26-2003 07:29 PM


All times are GMT -5. The time now is 07:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration