Hidden strcmp in glibc


 
Thread Tools Search this Thread
Top Forums Programming Hidden strcmp in glibc
# 1  
Old 03-12-2013
Hidden strcmp in glibc

In glibc in file strcmp I see a definition of strcmp function and below it there is a macro "libc_hidden_builtin_def (strcmp)".
This macro "libc_hidden_builtin_def (strcmp)" looks to be defining some platform(x32-64, i386) specific implementation of strcmp.

Question is when is this libc_hidden_builtin_def (strcmp) gets enabled, called and used?
# 2  
Old 03-12-2013
It's not a real function. g++ and many other compilers will inline these functions -- add a few instructions in the program itself, rather than doing an entire branch/return for a function. Since a branch/return may be as time-consuming as the comparison itself for such a simple thing as strcmp, this saves a lot of performance.
These 2 Users Gave Thanks to Corona688 For This Post:
# 3  
Old 03-12-2013
Some CPUs come pretty close to providing libc funtions, so a call and stack pushes are an undesirable overhead, while others need considerable code to do it, which can be had as a call, or optionally as an inlined function, depending on the compiler directives and options. If you strcmp once a day, why not do the call? If it is in an inner loop, inlining opens it up to scheduling compilers that rearrange the pieces for optimal CPU internal exploitation, like for CPUs with multiple parallel integer units calculating addresses and data.
These 2 Users Gave Thanks to DGPickett For This Post:
# 4  
Old 03-12-2013
And even CPU's which don't have direct support, may have less overhead for a small sequence of instructions than a function call.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 03-12-2013
Thanks Corona and DGPicket for the reply.
That clears my doubt.
# 6  
Old 03-12-2013
You gotta have it for compilations where it was not inlined. But branches and calls do mess up the instruction buffering and scheduling compiler efforts, very much like a seek flushing i/o buffers.
This User Gave Thanks to DGPickett For This Post:
# 7  
Old 03-12-2013
Ok thanks dgpickett.
Actually my call to getopt_long() is crashing in __strncmp_sse2 and so I had raised this post.
I will debug the inputs of getopt_long.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsync - how to copy hidden folder or hidden files when using full path

Hello. I use this command : rsync -av --include=".*" --dry-run "$A_FULL_PATH_S" "$A_FULL_PATH_D"The data comes from the output of a find command. And no full source directories are in use, only some files. Source example... (2 Replies)
Discussion started by: jcdole
2 Replies

2. UNIX and Linux Applications

Install glibc-debug for glibc-2.11.3-17.31.1 on SLES 11

I have to debug a function getopt_long in glibc-2.11.3-17.31.1. For that how can I download and install its corresponding glibc-debug on SLES 11? (8 Replies)
Discussion started by: rupeshkp728
8 Replies

3. UNIX for Dummies Questions & Answers

List all directories hidden or not hidden

I want to list all directories hidden or not hidden. ls -ld */ => shows only not hidden directories so i guess the answer would be to add the a option to show all files ls -lad */ => not working :confused: ls -la | grep "^d" => works But I would like to know why I can't use ls -lad... (4 Replies)
Discussion started by: servus
4 Replies

4. Ubuntu

glibc version

I need glibc version 2.2 - 2.11 for a installation. but i got glibc 2.0-2.1 from software centre... what to do? can u help? (8 Replies)
Discussion started by: paramad
8 Replies

5. Programming

glibc error

Hi All, This is my first time posting on this forum. I'd like to participate actively on this list. Here we go! I'm making a little application and I'm using ncurses. After a while using it, I receive the following error and the stack trace is shown: ***glibc detected*** malloc() :... (6 Replies)
Discussion started by: lagigliaivan
6 Replies

6. Shell Programming and Scripting

Finding Hidden files and protecting the folder containing hidden files from deletion

Hi. I have a script which is deleting files with a particular extension and older than 45 days.The code is: find <path> -name "<filename_pattern>" -mtime +45 -exec rm {} \; But the problem is that some important files are also getting deleted.To prevent this I have decide to make a dummy... (4 Replies)
Discussion started by: pochaw
4 Replies

7. UNIX for Advanced & Expert Users

install glibc-2.6.1

Hi, I have downloaded glibc-2.6.1.tar.tar. But I do not know how to install it on Xubuntu. Do you know ? Thank you. (4 Replies)
Discussion started by: big123456
4 Replies

8. Programming

strcmp core dumps

hi everyone, Right now when I do: strcmp(s1, s2); i get a core dump because at times s1 or s2 can be nothing so that makes strcmp() core dump. What is the solution, if at times I expect one of them (or both) to be NULL? I want to be able to compare that s1 is NULL and s2 is "blah" or... (6 Replies)
Discussion started by: annie
6 Replies

9. UNIX for Dummies Questions & Answers

glibc 2.2.2

After installing glibc 2.2.2 on my redhat 6.1 (with all necessary updates). I try to restart but my compter say i do not existst like you deleted root account and you are root. (i have seen people doing that ;-P ). I run configure with these command --bindir=/bin --sbindir=/sbin --libdir=/lib... (1 Reply)
Discussion started by: jurrien
1 Replies
Login or Register to Ask a Question