OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [compat/] [memcmp.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * memcmp.c --
3
 *
4
 *      Source code for the "memcmp" library routine.
5
 *
6
 * Copyright (c) 1998 Sun Microsystems, Inc.
7
 *
8
 * See the file "license.terms" for information on usage and redistribution
9
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
 *
11
 * SCCS: @(#) memcmp.c 1.2 98/01/19 10:48:58
12
 */
13
 
14
#include "tcl.h"
15
#include "tclPort.h"
16
 
17
/*
18
 * Here is the prototype just in case it is not included
19
 * in tclPort.h.
20
 */
21
 
22
int             memcmp _ANSI_ARGS_((CONST VOID *s1,
23
                            CONST VOID *s2, size_t n));
24
 
25
/*
26
 *----------------------------------------------------------------------
27
 *
28
 * memcmp --
29
 *
30
 *      Compares two bytes sequences.
31
 *
32
 * Results:
33
 *     compares  its  arguments, looking at the first n
34
 *     bytes (each interpreted as an unsigned char), and  returns
35
 *     an integer less than, equal to, or greater than 0, accord-
36
 *     ing as s1 is less  than,  equal  to,  or
37
 *     greater than s2 when taken to be unsigned 8 bit numbers.
38
 *
39
 * Side effects:
40
 *      None.
41
 *
42
 *----------------------------------------------------------------------
43
 */
44
 
45
int
46
memcmp(s1, s2, n)
47
    CONST VOID *s1;                     /* First string. */
48
    CONST VOID *s2;                     /* Second string. */
49
    size_t      n;                      /* Length to compare. */
50
{
51
    unsigned char u1, u2;
52
 
53
    for ( ; n-- ; s1++, s2++) {
54
        u1 = * (unsigned char *) s1;
55
        u2 = * (unsigned char *) s2;
56
        if ( u1 != u2) {
57
            return (u1-u2);
58
        }
59
    }
60
    return 0;
61
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.