⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flsysvxw.c

📁 DOC文件系统驱动源代码
💻 C
📖 第 1 页 / 共 3 页
字号:


/* ---------------------------------------------------------------------- * 
 *                                                                        * 
 *                   f l m e m s e t                                      * 
 *                                                                        * 
 * 8-bit 'memset' routine.                                                * 
 *                                                                        * 
 * Parameters:                                                            * 
 *                                                                        * 
 *      dest            : pointer to the target buffer                    * 
 *      val             : character to fill                               * 
 *      count           : number of bytes to fill                         * 
 *                                                                        * 
 * Returns:                                                               * 
 *                                                                        * 
 *      arguement 'dest'                                                  * 
 *                                                                        * 
 * ---------------------------------------------------------------------- */

void FAR0 *  flmemset ( void FAR0 * dest, 
                        int         val, 
                        size_t      count )
{
    register size_t  i;

    for (i = 0;  i < count;  i++)
        *((unsigned char FAR0 *)dest + i) = (unsigned char) val;

    return dest;
}




/* ---------------------------------------------------------------------- * 
 *                                                                        * 
 *                   f l m e m c m p                                      * 
 *                                                                        * 
 * 8-bit 'memcmp' routine.                                                * 
 *                                                                        * 
 * Parameters:                                                            * 
 *                                                                        * 
 *      dest            : pointer to the target buffer                    * 
 *      src             : pointer to the source buffer                    * 
 *      count           : number of bytes to compare                      * 
 *                                                                        * 
 * Returns:                                                               * 
 *                                                                        * 
 *      zero if buffers identical otherwise offset at which miscompare    * 
 *      occurs                                                            * 
 *                                                                        * 
 * ---------------------------------------------------------------------- */

int  flmemcmp ( const void FAR0 * dest, 
                const void FAR0 * src, 
                size_t            count )
{
    register int  i;

    for (i = 0; (size_t) i < count; i++) {

        if( *((const unsigned char FAR0 *)dest + i) !=
            *((const unsigned char FAR0 *)src  + i) ) {

            return -1;  /* miscompare */
        }
    }

    return 0;  /* buffers identical */
}




/* ---------------------------------------------------------------------- *
 *                                                                        *
 *                        f l c p y                                       *
 *                                                                        *
 * 32-bit 'memcopy' routine.                                              *
 *                                                                        *
 * Parameters:                                                            *
 *                                                                        *
 *      dest            : pointer to the destination buffer               *
 *      src             : pointer to the source buffer                    *
 *      size            : number of bytes to copy                         *
 *                                                                        *
 * Returns:                                                               *
 *                                                                        *
 *      arguement 'dest'                                                  *
 *                                                                        *
 * ---------------------------------------------------------------------- */

void *  flcpy ( void       * dest, 
                const void * src, 
                size_t       count )
{
    register size_t  i;

    /* if either src or dest are unaligned, do it in 8-bit */ 

    if( ((((long)dest) & (sizeof(long) - 1)) != 0)  
         ||
        ((((long)src ) & (sizeof(long) - 1)) != 0) ) {

        return  flmemcpy (dest, src, count);
    }

    /* do it in 32-bit */

    for (i = 0;  i < (count >> 2);  i++)
        *((unsigned long *)dest + i) = *((const unsigned long *)src + i);

    /* do up to three remaining bytes */

    count &= (sizeof(long) - 1);

    if (count) {

        dest = (unsigned long *)dest + i; 
        src  = (unsigned long *)src  + i; 

        for (i = 0; i < count; i++)
            *((unsigned char *)dest + i) = *((const unsigned char *)src + i);
    }

    return dest;
}




/* ---------------------------------------------------------------------- *
 *                                                                        *
 *                          f l s e t                                     *
 *                                                                        *
 * 32-bit 'memset' routine.                                               *
 *                                                                        *
 * Parameters:                                                            *
 *                                                                        *
 *      dest            : pointer to the target buffer                    *
 *      val             : character to fill                               *
 *      count           : number of bytes to fill                         *
 *                                                                        *
 * Returns:                                                               *
 *                                                                        *
 *      arguement 'dest'                                                  *
 *                                                                        *
 * ---------------------------------------------------------------------- */

void *  flset ( void  * dest, 
                int     val, 
                size_t  count )
{
    register size_t  i;
    unsigned long    longval;

    /* if dest is unaligned, do it in 8-bit */

    if( (((long)dest) & (sizeof(long) - 1)) != 0 )
        return  flmemset (dest, val, count);    

    /* construct 32-bit value */

    val &= 0xff;

    longval = (((unsigned long) val) << 24) | (((unsigned long) val) << 16) |
              (((unsigned long) val) <<  8) |  ((unsigned long) val);  
  
    /* do it in 32-bit */

    for (i = 0;  i < (count >> 2);  i++)
        *((unsigned long *)dest + i) = longval;

    /* do up to three remaining bytes */

    count &= (sizeof(long) - 1);

    if (count) {

        dest = (unsigned long *)dest + i; 

        for (i = 0; i < count; i++)
            *((unsigned char *)dest + i) = (unsigned char) val;
    }

    return dest;
}




/* ---------------------------------------------------------------------- *
 *                                                                        *
 *                         f l c m p                                      *
 *                                                                        *
 * 32-bit 'memcmp' routine.                                               *
 *                                                                        *
 * Parameters:                                                            *
 *                                                                        *
 *      dest            : pointer to the target buffer                    *
 *      src             : pointer to the source buffer                    *
 *      count           : number of bytes to compare                      *
 *                                                                        *
 * Returns:                                                               *
 *                                                                        *
 *      zero if buffers identical otherwise offset at which miscompare    *
 *      occurs                                                            *
 *                                                                        *
 * ---------------------------------------------------------------------- */

int  flcmp ( const void * dest, 
             const void * src, 
             size_t       count )
{
    register size_t  i;

    /* if either src or dest are unaligned, do it in 8-bit */ 

    if( ((((long)dest) & (sizeof(long) - 1)) != 0)  
              ||
        ((((long)src ) & (sizeof(long) - 1)) != 0) ) {

        return  flmemcmp (dest, src, count);
    }

    /* do it in 32-bit */

    for (i = 0;  i < (count >> 2);  i++) {

        if( *((unsigned long *)dest + i) != *((const unsigned long *)src + i) )
            return -1;  /* miscompare */
    }
            
    /* do up to three remaining bytes */

    count &= (sizeof(long) - 1);

    if (count) {

        dest = (unsigned long *)dest + i; 
        src  = (unsigned long *)src  + i; 

        for (i = 0; i < count; i++) {

            if( *((unsigned char *)dest + i) != *((const unsigned char *)src + i) )
                return -1;  /* miscompare */
        }
    }

    return 0;  /* buffers identical */
}




/* ---------------------------------------------------------------------- *
 *                                                                        *
 *                 f l C r e a t e M u t e x                              *
 *                                                                        *
 * Creates or initializes a mutex                                         *
 *                                                                        *
 * Parameters:                                                            *
 *                                                                        *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -