From owner-freebsd-questions Tue Sep 12 11:52:24 2000 Delivered-To: freebsd-questions@freebsd.org Received: from karon.dynas.se (karon.dynas.se [192.71.43.4]) by hub.freebsd.org (Postfix) with SMTP id 7D2AE37B43E for ; Tue, 12 Sep 2000 11:52:20 -0700 (PDT) Received: (qmail 25489 invoked from network); 12 Sep 2000 18:52:18 -0000 Received: from spirit.sto.dynas.se (HELO spirit.dynas.se) (172.16.1.10) by karon.sto.dynas.se with SMTP; 12 Sep 2000 18:52:18 -0000 Received: (qmail 15342 invoked from network); 12 Sep 2000 18:52:23 -0000 Received: from explorer.rsa.com (10.81.217.59) by spirit.dynas.se with SMTP; 12 Sep 2000 18:52:23 -0000 Received: (from mikko@localhost) by explorer.rsa.com (8.11.0/8.11.0) id e8CIqBw04231; Tue, 12 Sep 2000 11:52:11 -0700 (PDT) (envelope-from mikko) Date: Tue, 12 Sep 2000 11:52:11 -0700 (PDT) From: Mikko Tyolajarvi Message-Id: <200009121852.e8CIqBw04231@explorer.rsa.com> To: zzhang@cs.binghamton.edu Cc: freebsd-questions@freebsd.org Subject: Re: where is system() implemented? Newsgroups: local.freebsd-questions References: X-Newsreader: NN version 6.5.6 (NOV) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In local.freebsd-questions Zhihui Zhang writes: >The library call __system() is implemented in lib/libc/stdlib/system.c. >But we normally use it as system() without the two preceding '_' >characters. Where is the magic done to add the "__" in the source code? >Thanks. Scroll to the bottom of system.c, and you will find (on -STABLE at least): #ifndef _THREAD_SAFE __weak_reference(__system, system); #endif For libc, this creates a "weak reference" (linker magic: sort-of an alias, which is used unless overridden by a "real" symbol by the same name). The __weak_reference() macro seems to be implemented in . When compiling libc_r, lib/lic_r/uthread/uthead_system.c implements a "wrapper" system() function, doing some threading magic, before calling the actual __system() function. Remember, "grep" is your friend :-) $.02, /Mikko -- Mikko Työläjärvi_______________________________________mikko@rsasecurity.com RSA Security To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message