Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
93
cde/programs/dtksh/ksh93/src/lib/libast/hash/memsum.c
Normal file
93
cde/programs/dtksh/ksh93/src/lib/libast/hash/memsum.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/* $XConsortium: memsum.c /main/3 1995/11/01 17:34:05 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
#include "hashlib.h"
|
||||
|
||||
/*
|
||||
* return a running 32 bit checksum of buffer b of length n
|
||||
*
|
||||
* c is the return value from a previous
|
||||
* memsum() or strsum() call, 0 on the first call
|
||||
*
|
||||
* the result is the same on all implementations
|
||||
*/
|
||||
|
||||
unsigned long
|
||||
memsum __PARAM__((const __V_* ap, int n, register unsigned long c), (ap, n, c)) __OTORP__(const __V_* ap; int n; register unsigned long c;){
|
||||
register const unsigned char* p = (const unsigned char*)ap;
|
||||
register const unsigned char* e = p + n;
|
||||
|
||||
while (p < e) HASHPART(c, *p++);
|
||||
#if LONG_MAX > 2147483647
|
||||
return(c & 0xffffffff);
|
||||
#else
|
||||
return(c);
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user