Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 0
Integer division operation in Linux kernel

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

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

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
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.


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 12:44 PM.

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