According to the Be Book you can find out if areas are shared by testing if the area’s team is equal to the current team. The area_info header contains the team of the area but how do I find out the current team ID? So far I’ve found an iterator for all areas, and another for all teams, but when I try to find a simple getter for the current team there doesn’t seem to be one there. Passing a 0 to most team functions is a shorthand for the current team but that doesn’t seem to work for the comparison.
Call be_app->Team();
See BApplication::GetAppInfo() method here for more info:
https://www.haiku-os.org/legacy-docs/bebook/BApplication.html
Here is a more low level version:
Thanks! One of those should work under Rust’s FFI.
Edit
AppMisc.h appears to be private so i guess CurrentTeam() shouldn’t be added to the FFI.
I guess I’d better see about making a Rust header for ApplicationKit.
BApplications are only used in GUI applications, generally. Instead, you should call get_thread_info
the same way current_team
does in the above code.
Thanks! I won’t be writing graphical utilities in Wasmer for a while. Now I see what you mean.
The most portable way is to use the get_thread_info()
, which is part of libroot and OS.h. See this code snippet for how I did it previously. Both functions called in this code snippet are now part of the libc
crate.
Note that you might have to use MaybeUnit<T>
on recent rustc
builds, because thread_info
contains function pointers.
EDIT: just saw that @waddlesplash gave the same answer. I hope the additional notes help.
Yeah my intention sharing that snippet was to show how to do it, since it is only a few lines of code. I should have added more context.
Maybe use getpid()