/*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2016 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
@param size Size of the memory requested.
@result Pointer to the allocated memory, or zero on failure. */
-void * IOMalloc(vm_size_t size);
+void * IOMalloc(vm_size_t size) __attribute__((alloc_size(1)));
/*! @function IOFree
@abstract Frees memory allocated with IOMalloc.
@discussion This function frees memory allocated with IOMalloc, it may block and so should not be called from interrupt level or while a simple lock is held.
- @param address Pointer to the allocated memory.
- @param size Size of the memory allocated. */
+ @param address Pointer to the allocated memory. Must be identical to result
+ @of a prior IOMalloc.
+ @param size Size of the memory allocated. Must be identical to size of
+ @the corresponding IOMalloc */
void IOFree(void * address, vm_size_t size);
@param alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bit 0-7 zero.
@result Pointer to the allocated memory, or zero on failure. */
-void * IOMallocAligned(vm_size_t size, vm_offset_t alignment);
+void * IOMallocAligned(vm_size_t size, vm_offset_t alignment) __attribute__((alloc_size(1)));
/*! @function IOFreeAligned
@abstract Frees memory allocated with IOMallocAligned.
@result Virtual address of the allocated memory, or zero on failure. */
void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
- IOPhysicalAddress * physicalAddress) __attribute__((deprecated));
+ IOPhysicalAddress * physicalAddress) __attribute__((deprecated)) __attribute__((alloc_size(1)));
/*! @function IOFreeContiguous
@abstract Deprecated - use IOBufferMemoryDescriptor. Frees memory allocated with IOMallocContiguous.
@param alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bits 0-7 zero.
@result Pointer to the allocated memory, or zero on failure. */
-void * IOMallocPageable(vm_size_t size, vm_size_t alignment);
+void * IOMallocPageable(vm_size_t size, vm_size_t alignment) __attribute__((alloc_size(1)));
/*! @function IOFreePageable
@abstract Frees memory allocated with IOMallocPageable.
/*
* Typed memory allocation macros. Both may block.
*/
-#define IONew(type,number) (type*)IOMalloc(sizeof(type) * (number) )
+#define IONew(type,number) \
+( ((number) != 0 && ((vm_size_t) ((sizeof(type) * (number) / (number))) != sizeof(type)) /* overflow check 20847256 */ \
+ ? 0 \
+ : ((type*)IOMalloc(sizeof(type) * (number)))) )
+
#define IODelete(ptr,type,number) IOFree( (ptr) , sizeof(type) * (number) )
/////////////////////////////////////////////////////////////////////////////
void IOSleep(unsigned milliseconds);
+/*! @function IOSleepWithLeeway
+ @abstract Sleep the calling thread for a number of milliseconds, with a specified leeway the kernel may use for timer coalescing.
+ @discussion This function blocks the calling thread for at least the number of specified milliseconds, giving time to other processes. The kernel may also coalesce any timers involved in the delay, using the leeway given as a guideline.
+ @param intervalMilliseconds The integer number of milliseconds to wait.
+ @param leewayMilliseconds The integer number of milliseconds to use as a timer coalescing guideline. */
+
+void IOSleepWithLeeway(unsigned intervalMilliseconds, unsigned leewayMilliseconds);
+
/*! @function IODelay
@abstract Spin delay for a number of microseconds.
@discussion This function spins to delay for at least the number of specified microseconds. Since the CPU is busy spinning no time is made available to other processes; this method of delay should be used only for short periods. Also, the AbsoluteTime based APIs of kern/clock.h provide finer grained and lower cost delays.
/*! @function IOPause
@abstract Spin delay for a number of nanoseconds.
@discussion This function spins to delay for at least the number of specified nanoseconds. Since the CPU is busy spinning no time is made available to other processes; this method of delay should be used only for short periods.
- @param microseconds The integer number of nanoseconds to spin wait. */
+ @param nanoseconds The integer number of nanoseconds to spin wait. */
void IOPause(unsigned nanoseconds);
@abstract Log a message to console in text mode, and /var/log/system.log.
@discussion This function allows a driver to log diagnostic information to the screen during verbose boots, and to a log file found at /var/log/system.log. IOLog should not be called from interrupt context.
@param format A printf() style format string (see printf(3) documentation).
- @param other arguments described by the format string. */
+ */
void IOLog(const char *format, ...)
__attribute__((format(printf, 1, 2)));
@param format A printf() style format string (see printf(3) documentation).
@param ap stdarg(3) style variable arguments. */
-void IOLogv(const char *format, va_list ap);
+void IOLogv(const char *format, va_list ap)
+__attribute__((format(printf, 1, 0)));
#ifndef _FN_KPRINTF
#define _FN_KPRINTF
#else
struct OSDictionary *
#endif
-IOOFPathMatching( const char * path, char * buf, int maxLen );
+IOOFPathMatching( const char * path, char * buf, int maxLen ) __attribute__((deprecated));
/*
* Convert between size and a power-of-two alignment.
#endif /* __APPLE_API_OBSOLETE */
+#if XNU_KERNEL_PRIVATE
+vm_tag_t
+IOMemoryTag(vm_map_t map);
+#endif
+
__END_DECLS
#endif /* !__IOKIT_IOLIB_H */