LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 02:59 AM   #1
MahendraL
LQ Newbie
 
Registered: Jul 2009
Posts: 29

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, 07:10 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
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



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 06:49 AM
LXer: Title: Linux Kernel "get_fdb_entries()" Integer Overflow ... LXer Syndicated Linux News 0 11-30-2006 03:03 PM
LXer: Interview: Guy Martin of Motorola's Linux Division LXer Syndicated Linux News 0 08-30-2006 02:03 AM
Error upgrading kernel, /sbin/mkinitrdi integer expression expected amp2000 Linux - General 2 12-05-2003 05:38 AM
Kernel Panic during tar operation ryanz Linux - Newbie 1 10-26-2003 06:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:44 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
Open Source Consulting | Domain Registration