u3: adds version number to checkpoint patch files

This commit is contained in:
Joe Bryan 2020-11-19 22:09:01 -08:00
parent c9ae9b6ffb
commit 32ad4f04e3
2 changed files with 22 additions and 11 deletions

View File

@ -14,7 +14,7 @@
/* u3e_control: memory change, control file. /* u3e_control: memory change, control file.
*/ */
typedef struct _u3e_control { typedef struct _u3e_control {
c3_d evt_d; // event number c3_w ver_y; // version number
c3_w nor_w; // new page count north c3_w nor_w; // new page count north
c3_w sou_w; // new page count south c3_w sou_w; // new page count south
c3_w pgs_w; // number of changed pages c3_w pgs_w; // number of changed pages
@ -41,7 +41,6 @@
*/ */
typedef struct _u3e_pool { typedef struct _u3e_pool {
c3_c* dir_c; // path to c3_c* dir_c; // path to
c3_d evt_d; // last patch written at event
c3_w dit_w[u3a_pages >> 5]; // touched since last save c3_w dit_w[u3a_pages >> 5]; // touched since last save
u3e_image nor_u; // north segment u3e_image nor_u; // north segment
u3e_image sou_u; // south segment u3e_image sou_u; // south segment
@ -55,6 +54,9 @@
c3_global u3e_pool u3e_Pool; c3_global u3e_pool u3e_Pool;
# define u3P u3e_Pool # define u3P u3e_Pool
/** Constants.
**/
# define u3e_version 1
/** Functions. /** Functions.
**/ **/

View File

@ -308,6 +308,14 @@ _ce_patch_verify(u3_ce_patch* pat_u)
{ {
c3_w i_w; c3_w i_w;
if ( u3e_version != pat_u->con_u->ver_y ) {
fprintf(stderr, "loom: patch version mismatch: have %u, need %u\r\n",
pat_u->con_u->ver_y,
u3e_version);
c3_assert(0);
return c3n;
}
for ( i_w = 0; i_w < pat_u->con_u->pgs_w; i_w++ ) { for ( i_w = 0; i_w < pat_u->con_u->pgs_w; i_w++ ) {
c3_w pag_w = pat_u->con_u->mem_u[i_w].pag_w; c3_w pag_w = pat_u->con_u->mem_u[i_w].pag_w;
c3_w mug_w = pat_u->con_u->mem_u[i_w].mug_w; c3_w mug_w = pat_u->con_u->mem_u[i_w].mug_w;
@ -571,6 +579,7 @@ _ce_patch_compose(void)
_ce_patch_create(pat_u); _ce_patch_create(pat_u);
pat_u->con_u = c3_malloc(sizeof(u3e_control) + (pgs_w * sizeof(u3e_line))); pat_u->con_u = c3_malloc(sizeof(u3e_control) + (pgs_w * sizeof(u3e_line)));
pat_u->con_u->ver_y = u3e_version;
pgc_w = 0; pgc_w = 0;
for ( i_w = 0; i_w < nor_w; i_w++ ) { for ( i_w = 0; i_w < nor_w; i_w++ ) {