From: Takashi Iwai Subject: Re: [PATCH] Sample generation on big endian platforms was broken. Date: Fri, 03 Jul 2009 17:28:55 +0200 Message-ID: References: <1246630771.7922.25.camel@localhost.localdomain> <1246632695.7922.34.camel@localhost.localdomain> <1246633897.7922.39.camel@localhost.localdomain> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (cantor.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id 952B6248FF for ; Fri, 3 Jul 2009 17:28:55 +0200 (CEST) In-Reply-To: <1246633897.7922.39.camel@localhost.localdomain> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Kenneth Johansson Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Fri, 03 Jul 2009 17:11:37 +0200, Kenneth Johansson wrote: > > On Fri, 2009-07-03 at 17:00 +0200, Takashi Iwai wrote: > > At Fri, 03 Jul 2009 16:51:35 +0200, > > Kenneth Johansson wrote: > > > > > > On Fri, 2009-07-03 at 16:39 +0200, Takashi Iwai wrote: > > > > At Fri, 03 Jul 2009 16:19:31 +0200, > > > > Kenneth Johansson wrote: > > > > > > > > > > Has not worked since commit 3d1fa924906996463ac33cba5b5143f762d913cf > > > > > > > > > > Signed-off-by: Kenneth Johansson > > > > > > > > Hrm, sorry, but your version is also broken as doing type-punning. > > > > The code has to be rewritten completely... > > > > > > > > > > > > Takashi > > > > > > hmm I think you have to explain this. now it works on both little/big > > > endian without any explicit byte moves. > > > > > > It did not understand what problem you see. > > > > You can't cast from a char pointer to another type (e.g. short) and > > read the value. This is called "type-punning" and doesn't work > > properly with the recent GCC (depending on the optimization and > > code parsing) since it handles strict-aliasing. > > > > See GCC info for details. > > > > > > Takashi > > But there is no aliasing problem in that code. The memory is only > accessed(written in this case) using one type. One type? + switch(bps){ + case 1: + *(samples[chn]) = res; + break; + case 2: + *(short*)(samples[chn]) = res; + break; + case 4: + *(int*)(samples[chn]) = res; + }