From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 3 14:04:11 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FA99106566B for ; Wed, 3 Feb 2010 14:04:11 +0000 (UTC) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [77.47.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id 5CEF68FC0C for ; Wed, 3 Feb 2010 14:04:09 +0000 (UTC) Received: from pm513-1.comsys.ntu-kpi.kiev.ua ([10.18.52.101]) by comsys.ntu-kpi.kiev.ua with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1NcfkI-0008R4-3b; Wed, 03 Feb 2010 15:58:18 +0200 Received: by pm513-1.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1001) id 030311CC23; Wed, 3 Feb 2010 16:03:13 +0200 (EET) Date: Wed, 3 Feb 2010 16:03:12 +0200 From: Andrey Simonenko To: Stefan Midjich Message-ID: <20100203140312.GA34290@pm513-1.comsys.ntu-kpi.kiev.ua> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Authenticated-User: simon@comsys.ntu-kpi.kiev.ua X-Authenticator: plain X-Invalid-HELO: Host impersonating [comsys.ntu-kpi.kiev.ua] X-Sender-Verify: SUCCEEDED (sender exists & accepts mail) X-Exim-Version: 4.63 (build at 06-Jan-2007 23:14:37) X-Date: 2010-02-03 15:58:18 X-Connected-IP: 10.18.52.101:46273 X-Message-Linecount: 46 X-Body-Linecount: 31 X-Message-Size: 1956 X-Body-Size: 1273 Cc: freebsd-hackers@freebsd.org Subject: Re: Does getc(3) use the read(2) syscall? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Feb 2010 14:04:11 -0000 Hello, On Wed, Feb 03, 2010 at 12:26:02PM +0100, Stefan Midjich wrote: > I'm having trouble looking this function up in the source tree, the trail > seems to end at __sys_read which has a bunch of prototypes but i can't find > the actual function code. > > So my question is primarily, does getc use the read system call eventually? The easiest way is to write a simple program with this function and run it under ktrace and verify all calls in the output of kdump. > > But i would also love it if someone could show me where __sys_read is > defined. Quick check of the path gave me the following: getc -> __sgetc -> __srget -> __srefill -> _sread -> [._read ] -> __sread -> _read Look how Assembler files for system calls invocations are generated in the lib/libc/sys/Makefile.inc file, and look at macro variables defined in the amd64/SYS.h file. If you understand the idea, then check read.S file in the /lib/libc/ directory and the output of "nm read.So". Declaration of _read() in libc/stdio/stdio.c is done by a trick with two header files namespace.h included before and un-namespace.h included after another header files. Looks like that __sys_read in libc/ is used in directories with thread code and prototype for __sys_read is defined there.