a45276ab91
This can only be landed when `Allocator`, `Opaque`, and `AllocatorAlloc` have rolled into Flutter/engine, that into Flutter/flutter, and into g3. Deletes all the copies of `_CallocAllocator` and uses the one from `package:ffi` instead. Bug: https://github.com/dart-lang/sdk/issues/44622 Bug: https://github.com/dart-lang/sdk/issues/43974 Bug: https://github.com/dart-lang/sdk/issues/44621 Bug: https://github.com/dart-lang/sdk/issues/38721 Change-Id: I486034b379b5a63cad4aefd503ccd0f2ce5dd45e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180188 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com>
45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// VMOptions=--worker-thread-priority=15
|
|
|
|
import 'dart:ffi';
|
|
import 'dart:io';
|
|
|
|
import 'package:expect/expect.dart';
|
|
import 'package:ffi/ffi.dart';
|
|
|
|
// pthread_t pthread_self()
|
|
typedef PthreadSelfFT = int Function();
|
|
typedef PthreadSelfNFT = IntPtr Function();
|
|
|
|
// int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param);
|
|
typedef GetSchedParamFT = int Function(
|
|
int self, Pointer<Int32> policy, Pointer<SchedParam> param);
|
|
typedef GetSchedParamNFT = IntPtr Function(
|
|
IntPtr self, Pointer<Int32> policy, Pointer<SchedParam> param);
|
|
|
|
final pthreadSelf = DynamicLibrary.process()
|
|
.lookupFunction<PthreadSelfNFT, PthreadSelfFT>('pthread_self');
|
|
|
|
final pthreadGetSchedParam = DynamicLibrary.process()
|
|
.lookupFunction<GetSchedParamNFT, GetSchedParamFT>('pthread_getschedparam');
|
|
|
|
// struct sched_param { int sched_priority; }
|
|
class SchedParam extends Struct {
|
|
@Int32()
|
|
external int schedPriority;
|
|
}
|
|
|
|
main(args) {
|
|
if (Platform.isMacOS) {
|
|
final policy = calloc<Int32>(1);
|
|
final param = calloc<SchedParam>(1);
|
|
Expect.equals(0, pthreadGetSchedParam(pthreadSelf(), policy, param));
|
|
Expect.equals(15, param.ref.schedPriority);
|
|
calloc.free(policy);
|
|
calloc.free(param);
|
|
}
|
|
}
|