Skip to content
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

Android target issues #755

Merged
merged 5 commits into from
Dec 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
6 changes: 4 additions & 2 deletions CoreFoundation/Base.subproj/CFSortFunctions.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ enum {
#define __check_int64_div(x, y, err) (x / y)
#define __check_uint64_div(x, y, err) (x / y)

#define __checkint_int64_mul(x, y, err) (x * y)
#define __checkint_uint64_add(x, y, err) (x + y)
#define __checkint_int64_mul(x, y, err) __check_int64_mul(x, y, err)
#define __checkint_int32_mul(x, y, err) __check_int32_mul(x, y, err)
#define __checkint_uint64_add(x, y, err) __check_uint64_add(x, y, err)
#define __checkint_uint32_add(x, y, err) __check_uint32_add(x, y, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason when the __checkint_ shim macros are defined in CFSortFunctions.c, the prefix used is __check_ instead of __checkint_, and then only the used references are redefined as __checkint_. I added the 32 bits version of those references used.

I can rewrite this shim macros with the prefix __checkint_, as for what I see here they're not used anywhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is just a stub until it can actually be done correctly to actually check... so looks fine to me


#endif

Expand Down
1 change: 0 additions & 1 deletion CoreFoundation/Base.subproj/CFUtilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,6 @@ void CFLog1(CFLogLevel lev, CFStringRef message) {
if (maxLength > sizeof(stack_buffer) / sizeof(stack_buffer[0])) {
buffer = calloc(sizeof(char), maxLength);
if (!buffer) {
- __android_log_print(ANDROID_LOG_ERROR, tag, "Unable to allocate %d bytes for log message - truncating.", (int)axLength);
maxLength = sizeof(stack_buffer) / sizeof(stack_buffer[0]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@johnno1962 @phausler for what I understand the intention in this commit was to remove this line. Is this correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

tbh if the calloc fails bigger problems are going to happen down the road anyhow.

My opinion is just let it fail. It is not like this is a recoverable path or a container like Data

buffer = &stack_buffer[0];
buffer[maxLength-1] = '\000';
Expand Down
2 changes: 2 additions & 0 deletions CoreFoundation/NumberDate.subproj/CFTimeZone.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
#include <dirent.h>
#include <unistd.h>
#if !TARGET_OS_ANDROID
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't Android have it as #include <fcntl.h>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. It was already in the same file, 10 lines before this.

#include <sys/fcntl.h>
#endif
#endif
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
#include <tzfile.h>
#elif DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
Expand Down
2 changes: 2 additions & 0 deletions CoreFoundation/PlugIn.subproj/CFBundle_InfoPlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#if TARGET_OS_CYGWIN
#else
#include <dirent.h>
#if !TARGET_OS_ANDROID
#include <sys/sysctl.h>
#endif
#include <sys/mman.h>
#endif
#endif
Expand Down
2 changes: 2 additions & 0 deletions CoreFoundation/PlugIn.subproj/CFBundle_Resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_LINUX
#include <unistd.h>
#if !TARGET_OS_ANDROID
#include <sys/sysctl.h>
#endif
#include <sys/stat.h>
#include <dirent.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSHost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ open class Host: NSObject {
}
var hints = addrinfo()
hints.ai_family = PF_UNSPEC
#if os(OSX) || os(iOS)
#if os(OSX) || os(iOS) || os(Android)
hints.ai_socktype = SOCK_STREAM
#else
hints.ai_socktype = Int32(SOCK_STREAM.rawValue)
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSPlatform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Glibc

#if os(OSX) || os(iOS)
fileprivate let _NSPageSize = Int(vm_page_size)
#elseif os(Linux)
#elseif os(Linux) || os(Android)
fileprivate let _NSPageSize = Int(getpagesize())
#endif

Expand Down