LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 01-29-2014, 10:41 AM   #1
Blue-Knight
LQ Newbie
 
Registered: Jan 2014
Distribution: LinuxMint
Posts: 11

Rep: Reputation: Disabled
Where to find Linux constants values?


In the "Linux Programmer's Manual" I find many names that represents a simple value, some of them are: O_RDWRCLONE_FILES, CLONE_FILES, O_RDWR, SIGCHLD, SIGSEGV...

But where to find which values they actually represent? How to find where they can be found (i.e. where they're defined)?

Thank you!

Last edited by Blue-Knight; 01-30-2014 at 05:50 AM.
 
Old 01-29-2014, 11:02 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,148

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
The header files that define these constants live under the /usr/include directory. They will be installed as part of the developer packages for the libraries which implement the code. For example, glibc-headers has the header files for the standard Linux libraries.
 
1 members found this post helpful.
Old 01-29-2014, 11:22 AM   #3
Blue-Knight
LQ Newbie
 
Registered: Jan 2014
Distribution: LinuxMint
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
The header files that define these constants live under the /usr/include directory. They will be installed as part of the developer packages for the libraries which implement the code. For example, glibc-headers has the header files for the standard Linux libraries.
Ah, there's no easy way then. I will have to search and then copy them one by one...

The good thing is that I will have to do this one time only.

Thank you!
 
Old 01-29-2014, 11:24 AM   #4
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
If you know what you're looking for using grep on the source code will be a quick and dirty way to find it.

Code:
grep -irl 'O_RDWRCLONE_FILES' /path/to/source/
See grep man page for a description of -i -r and -l options.
 
1 members found this post helpful.
Old 01-29-2014, 11:25 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Note: Specially O_RDWR comes from /usr/include/asm-generic/fcntl.h (But you are not supposed to include this file into your program -- 'man 2 open' tells you which headers you should include)
 
Old 01-29-2014, 11:32 AM   #6
Blue-Knight
LQ Newbie
 
Registered: Jan 2014
Distribution: LinuxMint
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Note: Specially O_RDWR comes from /usr/include/asm-generic/fcntl.h (But you are not supposed to include this file into your program -- 'man 2 open' tells you which headers you should include)
I know, the problem is that I cannot simply include any of those files because I'm not using C. I have to know the value of all of them...
 
Old 01-29-2014, 11:49 AM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Please don't tell you are trying to write code in Assembly...
 
Old 01-29-2014, 11:59 AM   #8
Blue-Knight
LQ Newbie
 
Registered: Jan 2014
Distribution: LinuxMint
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Please don't tell you are trying to write code in Assembly...
But I am. =X
 
Old 01-29-2014, 05:28 PM   #9
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 229Reputation: 229Reputation: 229
You can use preprocessor to get the values:
Code:
[/tmp]$ cat a.c
#define _GNU_SOURCE
#include <fcntl.h>
#include <sched.h>
#include <signal.h>

"CLONE_FILES"=CLONE_FILES
"O_RDWR"=O_RDWR
"SIGCHLD"=SIGCHLD
"SIGSEGV"=SIGSEGV
[/tmp]$ gcc -E a.c | tail -n 4
"CLONE_FILES"=0x00000400
"O_RDWR"=02
"SIGCHLD"=17
"SIGSEGV"=11
[/tmp]$
I'm not aware of a portable way of getting those constants included in assembly source code though.
 
1 members found this post helpful.
  


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
[SOLVED] Perl to find max and min values eminempark Programming 1 01-09-2013 04:45 AM
Trying to install PerlMagick (ImageMagick) - where do I find values for LIB / INC? gginnj Linux - General 9 06-03-2011 01:10 AM
Python, find unique values in a tuple or dictionary action_owl Programming 2 05-11-2010 07:16 PM
C++ Maximum values and global constants CoderMan Programming 9 09-29-2009 04:10 AM
find values and increment akelder Programming 3 07-16-2009 03:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:57 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