LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-29-2012, 02:58 AM   #1
ankitm
Member
 
Registered: Sep 2011
Posts: 33

Rep: Reputation: Disabled
LINUX_VERSION_CODE in c


Hi,
My Linux version is
Linux 2.6.9-42.ELsmp
I am printing the value of LINUX_VERSION_CODE in c program which comes out to be 132116.

I also tried to get the value by KERNEL_VERSION(2,6,9) which is 132617 as [(2 << 16)+(6<<8)+9 ] .

Does LINUX_VERSION_CODE and KERNEL_VERSION(2,6,9) calculates value differently ?

Please correct me if I am wrong as I am understanding LINUX_VERSION_CODE and KERNEL_VERSION(2,6,9) .

Thanks
 
Old 03-29-2012, 03:15 AM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 206Reputation: 206Reputation: 206
You can see these definitions in the top level Makefile of the Linux source tree. I pulled these from a 3.x series kernel source:

Code:
 986 define filechk_version.h
 987     (echo \#define LINUX_VERSION_CODE $(shell                             \
 988     expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL));     \
 989     echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
 990 endef
But anyway, your program is probably printing the user-space value defined in /usr/include/linux/version.h. So what's in there? 132116 ? On my system, the value is equivalent to 3.0.14, which is NOT the running kernel version. Rather, it is the version associated with the Linux headers when they got installed. I have since moved on to 3.0.16, but no one (not a package nor me) has updated the headers, I guess.

Particularly, an update to that file (<linux/version.h>) would result from running a make headers_install in the linux source tree.

Last edited by jhwilliams; 03-29-2012 at 03:18 AM.
 
Old 03-30-2012, 11:06 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,598

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
uname(2) is your friend
 
  


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



All times are GMT -5. The time now is 04:11 AM.

Main Menu
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