+#define MEMORYSTATUS_CMD_SET_JETSAM_PANIC_BITS 1001
+#endif /* PRIVATE */
+
+typedef struct memorystatus_priority_properties {
+ int32_t priority;
+ uint64_t user_data;
+} memorystatus_priority_properties_t;
+
+#ifdef XNU_KERNEL_PRIVATE
+
+/* p_memstat_state flags */
+
+#define P_MEMSTAT_SUSPENDED 0x00000001
+#define P_MEMSTAT_FROZEN 0x00000002
+#define P_MEMSTAT_NORECLAIM 0x00000004
+#define P_MEMSTAT_ERROR 0x00000008
+#define P_MEMSTAT_LOCKED 0x00000010
+#define P_MEMSTAT_TERMINATED 0x00000020
+#define P_MEMSTAT_NOTFIED 0x00000040
+#define P_MEMSTAT_PRIORITYUPDATED 0x00000080
+#define P_MEMSTAT_FOREGROUND 0x00000100
+#define P_MEMSTAT_DIAG_SUSPENDED 0x00000200
+#define P_MEMSTAT_PRIOR_THAW 0x00000400
+#define P_MEMSTAT_MEMLIMIT_BACKGROUND 0x00000800 /* Task has a memory limit for when it's in the background. Used for a process' "high water mark".*/
+#define P_MEMSTAT_INTERNAL 0x00001000
+#define P_MEMSTAT_FATAL_MEMLIMIT 0x00002000 /* cross this limit and the process is killed. Types: system-wide default task memory limit and per-task custom memory limit. */
+
+extern void memorystatus_init(void) __attribute__((section("__TEXT, initcode")));
+
+extern int memorystatus_add(proc_t p, boolean_t locked);
+extern int memorystatus_update(proc_t p, int priority, uint64_t user_data, boolean_t effective, boolean_t update_memlimit, int32_t memlimit, boolean_t memlimit_background, boolean_t is_fatal_limit);
+extern int memorystatus_remove(proc_t p, boolean_t locked);
+
+extern int memorystatus_dirty_track(proc_t p, uint32_t pcontrol);
+extern int memorystatus_dirty_set(proc_t p, boolean_t self, uint32_t pcontrol);
+extern int memorystatus_dirty_get(proc_t p);
+extern int memorystatus_dirty_clear(proc_t p, uint32_t pcontrol);
+
+extern int memorystatus_on_terminate(proc_t p);
+
+extern void memorystatus_on_suspend(proc_t p);
+extern void memorystatus_on_resume(proc_t p);
+extern void memorystatus_on_inactivity(proc_t p);
+
+extern void memorystatus_on_pageout_scan_end(void);
+
+/* Memorystatus kevent */
+
+void memorystatus_kevent_init(lck_grp_t *grp, lck_attr_t *attr);
+
+int memorystatus_knote_register(struct knote *kn);
+void memorystatus_knote_unregister(struct knote *kn);
+
+#if CONFIG_JETSAM
+
+typedef enum memorystatus_policy {
+ kPolicyDefault = 0x0,
+ kPolicyMoreFree = 0x1,
+ kPolicyDiagnoseAll = 0x2,
+ kPolicyDiagnoseFirst = 0x4,
+ kPolicyDiagnoseActive = (kPolicyDiagnoseAll | kPolicyDiagnoseFirst),
+} memorystatus_policy_t;
+
+extern int memorystatus_jetsam_wakeup;
+extern unsigned int memorystatus_jetsam_running;
+
+boolean_t memorystatus_kill_on_VM_page_shortage(boolean_t async);
+boolean_t memorystatus_kill_on_VM_thrashing(boolean_t async);
+boolean_t memorystatus_kill_on_FC_thrashing(boolean_t async);
+boolean_t memorystatus_kill_on_vnode_limit(void);
+
+void memorystatus_on_ledger_footprint_exceeded(int warning, const int max_footprint_mb);
+void jetsam_on_ledger_cpulimit_exceeded(void);
+
+void memorystatus_pages_update(unsigned int pages_avail);
+
+#else /* CONFIG_JETSAM */
+
+boolean_t memorystatus_idle_exit_from_VM(void);
+
+#endif /* !CONFIG_JETSAM */