Loading...
libkern/c++/OSRuntime.cpp xnu-201.42.3 xnu-344.49
--- xnu/xnu-201.42.3/libkern/c++/OSRuntime.cpp
+++ xnu/xnu-344.49/libkern/c++/OSRuntime.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * 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.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * 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.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -44,13 +47,6 @@
 extern int debug_iomalloc_size;
 #endif
 
-#define	MDECL(reqlen)					\
-typedef union {						\
-	struct	_mhead hdr;				\
-	char	_m[(reqlen) + sizeof (struct _mhead)];	\
-} hdr_t;						\
-hdr_t
-
 struct _mhead {
 	size_t	mlen;
 	char	dat[0];
@@ -59,13 +55,13 @@
 void *kern_os_malloc(
 	size_t		size)
 {
-	MDECL(size)	*mem;
-	size_t		memsize = sizeof (*mem);
+	struct _mhead	*mem;
+	size_t		memsize = sizeof (*mem) + size ;
 
 	if (size == 0)
 		return (0);
 
-	mem = (hdr_t *)kalloc(memsize);
+	mem = (struct _mhead *)kalloc(memsize);
 	if (!mem)
 		return (0);
 
@@ -73,10 +69,10 @@
 	debug_iomalloc_size += memsize;
 #endif
 
-	mem->hdr.mlen = memsize;
-	(void) memset(mem->hdr.dat, 0, size);
-
-	return  (mem->hdr.dat);
+	mem->mlen = memsize;
+	(void) memset(mem->dat, 0, size);
+
+	return  (mem->dat);
 }
 
 void kern_os_free(
@@ -105,7 +101,7 @@
 	size_t		nsize)
 {
 	struct _mhead	*ohdr;
-	MDECL(nsize)	*nmem;
+	struct _mhead	*nmem;
 	size_t		nmemsize, osize;
 
 	if (!addr)
@@ -121,8 +117,8 @@
 		return (0);
 	}
 
-	nmemsize = sizeof (*nmem);
-	nmem = (hdr_t *) kalloc(nmemsize);
+	nmemsize = sizeof (*nmem) + nsize ;
+	nmem = (struct _mhead *) kalloc(nmemsize);
 	if (!nmem){
 		kern_os_free(addr);
 		return (0);
@@ -132,14 +128,14 @@
 	debug_iomalloc_size += (nmemsize - ohdr->mlen);
 #endif
 
-	nmem->hdr.mlen = nmemsize;
+	nmem->mlen = nmemsize;
 	if (nsize > osize)
-		(void) memset(&nmem->hdr.dat[osize], 0, nsize - osize);
-	(void) memcpy(nmem->hdr.dat, ohdr->dat,
+		(void) memset(&nmem->dat[osize], 0, nsize - osize);
+	(void) memcpy(nmem->dat, ohdr->dat,
 					(nsize > osize) ? osize : nsize);
 	kfree((vm_offset_t)ohdr, ohdr->mlen);
 
-	return (nmem->hdr.dat);
+	return (nmem->dat);
 }
 
 size_t kern_os_malloc_size(
@@ -154,7 +150,11 @@
 	return( hdr->mlen - sizeof (struct _mhead));
 }
 
+#if __GNUC__ >= 3
+void __cxa_pure_virtual( void )	{ panic(__FUNCTION__); }
+#else
 void __pure_virtual( void )	{ panic(__FUNCTION__); }
+#endif
 
 typedef void (*structor_t)(void);