Loading...
libkern/c++/OSRuntime.cpp xnu-1228 xnu-344.49
--- xnu/xnu-1228/libkern/c++/OSRuntime.cpp
+++ xnu/xnu-344.49/libkern/c++/OSRuntime.cpp
@@ -1,19 +1,16 @@
 /*
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
  * 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. The rights granted to you under the License
- * may not be used to create, or enable the creation or redistribution of,
- * unlawful or unlicensed copies of an Apple operating system, or to
- * circumvent, violate, or enable the circumvention or violation of, any
- * terms of an Apple operating system software license agreement.
- * 
- * Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 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
@@ -23,7 +20,7 @@
  * Please see the License for the specific language governing rights and
  * limitations under the License.
  * 
- * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ * @APPLE_LICENSE_HEADER_END@
  */
 /*
  * Copyright (c) 1997 Apple Computer, Inc.
@@ -73,7 +70,7 @@
 #endif
 
 	mem->mlen = memsize;
-	bzero( mem->dat, size);
+	(void) memset(mem->dat, 0, size);
 
 	return  (mem->dat);
 }
@@ -95,7 +92,7 @@
 #if 0
 	memset((vm_offset_t)hdr, 0xbb, hdr->mlen);
 #else
-	kfree(hdr, hdr->mlen);
+	kfree((vm_offset_t)hdr, hdr->mlen);
 #endif
 }
 
@@ -136,7 +133,7 @@
 		(void) memset(&nmem->dat[osize], 0, nsize - osize);
 	(void) memcpy(nmem->dat, ohdr->dat,
 					(nsize > osize) ? osize : nsize);
-	kfree(ohdr, ohdr->mlen);
+	kfree((vm_offset_t)ohdr, ohdr->mlen);
 
 	return (nmem->dat);
 }
@@ -161,11 +158,7 @@
 
 typedef void (*structor_t)(void);
 
-// Given a pointer to a 32 bit mach object segment, iterate the segment to
-// obtain a 32 bit destructor section for C++ objects, and call each of the
-// destructors there.
-void
-OSRuntimeUnloadCPPForSegment(struct segment_command * segment) {
+void OSRuntimeUnloadCPPForSegment(struct segment_command * segment) {
 
     struct section * section;
 
@@ -189,7 +182,6 @@
     return;
 }
 
-// This function will only operate on 32 bit kmods
 void OSRuntimeUnloadCPP(kmod_info_t *ki, void *)
 {
     if (ki && ki->address) {
@@ -232,7 +224,6 @@
 }
 
 // Functions used by the extenTools/kmod library project
-// This function will only operate on 32 bit kmods
 kern_return_t OSRuntimeInitializeCPP(kmod_info_t *ki, void *)
 {
     struct mach_header *header;
@@ -322,14 +313,8 @@
 }
 
 static KMOD_LIB_DECL(__kernel__, 0);
-
-extern lck_spin_t  gOSObjectTrackLock;
-extern lck_grp_t * IOLockGroup;
-
 void OSlibkernInit(void)
 {
-    lck_spin_init(&gOSObjectTrackLock, IOLockGroup, LCK_ATTR_NULL);
-
     vm_address_t *headerArray = (vm_address_t *) getmachheaders();
 
     KMOD_INFO_NAME.address = headerArray[0]; assert(!headerArray[1]);
@@ -346,6 +331,8 @@
     void * result;
 
     result = (void *) kern_os_malloc( size);
+    if( result)
+	bzero( result, size);
     return( result);
 }