From 7bd7e6e6c719585454346df74db211b9aba76ce9 Mon Sep 17 00:00:00 2001 From: Robert Spalek Date: Wed, 25 Oct 2006 18:56:57 -0700 Subject: [PATCH] ALIGN renamed to ALIGN_TO --- images/image.c | 2 +- lib/conf-intr.c | 2 +- lib/fb-mmap.c | 8 ++++---- lib/lib.h | 2 +- lib/lizard-safe.c | 2 +- lib/partmap.c | 2 +- lib/qache.c | 4 ++-- lib/sorter.h | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/images/image.c b/images/image.c index e6111ab8..e42b06c1 100644 --- a/images/image.c +++ b/images/image.c @@ -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)) diff --git a/lib/conf-intr.c b/lib/conf-intr.c index 2d51fd90..b90640f1 100644 --- a/lib/conf-intr.c +++ b/lib/conf-intr.c @@ -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) diff --git a/lib/fb-mmap.c b/lib/fb-mmap.c index d7eaa3d0..67b7f910 100644 --- a/lib/fb-mmap.c +++ b/lib/fb-mmap.c @@ -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); diff --git a/lib/lib.h b/lib/lib.h index ec9d58b9..43135c6c 100644 --- 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)) diff --git a/lib/lizard-safe.c b/lib/lizard-safe.c index 4ca3d9be..c91b847a 100644 --- a/lib/lizard-safe.c +++ b/lib/lizard-safe.c @@ -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]; diff --git a/lib/partmap.c b/lib/partmap.c index 49f12322..8dba8f8f 100644 --- a/lib/partmap.c +++ b/lib/partmap.c @@ -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); diff --git a/lib/qache.c b/lib/qache.c index 050f1c9a..3802c3f6 100644 --- a/lib/qache.c +++ b/lib/qache.c @@ -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)) ; diff --git a/lib/sorter.h b/lib/sorter.h index 11daf95a..ed82eb34 100644 --- a/lib/sorter.h +++ b/lib/sorter.h @@ -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; -- 2.39.2