This email didn't make it onto the mailing list, probably due to the size limit. We're trying to persuade iftop to compile on NetBSD, which like any decent UNIX has its own, uniquely broken pthread implementation. This one doesn't seem to be able to spell "pthread_cancel".
Chris, as someone who's suffered more at the hands of broken pthread implementations, is this something you've seen before?
Paul
On Mon, Mar 08, 2004 at 06:52:34PM -0600, John Thompson wrote:
configure:6465: gcc -o conftest -g -O2 -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses >&5 configure:6468: $? = 0 configure:6471: test -s conftest configure:6474: $? = 0 configure:6498: result: -lncurses configure:6504: checking how to compile a working program with POSIX threads configure:6524: gcc -o conftest -g -O2 -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses
&5/var/tmp/ccbn0NX0.o: In function `worker_thread':
/tmp/iftop-0.16/configure:6542: undefined reference to `pthread_mutex_lock'/tmp/iftop-0.16/configure:6543: undefined reference to `pthread_cond_signal'/tmp/iftop-0.16/configure:6544: undefined reference to `pthread_mutex_unlock'/tmp/iftop-0.16/configure:6547: undefined reference to `pthread_testcancel'/var/tmp/ccbn0NX0.o: In function `main':/tmp/iftop-0.16/configure:6559: undefined reference to `pthread_mutex_lock'/tmp/iftop-0.16/configure:6559: undefined reference to `pthread_create'/tmp/iftop-0.16/configure:6569: undefined reference to `pthread_cond_timedwait'/tmp/iftop-0.16/configure:6576: undefined reference to `pthread_cancel'/tmp/iftop-0.16/configure:6576: undefined reference to `pthread_join' configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses -lpthread
&5
/usr/pkg/pthreads/lib//libpthread.so: warning: reference to compatibility sys_errlist[]; include <errno.h> for correct reference/usr/pkg/pthreads/lib//libpthread.so: warning: reference to compatibility sys_nerr; include <errno.h> for correct reference/var/tmp/ccL8U8Of.o: In function `worker_thread':/tmp/iftop-0.16/configure:6547: undefined reference to `pthread_testcancel'/var/tmp/ccL8U8Of.o: In function `main': /tmp/iftop-0.16/configure:6576: undefined reference to `pthread_cancel' configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses -lpthread -lposix4 >&5 ld: cannot find -lposix4 configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -mt -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses >&5 cc1: Invalid option `t' configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -mt -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses -lpthread
&5
cc1: Invalid option `t' configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -mt -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses -lpthread -lposix4 >&5 cc1: Invalid option `t' configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -pthread -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses >&5 gcc: unrecognized option `-pthread'/var/tmp/ccVLEfkq.o: In function `worker_thread':/tmp/iftop-0.16/configure:6542: undefined reference to `pthread_mutex_lock'/tmp/iftop-0.16/configure:6543: undefined reference to `pthread_cond_signal'/tmp/iftop-0.16/configure:6544: undefined reference to `pthread_mutex_unlock'/tmp/iftop-0.16/configure:6547: undefined reference to `pthread_testcancel'/var/tmp/ccVLEfkq.o: In function `main':/tmp/iftop-0.16/configure:6559: undefined reference to `pthread_mutex_lock'/tmp/iftop-0.16/configure:6559: undefined reference to `pthread_create'/tmp/iftop-0.16/configure:6569: undefined reference to `pthread_cond_timedwait'/tmp/iftop-0.16/configure:6576: undefined reference to `pthread_cancel'/tmp/iftop-0.16/configure:6576: undefined reference to `pthread_join' configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -pthread -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses -lpthread
&5
gcc: unrecognized option `-pthread' /usr/pkg/pthreads/lib//libpthread.so: warning: reference to compatibility sys_errlist[]; include <errno.h> for correct reference/usr/pkg/pthreads/lib//libpthread.so: warning: reference to compatibility sys_nerr; include <errno.h> for correct reference/var/tmp/cc5PSfvD.o: In function `worker_thread':/tmp/iftop-0.16/configure:6547: undefined reference to `pthread_testcancel'/var/tmp/cc5PSfvD.o: In function `main': /tmp/iftop-0.16/configure:6576: undefined reference to `pthread_cancel' configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -pthread -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses -lpthread -lposix4 >&5 gcc: unrecognized option `-pthread' ld: cannot find -lposix4 configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -thread -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses >&5 gcc: unrecognized option `-thread'/var/tmp/ccBEe91M.o: In function `worker_thread':/tmp/iftop-0.16/configure:6542: undefined reference to `pthread_mutex_lock'/tmp/iftop-0.16/configure:6543: undefined reference to `pthread_cond_signal'/tmp/iftop-0.16/configure:6544: undefined reference to `pthread_mutex_unlock'/tmp/iftop-0.16/configure:6547: undefined reference to `pthread_testcancel'/var/tmp/ccBEe91M.o: In function `main':/tmp/iftop-0.16/configure:6559: undefined reference to `pthread_mutex_lock'/tmp/iftop-0.16/configure:6559: undefined reference to `pthread_create'/tmp/iftop-0.16/configure:6569: undefined reference to `pthread_cond_timedwait'/tmp/iftop-0.16/configure:6576: undefined reference to `pthread_cancel'/tmp/iftop-0.16/configure:6576: undefined reference to `pthread_join' configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -thread -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses -lpthread
&5
gcc: unrecognized option `-thread' /usr/pkg/pthreads/lib//libpthread.so: warning: reference to compatibility sys_errlist[]; include <errno.h> for correct reference/usr/pkg/pthreads/lib//libpthread.so: warning: reference to compatibility sys_nerr; include <errno.h> for correct reference/var/tmp/ccFxVAF0.o: In function `worker_thread':/tmp/iftop-0.16/configure:6547: undefined reference to `pthread_testcancel'/var/tmp/ccFxVAF0.o: In function `main': /tmp/iftop-0.16/configure:6576: undefined reference to `pthread_cancel' configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6524: gcc -o conftest -g -O2 -thread -L/usr/pkg/pthreads/lib/ -I/usr/pkg/pthreads/include conftest.c -lpcap -lm -lncurses -lpthread -lposix4 >&5 gcc: unrecognized option `-thread' ld: cannot find -lposix4 configure:6527: $? = 1 configure: program exited with status 1 configure: failed program was: #line 6518 "configure" #include "confdefs.h" /*
- pthread.c:
- Tiny test program to see whether POSIX threads work.
*/
static const char rcsid[] = "$Id: pthread.c,v 1.3 2004/01/20 09:51:48 pdw Exp $";
#include <sys/types.h>
#include <errno.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int return_value = -1;
void *worker_thread(void *v) { /* Record successful return and signal parent to wake up. */ return_value = 0; pthread_mutex_lock(&mtx); pthread_cond_signal(&cond); pthread_mutex_unlock(&mtx); while (1) { sleep(1); pthread_testcancel(); } }
/* Start a thread, and have it set a variable to some other value, then signal * a condition variable. If this doesn't happen within some set time, we assume * that something's gone badly wrong and abort (for instance, the thread never * got started). */ int main(void) { pthread_t thr; int res; struct timespec deadline = {0}; if ((res = pthread_mutex_lock(&mtx)) != 0 || (res = pthread_create(&thr, NULL, worker_thread, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
/* Thread should now be running; we should wait on the condition * variable. */ do deadline.tv_sec = 2 + time(NULL); while ((res = pthread_cond_timedwait(&cond, &mtx, &deadline)) ==
EINTR); if (res != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; }
if ((res = pthread_cancel(thr)) != 0 || (res = pthread_join(thr, NULL)) != 0) { fprintf(stderr, "%s\n", strerror(res)); return -1; } return return_value;
} configure:6554: result: no idea configure:6557: error: can't figure out how to compile with POSIX threads If your system actually supports POSIX threads, this means we've messed up.
## ---------------- ## ## Cache variables. ## ## ---------------- ##
ac_cv_build=i386-unknown-netbsdelf1.6.1 ac_cv_build_alias=i386-unknown-netbsdelf1.6.1 ac_cv_c_compiler_gnu=yes ac_cv_c_const=yes ac_cv_env_CC_set= ac_cv_env_CC_value= ac_cv_env_CFLAGS_set= ac_cv_env_CFLAGS_value= ac_cv_env_CPPFLAGS_set=set ac_cv_env_CPPFLAGS_value=-L/usr/pkg/pthreads/lib/ ac_cv_env_CPP_set= ac_cv_env_CPP_value= ac_cv_env_LDFLAGS_set=set ac_cv_env_LDFLAGS_value=-I/usr/pkg/pthreads/include ac_cv_env_build_alias_set= ac_cv_env_build_alias_value= ac_cv_env_host_alias_set= ac_cv_env_host_alias_value= ac_cv_env_target_alias_set= ac_cv_env_target_alias_value= ac_cv_exeext= ac_cv_func_gethostbyname=yes ac_cv_func_inet_aton=yes ac_cv_func_inet_pton=yes ac_cv_func_regcomp=yes ac_cv_func_select=yes ac_cv_func_strdup=yes ac_cv_func_strerror=yes ac_cv_func_strspn=yes ac_cv_header_inttypes_h=yes ac_cv_header_memory_h=yes ac_cv_header_pcap_h=yes ac_cv_header_stdc=yes ac_cv_header_stdint_h=yes ac_cv_header_stdlib_h=yes ac_cv_header_string_h=yes ac_cv_header_strings_h=yes ac_cv_header_sys_dlpi_h=no ac_cv_header_sys_ioctl_h=yes ac_cv_header_sys_sockio_h=yes ac_cv_header_sys_stat_h=yes ac_cv_header_sys_time_h=yes ac_cv_header_sys_types_h=yes ac_cv_header_time=yes ac_cv_header_unistd_h=yes ac_cv_host=i386-unknown-netbsdelf1.6.1 ac_cv_host_alias=i386-unknown-netbsdelf1.6.1 ac_cv_lib_pcap_pcap_open_live=yes ac_cv_objext=o ac_cv_path_install='/usr/bin/install -c' ac_cv_prog_AWK=awk ac_cv_prog_CPP='gcc -E' ac_cv_prog_ac_ct_CC=gcc ac_cv_prog_cc_g=yes ac_cv_prog_cc_stdc= ac_cv_prog_make_make_set=yes ac_cv_search_gethostbyaddr='none required' ac_cv_search_gethostbyaddr_r=no ac_cv_search_getnameinfo='none required' ac_cv_search_inet_aton='none required' ac_cv_search_inet_pton='none required' ac_cv_search_log=-lm ac_cv_search_socket='none required' ac_cv_target=i386-unknown-netbsdelf1.6.1 ac_cv_target_alias=i386-unknown-netbsdelf1.6.1 ac_cv_type_size_t=yes am_cv_CC_dependencies_compiler_type=gcc
## ----------- ## ## confdefs.h. ## ## ----------- ##
#define PACKAGE_NAME "" #define PACKAGE_TARNAME "" #define PACKAGE_VERSION "" #define PACKAGE_STRING "" #define PACKAGE_BUGREPORT "" #define PACKAGE "iftop" #define VERSION "0.16" #define IFTOP_VERSION "0.16" #define STDC_HEADERS 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_STAT_H 1 #define HAVE_STDLIB_H 1 #define HAVE_STRING_H 1 #define HAVE_MEMORY_H 1 #define HAVE_STRINGS_H 1 #define HAVE_INTTYPES_H 1 #define HAVE_STDINT_H 1 #define HAVE_UNISTD_H 1 #define HAVE_SYS_IOCTL_H 1 #define HAVE_SYS_TIME_H 1 #define HAVE_SYS_SOCKIO_H 1 #define HAVE_UNISTD_H 1 #define TIME_WITH_SYS_TIME 1 #define HAVE_REGCOMP 1 #define HAVE_SELECT 1 #define HAVE_STRDUP 1 #define HAVE_STRERROR 1 #define HAVE_STRSPN 1 #define HAVE_INET_ATON 1 #define HAVE_INET_PTON 1 #define SIZEOF_U_INT8_T 1 #define SIZEOF_U_INT16_T 2 #define SIZEOF_U_INT32_T 4 #define USE_FORKING_RESOLVER 1 #define HAVE_LIBPCAP 1 #define HAVE_PCAP_H 1
configure: exit 1
The proper fix is to add a --with-pthread option, much like the --with-libpcap option to configure.in. Patches gratefully received - I won't be doing this myself as I have a broken hand and typing is painfully slow...
Bummer. I'll help if I can -- assuming I can get this working... :-)
--
-John (JohnThompson@new.rr.com)
On Fri, Mar 12, 2004 at 03:20:37PM +0000, Paul Warren wrote:
This email didn't make it onto the mailing list, probably due to the size limit. We're trying to persuade iftop to compile on NetBSD, which like any decent UNIX has its own, uniquely broken pthread implementation. This one doesn't seem to be able to spell "pthread_cancel".
hmm. From the transcript it looks like it's failing to link with the pthread library. The thing to do is probably to figure out how to compile a pthread program (like the test one), perhaps from the pthread(3) man page, then try to figure out why configure isn't figuring it out. Are the NetBSD man pages online?
On Fri, Mar 12, 2004 at 03:28:28PM +0000, Chris Lightfoot wrote:
On Fri, Mar 12, 2004 at 03:20:37PM +0000, Paul Warren wrote:
This email didn't make it onto the mailing list, probably due to the size limit. We're trying to persuade iftop to compile on NetBSD, which like any decent UNIX has its own, uniquely broken pthread implementation. This one doesn't seem to be able to spell "pthread_cancel".
hmm. From the transcript it looks like it's failing to link with the pthread library. The thing to do is probably to figure out how to compile a pthread program (like the test one), perhaps from the pthread(3) man page, then try to figure out why configure isn't figuring it out. Are the NetBSD man pages online?
Hmm. I think previously it was failing to link against loads of things, and now it's just down to that one function, BICBW.
Paul
On Fri, Mar 12, 2004 at 03:33:48PM +0000, Paul Warren wrote:
On Fri, Mar 12, 2004 at 03:28:28PM +0000, Chris Lightfoot wrote:
On Fri, Mar 12, 2004 at 03:20:37PM +0000, Paul Warren wrote:
This email didn't make it onto the mailing list, probably due to the size limit. We're trying to persuade iftop to compile on NetBSD, which like any decent UNIX has its own, uniquely broken pthread implementation. This one doesn't seem to be able to spell "pthread_cancel".
hmm. From the transcript it looks like it's failing to link with the pthread library. The thing to do is probably to figure out how to compile a pthread program (like the test one), perhaps from the pthread(3) man page, then try to figure out why configure isn't figuring it out. Are the NetBSD man pages online?
Hmm. I think previously it was failing to link against loads of things, and now it's just down to that one function, BICBW.
Quite right, I was only reading the top of the log :(
According to the man pages for -current on http://www.netbsd.org/, the implementation supports pthread_cancel and pthread_testcancel, and all you need to do is link with -lpthread. Dunno about older versions though.
Can you try compiling the test program (config/pthread.c) with,
cc -lpthread -g -Wall -o pthread pthread.c
and tell me what you get?
On Fri, 12 Mar 2004 15:38:44 +0000 Chris Lightfoot chris@ex-parrot.com wrote:
Can you try compiling the test program (config/pthread.c) with,
cc -lpthread -g -Wall -o pthread pthread.c
and tell me what you get?
Sure:
-bash-2.05b$ cc -I/usr/pkg/include -lpthread -g -Wall -o pthread pthread.c pthread.c: In function `worker_thread': pthread.c:29: warning: implicit declaration of function `pthread_testcancel' pthread.c: In function `main': pthread.c:58: warning: implicit declaration of function`pthread_cancel' ld: cannot find -lpthread
On Fri, Mar 12, 2004 at 11:16:03AM -0600, John Thompson wrote:
On Fri, 12 Mar 2004 15:38:44 +0000 Chris Lightfoot chris@ex-parrot.com wrote:
Can you try compiling the test program (config/pthread.c) with,
cc -lpthread -g -Wall -o pthread pthread.c
and tell me what you get?
Sure:
-bash-2.05b$ cc -I/usr/pkg/include -lpthread -g -Wall -o pthread pthread.c pthread.c: In function `worker_thread': pthread.c:29: warning: implicit declaration of function `pthread_testcancel' pthread.c: In function `main': pthread.c:58: warning: implicit declaration of function`pthread_cancel' ld: cannot find -lpthread
hmm. Are you running -current? Is there a man page for pthread_cancel on your system?
On Fri, 12 Mar 2004 17:20:17 +0000 Chris Lightfoot chris@ex-parrot.com wrote:
hmm. Are you running -current? Is there a man page for pthread_cancel on your system?
I am running NetBSD 1.6.1.
No man entry for pthread_cancel.
Perhaps this function was added to -curent since I installed NetBSD 1.6.1 last summer...
On Fri, Mar 12, 2004 at 11:16:03AM -0600, John Thompson wrote:
Can you try compiling the test program (config/pthread.c) with,
cc -lpthread -g -Wall -o pthread pthread.c
and tell me what you get?
Sure:
-bash-2.05b$ cc -I/usr/pkg/include -lpthread -g -Wall -o pthread pthread.c pthread.c: In function `worker_thread': pthread.c:29: warning: implicit declaration of function `pthread_testcancel' pthread.c: In function `main': pthread.c:58: warning: implicit declaration of function`pthread_cancel' ld: cannot find -lpthread
^^^^^^^^^^^^^^^^^^^^^^^^^
Try:
cc -I/usr/pkg/include -L/usr/pkg/wotsit -lpthread -g -Wall -o pthread
Paul
On Fri, 12 Mar 2004 15:28:28 +0000 Chris Lightfoot chris@ex-parrot.com wrote:
On Fri, Mar 12, 2004 at 03:20:37PM +0000, Paul Warren wrote:
This email didn't make it onto the mailing list, probably due to the size limit. We're trying to persuade iftop to compile on NetBSD, which like any decent UNIX has its own, uniquely broken pthread implementation. This one doesn't seem to be able to spell "pthread_cancel".
hmm. From the transcript it looks like it's failing to link with the pthread library. The thing to do is probably to figure out how to compile a pthread program (like the test one), perhaps from the pthread(3) man page, then try to figure out why configure isn't figuring it out. Are the NetBSD man pages online?
Yes:
http://netbsd.gw.com/cgi-bin/man-cgi?++NetBSD-current