From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17894 invoked by alias); 23 Jun 2011 07:27:01 -0000 Received: (qmail 17881 invoked by uid 22791); 23 Jun 2011 07:27:00 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from www.meduna.org (HELO meduna.org) (92.240.244.38) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Jun 2011 07:26:43 +0000 Received: from dial-95-105-188-19-orange.orange.sk ([95.105.188.19] helo=[192.168.130.27]) by meduna.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1QZeJ8-0005nX-QG; Thu, 23 Jun 2011 09:26:40 +0200 Message-ID: <4E02EAA5.7080405@meduna.org> Date: Thu, 23 Jun 2011 07:27:00 -0000 From: Stanislav Meduna User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Lightning/1.0b2 Thunderbird/3.1.11 MIME-Version: 1.0 To: ecos-devel@ecos.sourceware.org CC: Michael Bergandi Subject: Re: Thread stack alignment requirements for ARM References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Authenticated-User: stano@meduna.org X-Authenticator: dovecot_plain X-Spam-Score: -8.1 X-Spam-Score-Int: -80 X-Exim-Version: 4.69 (build at 30-Jan-2011 20:48:48) X-Date: 2011-06-23 09:26:40 X-Connected-IP: 95.105.188.19:1147 X-Message-Linecount: 46 X-Body-Linecount: 33 X-Message-Size: 1845 X-Body-Size: 1238 X-Received-Count: 1 X-Recipient-Count: 2 X-Local-Recipient-Count: 2 X-Local-Recipient-Defer-Count: 0 X-Local-Recipient-Fail-Count: 0 X-IsSubscribed: yes Mailing-List: contact ecos-devel-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-devel-owner@ecos.sourceware.org X-SW-Source: 2011-06/txt/msg00018.txt.bz2 On 23.06.2011 04:37, Michael Bergandi wrote: > According to the ARM site, they say that stacks should be 16 byte > aligned. Then, they go on to say that there are a couple ways that > stack alignment requirement can be managed. One of which was if you > are running on an OS and the OS has taken steps to ensure the > requirement is met, then the application need not worry about it. I > don't think I fully understand what this means exactly. HAL_THREAD_INIT_CONTEXT forces the alignment of the stack - see e.g. packages\hal\arm\arch\current\include\hal_arch.h: register CYG_WORD _sp_ = ((CYG_WORD)_sparg_) &~15; > Our particular target is the mx27 (ARM9). Out of habit, we make all > the memory for the thread stacks in our applications 4 byte aligned. > Is this enough? Is it really necessary? Yes (but you are eventually wasting up to 12 bytes), no. The linker script takes care of the sections and the compiler and standard library (malloc) of the rest of the alignment needs. It only matters if you are building some kind of compiler/ linker/dynamic loader functionality or if you are upcasting some datatypes (such as int * to double *) - I got burned with this... Regards -- Stano