memcmp.c

来自「test file nucleus source」· C语言 代码 · 共 93 行

C
93
字号
/***************************************************************************               Copyright Mentor Graphics Corporation 2002*                         All Rights Reserved.** THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS* SUBJECT TO LICENSE TERMS.**************************************************************************//************************************************************************** FILE NAME                                     VERSION**       memcmp.c                                Nucleus Common Library 1.1** DESCRIPTION**       This file contains the implementation of NCL_memcmp.** DATA STRUCTURES**       None.** FUNCTIONS**       NCL_memcmp** DEPENDENCIES**       ncl.h*       string.h*       nucleus.h*************************************************************************/#define NU_NCL_SOURCE_FILE#include "ncl\inc\ncl.h"#include "ncl\inc\string.h"#include "plus\nucleus.h"                                /* MMU Support *//***************************************************************************   FUNCTION**       NCL_memcmp**   DESCRIPTION**      Copies a section of memory**   INPUTS**       s1                  Memory to compare.*       s2                  Memory to compare.*       n                   Number of bytes to compare.**   OUTPUTS**       int                 0 means s1 == s2;*                           -1 means s1 < s2;*                           1 means s1 > s2**************************************************************************/int NCL_memcmp (const void *s1, const void *s2, size_t n){    register unsigned char *p1 = (unsigned char*) s1;    register unsigned char *p2 = (unsigned char*) s2;    register unsigned char *end = p1 + n;    while (p1 < end)    {        if (*p1 != *p2)        {            if (*p1 < *p2)            {                return (-1);            }            else            {                return (1);            }        }        ++p1;        ++p2;    }    return (0);               /* memory blocks are equal */}

⌨️ 快捷键说明

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