From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: oops? read/write vs type of length parameter Date: Tue, 12 Apr 2011 06:01:36 +0300 Message-ID: <83k4f0qijz.fsf@gnu.org> References: <87wrj1jhfc.fsf@rho.meyering.net> <87hba5yq0p.fsf@uwakimon.sk.tsukuba.ac.jp> <834o64sxd7.fsf@gnu.org> <4DA3A7F8.1020503@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1302577403 17660 80.91.229.12 (12 Apr 2011 03:03:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 12 Apr 2011 03:03:23 +0000 (UTC) Cc: emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 12 05:03:18 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from [140.186.70.17] (helo=lists.gnu.org) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q9Tss-0006mc-7c for ged-emacs-devel@m.gmane.org; Tue, 12 Apr 2011 05:03:18 +0200 Original-Received: from localhost ([::1]:53898 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9Tsr-0000ZD-Cp for ged-emacs-devel@m.gmane.org; Mon, 11 Apr 2011 23:03:17 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:41998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9Tso-0000Yn-N5 for emacs-devel@gnu.org; Mon, 11 Apr 2011 23:03:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q9Tsn-0005wt-Gs for emacs-devel@gnu.org; Mon, 11 Apr 2011 23:03:14 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:38655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9Tsn-0005we-AH for emacs-devel@gnu.org; Mon, 11 Apr 2011 23:03:13 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0LJI00M00R281P00@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Tue, 12 Apr 2011 06:03:10 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([77.127.31.148]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LJI00L80R58HHB0@a-mtaout20.012.net.il>; Tue, 12 Apr 2011 06:03:10 +0300 (IDT) In-reply-to: <4DA3A7F8.1020503@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.166 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-Broken-Reverse-DNS: no host name found for IP address 140.186.70.17 Xref: news.gmane.org gmane.emacs.devel:138415 Archived-At: > Date: Mon, 11 Apr 2011 18:16:40 -0700 > From: Paul Eggert > > emacs_read and emacs_write are a bit of a special case, > because by design Emacs always invokes them with a > small positive size (currently limited to 64 KiB, if memory > serves). That's not true. When Emacs saves a buffer or some its portion, write-region can call emacs_write (though a_write and e_write) with the full extent of the region to be saved. At least with a pure-ASCII file, that's how write-region works. Just step through the code with a debugger, and you will see it. That's why I changed the signature (and the local variables inside emacs_write): without that, you simply cannot save regions that are larger than 2GB. The previous version would leave the saved file empty, if invoked on large buffers. So it is not a theoretically motivated change; it had very specific real reason. The old signature simply didn't work in that case. > * When dealing with system objects, such as file descriptors > and C object sizes, use the relevant system types, > such as 'int' and 'size_t'. > > * When dealing with Emacs fixnums, which are always signed, > use EMACS_INT. The issue here is that emacs_write and emacs_read are on the boundary: they accept Emacs Lisp integers, but then call a system API. Thus the dilemma what to use in this case, which I resolved in favor of the system type. sysdep.c in general uses system types.