Date: Tue, 12 Sep 2000 11:52:11 -0700 (PDT) From: Mikko Tyolajarvi <mikko@dynas.se> To: zzhang@cs.binghamton.edu Cc: freebsd-questions@freebsd.org Subject: Re: where is system() implemented? Message-ID: <200009121852.e8CIqBw04231@explorer.rsa.com> References: <Pine.SOL.4.21.0009121046160.22903-100000@sol.cs.binghamton.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
In local.freebsd-questions Zhihui Zhang <zzhang@cs.binghamton.edu> 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 <sys/cdefs.h>. 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009121852.e8CIqBw04231>