RSS | technovelty home | page of ian | ianw@ieee.org
This question seems to come up constantly. A compile time check
for NPTL probably isn't what you want, since you can easily turn NPTL
on or off on a program with something like
LD_ASSUME_KERNEL. The following snippet is, AFAIK, the
best way to check for NPTL support.
#include <stdio.h>
#include <unistd.h>
#include <alloca.h>
#include <string.h>
int isnptl (void)
{
size_t n = confstr (_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
if (n > 0)
{
char *buf = alloca (n);
confstr (_CS_GNU_LIBPTHREAD_VERSION, buf, n);
if (strstr (buf, "NPTL"))
return 1;
}
return 0;
}
int main(void)
{
printf("NPTL: %s\n", isnptl() ? "yes" : "no");
return 0;
}
But more important is why are you checking?.
posted at: Thu, 10 Feb 2005 11:30 | in /code/c | permalink | add comment (0 others)

This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.