X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/55e303ae13a4cf49d70f2294092726f2fffb9ef2..39236c6e673c41db228275375ab7fdb0f837b292:/osfmk/profiling/i386/profile-md.h diff --git a/osfmk/profiling/i386/profile-md.h b/osfmk/profiling/i386/profile-md.h index 6158151d0..86ed5b023 100644 --- a/osfmk/profiling/i386/profile-md.h +++ b/osfmk/profiling/i386/profile-md.h @@ -1,16 +1,19 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2012 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ - * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * 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. + * 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. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER @@ -20,7 +23,7 @@ * Please see the License for the specific language governing rights and * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ @@ -154,8 +157,13 @@ * Integer types used. */ -typedef long prof_ptrint_t; /* hold either pointer or signed int */ -typedef unsigned long prof_uptrint_t; /* hold either pointer or unsigned int */ +/* + * These hold either a pointer or a signed/unsigned int. + * They are 32 bit on i386 and 64 bit on x86_64. + */ +typedef long prof_ptrint_t; +typedef unsigned long prof_uptrint_t; + typedef long prof_lock_t; /* lock word type */ typedef unsigned char prof_flag_t; /* type for boolean flags */ @@ -163,48 +171,15 @@ typedef unsigned char prof_flag_t; /* type for boolean flags */ * Double precision counter. */ -typedef struct prof_cnt_t { - prof_uptrint_t low; /* low 32 bits of counter */ - prof_uptrint_t high; /* high 32 bits of counter */ -} prof_cnt_t; - -#if defined(__GNUC__) && !defined(lint) -#define PROF_CNT_INC(cnt) \ - __asm__("addl $1,%0; adcl $0,%1" \ - : "=g" ((cnt).low), "=g" ((cnt).high) \ - : "0" ((cnt).low), "1" ((cnt).high)) - -#define PROF_CNT_ADD(cnt,val) \ - __asm__("addl %2,%0; adcl $0,%1" \ - : "=g,r" ((cnt).low), "=g,r" ((cnt).high) \ - : "r,g" ((unsigned long)(val)), \ - "0,0" ((cnt).low), "1,1" ((cnt).high)) - -#define PROF_CNT_LADD(cnt,val) \ - __asm__("addl %2,%0; adcl %3,%1" \ - : "=g,r" ((cnt).low), "=g,r" ((cnt).high) \ - : "r,g" ((val).low), "r,g" ((val).high), \ - "0,0" ((cnt).low), "1,1" ((cnt).high)) - -#define PROF_CNT_SUB(cnt,val) \ - __asm__("subl %2,%0; sbbl $0,%1" \ - : "=g,r" ((cnt).low), "=g,r" ((cnt).high) \ - : "r,g" ((unsigned long)(val)), \ - "0,0" ((cnt).low), "1,1" ((cnt).high)) - -#define PROF_CNT_LSUB(cnt,val) \ - __asm__("subl %2,%0; sbbl %3,%1" \ - : "=g,r" ((cnt).low), "=g,r" ((cnt).high) \ - : "r,g" ((val).low), "r,g" ((val).high), \ - "0,0" ((cnt).low), "1,1" ((cnt).high)) - -#else -#define PROF_CNT_INC(cnt) ((++((cnt).low) == 0) ? ++((cnt).high) : 0) -#define PROF_CNT_ADD(cnt,val) (((((cnt).low + (val)) < (val)) ? ((cnt).high++) : 0), ((cnt).low += (val))) -#define PROF_CNT_LADD(cnt,val) (PROF_CNT_ADD(cnt,(val).low), (cnt).high += (val).high) -#define PROF_CNT_SUB(cnt,val) (((((cnt).low - (val)) > (cnt).low) ? ((cnt).high--) : 0), ((cnt).low -= (val))) -#define PROF_CNT_LSUB(cnt,val) (PROF_CNT_SUB(cnt,(val).low), (cnt).high -= (val).high) -#endif +/* These are 64 bit on both i386 and x86_64 */ +typedef unsigned long prof_cnt_t; + +/* x86_64 */ +#define PROF_CNT_INC(cnt) (cnt++) +#define PROF_CNT_ADD(cnt,val) (cnt+=val) +#define PROF_CNT_LADD(cnt,val) (cnt+=val) +#define PROF_CNT_SUB(cnt,val) (cnt-=val) +#define PROF_CNT_LSUB(cnt,val) (cnt-=val) #define PROF_ULONG_TO_CNT(cnt,val) (((cnt).high = 0), ((cnt).low = val)) #define PROF_CNT_OVERFLOW(cnt,high,low) (((high) = (cnt).high), ((low) = (cnt).low))