Bug 46516
Summary: | pthread functions declared as macros instead of functions | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | John William <jw2357> |
Component: | glibc | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED NOTABUG | QA Contact: | Aaron Brown <abrown> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 7.0 | CC: | fweimer |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i586 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2001-07-24 04:28:44 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
John William
2001-06-29 03:55:24 UTC
How exactly it does not compile? It works just fine for me (well, to get rid of warnings a (void (*)(void *)) cast is desirable). What error messages do you get? What glibc rpm version and release are you using? I'm using glibc-2.2.2-10 (-devel and -common are also 2.2.2-10). The following code will not compile: #include <pthread.h> main() { pthread_mutex_t threads_mutex; pthread_cleanup_push(pthread_mutex_unlock, (void *)&threads_mutex); pthread_mutex_lock(&threads_mutex); if (1) { pthread_mutex_unlock(&threads_mutex); pthread_cleanup_pop(0); } else { pthread_mutex_unlock(&threads_mutex); pthread_cleanup_pop(0); } } It fails with: test.c: In function `main': test.c:7: warning: passing arg 2 of `_pthread_cleanup_push' from incompatible po inter type test.c:15: parse error before `else' test.c:18: `_buffer' undeclared (first use in this function) test.c:18: (Each undeclared identifier is reported only once test.c:18: for each function it appears in.) test.c: At top level: test.c:19: parse error before `}' I was originally mistaken - it's actually the way pthread_cleanup_push() and ..._pop() are written that makes code not compile. From looking at the preprocessor output, both the _push() and the _pop() need to be at the same level. This is nonsense, as these should be true functions. These cannot be functions, please read the documentation: Matching pairs of `pthread_cleanup_push' and `pthread_cleanup_pop' must occur in the same function, at the same level of block nesting. Actually, `pthread_cleanup_push' and `pthread_cleanup_pop' are macros, and the expansion of `pthread_cleanup_push' introduces an open brace `{' with the matching closing brace `}' being introduced by the expansion of the matching `pthread_cleanup_pop'. |