]> granicus.if.org Git - php/commitdiff
Fixed 64-bit support
authorDmitry Stogov <dmitry@php.net>
Mon, 9 Apr 2007 15:38:58 +0000 (15:38 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 9 Apr 2007 15:38:58 +0000 (15:38 +0000)
Zend/zend_alloc.c
ext/spl/spl_directory.c
ext/standard/streamsfuncs.c
main/streams/plain_wrapper.c

index 9515cd4a1a77b9cbf8022d09f05429dee619ed03..b9a10dc14de16c1afdd4648b9a952700936125d7 100644 (file)
@@ -304,7 +304,7 @@ static const zend_mm_mem_handlers mem_handlers[] = {
 /* mm block type */
 typedef struct _zend_mm_block_info {
 #if ZEND_MM_COOKIES
-       unsigned long _cookie;
+       size_t _cookie;
 #endif
        size_t _size;
        size_t _prev;
@@ -429,7 +429,7 @@ struct _zend_mm_heap {
 static unsigned int _zend_mm_cookie = 0;
 
 # define ZEND_MM_COOKIE(block) \
-       (((unsigned long)(block)) ^ _zend_mm_cookie)
+       (((size_t)(block)) ^ _zend_mm_cookie)
 # define ZEND_MM_SET_COOKIE(block) \
        (block)->info._cookie = ZEND_MM_COOKIE(block)
 # define ZEND_MM_CHECK_COOKIE(block) \
@@ -447,11 +447,17 @@ static unsigned int _zend_mm_cookie = 0;
 /* Reserved space for error reporting in case of memory overflow */
 #define ZEND_MM_RESERVE_SIZE            (8*1024)
 
-#define ZEND_MM_TYPE_MASK                              0x3L
+#ifdef _WIN64
+# define ZEND_MM_LONG_CONST(x) (x##i64)
+#else
+# define ZEND_MM_LONG_CONST(x) (x##L)
+#endif
+
+#define ZEND_MM_TYPE_MASK              ZEND_MM_LONG_CONST(0x3)
 
-#define ZEND_MM_FREE_BLOCK                             0x0L
-#define ZEND_MM_USED_BLOCK                             0x1L
-#define ZEND_MM_GUARD_BLOCK                            0x3L
+#define ZEND_MM_FREE_BLOCK             ZEND_MM_LONG_CONST(0x0)
+#define ZEND_MM_USED_BLOCK             ZEND_MM_LONG_CONST(0x1)
+#define ZEND_MM_GUARD_BLOCK            ZEND_MM_LONG_CONST(0x3)
 
 #define ZEND_MM_BLOCK(b, type, size)   do { \
                                                                                        size_t _size = (size); \
@@ -710,7 +716,7 @@ static inline void zend_mm_add_to_free_list(zend_mm_heap *heap, zend_mm_free_blo
                        *p = mm_block;
                        mm_block->parent = p;
                        mm_block->prev_free_block = mm_block->next_free_block = mm_block;
-                       heap->large_free_bitmap |= (1L << index);
+                       heap->large_free_bitmap |= (ZEND_MM_LONG_CONST(1) << index);
                } else {
                        size_t m;
 
@@ -743,7 +749,7 @@ static inline void zend_mm_add_to_free_list(zend_mm_heap *heap, zend_mm_free_blo
 
                prev = ZEND_MM_SMALL_FREE_BUCKET(heap, index);
                if (prev->prev_free_block == prev) {
-                       heap->free_bitmap |= (1L << index);
+                       heap->free_bitmap |= (ZEND_MM_LONG_CONST(1) << index);
                }
                next = prev->next_free_block;
 
@@ -777,7 +783,7 @@ static inline void zend_mm_remove_from_free_list(zend_mm_heap *heap, zend_mm_fre
                        ZEND_MM_CHECK_TREE(mm_block);
                        *mm_block->parent = NULL;
                        if (mm_block->parent == &heap->large_free_buckets[index]) {
-                               heap->large_free_bitmap &= ~(1L << index);
+                               heap->large_free_bitmap &= ~(ZEND_MM_LONG_CONST(1) << index);
                    }
                } else {
                        while (*(cp = &(prev->child[prev->child[1] != NULL])) != NULL) {
@@ -815,7 +821,7 @@ subst_block:
                                size_t index = ZEND_MM_BUCKET_INDEX(ZEND_MM_FREE_BLOCK_SIZE(mm_block));
 
                                if (EXPECTED(heap->free_buckets[index*2] == heap->free_buckets[index*2+1])) {
-                                       heap->free_bitmap &= ~(1L << index);
+                                       heap->free_bitmap &= ~(ZEND_MM_LONG_CONST(1) << index);
                                }
                        }
                } else if (UNEXPECTED(mm_block->parent != NULL)) {
@@ -1022,7 +1028,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers,
        heap->real_size = 0;
        heap->overflow = 0;
        heap->real_peak = 0;
-       heap->limit = 1L<<30;
+       heap->limit = ZEND_MM_LONG_CONST(1)<<(ZEND_MM_NUM_BUCKETS-2);
        heap->size = 0;
        heap->peak = 0;
        heap->internal = internal;
@@ -1644,7 +1650,7 @@ static zend_mm_free_block *zend_mm_search_large_block(zend_mm_heap *heap, size_t
                                best_size = ZEND_MM_FREE_BLOCK_SIZE(p);
                                best_fit = p;
                        }
-                       if ((m & (1L << (ZEND_MM_NUM_BUCKETS-1))) == 0) {
+                       if ((m & (ZEND_MM_LONG_CONST(1) << (ZEND_MM_NUM_BUCKETS-1))) == 0) {
                                if (p->child[1]) {
                                        rst = p->child[1];
                                }
index c59f657981de276d82f7a3f8f07fe62085d82794..07cf43e4b4a3f6b8bd9b9be2c3d7315f56bc3a3f 100755 (executable)
@@ -595,7 +595,8 @@ SPL_METHOD(SplFileInfo, getBasename)
 {
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        char *fname, *suffix = 0;
-       int flen, slen = 0;
+       size_t flen;
+       int slen = 0;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &suffix, &slen) == FAILURE) {
                return;
@@ -621,7 +622,8 @@ SPL_METHOD(DirectoryIterator, getBasename)
 {
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        char *suffix = 0, *fname;
-       int slen = 0, flen;
+       int slen = 0;
+       size_t flen;
        
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &suffix, &slen) == FAILURE) {
                return;
index e296d9aaea48e81e68abcc6da3a61c90cf0079df..a964dd68828ac6b776327e1da6bcf85c0e39aa6e 100644 (file)
@@ -712,7 +712,7 @@ PHP_FUNCTION(stream_select)
        struct timeval  tv;
        struct timeval *tv_p = NULL;
        fd_set                  rfds, wfds, efds;
-       int                             max_fd = 0;
+       php_socket_t    max_fd = 0;
        int                             retval, sets = 0;
        long                    usec = 0;
        int                             set_count, max_set_count = 0;
index b913a42fdd97c071580c37bd4c705288ed3e5d23..8e31d02bc596e88438b0cd8415496515b867943e 100644 (file)
@@ -1301,7 +1301,7 @@ not_relative_path:
        
 #ifdef PHP_WIN32
        if (IS_SLASH(filename[0])) {
-               int cwd_len;
+               size_t cwd_len;
                char *cwd;
                cwd = virtual_getcwd_ex(&cwd_len TSRMLS_CC);
                /* getcwd() will return always return [DRIVE_LETTER]:/) on windows. */