Skip to content

Commit d4641de

Browse files
authored
Merge pull request #2556 from compnerd/modularization-preparation
CoreFoundation: prepare for modularization (NFC)
2 parents 2195121 + 9569974 commit d4641de

File tree

8 files changed

+54
-41
lines changed

8 files changed

+54
-41
lines changed

CoreFoundation/Base.subproj/CFLocking.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@ static inline CFLock_t __CFLockInit(void) { return CFLockInit; }
3737
#elif TARGET_OS_WIN32
3838

3939
#define NOMINMAX
40+
#define VC_EXTRALEAN
4041
#define WIN32_LEAN_AND_MEAN
41-
#define VCEXTRALEAN
4242
#include <Windows.h>
43+
#include <synchapi.h>
4344

4445
typedef int32_t CFLock_t;
4546
#define CFLockInit 0
4647
#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit)
4748

4849
CF_INLINE void __CFLock(volatile CFLock_t *lock) {
49-
while (InterlockedCompareExchange((LONG volatile *)lock, ~0, 0) != 0) {
50+
while (InterlockedCompareExchange((long volatile *)lock, ~0, 0) != 0) {
5051
Sleep(0);
5152
}
5253
}
@@ -57,7 +58,7 @@ CF_INLINE void __CFUnlock(volatile CFLock_t *lock) {
5758
}
5859

5960
CF_INLINE Boolean __CFLockTry(volatile CFLock_t *lock) {
60-
return (InterlockedCompareExchange((LONG volatile *)lock, ~0, 0) == 0);
61+
return (InterlockedCompareExchange((long volatile *)lock, ~0, 0) == 0);
6162
}
6263

6364
// SPI to permit initialization of values in Swift
@@ -66,6 +67,7 @@ static inline CFLock_t __CFLockInit(void) { return CFLockInit; }
6667
#elif TARGET_OS_LINUX || TARGET_OS_BSD
6768

6869
#include <stdint.h>
70+
#include <unistd.h>
6971

7072
typedef int32_t CFLock_t;
7173
#define CFLockInit 0

CoreFoundation/Base.subproj/CFPriv.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ CF_EXPORT const char **_CFGetProcessPath(void);
5959
CF_EXPORT const char **_CFGetProgname(void);
6060

6161
#if !TARGET_OS_WIN32
62+
#include <sys/types.h>
63+
6264
CF_EXPORT void _CFGetUGIDs(uid_t *euid, gid_t *egid);
6365
CF_EXPORT uid_t _CFGetEUID(void);
6466
CF_EXPORT uid_t _CFGetEGID(void);
@@ -492,8 +494,8 @@ void CFCharacterSetInitInlineBuffer(CFCharacterSetRef cset, CFCharacterSetInline
492494
@result true, if the value is in the character set, otherwise false.
493495
*/
494496
#if defined(CF_INLINE)
495-
CF_INLINE bool CFCharacterSetInlineBufferIsLongCharacterMember(const CFCharacterSetInlineBuffer *buffer, UTF32Char character) {
496-
bool isInverted = ((0 == (buffer->flags & kCFCharacterSetIsInverted)) ? false : true);
497+
CF_INLINE Boolean CFCharacterSetInlineBufferIsLongCharacterMember(const CFCharacterSetInlineBuffer *buffer, UTF32Char character) {
498+
Boolean isInverted = ((0 == (buffer->flags & kCFCharacterSetIsInverted)) ? FALSE : TRUE);
497499

498500
if ((character >= buffer->rangeStart) && (character < buffer->rangeLimit)) {
499501
if ((character > 0xFFFF) || (0 != (buffer->flags & kCFCharacterSetNoBitmapAvailable))) return (CFCharacterSetIsLongCharacterMember(buffer->cset, character) != 0);
@@ -569,6 +571,7 @@ CF_EXPORT CFMessagePortRef _CFMessagePortCreateLocalEx(CFAllocatorRef allocator,
569571
#if _POSIX_THREADS
570572
#include <pthread.h>
571573
#endif
574+
#include <time.h>
572575

573576
CF_INLINE CFAbsoluteTime _CFAbsoluteTimeFromFileTimeSpec(struct timespec ts) {
574577
return (CFAbsoluteTime)((CFTimeInterval)ts.tv_sec - kCFAbsoluteTimeIntervalSince1970) + (1.0e-9 * (CFTimeInterval)ts.tv_nsec);
@@ -592,10 +595,10 @@ CF_INLINE struct timespec _CFFileTimeSpecFromAbsoluteTime(CFAbsoluteTime at) {
592595
}
593596

594597
// The 'filtered' function below is preferred to this older one
595-
CF_EXPORT bool _CFPropertyListCreateSingleValue(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFStringRef keyPath, CFPropertyListRef *value, CFErrorRef *error);
598+
CF_EXPORT Boolean _CFPropertyListCreateSingleValue(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFStringRef keyPath, CFPropertyListRef *value, CFErrorRef *error);
596599

597600
// Returns a subset of the property list, only including the keyPaths in the CFSet. If the top level object is not a dictionary, you will get back an empty dictionary as the result.
598-
CF_EXPORT bool _CFPropertyListCreateFiltered(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFSetRef keyPaths, CFPropertyListRef *value, CFErrorRef *error) API_AVAILABLE(macos(10.8), ios(6.0), watchos(2.0), tvos(9.0));
601+
CF_EXPORT Boolean _CFPropertyListCreateFiltered(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFSetRef keyPaths, CFPropertyListRef *value, CFErrorRef *error) API_AVAILABLE(macos(10.8), ios(6.0), watchos(2.0), tvos(9.0));
599602

600603
// Returns a set of the keys of the top-level dictionary of a plist. Optimized for bplist (though it works with XML too). Only supports string keys.
601604
CF_EXPORT CFSetRef _CFPropertyListCopyTopLevelKeys(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFErrorRef *outError) API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0));

CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#if TARGET_OS_WIN32
3434
#define NOMINMAX
35+
#define VC_EXTRALEAN
3536
#define WIN32_LEAN_AND_MEAN
3637
#include <Windows.h>
3738
#else
@@ -78,6 +79,8 @@
7879
#endif //__GLIBC_PREREQ(2. 28)
7980
#endif // TARGET_OS_LINUX
8081

82+
#include <stdlib.h>
83+
8184

8285
_CF_EXPORT_SCOPE_BEGIN
8386

@@ -352,12 +355,12 @@ CF_EXPORT char *_Nullable *_Nonnull _CFEnviron(void);
352355
CF_EXPORT void CFLog1(CFLogLevel lev, CFStringRef message);
353356

354357
#if TARGET_OS_WIN32
355-
typedef HANDLE _CFThreadRef;
358+
typedef void *_CFThreadRef;
356359
typedef struct _CFThreadAttributes {
357-
DWORD dwSizeOfAttributes;
358-
DWORD dwThreadStackReservation;
360+
unsigned long dwSizeOfAttributes;
361+
unsigned long dwThreadStackReservation;
359362
} _CFThreadAttributes;
360-
typedef DWORD _CFThreadSpecificKey;
363+
typedef unsigned long _CFThreadSpecificKey;
361364
#elif _POSIX_THREADS
362365
typedef pthread_t _CFThreadRef;
363366
typedef pthread_attr_t _CFThreadAttributes;
@@ -592,27 +595,27 @@ static inline int _CF_renameat2(int olddirfd, const char *_Nonnull oldpath,
592595
CF_EXPORT void __CFSocketInitializeWinSock(void);
593596

594597
typedef struct _REPARSE_DATA_BUFFER {
595-
ULONG ReparseTag;
596-
USHORT ReparseDataLength;
597-
USHORT Reserved;
598+
unsigned long ReparseTag;
599+
unsigned short ReparseDataLength;
600+
unsigned short Reserved;
598601
union {
599602
struct {
600-
USHORT SubstituteNameOffset;
601-
USHORT SubstituteNameLength;
602-
USHORT PrintNameOffset;
603-
USHORT PrintNameLength;
604-
ULONG Flags;
605-
WCHAR PathBuffer[1];
603+
unsigned short SubstituteNameOffset;
604+
unsigned short SubstituteNameLength;
605+
unsigned short PrintNameOffset;
606+
unsigned short PrintNameLength;
607+
unsigned long Flags;
608+
short PathBuffer[1];
606609
} SymbolicLinkReparseBuffer;
607610
struct {
608-
USHORT SubstituteNameOffset;
609-
USHORT SubstituteNameLength;
610-
USHORT PrintNameOffset;
611-
USHORT PrintNameLength;
612-
WCHAR PathBuffer[1];
611+
unsigned short SubstituteNameOffset;
612+
unsigned short SubstituteNameLength;
613+
unsigned short PrintNameOffset;
614+
unsigned short PrintNameLength;
615+
short PathBuffer[1];
613616
} MountPointReparseBuffer;
614617
struct {
615-
UCHAR DataBuffer[1];
618+
unsigned char DataBuffer[1];
616619
} GenericReparseBuffer;
617620
} DUMMYUNIONNAME;
618621
} REPARSE_DATA_BUFFER;

CoreFoundation/Locale.subproj/CFDateIntervalFormatter.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ void _CFDateIntervalFormatterInitializeFromCoderValues(CFDateIntervalFormatterRe
241241
int64_t timeStyle,
242242
CFStringRef _Nullable dateTemplate,
243243
CFStringRef _Nullable dateTemplateFromStyles,
244-
bool modified,
245-
bool useTemplate,
244+
Boolean modified,
245+
Boolean useTemplate,
246246
CFLocaleRef _Nullable locale,
247247
CFCalendarRef _Nullable calendar,
248248
CFTimeZoneRef _Nullable timeZone) {
@@ -277,8 +277,8 @@ void _CFDateIntervalFormatterCopyCoderValues(CFDateIntervalFormatterRef formatte
277277
int64_t *timeStyle,
278278
CFStringRef _Nullable *dateTemplate,
279279
CFStringRef _Nullable *dateTemplateFromStyles,
280-
bool *modified,
281-
bool *useTemplate,
280+
Boolean *modified,
281+
Boolean *useTemplate,
282282
CFLocaleRef _Nullable *locale,
283283
CFCalendarRef _Nullable *calendar,
284284
CFTimeZoneRef _Nullable *timeZone) {

CoreFoundation/Locale.subproj/CFDateIntervalFormatter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ CF_EXPORT void _CFDateIntervalFormatterInitializeFromCoderValues(CFDateIntervalF
7171
int64_t timeStyle,
7272
CFStringRef _Nullable dateTemplate,
7373
CFStringRef _Nullable dateTemplateFromStyles,
74-
bool modified,
75-
bool useTemplate,
74+
Boolean modified,
75+
Boolean useTemplate,
7676
CFLocaleRef _Nullable locale,
7777
CFCalendarRef _Nullable calendar,
7878
CFTimeZoneRef _Nullable timeZone);
@@ -82,8 +82,8 @@ CF_EXPORT void _CFDateIntervalFormatterCopyCoderValues(CFDateIntervalFormatterRe
8282
int64_t *timeStyle,
8383
CFStringRef _Nullable *_Nonnull dateTemplate,
8484
CFStringRef _Nullable *_Nonnull dateTemplateFromStyles,
85-
bool *modified,
86-
bool *useTemplate,
85+
Boolean *modified,
86+
Boolean *useTemplate,
8787
CFLocaleRef _Nullable *_Nonnull locale,
8888
CFCalendarRef _Nullable *_Nonnull calendar,
8989
CFTimeZoneRef _Nullable *_Nonnull timeZone);

CoreFoundation/Parsing.subproj/CFXMLInterface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ typedef void* _CFXMLDTDPtr;
142142
typedef void* _CFXMLDTDNodePtr;
143143

144144
_CFXMLNodePtr _CFXMLNewNode(_CFXMLNamespacePtr _Nullable name_space, const char* name);
145-
_CFXMLNodePtr _CFXMLCopyNode(_CFXMLNodePtr node, bool recursive);
145+
_CFXMLNodePtr _CFXMLCopyNode(_CFXMLNodePtr node, Boolean recursive);
146146

147147
_CFXMLDocPtr _CFXMLNewDoc(const unsigned char* version);
148148
_CFXMLNodePtr _CFXMLNewProcessingInstruction(const unsigned char* name, const unsigned char* value);
@@ -178,8 +178,8 @@ void _CFXMLNodeReplaceNode(_CFXMLNodePtr node, _CFXMLNodePtr replacement);
178178

179179
_CFXMLDocPtr _Nullable _CFXMLNodeGetDocument(_CFXMLNodePtr node);
180180

181-
bool _CFXMLDocStandalone(_CFXMLDocPtr doc);
182-
void _CFXMLDocSetStandalone(_CFXMLDocPtr doc, bool standalone);
181+
Boolean _CFXMLDocStandalone(_CFXMLDocPtr doc);
182+
void _CFXMLDocSetStandalone(_CFXMLDocPtr doc, Boolean standalone);
183183
_CFXMLNodePtr _Nullable _CFXMLDocRootElement(_CFXMLDocPtr doc);
184184
void _CFXMLDocSetRootElement(_CFXMLDocPtr doc, _CFXMLNodePtr node);
185185
CFStringRef _Nullable _CFXMLDocCopyCharacterEncoding(_CFXMLDocPtr doc);
@@ -211,7 +211,7 @@ _CFXMLDocPtr _CFXMLDocPtrFromDataWithOptions(CFDataRef data, unsigned int option
211211
CFStringRef _Nullable _CFXMLNodeCopyLocalName(_CFXMLNodePtr node);
212212
CFStringRef _Nullable _CFXMLNodeCopyPrefix(_CFXMLNodePtr node);
213213

214-
bool _CFXMLDocValidate(_CFXMLDocPtr doc, CFErrorRef _Nullable * error);
214+
Boolean _CFXMLDocValidate(_CFXMLDocPtr doc, CFErrorRef _Nullable * error);
215215

216216
_CFXMLDTDPtr _CFXMLNewDTD(_CFXMLDocPtr _Nullable doc, const unsigned char* name, const unsigned char* publicID, const unsigned char* systemID);
217217
_CFXMLDTDNodePtr _Nullable _CFXMLParseDTDNode(const unsigned char* xmlString);

CoreFoundation/PlugIn.subproj/CFPlugInCOM.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ CF_EXTERN_C_BEGIN
2020
/* The _reserved field is part of the Microsoft COM binary standard on Macintosh. */
2121
/* You can declare new C struct interfaces by defining a new struct that includes "IUNKNOWN_C_GUTS;" before the first field of the struct. */
2222

23-
#if !TARGET_OS_WIN32
23+
#if TARGET_OS_WIN32
24+
#define NOMINMAX
25+
#define VC_EXTRALEAN
26+
#define WIN32_LEAN_AND_MEAN
27+
#include <Windows.h>
28+
#else
2429
typedef SInt32 HRESULT;
2530
typedef UInt32 ULONG;
2631
typedef void *LPVOID;

Foundation/DateIntervalFormatter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ open class DateIntervalFormatter: Formatter {
133133
var timeStyle: Int64 = 0
134134
var dateTemplate: Unmanaged<CFString>?
135135
var dateTemplateFromStyles: Unmanaged<CFString>?
136-
var modified: Bool = false
137-
var useTemplate: Bool = false
136+
var modified: _DarwinCompatibleBoolean = false
137+
var useTemplate: _DarwinCompatibleBoolean = false
138138
var locale: Unmanaged<CFLocale>?
139139
var calendar: Unmanaged<CFCalendar>?
140140
var timeZone: Unmanaged<CFTimeZone>?

0 commit comments

Comments
 (0)