From owner-freebsd-questions Wed Aug 28 9: 6:31 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 761C637B400 for ; Wed, 28 Aug 2002 09:06:25 -0700 (PDT) Received: from creme-brulee.marcuscom.com (rdu57-17-158.nc.rr.com [66.57.17.158]) by mx1.FreeBSD.org (Postfix) with ESMTP id A558043E4A for ; Wed, 28 Aug 2002 09:06:24 -0700 (PDT) (envelope-from marcus@marcuscom.com) Received: from [10.2.1.0] (vpn-client-0.marcuscom.com [10.2.1.0]) by creme-brulee.marcuscom.com (8.12.5/8.12.5) with ESMTP id g7SG5Pix098727; Wed, 28 Aug 2002 12:05:25 -0400 (EDT) (envelope-from marcus@marcuscom.com) Subject: Re: pthreads compiler warnings From: Joe Marcus Clarke To: "Henning, Brian" Cc: "(E-mail)" In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 28 Aug 2002 12:06:10 -0400 Message-Id: <1030550771.329.1.camel@gyros.marcuscom.com> Mime-Version: 1.0 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 On Wed, 2002-08-28 at 09:40, Henning, Brian wrote: > 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. Don't explicitly link libc into your application. For example, on -stable, you should compile this like: > cc -o xxx -pthread xxx.c On -current: > cc -o xxx -lc_r xxx.c Joe > 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 > -- PGP Key : http://www.marcuscom.com/pgp.asc To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message