This reimplements the spinlock on top of std::atomic_flag, which is guaranteed to be lockless. It also inserts the PAUSE (REP NOP) instruction which is strongly recommended to be placed in busy-wait loops by Intel.
This also includes a recursive spinlock implementation.
The spinlock implementation is disabled by default, but can be enabled by adding the --override MUTEX_SPINLOCK=1 flag to makepanda.
Rationale:
1. Per standard, fstream::open takes 2 arguments.
If platforms add a third, they're out of spec.
2. The only platform I could find that takes a file
mask specifically as the third argument is IRIX,
which Panda hasn't targeted in forever.
3. The mask being requested isn't even particularly
interesting - falling back to a platform default
is best.
4. When USE_PANDAFILESTREAM is defined, pfstream
is implemented as PandaFileStream, which doesn't
have a three-argument open() and breaks immediately.
5. makepanda doesn't ever define HAVE_OPEN_MASK
6. It's been broken for so long that, if it were
important to anybody, it would have been fixed by now.
This makes it possible to include it multiple times in a single
translation unit, and/or multiple times in a single dynamic
library (and without excess code bloat, too).
As of f69354d9fa, this is just always
expected on all platforms. If it's not defined,
TemplateClass<X>::_type_handle won't link correctly with some compilers
(e.g. Clang) and the lack of 'extern template class' will result in
duplicated code in any case. In short, turning it off causes problems.
makepanda also always turns this on, so it doesn't represent any
optional feature or autodetected platform-specific behavior anyway.
It can be launched from the termux shell using the provided run_python.sh script, which can communicate with the Panda activity using a socket (which is the only way we can reliably get command-line output back to the program.)
The Python script needs to be readable by the Panda activity (which implies it needs to be in /sdcard).
The standard library is packed into the .apk, and loaded using zipimport. Extension modules are included using a special naming convention and import hook in order to comply with Android's strict demands on how libraries must be named to be included in an .apk.
[skip ci]