Граф коммитов

24 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 34f58bbed4
[runtime] Use calloc instead of malloc. (#20692)
It's safer, since the returned memory is zero-initialized.

Also add tests.
2024-06-07 16:56:54 +02:00
Rolf Bjarne Kvinge 21705ee361
[runtime] Use objc_[retain|release|autorelease] instead of sending messages. (#19415)
Calling the direct functions instead of sending messages is slightly faster,
and additionally it may make some static analyzers think we've enabled ARC for
our Objective-C code (which we don't, because we need to manually manage
reference counting).

These direct functions aren't in any public header (they're in a private header),
but they're documented as part of ARC here: https://clang.llvm.org/docs/AutomaticReferenceCounting.html#runtime-support,
and clang emits references to these methods from user code, so it should be safe for us to use them.

Fixes https://github.com/xamarin/xamarin-macios/issues/19413.
2023-11-14 07:42:55 +01:00
Rolf Bjarne Kvinge 0a53f3cd60
Add automatic support for not building iOS 32-bit stuff when min iOS version is >= 11.0 (#16746)
There are no changes for 32-bit watchOS, because watchOS support is likely to
go away completely anyways.
2022-11-18 07:59:46 +01:00
Rolf Bjarne Kvinge c8b6bc6c85
[dotnet] Build macOS/.NET for ARM64 as well. (#10959)
Partial fix for #10959.
2021-03-25 07:26:48 +01:00
Rolf Bjarne Kvinge 871e7b1cd0
[runtime] Build our runtime for Mac Catalyst/ARM64 for .NET. (#10739)
* [runtime] Build our runtime for Mac Catalyst/ARM64 for .NET.

* [ObjCRuntime] There's no need for the StartWWAN implementation on Mac Catalyst.

This also fixes a build error:

    error MT5214: Native linking failed, undefined symbol: _xamarin_start_wwan. This symbol was referenced by the managed member ObjCRuntime.Runtime.xamarin_start_wwan.

* Only exclude xamarin_start_wwan in the .NET version of Mac Catalyst.

* [tests] Update to not run the StartWWAN test on Mac Catalyst.

* Update conditional logic.

* Fix build with newer make versions.
2021-03-03 07:48:07 +01:00
Sebastien Pouliot 577af10467
[runtime] Remove strlen and memcpy usage from runtime/xamarin-support.m (#8879)
* NSString can give us the length of the string
* NSData can copy memory into a supplied buffer

The later is already covered by tests in `tests/linker/ios/link all/InternalsTest.cs`
2020-06-18 08:06:59 -04:00
Manuel de la Pena 3f0985ecac
[Runtime] Move some of the changes back to int. (#7529)
Some of the fixes done for the warnings have breaking changes. Move back
to int and ensure that we do not have any compilation errors (we are
using -Werror).

Fixes: https://github.com/xamarin/xamarin-macios/issues/7509
2019-12-11 22:17:29 -05:00
Manuel de la Pena 63ab48e679
[Runtime] Enable the -Wsign-conversion warnings flag and fix some of the warnings. (#7405)
The flag adds a lot (A LOT) of warnings. The diff would be huge and
dangerous to review. We enable the flag and fix file by file.
2019-11-12 15:10:16 -05:00
Manuel de la Pena 2e5b64893f
[Runtime] Enable the -Wshorten-64-to-32 flag and fix all warnings. (#7353)
* [Runtime] Enable the -Wshorten-64-to-32 flag and fix all warnings.

We want to enable the -Wconversion but that will raise too many warning
for a single commit. We are enabiling one by one the flags included in
-Wconversion so that we have smaller diffs.

-Wshorten-64-to-32 adds warnings when there is a implicit conversion that
loses integer precision. We are moving all the 32 to 64 conversions to
use 64. Expecially since most of the code changed is related with sizes,
legths and params counts that are never going to be negative.


Co-Authored-By: Rolf Bjarne Kvinge <rolf@xamarin.com>
2019-11-05 11:00:14 -05:00
William Kent 9be58e4b9c os_log(3) support (#7141)
* Add xamarin_os_log function

See the comment in the function for an explanation
of why this wrapper function is required.

* Add Darwin/OSLog.cs

* Add xamarin_os_log to header

This ensures that the symbol will not be subject
to C++ name mangling, therefore breaking mmp.
With this change applied, OSLog works as expected.

* Resolve stylistic PR feedback

* Move OSLog into CoreFoundation namespace

This is where the NativeObject class lives, and it
also feels like a better fit for a low-level API
that is available on non-Mac platforms than the
macOS-only Darwin namespace.
2019-10-24 17:46:03 -04:00
Rolf Bjarne Kvinge 303aa0a649 Merge remote-tracking branch 'origin/xcode11' into master-xcode11 2019-09-13 18:35:18 +02:00
Sebastien Pouliot 9e193eaca3
[foundation] Add support for NSValue/CGAffineTransform and StoreValueAtAddress overload (#6887)
Support for `NSValue`/`CGAffineTransform` exists in iOS/tvOS/watchOS,
from UIKit, but not for macOS. However this will be required for the
new protocols inside CoreImage.

Also add an overload for `StoreValueAtAddress` since the original
one was deprecated but we did not provide the new alternative to
update the code.
2019-08-30 18:00:04 -04:00
Rolf Bjarne Kvinge 010ae1d2c9
[runtime] Fix usage of objc_msgSend[Super] according to modified headers. (#6865)
It's now required to cast objc_msgSend[Super] to a function of the correct
signature, so let's do that.

Also remove the define that allowed us to use the previous behavior.
2019-08-28 08:05:38 -07:00
Rolf Bjarne Kvinge 80421bd655 [runtime] Fix xamarin_timezone_get_local_name signature. (#6593)
Define the xamarin_timezone_get_local_name function in a header, so that we
don't get C++ mangling. Also make it return a non-const char*, since the
caller is supposed to free the returned value.

Fixes this test:

* Xamarin.Tests.Misc.PublicSymbols(iOS): Failed libraries

    Expected: <empty>
    But was: "/Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libxamarin-debug.a:
        __Z31xamarin_timezone_get_local_namev
        __Z31xamarin_timezone_get_local_namev
        __Z31xamarin_timezone_get_local_namev
        __Z31xamarin_timezone_get_local_namev
        __Z31xamarin_timezone_get_local_namev
2019-07-18 10:36:44 +02:00
Steve Pfister a7cb29a4b7 Ensure Local TimeZone Id is Set For TimeZoneInfo.Local (#6564)
* Mirrors the runtime change found in https://github.com/mono/mono/pull/15667.

The fix here is to return the name of the local time zone so that TimeZoneInfo.Local
can have the correct Id.

* Added nil check on name.  Returns Local as the Id in the case of nil
2019-07-15 00:47:11 -07:00
Rolf Bjarne Kvinge 62043318d7 [runtime] Assume we're in the US if the OS doesn't know.
This fixes a crash when running tests in the watchOS 6.0 simulator.
2019-06-14 02:17:37 +02:00
Rolf Bjarne Kvinge bbbb5ba8a3
[runtime] Only write to NSLog in chunks of max 4096 characters. Fixes maccore#1014. (#4897)
It seems older iOS versions have a bug where big(ish) chunks of string can
cause it to hang.

Fix this by not writing big strings to NSLog, instead split them up in chunks.

Fixes https://github.com/xamarin/maccore/issues/1014.
2018-10-04 17:18:09 +02:00
Alex Soto b52d067558 [runtime] Fix bug 52308 Console.WriteLine text is not showing in Device Log. (#1821)
https://bugzilla.xamarin.com/show_bug.cgi?id=52308

Apple moved to os_log[1] in iOS 10 / macOS 10.12 / tvOS 10 / watchOS 3.0
whenever you call NSLog we used to rely on NSLog parsing "%S" but
it seems broken. We now just create a NSString from the unicode str
and give that to NSLog when not in watch (NSLog in watch is broken yay).

[1]: https://developer.apple.com/reference/os/logging?language=objc
2017-03-03 14:19:23 -06:00
Rolf Bjarne Kvinge a868ab2a3f [runtime] Fix an extraneous timezone release. (#1721)
Getting a time zone instance in two different code paths, one allocating the
time zone instance, and the other not allocating, is problematic when we're
unconditionally freeing the time zone at the end.

    xamarin-support.m:58:2: warning: Incorrect decrement of the reference count of an object that is not owned at this point by the caller
            [tz release];
            ^~~~~~~~~~~~

So fix this by autoreleasing the allocated timezone.
2017-02-20 17:19:38 +01:00
Rolf Bjarne Kvinge d3ae54adb6 Fix xamarin_log to not treat % as format specifiers. Fixes #45046. (#952) 2016-10-06 14:01:14 +02:00
Rolf Bjarne Kvinge cfb84f6e17 [runtime] Use printf on watchOS, NSLog doesn't shown up (by default) (#772)
* [runtime] Use printf on watchOS, NSLog doesn't shown up (by default).

* [runtime] Use a wrapper function for logging.

So that we can chose between printf and NSLog at runtime,
depending on where we're running.
2016-09-06 16:55:23 -04:00
Rolf Bjarne Kvinge af0d01c93a Initial review pass for COOP for watchOS. 2016-05-26 17:47:10 +02:00
Sebastien Pouliot 323c7f42fc [runtime] Add dummy _stret symbols for iOS/ARM64 (#66)
The `_stret` API are not included in the ARM64 version of iOS (not
needed) but the removal of `dlsym` cause build failures*

So we're providing dummy symbols, just like what we did for tvOS,
to please the native linker (so nothing is undefined) and keep the
benefits of not using dlsym.

* Xamarin.iOS.dll (or other bindings) when the linker is disabled.
Normally the linker would remove the 32bits parts of the bindings
on a 64bits slice (and that would not be noticed). However we can
not assume this will be done for all binding projects, hence this
workaround.
2016-05-18 16:51:45 -04:00
Rolf Bjarne Kvinge ac418df815 Build our runtime. 2016-04-24 14:47:24 -04:00