Hi all, In order to use IMG lib for dm642, the data need to be in double word alignment according to the document. May I know how to make sure that the data are in double word alignment in C. I know in asm, there is a tool call .align but can't find in C. Thanks. tnk
data alignment on TI dm642
Started by ●April 6, 2004
Reply by ●April 6, 20042004-04-06
Hello tnk, DATA_ALIGN(variable, 2^n alignment) #pragma DATA_ALIGN(a,8); short a[256]={1,2,3,... You can also use the text or visual linker to set complete sections aligned. Good luck, Wolfgang "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404060018.2bf9dc9f@posting.google.com...> Hi all, > In order to use IMG lib for dm642, the data need to be in double > word alignment according to the document. May I know how to make sure > that the data are in double word alignment in C. I know in asm, there > is a tool call .align but can't find in C. Thanks. > > tnk
Reply by ●April 6, 20042004-04-06
Hi Wolfgang, Thanks for your reply. Actually I've tried that already but gave me the following warning. 'v' represents my variable. warning: pragma can only be applied to a file level symbol, not 'v' So I thought there should have other tools for variable. tnk "Wolfgang" <never@nowhere.com> wrote in message news:<c4tto0$aq2$07$1@news.t-online.com>...> Hello tnk, > > DATA_ALIGN(variable, 2^n alignment) > > #pragma DATA_ALIGN(a,8); > short a[256]={1,2,3,... > > You can also use the text or visual linker to set complete sections aligned. > > Good luck, Wolfgang > > "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404060018.2bf9dc9f@posting.google.com... > > Hi all, > > In order to use IMG lib for dm642, the data need to be in double > > word alignment according to the document. May I know how to make sure > > that the data are in double word alignment in C. I know in asm, there > > is a tool call .align but can't find in C. Thanks. > > > > tnk
Reply by ●April 7, 20042004-04-07
Hi tnk, Snip a very short runable code. Then I could possilby see what the warning is about. Wolfgang "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404061637.4ca1e9c8@posting.google.com...> Hi Wolfgang, > Thanks for your reply. Actually I've tried that already but gave > me the following warning. 'v' represents my variable. > > warning: pragma can only be applied to a file level symbol, not > 'v' > > So I thought there should have other tools for variable. > > tnk > > "Wolfgang" <never@nowhere.com> wrote in message news:<c4tto0$aq2$07$1@news.t-online.com>... > > Hello tnk, > > > > DATA_ALIGN(variable, 2^n alignment) > > > > #pragma DATA_ALIGN(a,8); > > short a[256]={1,2,3,... > > > > You can also use the text or visual linker to set complete sections aligned. > > > > Good luck, Wolfgang > > > > "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404060018.2bf9dc9f@posting.google.com... > > > Hi all, > > > In order to use IMG lib for dm642, the data need to be in double > > > word alignment according to the document. May I know how to make sure > > > that the data are in double word alignment in C. I know in asm, there > > > is a tool call .align but can't find in C. Thanks. > > > > > > tnk
Reply by ●April 7, 20042004-04-07
Hi Wolfgang, Thanks for your help, the following short program will produce the warning. Actually it is a funciton. I made it to be compilable alone... #include <IMG_pix_expand.h> static int main(p) unsigned char * restrict p; { int i; unsigned int s,s2; #pragma DATA_ALIGN(v,8); short *v; v=v;//to surpress warning s = s2 = 0; IMG_pix_expand(256,p,v); s2=(unsigned int)DSP_vecsumsq(v,256); #pragma MUST_ITERATE(256,256,256); for (i=0; i<256; i++) { s+= (unsigned int)v; } return (int)(s2 - (s*s)/256); } tnk "Wolfgang" <never@nowhere.com> wrote in message news:<c50782$7dj$06$1@news.t-online.com>...> Hi tnk, > > Snip a very short runable code. Then I could possilby see what the warning is about. > > Wolfgang > > > "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404061637.4ca1e9c8@posting.google.com... > > Hi Wolfgang, > > Thanks for your reply. Actually I've tried that already but gave > > me the following warning. 'v' represents my variable. > > > > warning: pragma can only be applied to a file level symbol, not > > 'v' > > > > So I thought there should have other tools for variable. > > > > tnk > > > > "Wolfgang" <never@nowhere.com> wrote in message news:<c4tto0$aq2$07$1@news.t-online.com>... > > > Hello tnk, > > > > > > DATA_ALIGN(variable, 2^n alignment) > > > > > > #pragma DATA_ALIGN(a,8); > > > short a[256]={1,2,3,... > > > > > > You can also use the text or visual linker to set complete sections aligned. > > > > > > Good luck, Wolfgang > > > > > > "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404060018.2bf9dc9f@posting.google.com... > > > > Hi all, > > > > In order to use IMG lib for dm642, the data need to be in double > > > > word alignment according to the document. May I know how to make sure > > > > that the data are in double word alignment in C. I know in asm, there > > > > is a tool call .align but can't find in C. Thanks. > > > > > > > > tnk
Reply by ●April 8, 20042004-04-08
Hello tnk, You use #pragma DATA_ALIGN in main or in a function respectively. As far as I suggest these variables are created in the heap (A large pool of memory that can be allocated at runtime by application programs and by the executive.). It seems to me that you can't ALIGN variables in the heap. But you can ALIGN the heap itself. There are also possibilities to align a memory block: void *memalign(size_t alignment, size_t _size); Hope you now have a hint of what's going wrong, unfortunately can't help more as I don't see a need for ALIGN of the pointer v. Do you work with DM642 ? Detected some bugs so far ? Wolfgang P.S.: Copying "#pragma ... short *v;" at the top of the program solves all problems but seems not to be the solution for you (Then a global variable). ------------------------------------------------------------------------------------------------------------------------- "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404071632.73ba5d5@posting.google.com...> Hi Wolfgang, > Thanks for your help, the following short program will produce the > warning. Actually it is a funciton. I made it to be compilable > alone... > > #include <IMG_pix_expand.h> > static int main(p) > unsigned char * restrict p; > { > int i; > unsigned int s,s2; > #pragma DATA_ALIGN(v,8); > short *v; > v=v;//to surpress warning > s = s2 = 0; > IMG_pix_expand(256,p,v); > s2=(unsigned int)DSP_vecsumsq(v,256); > #pragma MUST_ITERATE(256,256,256); > for (i=0; i<256; i++) > { > s+= (unsigned int)v; > } > return (int)(s2 - (s*s)/256); > } > > tnk > > > "Wolfgang" <never@nowhere.com> wrote in message news:<c50782$7dj$06$1@news.t-online.com>... > > Hi tnk, > > > > Snip a very short runable code. Then I could possilby see what the warning is about. > > > > Wolfgang > > > > > > "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404061637.4ca1e9c8@posting.google.com... > > > Hi Wolfgang, > > > Thanks for your reply. Actually I've tried that already but gave > > > me the following warning. 'v' represents my variable. > > > > > > warning: pragma can only be applied to a file level symbol, not > > > 'v' > > > > > > So I thought there should have other tools for variable. > > > > > > tnk > > > > > > "Wolfgang" <never@nowhere.com> wrote in message news:<c4tto0$aq2$07$1@news.t-online.com>... > > > > Hello tnk, > > > > > > > > DATA_ALIGN(variable, 2^n alignment) > > > > > > > > #pragma DATA_ALIGN(a,8); > > > > short a[256]={1,2,3,... > > > > > > > > You can also use the text or visual linker to set complete sections aligned. > > > > > > > > Good luck, Wolfgang > > > > > > > > "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404060018.2bf9dc9f@posting.google.com... > > > > > Hi all, > > > > > In order to use IMG lib for dm642, the data need to be in double > > > > > word alignment according to the document. May I know how to make sure > > > > > that the data are in double word alignment in C. I know in asm, there > > > > > is a tool call .align but can't find in C. Thanks. > > > > > > > > > > tnk
Reply by ●April 8, 20042004-04-08
The warning tells that a local (in your case, a function level) variable, that is allocated on the stack cannot be aligned. Not sure why though. File level variables (that are allocated in e.g. .far) can be aligned with DATA_ALIGN() directive. Move v out of the function definition, #pragma DATA_ALIGN (v, byte_alignment); int v[123]; int fct(parameters) { ... // v can be used here } Rgds, Andrew tnk11@yahoo.com (tnk) wrote in message news:<326eb864.0404061637.4ca1e9c8@posting.google.com>...> Hi Wolfgang, > Thanks for your reply. Actually I've tried that already but gave > me the following warning. 'v' represents my variable. > > warning: pragma can only be applied to a file level symbol, not 'v' > > So I thought there should have other tools for variable. > > tnk > > "Wolfgang" <never@nowhere.com> wrote in message news:<c4tto0$aq2$07$1@news.t-online.com>... > > Hello tnk, > > > > DATA_ALIGN(variable, 2^n alignment) > > > > #pragma DATA_ALIGN(a,8); > > short a[256]={1,2,3,... > > > > You can also use the text or visual linker to set complete sections aligned. > > > > Good luck, Wolfgang > > > > "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404060018.2bf9dc9f@posting.google.com... > > > Hi all, > > > In order to use IMG lib for dm642, the data need to be in double > > > word alignment according to the document. May I know how to make sure > > > that the data are in double word alignment in C. I know in asm, there > > > is a tool call .align but can't find in C. Thanks. > > > > > > tnk
Reply by ●April 11, 20042004-04-11
OK! I got it. Thanks... The reason why I want to align is I am using img lib which needs data alignment. Heap memory can be aligned by using mem_alloc. Yeah I am working DM642, so far so good... haven't found any bugs yet... tnk andrew.nesterov@softhome.net (Andrew Nesterov) wrote in message news:<32a3848b.0404080057.75553270@posting.google.com>...> The warning tells that a local (in your case, a function level) variable, > that is allocated on the stack cannot be aligned. Not sure why though. > > File level variables (that are allocated in e.g. .far) can be aligned > with DATA_ALIGN() directive. Move v out of the function definition, > > #pragma DATA_ALIGN (v, byte_alignment); > int v[123]; > > int fct(parameters) > { > ... // v can be used here > } > > Rgds, > Andrew > > tnk11@yahoo.com (tnk) wrote in message news:<326eb864.0404061637.4ca1e9c8@posting.google.com>... > > Hi Wolfgang, > > Thanks for your reply. Actually I've tried that already but gave > > me the following warning. 'v' represents my variable. > > > > warning: pragma can only be applied to a file level symbol, not 'v' > > > > So I thought there should have other tools for variable. > > > > tnk > > > > "Wolfgang" <never@nowhere.com> wrote in message news:<c4tto0$aq2$07$1@news.t-online.com>... > > > Hello tnk, > > > > > > DATA_ALIGN(variable, 2^n alignment) > > > > > > #pragma DATA_ALIGN(a,8); > > > short a[256]={1,2,3,... > > > > > > You can also use the text or visual linker to set complete sections aligned. > > > > > > Good luck, Wolfgang > > > > > > "tnk" <tnk11@yahoo.com> schrieb im Newsbeitrag news:326eb864.0404060018.2bf9dc9f@posting.google.com... > > > > Hi all, > > > > In order to use IMG lib for dm642, the data need to be in double > > > > word alignment according to the document. May I know how to make sure > > > > that the data are in double word alignment in C. I know in asm, there > > > > is a tool call .align but can't find in C. Thanks. > > > > > > > > tnk