]> mj.ucw.cz Git - libucw.git/commitdiff
Use uintptr_t instead of addr_int_t.
authorMartin Mares <mj@ucw.cz>
Fri, 2 Feb 2007 11:02:39 +0000 (12:02 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 2 Feb 2007 11:02:39 +0000 (12:02 +0100)
No need to use our own type when we already rely on C99 anyway.

15 files changed:
images/image-test.c
lib/bigalloc.c
lib/conf-dump.c
lib/conf-intr.c
lib/conf-section.c
lib/fastbuf.h
lib/hashfunc.h
lib/kmp-test.c
lib/kmp.h
lib/mempool.c
lib/mempool.h
lib/redblack.h
lib/shell/config.c
lib/sorter.h
lib/wildmatch.c

index 0a22d47907abcf648d605316943e9a0e461e098d..043da30a29bc15c68eea31ad6ffb89b7d3c0f3e5 100644 (file)
@@ -64,7 +64,7 @@ test_image_iface(void)
   ASSERT(i1->pixel_size == 4);
   ASSERT(IMAGE_SSE_ALIGN_SIZE >= 16);
   ASSERT(!(i1->row_size & (IMAGE_SSE_ALIGN_SIZE - 1)));
-  ASSERT(!((addr_int_t)i1->pixels & (IMAGE_SSE_ALIGN_SIZE - 1)));
+  ASSERT(!((uintptr_t)i1->pixels & (IMAGE_SSE_ALIGN_SIZE - 1)));
   image_destroy(i1);
 
   i1 = image_new(&ctx, 283, 329, COLOR_SPACE_RGB, NULL);
index e2be03a227de42c95e21bed5b59b19dbe397bf99..ad6aeff0cd523e9acc97bcc53408e8367abb989d 100644 (file)
@@ -39,7 +39,7 @@ void
 big_free(void *start, unsigned int len)
 {
   byte *p = start;
-  ASSERT(!((addr_int_t) p & (CPU_PAGE_SIZE-1)));
+  ASSERT(!((uintptr_t) p & (CPU_PAGE_SIZE-1)));
   len = big_round(len);
 #ifdef CONFIG_DEBUG
   p -= CPU_PAGE_SIZE;
index 073bf129e4cd5096a2a11ca6c1a3dc609a993015..c4ac16bb076f847ff1a83c282429871057694894 100644 (file)
@@ -53,7 +53,7 @@ static byte *class_names[] = { "end", "static", "dynamic", "parser", "section",
 static void
 dump_item(struct fastbuf *fb, struct cf_item *item, int level, void *ptr)
 {
-  ptr += (addr_int_t) item->ptr;
+  ptr += (uintptr_t) item->ptr;
   enum cf_type type = item->type;
   uns size = cf_type_size(item->type, item->u.utype);
   int i;
index b90640f18563cce146db02dd6ed4182739cf3611..9777e5711a426f71e409dd6a4369312e041ac2a7 100644 (file)
@@ -151,7 +151,7 @@ interpret_section(struct cf_section *sec, int number, byte **pars, int *processe
   for (struct cf_item *ci=sec->cfg; ci->cls; ci++)
   {
     int taken;
-    byte *msg = interpret_set_item(ci, number, pars, &taken, ptr + (addr_int_t) ci->ptr, allow_dynamic && !ci[1].cls);
+    byte *msg = interpret_set_item(ci, number, pars, &taken, ptr + (uintptr_t) ci->ptr, allow_dynamic && !ci[1].cls);
     if (msg)
       return cf_printf("Item %s: %s", ci->name, msg);
     *processed += taken;
@@ -333,8 +333,8 @@ static int
 cmp_items(void *i1, void *i2, struct cf_item *item)
 {
   ASSERT(item->cls == CC_STATIC);
-  i1 += (addr_int_t) item->ptr;
-  i2 += (addr_int_t) item->ptr;
+  i1 += (uintptr_t) item->ptr;
+  i2 += (uintptr_t) item->ptr;
   if (item->type == CT_STRING)
     return strcmp(* (byte**) i1, * (byte**) i2);
   else                         // all numeric types
@@ -504,7 +504,7 @@ find_item(struct cf_section *curr_sec, byte *name, byte **msg, void **ptr)
        *msg = cf_printf("Unknown item %s", name);
       return NULL;
     }
-    *ptr += (addr_int_t) ci->ptr;
+    *ptr += (uintptr_t) ci->ptr;
     if (!c)
       return ci;
     if (ci->cls != CC_SECTION)
index b06b9fd6bca499534966740ed1b3c3c42c6baf8f..bbd3416426ef5ddc643928cfb739cd07bf34102f 100644 (file)
@@ -140,11 +140,11 @@ cf_init_section(byte *name, struct cf_section *sec, void *ptr, uns do_bzero)
   }
   for (struct cf_item *ci=sec->cfg; ci->cls; ci++)
     if (ci->cls == CC_SECTION)
-      cf_init_section(ci->name, ci->u.sec, ptr + (addr_int_t) ci->ptr, 0);
+      cf_init_section(ci->name, ci->u.sec, ptr + (uintptr_t) ci->ptr, 0);
     else if (ci->cls == CC_LIST)
-      clist_init(ptr + (addr_int_t) ci->ptr);
+      clist_init(ptr + (uintptr_t) ci->ptr);
     else if (ci->cls == CC_DYNAMIC) {
-      void **dyn = ptr + (addr_int_t) ci->ptr;
+      void **dyn = ptr + (uintptr_t) ci->ptr;
       if (!*dyn) {                     // replace NULL by an empty array
        static uns zero = 0;
        *dyn = (&zero) + 1;
@@ -163,13 +163,13 @@ commit_section(struct cf_section *sec, void *ptr, uns commit_all)
   byte *err;
   for (struct cf_item *ci=sec->cfg; ci->cls; ci++)
     if (ci->cls == CC_SECTION) {
-      if ((err = commit_section(ci->u.sec, ptr + (addr_int_t) ci->ptr, commit_all))) {
+      if ((err = commit_section(ci->u.sec, ptr + (uintptr_t) ci->ptr, commit_all))) {
        log(L_ERROR, "Cannot commit section %s: %s", ci->name, err);
        return "commit of a subsection failed";
       }
     } else if (ci->cls == CC_LIST) {
       uns idx = 0;
-      CLIST_FOR_EACH(cnode *, n, * (clist*) (ptr + (addr_int_t) ci->ptr))
+      CLIST_FOR_EACH(cnode *, n, * (clist*) (ptr + (uintptr_t) ci->ptr))
        if (idx++, err = commit_section(ci->u.sec, n, commit_all)) {
          log(L_ERROR, "Cannot commit node #%d of list %s: %s", idx, ci->name, err);
          return "commit of a list failed";
index 283281075561aed591277313a9cb4c329c58f60f..598a21d942f0c0997c31e0f0e2fb1d9f70d4492c 100644 (file)
@@ -402,7 +402,7 @@ static inline int bskip(struct fastbuf *f, uns len)
     return bskip_slow(f, len);
 }
 
-/* I/O on addr_int_t */
+/* I/O on uintptr_t */
 
 #ifdef CPU_64BIT_POINTERS
 #define bputa(x,p) bputq(x,p)
index fc836b3848588a7945b26380caa65dbac4355580..5f40c3d6783eb6c7346451a813170ca442347599 100644 (file)
@@ -38,6 +38,6 @@ uns hash_string_nocase(const byte *str) PURE;
  */
 static inline uns CONST hash_u32(uns x) { return 0x01008041*x; }
 static inline uns CONST hash_u64(u64 x) { return hash_u32((uns)x ^ (uns)(x >> 32)); }
-static inline uns CONST hash_pointer(void *x) { return ((sizeof(x) <= 4) ? hash_u32((uns)(addr_int_t)x) : hash_u64((u64)(addr_int_t)x)); }
+static inline uns CONST hash_pointer(void *x) { return ((sizeof(x) <= 4) ? hash_u32((uns)(uintptr_t)x) : hash_u64((u64)(uintptr_t)x)); }
 
 #endif
index e245fcff0de8e8f9a184cee6aef7e5242955c5e9..fcbc96efcff40a7e3997205c76f7207c89611beb 100644 (file)
@@ -167,7 +167,7 @@ kmp4_eq(struct kmp4_struct *kmp UNUSED, byte *a, byte *b)
 static inline uns
 kmp4_hash(struct kmp4_struct *kmp UNUSED, struct kmp4_state *s, byte *c)
 {
-  return (c ? (*c << 16) : 0) + (uns)(addr_int_t)s;
+  return (c ? (*c << 16) : 0) + (uns)(uintptr_t)s;
 }
 
 #define KMP_PREFIX(x) kmp4_##x
index 67889a17e9e78c03ce30e5eee9f39935ad0ffac4..aa889f694d08b25209b71cc17970af7ad8144806 100644 (file)
--- a/lib/kmp.h
+++ b/lib/kmp.h
@@ -168,7 +168,7 @@ P(hash_hash) (struct P(hash_table) *t, struct P(state) *f, P(char_t) c)
 static inline uns
 P(hash_hash) (struct P(hash_table) *t UNUSED, struct P(state) *f, P(char_t) c)
 {
-  return (((uns)c) << 16) + (uns)(addr_int_t)f;
+  return (((uns)c) << 16) + (uns)(uintptr_t)f;
 }
 #endif
 
index af65b2856770199bf73e38320b34941d6716814a..fffbbd299651f95022e15d8bae4836c45753eb8b 100644 (file)
@@ -68,7 +68,7 @@ mp_alloc(struct mempool *p, uns s)
 {
   if (s <= p->threshold)
     {
-      byte *x = (byte *)(((addr_int_t) p->free + POOL_ALIGN - 1) & ~(addr_int_t)(POOL_ALIGN - 1));
+      byte *x = (byte *)(((uintptr_t) p->free + POOL_ALIGN - 1) & ~(uintptr_t)(POOL_ALIGN - 1));
       if (x + s > p->last)
        {
          struct memchunk *c;
index efb5fa1bfe86e211570ba0e5caf5c8026e1cc238..d16fa6e09162abe44b14dd771c42e2ad49ecb3a8 100644 (file)
@@ -30,7 +30,7 @@ void *mp_alloc_zero(struct mempool *, uns) LIKE_MALLOC;
 static inline void * LIKE_MALLOC
 mp_alloc_fast(struct mempool *p, uns l)
 {
-  byte *f = (void *) (((addr_int_t) p->free + POOL_ALIGN - 1) & ~(addr_int_t)(POOL_ALIGN - 1));
+  byte *f = (void *) (((uintptr_t) p->free + POOL_ALIGN - 1) & ~(uintptr_t)(POOL_ALIGN - 1));
   byte *ee = f + l;
   if (ee > p->last)
     return mp_alloc(p, l);
index 1776bedbcc20600138dee3decf4c3c3c2e443e6b..e278204856afa1c2ff6d4329fd013a2f666834d9 100644 (file)
@@ -263,13 +263,13 @@ typedef struct P(stack_entry) {
 #else
        /* Pointers are aligned, hence we can use lower bits.  */
        static inline uns P(red_flag) (P(bucket) *node)
-       { return ((addr_int_t) node->son[0]) & 1L; }
+       { return ((uintptr_t) node->son[0]) & 1L; }
        static inline void P(set_red_flag) (P(bucket) *node, uns flag)
-       { node->son[0] = (void*) ( (((addr_int_t) node->son[0]) & ~1L) | (flag & 1L) ); }
+       { node->son[0] = (void*) ( (((uintptr_t) node->son[0]) & ~1L) | (flag & 1L) ); }
        static inline P(bucket) * P(tree_son) (P(bucket) *node, uns id)
-       { return (void *) (((addr_int_t) node->son[id]) & ~1L); }
+       { return (void *) (((uintptr_t) node->son[id]) & ~1L); }
        static inline void P(set_tree_son) (P(bucket) *node, uns id, P(bucket) *son)
-       { node->son[id] = (void *) ((addr_int_t) son | (((addr_int_t) node->son[id]) & 1L) ); }
+       { node->son[id] = (void *) ((uintptr_t) son | (((uintptr_t) node->son[id]) & 1L) ); }
 #endif
 
 /* Defaults for missing parameters.  */
index df53a4084610c33a77dee931ef8780b425de1407..02d89dd854a6e6464bb60ff6b662283fbc325742 100644 (file)
@@ -274,7 +274,7 @@ parse_section(struct section *section)
        }
       if (section->item.cf.cls == CC_LIST)
         {
-          item->cf.ptr = (void *)(addr_int_t)section->size;
+          item->cf.ptr = (void *)(uintptr_t)section->size;
           section->size += sizeof(union value);
         }
       else
@@ -375,7 +375,7 @@ dump_item(struct item *item, void *ptr, uns path_len)
 {
   if (item->flags & FLAG_HIDE)
     return;
-  byte *val = (byte *)((addr_int_t)ptr + (addr_int_t)item->cf.ptr);
+  byte *val = (byte *)((uintptr_t)ptr + (uintptr_t)item->cf.ptr);
   if (item->cf.cls == CC_LIST)
     {
       uns len = strlen(item->cf.name);
index ed82eb34893fad81c80350a06975d264267b56da..71fcff1ecc6cbe4011290d7dbfe4b899996e1ad3 100644 (file)
@@ -401,7 +401,7 @@ P(presort)(struct fastbuf **fb1, struct fastbuf **fb2)
        }
       for(;;)
        {
-         current = (byte *) ALIGN_TO((addr_int_t) current, CPU_STRUCT_ALIGN);
+         current = (byte *) ALIGN_TO((uintptr_t) current, CPU_STRUCT_ALIGN);
          if (current + sizeof(*this) > bufend)
            break;
          this = (SORT_NODE *) current;
index a5eb76ede41e01ac52e84e12a9fb3d3347d0a33f..fed2ddb944efd5e9c8e6141cdbeb5fbe3337be52 100644 (file)
@@ -29,7 +29,7 @@ struct nfa_state {
 };
 
 struct dfa_state {
-  addr_int_t edge[256];                /* Outgoing DFA edges. Bit 0 is set for incomplete edges which
+  uintptr_t edge[256];         /* Outgoing DFA edges. Bit 0 is set for incomplete edges which
                                 * contain just state set and clear for complete ones which point
                                 * to other states. NULL means `no match'.
                                 */
@@ -157,12 +157,12 @@ wp_match(struct wildpatt *w, byte *s)
   d = w->dfa_start;
   while (*s)
     {
-      addr_int_t next = d->edge[*s];
+      uintptr_t next = d->edge[*s];
       if (next & 1)
        {
          /* Need to lookup/create the destination state */
          struct dfa_state *new = wp_new_state(w, next & ~1);
-         d->edge[*s] = (addr_int_t) new;
+         d->edge[*s] = (uintptr_t) new;
          d = new;
        }
       else if (!next)