Something like DashMap for Haiku?

The Region crate is used by Wasmer to wrap the MMU capabilities of most operating systems. It expects to be able to feed me an address and get a page set back that it is the base address of. Haiku's Area handling functions return an enumeration that has to be passed with an empty buffer into another system function to get a snapshot of the AreaInfo. This snapshot's contents grows stale quickly so the enumeration (area_id type) must be reused to get a fresh copy whenever the size or handle is needed.

In order to bypass the address-to-area_id converter's flagging of areas allocated with the NONE access as an error, I've tried to implement a static HashMap inside a Mutex using lazy_static!. It compiled but something about the mutex didn't let the unit-tests succeed. Is it a race condition?

When I tried removing the mutex, there was no mutable reference to self in the HashMap to allow the insert and remove functions to work. Searching the forum, the DashMap crate came up as an alternative but it seems to be specific only to x86_64 instruction sets on mainstream OS's. Haiku supports RISC-V and will soon support AArch64 as well so DashMap won't work. Are there any comparable alternatives that are available on Haiku?

A mutex in a static global should work, but you should note that all tests will share the same global, so they can see each other's changes in the global.

(Also, I would recommend that you use the parking_lot mutex so that you don't need lazy_static, as the parking_lot mutex can be constructed in a const context.)

Thanks! I'll try the other mutex implementation.

I'd be interested to hear where this comes from and why it is, sad I use dashmap and wasn't aware of this limitation.

When I looked at the pull down menu listing supported architectures, only x86_64 architectures were listed in the documentation. I don't know if third-party operating systems are excluded but I can't chance processor-specific code because I'm trying to implement Wasmer in Haiku in the interest of making WebAssembly derived packages work on every supported hardware platform the Haiku OS runs on.

I think what you're seeing there is the set of platforms for which generates documentation. It's the same list for every crate I've looked at, including one of mine with no dependencies, and with no processor-specific code.

1 Like

Thanks! I wasn't aware of this. I'll check into it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.