]> git.saurik.com Git - apple/libc.git/blob - include/libkern/OSMemoryNotification.h
d4e450bba76aca4159692155c4c362cc27728a15
[apple/libc.git] / include / libkern / OSMemoryNotification.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef _OSMEMORYNOTIFICATION_H_
25 #define _OSMEMORYNOTIFICATION_H_
26
27 #include <sys/cdefs.h>
28 #include <Availability.h>
29
30 /*
31 ** OSMemoryNotification.h
32 **
33 ** Kernel-generated notification mechanism to alert registered tasks when physical memory
34 ** pressure reaches certain thresholds. Notifications are triggered in both directions
35 ** so clients can manage their memory usage more and less aggressively.
36 **
37 ** All of these functions and data types are iOS-only and deprecated in iOS 5.0. Applications
38 ** should listen to UIKit memory warnings (didReceiveMemoryWarning or
39 ** UIApplicationDidReceiveMemoryWarningNotification) instead.
40 */
41
42 __BEGIN_DECLS
43
44 struct timeval;
45
46 /*
47 ** Opaque type for notification object
48 **
49 ** DEPRECATED. Use UIKit memory notification system.
50 */
51
52 typedef struct _OSMemoryNotification * OSMemoryNotificationRef;
53
54 /*
55 ** Threshold values for notifications
56 **
57 ** DEPRECATED. Use UIKit memory notification system.
58 */
59
60 typedef enum {
61 OSMemoryNotificationLevelAny = -1,
62 OSMemoryNotificationLevelNormal = 0,
63 OSMemoryNotificationLevelWarning = 1,
64 OSMemoryNotificationLevelUrgent = 2,
65 OSMemoryNotificationLevelCritical = 3
66 } OSMemoryNotificationLevel;
67
68 /*
69 ** Creation routines. Returns the created OSMemoryNotificationRef in the note param.
70 ** returns: 0 on success
71 ** ENOMEM if insufficient memory or resources exists to create the notification object
72 ** EINVAL if the threshold is not a valid notification level
73 **
74 ** DEPRECATED. Use UIKit memory notification system.
75 */
76
77 int OSMemoryNotificationCreate(OSMemoryNotificationRef *note) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_2_0, __IPHONE_5_0);
78
79 /*
80 ** returns: 0 on success
81 ** EINVAL if the notification is not an initialized notification object
82 **
83 ** DEPRECATED. Use UIKit memory notification system.
84 */
85
86 int OSMemoryNotificationDestroy(OSMemoryNotificationRef note) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_2_0, __IPHONE_5_0);
87
88 /*
89 ** Block waiting for notification
90 ** returns: 0 on success, with the level that triggered the notification in the level param
91 ** EINVAL if the notification object is invalid
92 ** ETIMEDOUT if abstime passes before notification occurs
93 **
94 ** 'note' is now ignored.
95 **
96 ** DEPRECATED. Use UIKit memory notification system.
97 */
98 int OSMemoryNotificationWait(OSMemoryNotificationRef note, OSMemoryNotificationLevel *level) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_2_0, __IPHONE_5_0);
99 int OSMemoryNotificationTimedWait(OSMemoryNotificationRef note, OSMemoryNotificationLevel *level, const struct timeval *abstime) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_2_0, __IPHONE_5_0);
100
101 /*
102 ** Simple polling interface to detect current memory pressure level
103 **
104 ** DEPRECATED. This is not a reliable way to discover the system's memory condition and
105 ** the level is not meaningful in iOS 5.0 and later. Use UIKit memory notification
106 ** system instead, with no need to check the level.
107 */
108
109 OSMemoryNotificationLevel OSMemoryNotificationCurrentLevel(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_2_0, __IPHONE_5_0);
110
111 /*
112 ** External notify(3) string for manual notification setup
113 **
114 ** DEPRECATED. Use UIKit memory notification system.
115 */
116
117 extern const char *kOSMemoryNotificationName __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_2_0, __IPHONE_5_0);
118
119 __END_DECLS
120
121 #endif /* _OSMEMORYNOTIFICATION_H_ */