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,18 +14,18 @@
/* u3e_control: memory change, control file.
*/
typedef struct _u3e_control {
c3_d evt_d; // event number
c3_w nor_w; // new page count north
c3_w sou_w; // new page count south
c3_w pgs_w; // number of changed pages
c3_w ver_y; // version number
c3_w nor_w; // new page count north
c3_w sou_w; // new page count south
c3_w pgs_w; // number of changed pages
u3e_line mem_u[0]; // per page
} u3e_control;
/* u3_cs_patch: memory change, top level.
*/
typedef struct _u3_cs_patch {
c3_i ctl_i;
c3_i mem_i;
c3_i ctl_i;
c3_i mem_i;
u3e_control* con_u;
} u3_ce_patch;
@ -40,11 +40,10 @@
/* u3e_pool: entire memory system.
*/
typedef struct _u3e_pool {
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
u3e_image nor_u; // north segment
u3e_image sou_u; // south segment
c3_c* dir_c; // path to
c3_w dit_w[u3a_pages >> 5]; // touched since last save
u3e_image nor_u; // north segment
u3e_image sou_u; // south segment
} u3e_pool;
@ -55,6 +54,9 @@
c3_global u3e_pool u3e_Pool;
# define u3P u3e_Pool
/** Constants.
**/
# define u3e_version 1
/** Functions.
**/

View File

@ -308,6 +308,14 @@ _ce_patch_verify(u3_ce_patch* pat_u)
{
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++ ) {
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;
@ -571,6 +579,7 @@ _ce_patch_compose(void)
_ce_patch_create(pat_u);
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;
for ( i_w = 0; i_w < nor_w; i_w++ ) {