[Groonga-commit] groonga/groonga at 8647006 [master] Make enums UPPER_CASE for "grn_io_rw_mode" (#969)

Back to archive index
Yasuhiro Horimoto null+****@clear*****
Mon May 27 10:44:23 JST 2019


Yasuhiro Horimoto	2019-05-27 10:44:23 +0900 (Mon, 27 May 2019)

  Revision: 864700639de3b33b6da83a1ade60dcc3f045013f
  https://github.com/groonga/groonga/commit/864700639de3b33b6da83a1ade60dcc3f045013f

  Message:
    Make enums UPPER_CASE for "grn_io_rw_mode" (#969)
    
    A part of fix for issue #43

  Modified files:
    lib/grn_io.h
    lib/ii.c
    lib/io.c
    lib/store.c

  Modified: lib/grn_io.h (+3 -3)
===================================================================
--- lib/grn_io.h    2019-05-24 12:48:14 +0900 (2f2c4563f)
+++ lib/grn_io.h    2019-05-27 10:44:23 +0900 (83b7b3bb1)
@@ -32,9 +32,9 @@ extern "C" {
 #endif /* WIN32 */
 
 typedef enum {
-  grn_io_rdonly,
-  grn_io_wronly,
-  grn_io_rdwr
+  GRN_IO_RDONLY,
+  GRN_IO_WRONLY,
+  GRN_IO_RDWR
 } grn_io_rw_mode;
 
 typedef enum {

  Modified: lib/ii.c (+13 -13)
===================================================================
--- lib/ii.c    2019-05-24 12:48:14 +0900 (9f33b3435)
+++ lib/ii.c    2019-05-27 10:44:23 +0900 (4df6b828b)
@@ -600,7 +600,7 @@ chunk_new(grn_ctx *ctx, grn_ii *ii, uint32_t *res, uint32_t size)
       iw_.addr = NULL;
       gseg = &header->garbages[m - GRN_II_W_LEAST_CHUNK];
       while (*gseg != GRN_II_PSEG_NOT_ASSIGNED) {
-        ginfo = WIN_MAP(ii->chunk, ctx, &iw, *gseg, 0, S_GARBAGE, grn_io_rdwr);
+        ginfo = WIN_MAP(ii->chunk, ctx, &iw, *gseg, 0, S_GARBAGE, GRN_IO_RDWR);
         //GRN_IO_SEG_MAP2(ii->chunk, *gseg, ginfo);
         if (!ginfo) {
           if (iw_.addr) { grn_io_win_unmap(&iw_); }
@@ -695,7 +695,7 @@ chunk_free(grn_ctx *ctx, grn_ii *ii,
   gseg = &ii->header.common->garbages[m - GRN_II_W_LEAST_CHUNK];
   iw_.addr = NULL;
   while (*gseg != GRN_II_PSEG_NOT_ASSIGNED) {
-    ginfo = WIN_MAP(ii->chunk, ctx, &iw, *gseg, 0, S_GARBAGE, grn_io_rdwr);
+    ginfo = WIN_MAP(ii->chunk, ctx, &iw, *gseg, 0, S_GARBAGE, GRN_IO_RDWR);
     // GRN_IO_SEG_MAP2(ii->chunk, *gseg, ginfo);
     if (!ginfo) {
       if (iw_.addr) { grn_io_win_unmap(&iw_); }
@@ -712,7 +712,7 @@ chunk_free(grn_ctx *ctx, grn_ii *ii,
       if (iw_.addr) { grn_io_win_unmap(&iw_); }
       return rc;
     }
-    ginfo = WIN_MAP(ii->chunk, ctx, &iw, *gseg, 0, S_GARBAGE, grn_io_rdwr);
+    ginfo = WIN_MAP(ii->chunk, ctx, &iw, *gseg, 0, S_GARBAGE, GRN_IO_RDWR);
     /*
     uint32_t i = 0;
     while (HEADER_CHUNK_AT(ii, i)) {
@@ -3179,7 +3179,7 @@ merge_dump_source_chunk(grn_ctx *ctx,
                             info.segno,
                             0,
                             info.size,
-                            grn_io_rdonly);
+                            GRN_IO_RDONLY);
         if (!sub_chunk) {
           GRN_LOG(ctx, data->log_level,
                   "%s[%.*s][%d/%d] <%.*s>(%u): chunk: "
@@ -3761,7 +3761,7 @@ chunk_flush(grn_ctx *ctx, grn_ii *ii, chunk_info *cinfo, uint8_t *enc, uint32_t
   if (encsize) {
     chunk_new(ctx, ii, &dcn, encsize);
     if (ctx->rc == GRN_SUCCESS) {
-      if ((dc = WIN_MAP(ii->chunk, ctx, &dw, dcn, 0, encsize, grn_io_wronly))) {
+      if ((dc = WIN_MAP(ii->chunk, ctx, &dw, dcn, 0, encsize, GRN_IO_WRONLY))) {
         grn_memcpy(dc, enc, encsize);
         grn_io_win_unmap(&dw);
         cinfo->segno = dcn;
@@ -3800,7 +3800,7 @@ chunk_merge(grn_ctx *ctx,
   uint32_t segno = cinfo->segno;
   uint32_t size = cinfo->size;
   uint32_t ndf = 0;
-  uint8_t *scp = WIN_MAP(ii->chunk, ctx, &sw, segno, 0, size, grn_io_rdonly);
+  uint8_t *scp = WIN_MAP(ii->chunk, ctx, &sw, segno, 0, size, GRN_IO_RDONLY);
   datavec rdv[MAX_N_ELEMENTS + 1];
   size_t bufsize = S_SEGMENT * ii->n_elements;
 
@@ -4575,7 +4575,7 @@ fake_map(grn_ctx *ctx, grn_io *io, grn_io_win *iw, void *addr, uint32_t seg, uin
   iw->ctx = ctx;
   iw->diff = 0;
   iw->io = io;
-  iw->mode = grn_io_wronly;
+  iw->mode = GRN_IO_WRONLY;
   iw->segment = ((seg) >> GRN_II_N_CHUNK_VARIATION);
   iw->offset = (((seg) & ((1 << GRN_II_N_CHUNK_VARIATION) - 1)) << GRN_II_W_LEAST_CHUNK);
   iw->size = size;
@@ -4626,7 +4626,7 @@ buffer_flush(grn_ctx *ctx, grn_ii *ii, uint32_t lseg, grn_hash *h)
       uint8_t *sc = NULL;
       if ((scn = sb->header.chunk) == GRN_II_PSEG_NOT_ASSIGNED ||
           (sc = WIN_MAP(ii->chunk, ctx, &sw, scn, 0,
-                        sb->header.chunk_size, grn_io_rdonly))) {
+                        sb->header.chunk_size, GRN_IO_RDONLY))) {
         uint16_t n = sb->header.nterms;
         memset(db, 0, S_SEGMENT);
         grn_memcpy(db->terms, sb->terms, n * sizeof(buffer_term));
@@ -4742,7 +4742,7 @@ grn_ii_buffer_check(grn_ctx *ctx, grn_ii *ii, uint32_t lseg)
     GRN_OUTPUT_INT64(sb->header.chunk_size);
   } else {
     if ((sc = WIN_MAP(ii->chunk, ctx, &sw, scn, 0, sb->header.chunk_size,
-                      grn_io_rdonly))) {
+                      GRN_IO_RDONLY))) {
       GRN_OUTPUT_CSTR("chunk size");
       GRN_OUTPUT_INT64(sb->header.chunk_size);
     } else {
@@ -5027,7 +5027,7 @@ buffer_split(grn_ctx *ctx, grn_ii *ii, uint32_t lseg, grn_hash *h)
         uint8_t *sc = NULL;
         if ((scn = sb->header.chunk) == GRN_II_PSEG_NOT_ASSIGNED ||
             (sc = WIN_MAP(ii->chunk, ctx, &sw, scn, 0,
-                          sb->header.chunk_size, grn_io_rdonly))) {
+                          sb->header.chunk_size, GRN_IO_RDONLY))) {
           term_split(ctx, ii->lexicon, sb, db0, db1);
           uint8_t *dc0 = NULL;
           buffer_merge(ctx, ii, lseg, h, sb, sc, db0, &dc0);
@@ -6370,7 +6370,7 @@ chunk_is_reused(grn_ctx *ctx, grn_ii *ii, grn_ii_cursor *c, uint32_t offset, uin
     while (gseg != GRN_II_PSEG_NOT_ASSIGNED) {
       grn_io_win iw;
       grn_ii_ginfo *ginfo = WIN_MAP(ii->chunk, ctx, &iw, gseg, 0, S_GARBAGE,
-                                    grn_io_rdwr);
+                                    GRN_IO_RDWR);
       if (!ginfo) { break; }
       for (i = 0; i < ginfo->nrecs; i++) {
         if (ginfo->recs[i] == offset) {
@@ -6438,7 +6438,7 @@ grn_ii_cursor_open(grn_ctx *ctx, grn_ii *ii, grn_id tid,
       c->ppseg = grn_ii_get_buffer_pseg_address_inline(ii, lseg);
       if (bt->size_in_chunk && (chunk = c->buf->header.chunk) != GRN_II_PSEG_NOT_ASSIGNED) {
         if (!(c->cp = WIN_MAP(ii->chunk, ctx, &c->iw, chunk, bt->pos_in_chunk,
-                              bt->size_in_chunk, grn_io_rdonly))) {
+                              bt->size_in_chunk, GRN_IO_RDONLY))) {
           buffer_close(ctx, ii, c->buffer_pseg);
           GRN_FREE(c);
           c = NULL;
@@ -6665,7 +6665,7 @@ grn_ii_cursor_next_internal(grn_ctx *ctx, grn_ii_cursor *c,
                 uint32_t size = c->cinfo[c->curr_chunk].size;
                 if (size && (cp = WIN_MAP(c->ii->chunk, ctx, &iw,
                                           c->cinfo[c->curr_chunk].segno, 0,
-                                          size, grn_io_rdonly))) {
+                                          size, GRN_IO_RDONLY))) {
                   int decoded_size;
                   decoded_size =
                     grn_p_decv(ctx, c->ii, c->id,

  Modified: lib/io.c (+6 -6)
===================================================================
--- lib/io.c    2019-05-24 12:48:14 +0900 (355ae7c38)
+++ lib/io.c    2019-05-27 10:44:23 +0900 (32d39a300)
@@ -1137,8 +1137,8 @@ grn_io_win_map(grn_io *io, grn_ctx *ctx, grn_io_win *iw, uint32_t segment,
     if (!(iw->addr = GRN_MALLOC(size))) { return NULL; }
     iw->cached = 0;
     switch (mode) {
-    case grn_io_rdonly:
-    case grn_io_rdwr:
+    case GRN_IO_RDONLY:
+    case GRN_IO_RDWR:
       {
         byte *p, *q = NULL;
         uint32_t s, r;
@@ -1154,7 +1154,7 @@ grn_io_win_map(grn_io *io, grn_ctx *ctx, grn_io_win *iw, uint32_t segment,
         }
       }
       break;
-    case grn_io_wronly:
+    case GRN_IO_WRONLY:
       break;
     default :
       return NULL;
@@ -1175,12 +1175,12 @@ grn_io_win_unmap(grn_io_win *iw)
     grn_io *io = iw->io;
     grn_ctx *ctx = iw->ctx;
     switch (iw->mode) {
-    case grn_io_rdonly:
+    case GRN_IO_RDONLY:
       if (!iw->addr) { return GRN_INVALID_ARGUMENT; }
       GRN_FREE(iw->addr);
       return GRN_SUCCESS;
-    case grn_io_rdwr:
-    case grn_io_wronly:
+    case GRN_IO_RDWR:
+    case GRN_IO_WRONLY:
       {
         byte *p, *q = NULL;
         uint32_t segment_size = io->header->segment_size;

  Modified: lib/store.c (+2 -2)
===================================================================
--- lib/store.c    2019-05-24 12:48:14 +0900 (1ac7489e2)
+++ lib/store.c    2019-05-27 10:44:23 +0900 (4bb9ed312)
@@ -568,7 +568,7 @@ grn_ja_ref_raw(grn_ctx *ctx, grn_ja *ja, grn_id id, grn_io_win *iw, uint32_t *va
         } else {
           EINFO_DEC(ei, jag, vpos, vsize);
         }
-        grn_io_win_map(ja->io, ctx, iw, jag, vpos, vsize, grn_io_rdonly);
+        grn_io_win_map(ja->io, ctx, iw, jag, vpos, vsize, GRN_IO_RDONLY);
       }
       if (!iw->addr) { GRN_IO_SEG_UNREF(ja->io, pseg); }
     }
@@ -758,7 +758,7 @@ grn_ja_alloc(grn_ctx *ctx, grn_ja *ja, grn_id id,
       } else {
         if (i == j + n) {
           j++;
-          addr = grn_io_win_map(ja->io, ctx, iw, j, 0, element_size, grn_io_wronly);
+          addr = grn_io_win_map(ja->io, ctx, iw, j, 0, element_size, GRN_IO_WRONLY);
           if (!addr) {
             ERR(GRN_NO_MEMORY_AVAILABLE,
                 "[ja][alloc] failed to map new window: <%u>:<%u>",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190527/66f2ba90/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index