Skip to content

The Mojave Core Foundation merge. #1708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CoreFoundation/AppServices.subproj/CFNotificationCenter.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* CFNotificationCenter.h
Copyright (c) 1998-2017, Apple Inc. and the Swift project authors
Copyright (c) 1998-2018, Apple Inc. and the Swift project authors

Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
Portions Copyright (c) 2014-2018, Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
Expand Down Expand Up @@ -37,7 +37,7 @@ CF_EXPORT CFTypeID CFNotificationCenterGetTypeID(void);

CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetLocalCenter(void);

#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || TARGET_OS_WIN32
#if TARGET_OS_OSX || TARGET_OS_WIN32
CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);
#endif

Expand Down
50 changes: 27 additions & 23 deletions CoreFoundation/AppServices.subproj/CFUserNotification.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* CFUserNotification.c
Copyright (c) 2000-2017, Apple Inc. All rights reserved.
Copyright (c) 2000-2018, Apple Inc. All rights reserved.

Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
Portions Copyright (c) 2014-2018, Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
Expand All @@ -14,6 +14,7 @@
#include <CoreFoundation/CFNumber.h>
#include <CoreFoundation/CFRunLoop.h>
#include "CFInternal.h"
#include "CFRuntime_Internal.h"
#include <CoreFoundation/CFMachPort.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down Expand Up @@ -54,13 +55,13 @@ CONST_STRING_DECL(kCFUserNotificationPopUpTitlesKey, "PopUpTitles")
CONST_STRING_DECL(kCFUserNotificationTextFieldTitlesKey, "TextFieldTitles")
CONST_STRING_DECL(kCFUserNotificationCheckBoxTitlesKey, "CheckBoxTitles")
CONST_STRING_DECL(kCFUserNotificationTextFieldValuesKey, "TextFieldValues")
#if TARGET_OS_OSX
CONST_STRING_DECL(kCFUserNotificationPopUpSelectionKey, "PopUpSelection")
#endif
CONST_STRING_DECL(kCFUserNotificationKeyboardTypesKey, "KeyboardTypes")
CONST_STRING_DECL(kCFUserNotificationAlertTopMostKey, "AlertTopMost") // boolean value


static CFTypeID __kCFUserNotificationTypeID = _kCFRuntimeNotATypeID;

struct __CFUserNotification {
CFRuntimeBase _base;
SInt32 _replyPort;
Expand All @@ -86,18 +87,13 @@ static CFStringRef __CFUserNotificationCopyDescription(CFTypeRef cf) {
#define MAX_PORT_NAME_LENGTH 63
#define NOTIFICATION_PORT_NAME_SUFFIX ".session."
#define MESSAGE_TIMEOUT 100
#if DEPLOYMENT_TARGET_MACOSX
#define NOTIFICATION_PORT_NAME "com.apple.UNCUserNotification"
#elif DEPLOYMENT_TARGET_EMBEDDED
#define NOTIFICATION_PORT_NAME "com.apple.SBUserNotification"
#else
#error Unknown or unspecified DEPLOYMENT_TARGET
#endif
#define NOTIFICATION_PORT_NAME_MAC "com.apple.UNCUserNotification"
#define NOTIFICATION_PORT_NAME_IOS "com.apple.SBUserNotification"


static void __CFUserNotificationDeallocate(CFTypeRef cf);

static const CFRuntimeClass __CFUserNotificationClass = {
const CFRuntimeClass __CFUserNotificationClass = {
0,
"CFUserNotification",
NULL, // init
Expand All @@ -110,9 +106,7 @@ static const CFRuntimeClass __CFUserNotificationClass = {
};

CFTypeID CFUserNotificationGetTypeID(void) {
static dispatch_once_t initOnce = 0;
dispatch_once(&initOnce, ^{ __kCFUserNotificationTypeID = _CFRuntimeRegisterClass(&__CFUserNotificationClass); });
return __kCFUserNotificationTypeID;
return _kCFRuntimeIDCFUserNotification;
}

static void __CFUserNotificationDeallocate(CFTypeRef cf) {
Expand All @@ -122,7 +116,7 @@ static void __CFUserNotificationDeallocate(CFTypeRef cf) {
CFRelease(userNotification->_machPort);
userNotification->_machPort = NULL; // NOTE: this is still potentially racey and should probably have a CAS (for now this is just a stop-gap to reduce an already very rare crash potential) <rdar://problem/21077032>
} else if (MACH_PORT_NULL != userNotification->_replyPort) {
mach_port_destroy(mach_task_self(), userNotification->_replyPort);
mach_port_mod_refs(mach_task_self(), userNotification->_replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
}
if (userNotification->_sessionID) CFRelease(userNotification->_sessionID);
if (userNotification->_responseDictionary) CFRelease(userNotification->_responseDictionary);
Expand Down Expand Up @@ -187,12 +181,19 @@ static SInt32 _CFUserNotificationSendRequest(CFAllocatorRef allocator, CFStringR
mach_msg_base_t *msg = NULL;
mach_port_t bootstrapPort = MACH_PORT_NULL, serverPort = MACH_PORT_NULL;
CFIndex size;
char namebuffer[MAX_PORT_NAME_LENGTH + 1];

strlcpy(namebuffer, NOTIFICATION_PORT_NAME, sizeof(namebuffer));

#if TARGET_OS_OSX
const char *namebuffer = NOTIFICATION_PORT_NAME_MAC;
const nameLen = sizeof(NOTIFICATION_PORT_NAME_MAC);
#else
const char *namebuffer = NOTIFICATION_PORT_NAME_IOS;
const nameLen = sizeof(NOTIFICATION_PORT_NAME_IOS);
#endif

if (sessionID) {
char sessionid[MAX_PORT_NAME_LENGTH + 1];
CFIndex len = MAX_PORT_NAME_LENGTH - sizeof(NOTIFICATION_PORT_NAME) - sizeof(NOTIFICATION_PORT_NAME_SUFFIX);
CFIndex len = MAX_PORT_NAME_LENGTH - nameLen - sizeof(NOTIFICATION_PORT_NAME_SUFFIX);
CFStringGetBytes(sessionID, CFRangeMake(0, CFStringGetLength(sessionID)), kCFStringEncodingUTF8, 0, false, (uint8_t *)sessionid, len, &size);
sessionid[len - 1] = '\0';
strlcat(namebuffer, NOTIFICATION_PORT_NAME_SUFFIX, sizeof(namebuffer));
Expand Down Expand Up @@ -271,7 +272,9 @@ CFUserNotificationRef CFUserNotificationCreate(CFAllocatorRef allocator, CFTimeI
} else {
if (dictionary) CFUserNotificationLog(CFDictionaryGetValue(dictionary, kCFUserNotificationAlertHeaderKey), CFDictionaryGetValue(dictionary, kCFUserNotificationAlertMessageKey));
}
if (ERR_SUCCESS != retval && MACH_PORT_NULL != replyPort) mach_port_destroy(mach_task_self(), replyPort);
if (ERR_SUCCESS != retval && MACH_PORT_NULL != replyPort) {
mach_port_mod_refs(mach_task_self(), replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
}
if (error) *error = retval;
return userNotification;
}
Expand All @@ -290,7 +293,7 @@ static void _CFUserNotificationMachPortCallBack(CFMachPortRef port, void *m, CFI
CFMachPortInvalidate(userNotification->_machPort);
CFRelease(userNotification->_machPort);
userNotification->_machPort = NULL;
mach_port_destroy(mach_task_self(), userNotification->_replyPort);
mach_port_mod_refs(mach_task_self(), userNotification->_replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
userNotification->_replyPort = MACH_PORT_NULL;
userNotification->_callout(userNotification, responseFlags);
}
Expand Down Expand Up @@ -328,7 +331,7 @@ SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification,
CFRelease(userNotification->_machPort);
userNotification->_machPort = NULL;
}
mach_port_destroy(mach_task_self(), userNotification->_replyPort);
mach_port_mod_refs(mach_task_self(), userNotification->_replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
userNotification->_replyPort = MACH_PORT_NULL;
}
CFAllocatorDeallocate(kCFAllocatorSystemDefault, msg);
Expand Down Expand Up @@ -440,7 +443,8 @@ CF_EXPORT SInt32 CFUserNotificationDisplayAlert(CFTimeInterval timeout, CFOption

#undef MAX_STRING_LENGTH
#undef MAX_STRING_COUNT
#undef NOTIFICATION_PORT_NAME
#undef NOTIFICATION_PORT_NAME_MAC
#undef NOTIFICATION_PORT_NAME_IOS
#undef MESSAGE_TIMEOUT
#undef MAX_PORT_NAME_LENGTH
#undef NOTIFICATION_PORT_NAME_SUFFIX
Expand Down
4 changes: 2 additions & 2 deletions CoreFoundation/AppServices.subproj/CFUserNotification.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* CFUserNotification.h
Copyright (c) 2000-2017, Apple Inc. and the Swift project authors
Copyright (c) 2000-2018, Apple Inc. and the Swift project authors

Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
Portions Copyright (c) 2014-2018, Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
Expand Down
18 changes: 15 additions & 3 deletions CoreFoundation/Base.subproj/CFAvailability.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* CFAvailability.h
Copyright (c) 2013-2017, Apple Inc. and the Swift project authors
Copyright (c) 2013-2018, Apple Inc. and the Swift project authors

Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
Portions Copyright (c) 2014-2018, Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
Expand All @@ -18,7 +18,7 @@
#error Missing header TargetConditionals.h
#endif

#if __has_include(<Availability.h>) && __has_include(<os/Availability.h>) && __has_include(<AvailabilityMacros.h>)
#if __has_include(<Availability.h>) && __has_include(<os/availability.h>) && __has_include(<AvailabilityMacros.h>)
#include <Availability.h>
#include <os/availability.h>
// Even if unused, these must remain here for compatibility, because projects rely on them being included.
Expand Down Expand Up @@ -114,16 +114,19 @@
// Enums and Options
#if __has_attribute(enum_extensibility)
#define __CF_ENUM_ATTRIBUTES __attribute__((enum_extensibility(open)))
#define __CF_CLOSED_ENUM_ATTRIBUTES __attribute__((enum_extensibility(closed)))
#define __CF_OPTIONS_ATTRIBUTES __attribute__((flag_enum,enum_extensibility(open)))
#else
#define __CF_ENUM_ATTRIBUTES
#define __CF_CLOSED_ENUM_ATTRIBUTES
#define __CF_OPTIONS_ATTRIBUTES
#endif

#define __CF_ENUM_GET_MACRO(_1, _2, NAME, ...) NAME
#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
#define __CF_NAMED_ENUM(_type, _name) enum __CF_ENUM_ATTRIBUTES _name : _type _name; enum _name : _type
#define __CF_ANON_ENUM(_type) enum __CF_ENUM_ATTRIBUTES : _type
#define CF_CLOSED_ENUM(_type, _name) enum __CF_CLOSED_ENUM_ATTRIBUTES _name : _type _name; enum _name : _type
#if (__cplusplus)
#define CF_OPTIONS(_type, _name) _type _name; enum __CF_OPTIONS_ATTRIBUTES : _type
#else
Expand All @@ -132,6 +135,7 @@
#else
#define __CF_NAMED_ENUM(_type, _name) _type _name; enum
#define __CF_ANON_ENUM(_type) enum
#define CF_CLOSED_ENUM(_type, _name) _type _name; enum
#define CF_OPTIONS(_type, _name) _type _name; enum
#endif

Expand Down Expand Up @@ -198,6 +202,14 @@ CF_ENUM(CFIndex) {
*/
#define CF_ERROR_ENUM(...) __CF_ERROR_ENUM_GET_MACRO(__VA_ARGS__, __CF_NAMED_ERROR_ENUM, __CF_ANON_ERROR_ENUM)(__VA_ARGS__)

#ifndef CF_SWIFT_BRIDGED_TYPEDEF
#if __has_attribute(swift_bridged_typedef)
#define CF_SWIFT_BRIDGED_TYPEDEF __attribute__((swift_bridged_typedef))
#else
#define CF_SWIFT_BRIDGED_TYPEDEF
#endif
#endif

// Extension availability macros
#define CF_EXTENSION_UNAVAILABLE(_msg) __OS_EXTENSION_UNAVAILABLE(_msg)
#define CF_EXTENSION_UNAVAILABLE_MAC(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg)
Expand Down
Loading