]> mj.ucw.cz Git - libucw.git/commitdiff
ALIGN renamed to ALIGN_TO
authorRobert Spalek <robert@ucw.cz>
Thu, 26 Oct 2006 01:56:57 +0000 (18:56 -0700)
committerRobert Spalek <robert@ucw.cz>
Thu, 26 Oct 2006 01:56:57 +0000 (18:56 -0700)
images/image.c
lib/conf-intr.c
lib/fb-mmap.c
lib/lib.h
lib/lizard-safe.c
lib/partmap.c
lib/qache.c
lib/sorter.h

index e6111ab8e995d98819f090bfc45cc854266ff0e6..e42b06c18e9af0b247d65ea8d22067330d1a35a6 100644 (file)
@@ -71,7 +71,7 @@ image_new(struct image_context *ctx, uns cols, uns rows, uns flags, struct mempo
   else
     align = 1;
   row_pixels_size = cols * pixel_size;
-  row_size = ALIGN(row_pixels_size, align);
+  row_size = ALIGN_TO(row_pixels_size, align);
   u64 image_size_64 = (u64)row_size * rows;
   u64 bytes_64 = image_size_64 + (sizeof(struct image) + IMAGE_SSE_ALIGN_SIZE - 1 + sizeof(uns));
   if (unlikely(bytes_64 > image_max_bytes))
index 2d51fd90daca242b7223f0c1b3e0493e6809b48a..b90640f18563cce146db02dd6ed4182739cf3611 100644 (file)
@@ -102,7 +102,7 @@ byte *cf_op_names[] = { CF_OPERATIONS };
 #undef T
 byte *cf_type_names[] = { "int", "u64", "double", "ip", "string", "lookup", "user" };
 
-#define DARY_HDR_SIZE ALIGN(sizeof(uns), CPU_STRUCT_ALIGN)
+#define DARY_HDR_SIZE ALIGN_TO(sizeof(uns), CPU_STRUCT_ALIGN)
 
 static byte *
 interpret_set_dynamic(struct cf_item *item, int number, byte **pars, void **ptr)
index d7eaa3d0f6b3e33d1470efed659926281484fe2e..67b7f910d94d4cc9284f37ef8a1ec7434b1dd0ba 100644 (file)
@@ -51,8 +51,8 @@ bfmm_map_window(struct fastbuf *f)
   struct fb_mmap *F = FB_MMAP(f);
   sh_off_t pos0 = f->pos & ~(sh_off_t)(PAGE_SIZE-1);
   int l = MIN((sh_off_t)mmap_window_size, F->file_extend - pos0);
-  uns ll = ALIGN(l, PAGE_SIZE);
-  uns oll = ALIGN(f->bufend - f->buffer, PAGE_SIZE);
+  uns ll = ALIGN_TO(l, PAGE_SIZE);
+  uns oll = ALIGN_TO(f->bufend - f->buffer, PAGE_SIZE);
   int prot = ((F->mode & O_ACCMODE) == O_RDONLY) ? PROT_READ : (PROT_READ | PROT_WRITE);
 
   DBG(" ... Mapping %x(%x)+%x(%x) len=%x extend=%x", (int)pos0, (int)f->pos, ll, l, (int)F->file_size, (int)F->file_extend);
@@ -109,7 +109,7 @@ bfmm_spout(struct fastbuf *f)
   f->pos = end;
   if (f->pos >= F->file_extend)
     {
-      F->file_extend = ALIGN(F->file_extend + mmap_extend_size, (sh_off_t)PAGE_SIZE);
+      F->file_extend = ALIGN_TO(F->file_extend + mmap_extend_size, (sh_off_t)PAGE_SIZE);
       if (sh_ftruncate(F->fd, F->file_extend))
        die("ftruncate(%s): %m", f->name);
     }
@@ -137,7 +137,7 @@ bfmm_close(struct fastbuf *f)
   struct fb_mmap *F = FB_MMAP(f);
 
   if (f->buffer)
-    munmap(f->buffer, ALIGN(f->bufend-f->buffer, PAGE_SIZE));
+    munmap(f->buffer, ALIGN_TO(f->bufend-f->buffer, PAGE_SIZE));
   if (F->file_extend > F->file_size &&
       sh_ftruncate(F->fd, F->file_size))
     die("ftruncate(%s): %m", f->name);
index ec9d58b9a9d5e80cb1ed7e8581f6ca50d0b09c90..43135c6cc27f5409ece71fd5cd4c3a7376bbc6c1 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -27,7 +27,7 @@
 #define PTR_TO(s, i) &((s*)0)->i
 #define OFFSETOF(s, i) ((unsigned int) PTR_TO(s, i))
 #define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
-#define ALIGN(s, a) (((s)+a-1)&~(a-1))
+#define ALIGN_TO(s, a) (((s)+a-1)&~(a-1))
 #define ALIGN_PTR(p, s) ((addr_int_t)(p) % (s) ? (typeof(p))((addr_int_t)(p) + (s) - (addr_int_t)(p) % (s)) : (p))
 #define UNALIGNED_PART(ptr, type) (((addr_int_t) (ptr)) % sizeof(type))
 
index 4ca3d9befec41ed9ef001ca16cbc3d28aeac56e4..c91b847a147406dd42deb2060f46525c9ff05e24 100644 (file)
@@ -78,7 +78,7 @@ lizard_decompress_safe(byte *in, struct lizard_buffer *buf, uns expected_length)
    * case of buffer-overflow.  The function is not re-entrant because of a
    * static longjmp handler.  */
 {
-  uns lock_offset = ALIGN(expected_length + 3, PAGE_SIZE);     // +3 due to the unaligned access
+  uns lock_offset = ALIGN_TO(expected_length + 3, PAGE_SIZE);  // +3 due to the unaligned access
   if (lock_offset > buf->len)
     lizard_realloc(buf, lock_offset);
   volatile sh_sighandler_t old_handler = signal_handler[SIGSEGV];
index 49f12322492d60fc261260ebeec148aa28182e96..8dba8f8fcffe6ec891978d919db7430acf934cbd 100644 (file)
@@ -71,7 +71,7 @@ partmap_load(struct partmap *p, sh_off_t start, uns size)
   sh_off_t win_start = start/PAGE_SIZE * PAGE_SIZE;
   size_t win_len = PARTMAP_WINDOW;
   if ((sh_off_t) (win_start+win_len) > p->file_size)
-    win_len = ALIGN(p->file_size - win_start, PAGE_SIZE);
+    win_len = ALIGN_TO(p->file_size - win_start, PAGE_SIZE);
   if ((sh_off_t) (win_start+win_len) < end)
     die("partmap_map: Window is too small for mapping %d bytes", size);
   p->start_map = sh_mmap(NULL, win_len, p->writeable ? (PROT_READ | PROT_WRITE) : PROT_READ, MAP_SHARED, p->fd, win_start);
index 050f1c9a304d3eb6409afc0d83a75981b541214e..3802c3f6a1372ed6e59075ffdd77c3e897d8f9d8 100644 (file)
@@ -82,7 +82,7 @@ qache_msync(struct qache *q UNUSED, uns start UNUSED, uns len UNUSED)
   /* We don't need msyncing on Linux, since the mappings are guaranteed to be coherent */
   len += (start % PAGE_SIZE);
   start -= start % PAGE_SIZE;
-  len = ALIGN(len, PAGE_SIZE);
+  len = ALIGN_TO(len, PAGE_SIZE);
   if (msync(q->mmap_data + start, len, MS_ASYNC | MS_INVALIDATE) < 0)
     log(L_ERROR, "Cache %s: msync failed: %m", q->file_name);
 #endif
@@ -383,7 +383,7 @@ qache_open(struct qache_params *par)
   q->file_name = xstrdup(par->file_name);
 
   ASSERT(par->block_size >= 8 && !(par->block_size & (par->block_size-1)));
-  par->cache_size = ALIGN(par->cache_size, par->block_size);
+  par->cache_size = ALIGN_TO(par->cache_size, par->block_size);
 
   if (par->force_reset <= 0 && qache_open_existing(q, par))
     ;
index 11daf95a0c933d53fb2699dc15e20f52e7e85466..ed82eb34893fad81c80350a06975d264267b56da 100644 (file)
@@ -401,7 +401,7 @@ P(presort)(struct fastbuf **fb1, struct fastbuf **fb2)
        }
       for(;;)
        {
-         current = (byte *) ALIGN((addr_int_t) current, CPU_STRUCT_ALIGN);
+         current = (byte *) ALIGN_TO((addr_int_t) current, CPU_STRUCT_ALIGN);
          if (current + sizeof(*this) > bufend)
            break;
          this = (SORT_NODE *) current;