X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/d7e50217d7adf6e52786a38bcaa4cd698cb9a79e..ac5ea4a98a4e1d34a076095ea1eaa87e43d1f335:/osfmk/kern/zalloc.c?ds=sidebyside diff --git a/osfmk/kern/zalloc.c b/osfmk/kern/zalloc.c index 6c1b81d27..66e36c016 100644 --- a/osfmk/kern/zalloc.c +++ b/osfmk/kern/zalloc.c @@ -3,22 +3,19 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -326,8 +323,8 @@ zinit( ((size-1) % sizeof(z->free_elements)); if (alloc == 0) alloc = PAGE_SIZE; - alloc = round_page_32(alloc); - max = round_page_32(max); + alloc = round_page(alloc); + max = round_page(max); /* * We look for an allocation size with least fragmentation * in the range of 1 - 5 pages. This size will be used unless @@ -434,7 +431,7 @@ zget_space( * Add at least one page to allocation area. */ - space_to_add = round_page_32(size); + space_to_add = round_page(size); if (new_space == 0) { kern_return_t retval; @@ -503,7 +500,7 @@ zget_space( void zone_steal_memory(void) { - zdata_size = round_page_32(128*sizeof(struct zone)); + zdata_size = round_page(128*sizeof(struct zone)); zdata = pmap_steal_memory(zdata_size); } @@ -529,7 +526,7 @@ zfill( if (nelem <= 0) return 0; size = nelem * zone->elem_size; - size = round_page_32(size); + size = round_page(size); kr = kmem_alloc_wired(kernel_map, &memory, size); if (kr != KERN_SUCCESS) return 0; @@ -587,17 +584,17 @@ zone_init( FALSE, TRUE, &zone_map); if (retval != KERN_SUCCESS) panic("zone_init: kmem_suballoc failed"); - zone_max = zone_min + round_page_32(max_zonemap_size); + zone_max = zone_min + round_page(max_zonemap_size); /* * Setup garbage collection information: */ - zone_table_size = atop_32(zone_max - zone_min) * + zone_table_size = atop(zone_max - zone_min) * sizeof(struct zone_page_table_entry); if (kmem_alloc_wired(zone_map, (vm_offset_t *) &zone_page_table, zone_table_size) != KERN_SUCCESS) panic("zone_init"); - zone_min = (vm_offset_t)zone_page_table + round_page_32(zone_table_size); - zone_pages = atop_32(zone_max - zone_min); + zone_min = (vm_offset_t)zone_page_table + round_page(zone_table_size); + zone_pages = atop(zone_max - zone_min); zone_map_min_address = zone_min; zone_map_max_address = zone_max; simple_lock_init(&zone_page_table_lock, ETAP_MISC_ZONE_PTABLE); @@ -668,7 +665,7 @@ zalloc_canblock( if (vm_pool_low()) alloc_size = - round_page_32(zone->elem_size); + round_page(zone->elem_size); else alloc_size = zone->alloc_size; @@ -1007,8 +1004,8 @@ zone_page_collectable( panic("zone_page_collectable"); #endif - i = atop_32(addr-zone_map_min_address); - j = atop_32((addr+size-1) - zone_map_min_address); + i = atop(addr-zone_map_min_address); + j = atop((addr+size-1) - zone_map_min_address); lock_zone_page_table(); for (; i <= j; i++) { if (zone_page_table[i].in_free_list == @@ -1033,8 +1030,8 @@ zone_page_keep( panic("zone_page_keep"); #endif - i = atop_32(addr-zone_map_min_address); - j = atop_32((addr+size-1) - zone_map_min_address); + i = atop(addr-zone_map_min_address); + j = atop((addr+size-1) - zone_map_min_address); lock_zone_page_table(); for (; i <= j; i++) { zone_page_table[i].in_free_list = 0; @@ -1054,8 +1051,8 @@ zone_page_in_use( panic("zone_page_in_use"); #endif - i = atop_32(addr-zone_map_min_address); - j = atop_32((addr+size-1) - zone_map_min_address); + i = atop(addr-zone_map_min_address); + j = atop((addr+size-1) - zone_map_min_address); lock_zone_page_table(); for (; i <= j; i++) { if (zone_page_table[i].in_free_list > 0) @@ -1076,8 +1073,8 @@ zone_page_free( panic("zone_page_free"); #endif - i = atop_32(addr-zone_map_min_address); - j = atop_32((addr+size-1) - zone_map_min_address); + i = atop(addr-zone_map_min_address); + j = atop((addr+size-1) - zone_map_min_address); lock_zone_page_table(); for (; i <= j; i++) { assert(zone_page_table[i].in_free_list >= 0); @@ -1099,8 +1096,8 @@ zone_page_init( panic("zone_page_init"); #endif - i = atop_32(addr-zone_map_min_address); - j = atop_32((addr+size-1) - zone_map_min_address); + i = atop(addr-zone_map_min_address); + j = atop((addr+size-1) - zone_map_min_address); lock_zone_page_table(); for (; i <= j; i++) { zone_page_table[i].alloc_count = value; @@ -1121,8 +1118,8 @@ zone_page_alloc( panic("zone_page_alloc"); #endif - i = atop_32(addr-zone_map_min_address); - j = atop_32((addr+size-1) - zone_map_min_address); + i = atop(addr-zone_map_min_address); + j = atop((addr+size-1) - zone_map_min_address); lock_zone_page_table(); for (; i <= j; i++) { /* Set alloc_count to (ZONE_PAGE_USED + 1) if @@ -1149,8 +1146,8 @@ zone_page_dealloc( panic("zone_page_dealloc"); #endif - i = atop_32(addr-zone_map_min_address); - j = atop_32((addr+size-1) - zone_map_min_address); + i = atop(addr-zone_map_min_address); + j = atop((addr+size-1) - zone_map_min_address); lock_zone_page_table(); for (; i <= j; i++) { zone_page_table[i].alloc_count--; @@ -1171,8 +1168,8 @@ zone_add_free_page_list( panic("zone_add_free_page_list"); #endif - i = atop_32(addr-zone_map_min_address); - j = atop_32((addr+size-1) - zone_map_min_address); + i = atop(addr-zone_map_min_address); + j = atop((addr+size-1) - zone_map_min_address); lock_zone_page_table(); for (; i <= j; i++) { if (zone_page_table[i].alloc_count == 0) { @@ -1398,7 +1395,7 @@ host_zone_info( names = *namesp; } else { - names_size = round_page_32(max_zones * sizeof *names); + names_size = round_page(max_zones * sizeof *names); kr = kmem_alloc_pageable(ipc_kernel_map, &names_addr, names_size); if (kr != KERN_SUCCESS) @@ -1411,7 +1408,7 @@ host_zone_info( info = *infop; } else { - info_size = round_page_32(max_zones * sizeof *info); + info_size = round_page(max_zones * sizeof *info); kr = kmem_alloc_pageable(ipc_kernel_map, &info_addr, info_size); if (kr != KERN_SUCCESS) {