Reputation: 191
libc_hidden_builtin_def (strspn)
I found the code above in glibc-2.18/string/strspn.c
.
Can someone explain what this mean. Is this important to rest of the code?
Here is the content of the file strspn.c
:
#include <string.h>
#undef strspn
/* Return the length of the maximum initial segment
of S which contains only characters in ACCEPT. */
size_t strspn (s, accept) const char *s; const char *accept; {
const char *p;
const char *a;
size_t count = 0;
for (p = s; *p != '\0'; ++p) {
for (a = accept; *a != '\0'; ++a) {
if (*p == *a)
break;
if (*a == '\0')
return count;
else
++count;
}
}
return count;
}
libc_hidden_builtin_def (strspn)
Upvotes: 1
Views: 2529
Reputation: 213754
Can someone explain what this mean.
It's a #define
d macro, which expands to nothing when building (non-shared) libc.a, and to:
extern __typeof (strcspn) __EI_strcspn __asm__("" "strcspn");
extern __typeof (strcspn) __EI_strcspn __attribute__((alias ("" "__GI_strcspn")));
when compiling libc.so.6.
What this does is define a symbol alias __GI_strcspn
that has the same value as strcspn
, but is not exported out of libc.so.6 (i.e. it's an internal symbol).
Is this important to rest of the code?
Yes: other code inside libc.so.6
may call this symbol without possibility to interpose it in e.g. LD_PRELOADED
library.
Upvotes: 4