OS_memset and OS_memcpy

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • OS_memset and OS_memcpy

    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

    #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

  • 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++;