blob: 66d92bb4dbbc479875c3a5255e958561e082d12e [file] [log] [blame]
Chris Simpsona9b6c702018-04-08 07:11:37 -04001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20
21import Foundation
22import CoreFoundation
23
24#if os(Linux)
25/// Extensions for Linux for incomplete Foundation API's.
26/// swift-corelibs-foundation is not yet 1:1 with OSX/iOS Foundation
27
28extension CFSocketError {
29 public static let success = kCFSocketSuccess
30}
31
32extension UInt {
33 public static func &(lhs: UInt, rhs: Int) -> UInt {
34 let cast = unsafeBitCast(rhs, to: UInt.self)
35 return lhs & cast
36 }
37}
38
39#else
40extension CFStreamPropertyKey {
41 static let shouldCloseNativeSocket = CFStreamPropertyKey(kCFStreamPropertyShouldCloseNativeSocket)
42 // Exists as Stream.PropertyKey.socketSecuritylevelKey but doesn't work with CFReadStreamSetProperty
43 static let socketSecurityLevel = CFStreamPropertyKey(kCFStreamPropertySocketSecurityLevel)
44 static let SSLSettings = CFStreamPropertyKey(kCFStreamPropertySSLSettings)
45}
46#endif