From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1181 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Silly question about strncpy(), strlen() and related funcs Date: Mon, 18 Jun 2012 22:35:14 +0200 Message-ID: <20120618203514.GW17860@port70.net> References: <20120619025409.4ec1ed49@sibserver.ru> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1340051728 25710 80.91.229.3 (18 Jun 2012 20:35:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 18 Jun 2012 20:35:28 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1182-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jun 18 22:35:27 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1SgifW-0003Iq-Eo for gllmg-musl@plane.gmane.org; Mon, 18 Jun 2012 22:35:26 +0200 Original-Received: (qmail 9862 invoked by uid 550); 18 Jun 2012 20:35:26 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 9854 invoked from network); 18 Jun 2012 20:35:26 -0000 Content-Disposition: inline In-Reply-To: <20120619025409.4ec1ed49@sibserver.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:1181 Archived-At: * orc [2012-06-19 02:54:09 +0800]: > What ALIGN and additional checks like 'if (((uintptr_t)s & ALIGN) == > ((uintptr_t)d & ALIGN))' {...} are mean in src/string/strpcpy.c and > similiar functions? i assume you meant stpncpy.c it checks whether s(ource) and d(estination) pointers have the same alignment relative to word boundaries (uintptr_t)s makes the pointer available for integer arithmetics ALIGN is a bit mask 00..01..11 such that a word aligned pointer has 0 bits where ALIGN has 1s so the expression (uintptr_t)s & ALIGN checks if s is word aligned (eg on 32bit systems a word aligned pointer is a multiple of 4 so it should end with two 0s) (alignment matters because even though the granularity of addressing is 1byte, load/store of >1byte objects can only be done (efficiently) with certain alignment)