[swift-users] Swift in bare-metal embedded programming/Swift runtime

Slava Pestov spestov at apple.com
Tue Aug 16 14:14:01 CDT 2016


> On Aug 15, 2016, at 3:36 PM, Rick Mann <rmann at latencyzero.com> wrote:
> 
> Well, even C++ requires some amount of run time. On a larger MCU, the runtime shouldn't be a problem at all. What I want to do is minimize the amount of OS I have to implement. For example, using newlib (https://sourceware.org/newlib/ <https://sourceware.org/newlib/>), I can stub out 20-odd functions, and everything gets statically linked into a monolithic block of code that is a combination of my code, the runtime, and those 20-odd function stubs. A special chunk of code, usually containing assembly language, ensures the processor and MMU are properly set up just after boot, and you're off to the races.
> 
> I imagine there will be additional burden to support threading and GCD (which would be nice to have). But before that, supporting synchronization and interrupt routines.
> 
> Ah, interrupt routines. Is there any way to mark a function as "naked" in Swift? How would I request that feature?

This would require significant design work. The main problem is that the Swift runtime is not re-entrant, because typical malloc() implementations are not re-entrant, and also because of how metadata caching uses locks. So even if you could emit a function with the right calling convention, it wouldn't be safe to use as an interrupt handler.

Slava

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160816/4b4909be/attachment.html>


More information about the swift-users mailing list