apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Allan Edwards <a...@us.ibm.com>
Subject Re: [PATCH] WIN64: apr_pools.c
Date Tue, 05 Oct 2004 18:02:20 GMT
> I'm like Jeff, I won't lose any sleep if we just say that
> 64 bit APR 1.0 cannot handle very large memory objects and go
> the path of validating restricting and casting. At least let's
> pursue that path and see how ugly it gets.

Going with plan 'B'... I tend to think it would be useful to
use a #define for any 64bit warning-quieting casts so that they
can be easily identified & ripped out for APR 2.0 - comments?

Allan

Index: srclib/apr/include/apr.h.in
===================================================================
RCS file: /home/cvs/apr/include/apr.h.in,v
retrieving revision 1.137
diff -U3 -r1.137 apr.h.in
--- srclib/apr/include/apr.h.in	5 Jun 2004 11:52:43 -0000	1.137
+++ srclib/apr/include/apr.h.in	5 Oct 2004 17:56:20 -0000
@@ -266,6 +266,10 @@
  /* Are we big endian? */
  #define APR_IS_BIGENDIAN	@bigendian@

+#define APR_INT_CAST    int
+#define APR_UINT32_CAST apr_uint32_t
+#define APR_UINT32_MAX  0xFFFFFFFFUL
+
  /* Mechanisms to properly type numeric literals */
  @int64_literal@
  @uint64_literal@
Index: srclib/apr/include/apr.hnw
===================================================================
RCS file: /home/cvs/apr/include/apr.hnw,v
retrieving revision 1.49
diff -U3 -r1.49 apr.hnw
--- srclib/apr/include/apr.hnw	1 Oct 2004 19:24:03 -0000	1.49
+++ srclib/apr/include/apr.hnw	5 Oct 2004 17:56:20 -0000
@@ -330,6 +330,9 @@
  #define APR_UINT64_T_HEX_FMT     "llx"
  #define APR_TIME_T_FMT APR_INT64_T_FMT

+#define APR_INT_CAST    int
+#define APR_UINT32_CAST apr_uint32_t
+#define APR_UINT32_MAX  0xFFFFFFFFUL
  #define APR_DWORD_MAX 0xFFFFFFFFUL    /* 2^32*/
  /** @} */

Index: srclib/apr/include/apr.hw
===================================================================
RCS file: /home/cvs/apr/include/apr.hw,v
retrieving revision 1.127
diff -U3 -r1.127 apr.hw
--- srclib/apr/include/apr.hw	1 Oct 2004 19:24:03 -0000	1.127
+++ srclib/apr/include/apr.hw	5 Oct 2004 17:56:20 -0000
@@ -342,6 +342,9 @@
  #define APR_SIZEOF_VOIDP   4
  #endif

+#define APR_INT_CAST    int
+#define APR_UINT32_CAST apr_uint32_t
+#define APR_UINT32_MAX  0xFFFFFFFFUL
  #define APR_DWORD_MAX 0xFFFFFFFFUL

  /* XXX These simply don't belong here, perhaps in apr_portable.h
Index: srclib/apr/memory/unix/apr_pools.c
===================================================================
RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
retrieving revision 1.206
diff -U3 -r1.206 apr_pools.c
--- srclib/apr/memory/unix/apr_pools.c	17 Jun 2004 14:13:58 -0000	1.206
+++ srclib/apr/memory/unix/apr_pools.c	5 Oct 2004 17:56:20 -0000
@@ -139,9 +139,10 @@
  }

  APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator,
-                                             apr_size_t size)
+                                             apr_size_t in_size)
  {
      apr_uint32_t max_free_index;
+    apr_uint32_t size = (APR_UINT32_CAST)in_size;

  #if APR_HAS_THREADS
      apr_thread_mutex_t *mutex;
@@ -168,7 +169,8 @@
  apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size)
  {
      apr_memnode_t *node, **ref;
-    apr_uint32_t i, index, max_index;
+    apr_uint32_t max_index;
+    apr_size_t i, index;

      /* Round up the block size to the next boundary, but always
       * allocate at least a certain size (MIN_ALLOC).
@@ -181,6 +183,10 @@
       * dividing its size by the boundary size
       */
      index = (size >> BOUNDARY_INDEX) - 1;
+
+    if (index > APR_UINT32_MAX) {
+        return NULL;
+    }

      /* First see if there are any nodes in the area we know
       * our node will fit into.
@@ -293,7 +299,7 @@
          return NULL;

      node->next = NULL;
-    node->index = index;
+    node->index = (APR_UINT32_CAST)index;
      node->first_avail = (char *)node + APR_MEMNODE_T_SIZE;
      node->endp = (char *)node + size;

@@ -582,7 +588,7 @@
  {
      apr_memnode_t *active, *node;
      void *mem;
-    apr_uint32_t free_index;
+    apr_size_t free_index;

      size = APR_ALIGN_DEFAULT(size);
      active = pool->active;
@@ -620,7 +626,7 @@
      free_index = (APR_ALIGN(active->endp - active->first_avail + 1,
                              BOUNDARY_SIZE) - BOUNDARY_SIZE) >> BOUNDARY_INDEX;

-    active->free_index = free_index;
+    active->free_index = (APR_UINT32_CAST)free_index;
      node = active->next;
      if (free_index >= node->free_index)
          return mem;
@@ -877,7 +883,7 @@
      apr_size_t cur_len, size;
      char *strp;
      apr_pool_t *pool;
-    apr_uint32_t free_index;
+    apr_size_t free_index;

      pool = ps->pool;
      active = ps->node;
@@ -907,7 +913,7 @@
          free_index = (APR_ALIGN(active->endp - active->first_avail + 1,
                                  BOUNDARY_SIZE) - BOUNDARY_SIZE) >> BOUNDARY_INDEX;

-        active->free_index = free_index;
+        active->free_index = (APR_UINT32_CAST)free_index;
          node = active->next;
          if (free_index < node->free_index) {
              do {
@@ -948,7 +954,7 @@
      char *strp;
      apr_size_t size;
      apr_memnode_t *active, *node;
-    apr_uint32_t free_index;
+    apr_size_t free_index;

      ps.node = active = pool->active;
      ps.pool = pool;
@@ -1008,7 +1014,7 @@
      free_index = (APR_ALIGN(active->endp - active->first_avail + 1,
                              BOUNDARY_SIZE) - BOUNDARY_SIZE) >> BOUNDARY_INDEX;

-    active->free_index = free_index;
+    active->free_index = (APR_UINT32_CAST)free_index;
      node = active->next;

      if (free_index >= node->free_index)



Mime
View raw message