From owner-freebsd-questions Wed Aug 28 6:41:23 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4DF9B37B400 for ; Wed, 28 Aug 2002 06:41:19 -0700 (PDT) Received: from mail.navitaire.com (mail.navitaire.com [205.182.62.81]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F06943E4A for ; Wed, 28 Aug 2002 06:41:18 -0700 (PDT) (envelope-from brian.henning@navitaire.com) Received: from exchange.Navitaire.com (exch.navitaire.com [149.122.4.14]) by mail.navitaire.com (Switch-2.1.4/Switch-2.1.0) with ESMTP id g7SDfIp23346 for ; Wed, 28 Aug 2002 08:41:18 -0500 (CDT) Received: by exchange.Navitaire.com with Internet Mail Service (5.5.2653.19) id ; Wed, 28 Aug 2002 08:40:40 -0500 Message-ID: From: "Henning, Brian" To: " (E-mail)" Subject: pthreads compiler warnings Date: Wed, 28 Aug 2002 08:40:39 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hello- i am trying to run the following code but, when i do i get these errors. Am i linking to the wrong library or doing something wrong? I read the man pages and it said to use libc_r for a threaded user program. thanks, brian > gcc thread_example.c -lc_r /usr/lib/libc.so: WARNING! setkey(3) not present in the system! /usr/lib/libc.so: warning: this program uses gets(), which is unsafe. /usr/lib/libc.so: warning: mktemp() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so: WARNING! des_setkey(3) not present in the system! /usr/lib/libc.so: WARNING! encrypt(3) not present in the system! /usr/lib/libc.so: warning: tmpnam() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so: warning: this program uses f_prealloc(), which is not recommended. /usr/lib/libc.so: WARNING! des_cipher(3) not present in the system! /usr/lib/libc.so: warning: tempnam() possibly used unsafely; consider using mkstemp() #include #include #define NUM_THREADS 3 void *BusyWork(void *null) { int i; double result = 0.0; for( i = 0; i < 1000000; i++ ) { result = result + (double)random(); } printf("result = %d\n",result); pthread_exit((void *) 0); } int main( int argc, char *argv[] ) { pthread_t thread[NUM_THREADS]; pthread_attr_t attr; int rc, t, status; /* Initialize and set thread detached attribute */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); for( t = 0; t < NUM_THREADS; t++ ) { printf("Creating thread %d\n", t); rc = pthread_create(&thread[t], &attr, BusyWork, NULL); if (rc) { printf("ERROR; return code from pthread_create() is %d\n", rc); exit(-1); } } /* Free attribute and wait for the other threads */ pthread_attr_destroy(&attr); for( t = 0; t < NUM_THREADS; t++ ) { rc = pthread_join(thread[t], (void **)&status); if (rc) { printf("ERROR; return code from pthread_join() is %d\n", rc); exit(-1); } printf("Completed join with thread %d status= %d\n",t, status); } pthread_exit(NULL); return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message