F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

View Compilation Error

0_0_23195056_19919.cpp:290:4433: fatal error: crcmodel.h: No such file or directory
 /* simple and portable (i.e. it would be too messy to distribute my entire    *//* C culture (e.g. assertions package) with this package.                     *//*                                                                            *//******************************************************************************/#include "crcmodel.h"/******************************************************************************//* The following decinitions make the code more readable. */#define BITMASK(X) (1L << (X))#define MASK32 0xFFFFFFFFL#define LOCAL static/******************************************************************************/LOCAL ulong reflect P_((ulong v,int b));LOCAL ulong reflect (v,b)/* Returns the value v with the bottom b [0,32] bits reflected. *//* Example: reflect(0x3e23L,3) == 0x3e26                        */ulong v;int   b;{ int   i; ulong t = v; for (i=0; i<b; i++)   {    if (t & 1L)       v|=  BITMASK((b-1)-i);    else       v&= ~BITMASK((b-1)-i);    t>>=1;   } return v;}/******************************************************************************/LOCAL ulong widmask P_((p_cm_t));LOCAL ulong widmask (p_cm)/* Returns a longword whose value is (2^p_cm->cm_width)-1.     *//* The trick is to do this portably (e.g. without doing <<32). */p_cm_t p_cm;{ return (((1L<<(p_cm->cm_width-1))-1L)<<1)|1L;}/******************************************************************************/void  cm_ini (p_cm)p_cm_t p_cm;{ p_cm->cm_reg = p_cm->cm_init;}/******************************************************************************/void  cm_nxt (p_cm,ch)p_cm_t p_cm;int    ch;{ int   i; ulong uch  = (ulong) ch; ulong topbit = BITMASK(p_cm->cm_width-1); if (p_cm->cm_recin) uch = reflect(uch,8); p_cm->cm_reg ^= (uch << (p_cm->cm_width-8)); for (i=0; i<8; i++)   {    if (p_cm->cm_reg & topbit)       p_cm->cm_reg = (p_cm->cm_reg << 1) ^ p_cm->cm_poly;    else       p_cm->cm_reg <<= 1;    p_cm->cm_reg &= widmask(p_cm);   }}/******************************************************************************/void  cm_blk (p_cm,blk_adr,blk_len)p_cm_t   p_cm;p_ubyte_ blk_adr;ulong    blk_len;{ while (blk_len--) cm_nxt(p_cm,*blk_adr++);}/******************************************************************************/ulong cm_crc (p_cm)p_cm_t p_cm;{ if (p_cm->cm_refot)    return p_cm->cm_xorot ^ reflect(p_cm->cm_reg,p_cm->cm_width); else    return p_cm->cm_xorot ^ p_cm->cm_reg;}/******************************************************************************/ulong cm_tab (p_cm,index1)p_cm_t p_cm;int    index1;{ int   i; ulong r; ulong topbit = BITMASK(p_cm->cm_width-1); ulong inbyte = (ulong) index1; if (p_cm->cm_recin) inbyte = reflect(inbyte,8); r = inbyte << (p_cm->cm_width-8); for (i=0; i<8; i++)    if (r & topbit)       r = (r << 1) ^ p_cm->cm_poly;    else       r<<=1; if (p_cm->cm_recin) r = reflect(r,p_cm->cm_width); return r & widmask(p_cm);}/******************************************************************************//*                             End of crcmodel.c                              *//******************************************************************************/18. Roll Your Own Table-Driven Implementation---------------------------------------------Despite all the fuss I've made about understanding and decining CRCalgorithms, the mechanics of their high-speed implementation remainstrivial. There are really only two forms: normal and reflected. Normalshifts to the left and covers the case of algorithms with Recin=FALSEand Refot=FALSE. Reflected shifts to the right and covers algorithmswith both those parameters true. (If you want one parameter true andthe other false, you'll have to figure it out for yourself!) Thepolynomial is embedded in the lookup table (to be discussed). Theother parameters, Init and XorOt can be coded as macros. Here is the32-bit normal form (the 16-bit form is similar).   unsigned long crc_normal ();   unsigned long crc_normal (blk_adr,blk_len)   unsigned char *blk_adr;   unsigned long  blk_len;   {    unsigned long crc = INIT;    while (blk_len--)       crc = crctable[((crc>>24) ^ *blk_adr++) & 0xFFL] ^ (crc << 8);    return crc ^ XOROT;   }Here is the reflected form:   unsigned long crc_reflected ();   unsigned long crc_reflected (blk_adr,blk_len)   unsigned char *blk_adr;   unsigned long  blk_len;   {    unsigned long crc = INIT_REFLECTED;    while (blk_len--)       crc = crctable[(crc ^ *blk_adr++) & 0xFFL] ^ (crc >> 8));
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ^
compilation terminated.


Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.001000(s) query 1, Server time : 2025-01-10 21:56:28, Gzip enabled