memcmp.c 998 Bytes
Newer Older
anton's avatar
anton committed
1 2
/* a memcmp implementation

Anton Ertl's avatar
Anton Ertl committed
3
  Copyright (C) 1995,1998,2000,2003,2007,2014,2017 Free Software Foundation, Inc.
anton's avatar
anton committed
4 5 6 7 8

  This file is part of Gforth.

  Gforth is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
9
  as published by the Free Software Foundation, either version 3
anton's avatar
anton committed
10 11 12 13 14 15 16 17
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
18
  along with this program; if not, see http://www.gnu.org/licenses/.
anton's avatar
anton committed
19 20
*/

21
#include "config.h"
22 23
#include "forth.h"

Bernd Paysan's avatar
Bernd Paysan committed
24
int memcmp(const void *s1, const void *s2, size_t n)
25
{
26
  Cell i;
27 28

  for (i=0; i<n; i++)
Bernd Paysan's avatar
Bernd Paysan committed
29 30
    if (((Char*)s1)[i] != ((Char*)s2)[i])
      return ((Char*)s1)[i]-((Char*)s2)[i];
31 32
  return 0;
}