/*
- * Copyright (c) 2006-2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2006-2013 Apple 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
* 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
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* 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_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _SYS_MCACHE_H
} while (0)
#endif /* __LP64__ */
-#define CPU_CACHE_SIZE 64
+#define atomic_or_8_ov(a, n) \
+ ((u_int8_t) OSBitOrAtomic8(n, (volatile UInt8 *)a))
+
+#define atomic_or_8(a, n) \
+ ((void) atomic_or_8_ov(a, n))
+
+#define atomic_bitset_8(a, n) \
+ atomic_or_8(a, n)
+
+#define atomic_or_16_ov(a, n) \
+ ((u_int16_t) OSBitOrAtomic16(n, (volatile UInt16 *)a))
+
+#define atomic_or_16(a, n) \
+ ((void) atomic_or_16_ov(a, n))
+
+#define atomic_bitset_16(a, n) \
+ atomic_or_16(a, n)
+
+#define atomic_or_32_ov(a, n) \
+ ((u_int32_t) OSBitOrAtomic(n, (volatile UInt32 *)a))
+
+#define atomic_or_32(a, n) \
+ ((void) atomic_or_32_ov(a, n))
+
+#define atomic_bitset_32(a, n) \
+ atomic_or_32(a, n)
+
+#define atomic_and_8_ov(a, n) \
+ ((u_int8_t) OSBitAndAtomic8(n, (volatile UInt8 *)a))
+
+#define atomic_and_8(a, n) \
+ ((void) atomic_and_8_ov(a, n))
+
+#define atomic_bitclear_8(a, n) \
+ atomic_and_8(a, ~(n))
+
+#define atomic_and_16_ov(a, n) \
+ ((u_int16_t) OSBitAndAtomic16(n, (volatile UInt16 *)a))
+
+#define atomic_and_16(a, n) \
+ ((void) atomic_and_16_ov(a, n))
+
+#define atomic_bitclear_16(a, n) \
+ atomic_and_16(a, ~(n))
+
+#define atomic_and_32_ov(a, n) \
+ ((u_int32_t) OSBitAndAtomic(n, (volatile UInt32 *)a))
+
+#define atomic_and_32(a, n) \
+ ((void) atomic_and_32_ov(a, n))
+
+#define atomic_bitclear_32(a, n) \
+ atomic_and_32(a, ~(n))
+
+/*
+ * Use CPU_CACHE_LINE_SIZE instead of MAX_CPU_CACHE_LINE_SIZE, unless
+ * wasting space is of no concern.
+ */
+#define MAX_CPU_CACHE_LINE_SIZE 64
+#define CPU_CACHE_LINE_SIZE mcache_cache_line_size()
#ifndef IS_P2ALIGNED
#define IS_P2ALIGNED(v, a) \
#ifndef P2ROUNDUP
#define P2ROUNDUP(x, align) \
- (-(-((uintptr_t)(x)) & -(align)))
+ (-(-((uintptr_t)(x)) & -((uintptr_t)align)))
#endif /* P2ROUNDUP */
#ifndef P2ROUNDDOWN
int cc_objs; /* number of objects in filled bkt */
int cc_pobjs; /* number of objects in previous bkt */
int cc_bktsize; /* number of elements in a full bkt */
-} __attribute__((aligned(CPU_CACHE_SIZE), packed)) mcache_cpu_t;
+} __attribute__((aligned(MAX_CPU_CACHE_LINE_SIZE), packed)) mcache_cpu_t;
typedef unsigned int (*mcache_allocfn_t)(void *, mcache_obj_t ***,
unsigned int, int);
mcache_t *mca_cache; /* parent cache of the buffer */
struct thread *mca_thread; /* thread doing transaction */
struct thread *mca_pthread; /* previous transaction thread */
- size_t mca_contents_size; /* size of contents */
- void *mca_contents; /* contents at last free */
+ size_t mca_contents_size; /* size of saved contents */
+ void *mca_contents; /* user-specific saved contents */
+ uint32_t mca_tstamp; /* transaction timestamp (ms) */
+ uint32_t mca_ptstamp; /* prev transaction timestamp (ms) */
uint16_t mca_depth; /* pc stack depth */
uint16_t mca_pdepth; /* previous transaction pc stack */
void *mca_stack[MCACHE_STACK_DEPTH];
__private_extern__ int assfail(const char *, const char *, int);
__private_extern__ void mcache_init(void);
__private_extern__ unsigned int mcache_getflags(void);
+__private_extern__ unsigned int mcache_cache_line_size(void);
__private_extern__ mcache_t *mcache_create(const char *, size_t,
size_t, u_int32_t, int);
__private_extern__ void *mcache_alloc(mcache_t *, int);
__private_extern__ void mcache_waiter_dec(mcache_t *);
__private_extern__ boolean_t mcache_bkt_isempty(mcache_t *);
-__private_extern__ void mcache_buffer_log(mcache_audit_t *, void *, mcache_t *);
+__private_extern__ void mcache_buffer_log(mcache_audit_t *, void *, mcache_t *,
+ struct timeval *);
__private_extern__ void mcache_set_pattern(u_int64_t, void *, size_t);
__private_extern__ void *mcache_verify_pattern(u_int64_t, void *, size_t);
__private_extern__ void *mcache_verify_set_pattern(u_int64_t, u_int64_t,
__private_extern__ void mcache_audit_panic(mcache_audit_t *, void *, size_t,
int64_t, int64_t);
-__private_extern__ mcache_t *mcache_audit_cache;
+extern mcache_t *mcache_audit_cache;
#ifdef __cplusplus
}