Tuesday, April 24th 2018, 6:27pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

fffromeo

Beginner

Date of registration: Dec 19th 2007

Posts: 4

1

Wednesday, December 19th 2007, 11:13am

OS_memset and OS_memcpy

Hallo
I am using embos "evaluation version" (near memory model) for
M32C and IAR compiler. I have implemented a TCP-IP stack to run an SNMP
application. I am able to get almost any MIB with no problem. The
trouble I see is that the OS hangs on an apparently normal get
involving a pointer. I am already using the thread-safe versions of the
malloc() and free(). Now I discovered that there are thread-safe versions of memset() and memcpy() functions, too.

I hope using those I'll solve my problems, but I am not able to do
that, cause there is no prototype declared, and I was not able to
create a prototype fitting the real one.
I RTOS.H I see:


/* memset and
memcpy need to be replaced for near memory
model */


/* this is
done in
OS_Priv
*/



#define OS_MEMSET(Adr, Value,
Size) OS_memset(Adr, Value, Size)


#define OS_MEMCPY(Dest, Src, Size)
OS_memcpy(Dest, Src, Size)



As you can see there is only a macro. redirecting OS_MEMSET to the thread safe version.

Someone can help me ?

Remember we are going to Christmas day.... ;)

Thanks in advance

fffromeo

Date of registration: Dec 20th 2007

Posts: 26

2

Thursday, December 20th 2007, 12:22pm

Hello,

The embOS internal OS_memcpy() and OS_memset() functions are private and can not be called.
embOS uses these functions to initialize internal data structures.
As we found out, that some compilers do not deliver these functions for all memory models, we added our own functions.
This was the only reason to implement the internal function OS_memset() and OS_memcpy().
They are NOT thread-safe, because there is nor reason for having thread-safe functions for that purpose.

If you have problems with the memset() and memcpy() functions from your system library,
you have to write your own functions.

These functions may look like follows:

These functions may look like follows:
_memset(void __huge * pDest, unsigned char Value, int Size) {
OS_U8 __huge* pD = pDest;
while (--Size >= 0) {
*pD = Value;
pD += 1;
}
}

void _memcpy( void* pDest, const void* pSrc, int Size) {
char *ss1 = pDest;
const char *ss2 = pSrc;
while ( Size-- ) {
*ss1++ = *ss2++;
}
}

/Armin

Similar threads