1 |
3 |
kfleming |
/*
|
2 |
|
|
* MEMOCODE Hardware/Software CoDesign Contest 2008
|
3 |
|
|
*
|
4 |
|
|
* Everyone is granted permission to copy, modify and redistribute
|
5 |
|
|
* this tool set under the following conditions:
|
6 |
|
|
*
|
7 |
|
|
* This source code is distributed for non-commercial use only.
|
8 |
|
|
* Please contact the maintainer for restrictions applying to
|
9 |
|
|
* commercial use.
|
10 |
|
|
*
|
11 |
|
|
* Permission is granted to anyone to make or distribute copies
|
12 |
|
|
* of this source code, either as received or modified, in any
|
13 |
|
|
* medium, provided that all copyright notices, permission and
|
14 |
|
|
* nonwarranty notices are preserved, and that the distributor
|
15 |
|
|
* grants the recipient permission for further redistribution as
|
16 |
|
|
* permitted by this document.
|
17 |
|
|
*
|
18 |
|
|
* Permission is granted to distribute this file in compiled
|
19 |
|
|
* or executable form under the same conditions that apply for
|
20 |
|
|
* source code, provided that either:
|
21 |
|
|
*
|
22 |
|
|
* A. it is accompanied by the corresponding machine-readable
|
23 |
|
|
* source code,
|
24 |
|
|
* B. it is accompanied by a written offer, with no time limit,
|
25 |
|
|
* to give anyone a machine-readable copy of the corresponding
|
26 |
|
|
* source code in return for reimbursement of the cost of
|
27 |
|
|
* distribution. This written offer must permit verbatim
|
28 |
|
|
* duplication by anyone, or
|
29 |
|
|
* C. it is distributed by someone who received only the
|
30 |
|
|
* executable form, and is accompanied by a copy of the
|
31 |
|
|
* written offer of source code that they received concurrently.
|
32 |
|
|
*
|
33 |
|
|
* In other words, you are welcome to use, share and improve this
|
34 |
|
|
* source file. You are forbidden to forbid anyone else to use, share
|
35 |
|
|
* and improve what you give them.
|
36 |
|
|
*
|
37 |
|
|
* THE SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER
|
38 |
|
|
* EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO ANY WARRANTY
|
39 |
|
|
* THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS OR BE ERROR-FREE AND ANY
|
40 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
|
41 |
|
|
* TITLE, OR NON-INFRINGEMENT. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
|
42 |
|
|
* BE LIABLE FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO DIRECT, INDIRECT,
|
43 |
|
|
* SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, OR IN
|
44 |
|
|
* ANY WAY CONNECTED WITH THIS SOFTWARE (WHETHER OR NOT BASED UPON WARRANTY,
|
45 |
|
|
* CONTRACT, TORT OR OTHERWISE).
|
46 |
|
|
*
|
47 |
|
|
*/
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
#ifndef RECORDIO_H
|
51 |
|
|
#define RECORDIO_H
|
52 |
|
|
|
53 |
|
|
#define MAXRECORD (1<<LOGVAL)
|
54 |
|
|
#define RNGSEED 1
|
55 |
|
|
//Need endianness
|
56 |
|
|
struct record_st {
|
57 |
|
|
unsigned int f4;
|
58 |
|
|
unsigned int f3;
|
59 |
|
|
unsigned int f2;
|
60 |
|
|
unsigned int f1;
|
61 |
|
|
};
|
62 |
|
|
typedef struct record_st RECORD;
|
63 |
|
|
|
64 |
|
|
extern RECORD db[MAXRECORD];
|
65 |
|
|
|
66 |
|
|
void initializedb(const unsigned char *gkey);
|
67 |
|
|
int verifydb ();
|
68 |
|
|
void readrecord (RECORD *r, unsigned idx);
|
69 |
|
|
void writerecord (RECORD *r, unsigned idx);
|
70 |
|
|
int comparerecord(unsigned idx1, unsigned idx2);
|
71 |
|
|
void swaprecord (unsigned idx1, unsigned idx2);
|
72 |
|
|
void sortrecord_bubble ();
|
73 |
|
|
void sortrecord ();
|
74 |
|
|
void showdb ();
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
#endif
|