~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to extra/innochecksum.c

Remove ulint and uchar from innochecksum.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
/* command line argument to do page checks (that's it) */
54
54
/* another argument to specify page ranges... seek to right spot and go from there */
55
55
 
56
 
typedef uint32_t ulint;
57
 
typedef unsigned char uchar;
58
 
 
59
56
/* innodb function in name; modified slightly to not have the ASM version (lots of #ifs that didn't apply) */
60
 
static ulint mach_read_from_4(uchar *b)
 
57
static uint32_t mach_read_from_4(unsigned char *b)
61
58
{
62
 
  return( ((ulint)(b[0]) << 24)
63
 
          + ((ulint)(b[1]) << 16)
64
 
          + ((ulint)(b[2]) << 8)
65
 
          + (ulint)(b[3])
 
59
  return( ((uint32_t)(b[0]) << 24)
 
60
          + ((uint32_t)(b[1]) << 16)
 
61
          + ((uint32_t)(b[2]) << 8)
 
62
          + (uint32_t)(b[3])
66
63
          );
67
64
}
68
65
 
69
 
static ulint
70
 
ut_fold_ulint_pair(
 
66
static uint32_t
 
67
ut_fold_uint32_t_pair(
71
68
/*===============*/
72
69
            /* out: folded value */
73
 
    ulint   n1, /* in: ulint */
74
 
    ulint   n2) /* in: ulint */
 
70
    uint32_t   n1, /* in: uint32_t */
 
71
    uint32_t   n2) /* in: uint32_t */
75
72
{
76
73
    return(((((n1 ^ n2 ^ UT_HASH_RANDOM_MASK2) << 8) + n1)
77
74
                        ^ UT_HASH_RANDOM_MASK) + n2);
78
75
}
79
76
 
80
 
static ulint
 
77
static uint32_t
81
78
ut_fold_binary(
82
79
/*===========*/
83
80
            /* out: folded value */
84
 
    uchar*   str,    /* in: string of bytes */
85
 
    ulint   len)    /* in: length */
 
81
    unsigned char*   str,    /* in: string of bytes */
 
82
    uint32_t   len)    /* in: length */
86
83
{
87
 
    ulint   i;
88
 
    ulint   fold= 0;
 
84
    uint32_t   i;
 
85
    uint32_t   fold= 0;
89
86
 
90
87
    for (i= 0; i < len; i++)
91
88
    {
92
 
      fold= ut_fold_ulint_pair(fold, (ulint)(*str));
 
89
      fold= ut_fold_uint32_t_pair(fold, (uint32_t)(*str));
93
90
 
94
91
      str++;
95
92
    }
97
94
    return(fold);
98
95
}
99
96
 
100
 
static ulint
 
97
static uint32_t
101
98
buf_calc_page_new_checksum(
102
99
/*=======================*/
103
100
               /* out: checksum */
104
 
    uchar*    page) /* in: buffer page */
 
101
    unsigned char*    page) /* in: buffer page */
105
102
{
106
 
    ulint checksum;
 
103
    uint32_t checksum;
107
104
 
108
105
    /* Since the fields FIL_PAGE_FILE_FLUSH_LSN and ..._ARCH_LOG_NO
109
106
    are written outside the buffer pool to the first pages of data
122
119
    return(checksum);
123
120
}
124
121
 
125
 
static ulint
 
122
static uint32_t
126
123
buf_calc_page_old_checksum(
127
124
/*=======================*/
128
125
               /* out: checksum */
129
 
    uchar*    page) /* in: buffer page */
 
126
    unsigned char*    page) /* in: buffer page */
130
127
{
131
 
    ulint checksum;
 
128
    uint32_t checksum;
132
129
 
133
130
    checksum= ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN);
134
131
 
141
138
int main(int argc, char **argv)
142
139
{
143
140
  FILE *f;                     /* our input file */
144
 
  uchar *p;                     /* storage of pages read */
 
141
  unsigned char *p;                     /* storage of pages read */
145
142
  int bytes;                   /* bytes read count */
146
 
  ulint ct;                    /* current page number (0 based) */
 
143
  uint32_t ct;                    /* current page number (0 based) */
147
144
  int now;                     /* current time */
148
145
  int lastt;                   /* last time */
149
 
  ulint oldcsum, oldcsumfield, csum, csumfield, logseq, logseqfield; /* ulints for checksum storage */
 
146
  uint32_t oldcsum, oldcsumfield, csum, csumfield, logseq, logseqfield; /* uint32_ts for checksum storage */
150
147
  struct stat st;              /* for stat, if you couldn't guess */
151
148
  unsigned long long int size; /* size of file (has to be 64 bits) */
152
 
  ulint pages;                 /* number of pages in file */
153
 
  ulint start_page= 0, end_page= 0, use_end_page= 0; /* for starting and ending at certain pages */
 
149
  uint32_t pages;                 /* number of pages in file */
 
150
  uint32_t start_page= 0, end_page= 0, use_end_page= 0; /* for starting and ending at certain pages */
154
151
  off_t offset= 0;
155
152
  int just_count= 0;          /* if true, just print page count */
156
153
  int verbose= 0;
259
256
  }
260
257
 
261
258
  /* allocate buffer for reading (so we don't realloc every time) */
262
 
  p= (uchar *)malloc(UNIV_PAGE_SIZE);
 
259
  p= (unsigned char *)malloc(UNIV_PAGE_SIZE);
263
260
 
264
261
  /* main checksumming loop */
265
262
  ct= start_page;