This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Reentrant function problems with memcpy()

I have a reentrant function that is passed a single parameter as follows:

void Filt_QR ( FilterDataType * FilterData )  reentrant
{
    unsigned char aucTemp40[5];
    memcpy( aucTemp40,                /*   void * dest   */
            FilterData->aucYpterm_40, /*   void * src    */
            5);                       /*   int    len    */

...

The memcpy() call always gets the destination wrong, but the source is correct. The single passed in parameter is a structure containing a few 5 byte char arrays and a long and a char. No big deal. If I make it a normal (not reentrant) function, everything is fine. I made my own "memcopy" type function, same result.
Yes, I have XBPSTACK set to 1.
This is driving me nuts. Any help will be appreciated.

Parents
  • Can you post the assembler code generated for this function from the .lst file?

    By "always gets the destination wrong", you mean "not anywhere in the reentrant stack"?

    What happens if you do this:

    void Filt_QR ( FilterDataType * FilterData )  reentrant
    {
        unsigned long aucTemp40_4;
        unsigned char aucTemp40_1;
        memcpy( &aucTemp40_4,                /*   void * dest   */
                FilterData->aucYpterm_40, /*   void * src    */
                5);                       /*   int    len    */
    
    
    

    Cheesy, but I'm curious if the array on the stack confuses the compiler.

    8051 variants with dual data pointers are a bit better at handling memcpy().

Reply
  • Can you post the assembler code generated for this function from the .lst file?

    By "always gets the destination wrong", you mean "not anywhere in the reentrant stack"?

    What happens if you do this:

    void Filt_QR ( FilterDataType * FilterData )  reentrant
    {
        unsigned long aucTemp40_4;
        unsigned char aucTemp40_1;
        memcpy( &aucTemp40_4,                /*   void * dest   */
                FilterData->aucYpterm_40, /*   void * src    */
                5);                       /*   int    len    */
    
    
    

    Cheesy, but I'm curious if the array on the stack confuses the compiler.

    8051 variants with dual data pointers are a bit better at handling memcpy().

Children
No data