]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/UserNotification/KUNCUserNotifications.c
xnu-1504.9.37.tar.gz
[apple/xnu.git] / osfmk / UserNotification / KUNCUserNotifications.c
index 21ef970a07e781fc4fd064a3ad365b400c88920d..740b8f12571b3bb26963d86a91f3eb86685065f5 100644 (file)
@@ -1,23 +1,29 @@
 /*
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2006 Apple Inc. All rights reserved.
  *
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * 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. 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.
  * 
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * 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_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 
 #include <mach/port.h>
  */
 
 #include <mach/port.h>
  */
 
 struct UNDReply {
  */
 
 struct UNDReply {
-       decl_mutex_data(,lock)                          /* UNDReply lock */
+       decl_lck_mtx_data(,lock)                                /* UNDReply lock */
        int                             userLandNotificationKey;
        KUNCUserNotificationCallBack    callback;
        boolean_t                       inprogress;
        ipc_port_t                      self_port;      /* Our port */
 };
 
        int                             userLandNotificationKey;
        KUNCUserNotificationCallBack    callback;
        boolean_t                       inprogress;
        ipc_port_t                      self_port;      /* Our port */
 };
 
-#define UNDReply_lock(reply)           mutex_lock(&reply->lock)
-#define UNDReply_lock_try(reply)       mutex_lock_try(&(reply)->lock)
-#define UNDReply_unlock(reply)         mutex_unlock(&(reply)->lock)
+#define UNDReply_lock(reply)           lck_mtx_lock(&reply->lock)
+#define UNDReply_unlock(reply)         lck_mtx_lock(&reply->lock)
 
 /* forward declarations */
 void UNDReply_deallocate(
 
 /* forward declarations */
 void UNDReply_deallocate(
@@ -110,7 +115,11 @@ UNDAlertCompletedWithResult_rpc (
         UNDReplyRef            reply,
         int                    result,
         xmlData_t              keyRef,         /* raw XML bytes */
         UNDReplyRef            reply,
         int                    result,
         xmlData_t              keyRef,         /* raw XML bytes */
+#ifdef KERNEL_CF
         mach_msg_type_number_t keyLen)
         mach_msg_type_number_t keyLen)
+#else
+        __unused mach_msg_type_number_t        keyLen)
+#endif
 {
 #ifdef KERNEL_CF
        CFStringRef             xmlError = NULL;
 {
 #ifdef KERNEL_CF
        CFStringRef             xmlError = NULL;
@@ -139,7 +148,7 @@ UNDAlertCompletedWithResult_rpc (
 #endif /* KERNEL_CF */
 
        if (reply->callback) {
 #endif /* KERNEL_CF */
 
        if (reply->callback) {
-               (reply->callback)((KUNCUserNotificationID) reply, result, dict);
+               (reply->callback)((int)(KUNCUserNotificationID)reply, result, dict);
        }
 
        UNDReply_lock(reply);
        }
 
        UNDReply_lock(reply);
@@ -180,9 +189,10 @@ UNDNotificationCreated_rpc (
  * KUNC Functions
 */
 
  * KUNC Functions
 */
 
+extern lck_grp_t LockCompatGroup;
 
 KUNCUserNotificationID
 
 KUNCUserNotificationID
-KUNCGetNotificationID()
+KUNCGetNotificationID(void)
 {
        UNDReplyRef reply;
 
 {
        UNDReplyRef reply;
 
@@ -193,7 +203,7 @@ KUNCGetNotificationID()
                        kfree(reply, sizeof(struct UNDReply));
                        reply = UND_REPLY_NULL;
                } else {
                        kfree(reply, sizeof(struct UNDReply));
                        reply = UND_REPLY_NULL;
                } else {
-                       mutex_init(&reply->lock, 0);
+                       lck_mtx_init(&reply->lock, &LockCompatGroup, LCK_ATTR_NULL);
                        reply->userLandNotificationKey = -1;
                        reply->inprogress = FALSE;
                        ipc_kobject_set(reply->self_port,
                        reply->userLandNotificationKey = -1;
                        reply->inprogress = FALSE;
                        ipc_kobject_set(reply->self_port,