Skip to content

stdlib: tweak import declarations #1724

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 1 commit into from
Mar 22, 2016
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
17 changes: 17 additions & 0 deletions stdlib/public/SDK/Darwin/Misc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include <fcntl.h>
#include <semaphore.h>

#define _REENTRANT
#include <math.h>

extern "C" int
_swift_Darwin_open(const char *path, int oflag, mode_t mode) {
return open(path, oflag, mode);
Expand Down Expand Up @@ -42,3 +45,17 @@
return fcntl(fd, cmd, ptr);
}

extern "C" float
_swift_Darwin_lgammaf_r(float x, int *psigngam) {
return lgammaf_r(x, psigngam);
}

extern "C" double
_swift_Darwin_lgamma_r(double x, int *psigngam) {
return lgamma_r(x, psigngam);
}

extern "C" long double
_swift_Darwin_lgammal_r(long double x, int *psigngam) {
return lgammal_r(x, psigngam);
}
3 changes: 2 additions & 1 deletion stdlib/public/SDK/Darwin/tgmath.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,10 @@ public func scalbn(x: ${T}, _ n: Int) -> ${T} {
% for T, CT, f in AllFloatTypes():
% # The real lgamma_r is not imported because it hides behind macro _REENTRANT.
@warn_unused_result
@_silgen_name("lgamma${f}_r")
@_silgen_name("_swift_Darwin_lgamma${f}_r")
func _swift_Darwin_lgamma${f}_r(_: ${CT},
_: UnsafeMutablePointer<CInt>) -> ${CT}

@_transparent
@warn_unused_result
public func lgamma(x: ${T}) -> (${T}, Int) {
Expand Down
1 change: 1 addition & 0 deletions stdlib/public/SDK/ObjectiveC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_swift_library(swiftObjectiveC IS_SDK_OVERLAY
ObjectiveC.mm
ObjectiveC.swift
SWIFT_MODULE_DEPENDS Darwin)

28 changes: 28 additions & 0 deletions stdlib/public/SDK/ObjectiveC/ObjectiveC.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 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
//
//===----------------------------------------------------------------------===//

#include <objc/objc-api.h>

OBJC_EXPORT
void *objc_autoreleasePoolPush(void);

OBJC_EXPORT
void objc_autoreleasePoolPop(void *);

extern "C" void *_swift_objc_autoreleasePoolPush(void) {
return objc_autoreleasePoolPush();
}

extern "C" void _swift_objc_autoreleasePoolPop(void *context) {
return objc_autoreleasePoolPop(context);
}

4 changes: 2 additions & 2 deletions stdlib/public/SDK/ObjectiveC/ObjectiveC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ typealias Zone = NSZone
//===----------------------------------------------------------------------===//

@warn_unused_result
@_silgen_name("objc_autoreleasePoolPush")
@_silgen_name("_swift_objc_autoreleasePoolPush")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gribozavr Do you know if these trampolines are necessary? Is the ObjectiveC module far enough long in the build that we could reliably import these from Clang instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not look like these functions are declared in the SDK, so there's no header that we could use.

func __pushAutoreleasePool() -> OpaquePointer

@_silgen_name("objc_autoreleasePoolPop")
@_silgen_name("_swift_objc_autoreleasePoolPop")
func __popAutoreleasePool(pool: OpaquePointer)

public func autoreleasepool(@noescape code: () -> Void) {
Expand Down