HN user

lochsh

226 karma
Posts14
Comments32
View on HN

Oxford Ionics | Embedded Software Engineers and Compiler Engineers | Full Time | ONSITE, HYBRID (Oxford, UK) | Quantum computing

Oxford Ionics is a small quantum computing start-up in Oxford, UK. We're looking for smart, motivated software engineers to join our growing team of engineers and scientists.

Rust | Python | FPGAs | qubits

This is a rare opportunity for a potentially really varied role, with the ability to make a big impact early on in the company's development. See links below for details

https://www.oxionics.com/careers

https://www.oxionics.com/software-engineer-embedded

https://www.oxionics.com/software-engineer-compiler

Thanks for bringing up variance -- this is a concept I've since learned about and have added a small update to the blog post about.

I understand your point about the `children_as_parents` example, I've added another update to point out that the mutability of the vector makes it problematic to have the `children` variable.

Thank you for the compliment ^_^ I'm glad you found the post helpful.

This isn't a typo, actually. If you look at the documentation of the BSRR register (which is screenshotted in the blog post), it says of BRy:

These bits are write-only [...] [Setting to 1] Resets the corresponding ODRx bit

So setting BR8 in the BSRR clears the ORD8 bit in the output data register. Because our LED is active low, this turns the LED on.

The indirection can make this a little confusing, I hope this cleans it up!

I don't have experience with this, but from talking to people who do, there are indeed open source implementations. They say the documentation is a bit confusing, but it does describe everything.

This Rust library is an abstract USB library that can implement CDC serial https://docs.rs/usb-device/0.2.5/usb_device/, and this library connects it to the STM32 USB peripheral https://github.com/stm32-rs/stm32-usbd

Examples here: https://github.com/stm32-rs/stm32-usbd-examples

I've made some updates to the blog post based on feedback -- thank you everyone who pointed out mistakes helpfully :)

I've made the updates clear, and linked to the archived version of the original post.

I haven't been able to find anything in the C11 standard about the initialisation of bar being a constraint violation. In 6.7.3, the only constraints for type qualifiers listed are for _Atomic and restrict. Could you let me know where you got the information you talk about here from? I could be missing part of the standard.

It would only be a VLA if defined in a block, I intended the code snippet to be at file-scope, giving the buffer size and array static storage duration.

But it does indeed compile in Clang, and I'm looking into why. I think this line in the C11 standard might be key: "An implementation may accept other forms of constant expressions."

This is what I was going for in the blog post, but I got confused after seeing these comments as Clang _does_ compile this when the buffer is of static storage class.

Which I don't think is standard -- but it's not using VLAs. I wondered if it just has constant expression semantics for const variables.

Weirdly, adding a _Static_assert to test this theory proves it for c99 but not c11 :/

https://godbolt.org/z/q-bb-n c99 with clang https://godbolt.org/z/ad14Ah c11 with clang https://godbolt.org/z/xJSDQa c11 with gcc (which is the only one giving the output I'd expect)

Yes, I think I made an embarrassing mess up here by using a compiler that doesn't support VLAs, and not fully understanding VLAs. Thanks for pointing it out.

I should probably make it smaller! 6MB is pretty indulgent. But I do like how it looks and this is mostly just a fun blog for myself :)

Ah yes, what I meant was that more optimisations can be made on memmove if we restrict src and dst, as the overlap case no longer needs to be considered.

I've never used restrict, so I could be missing something, but this is what I meant in the blog post by mentioning memmove.

This is all totally fair -- I've never used restrict, so it's hard for me to have a useful opinion on it.

I think it's easy to dismiss things that can help optimisation when you've never seen their effect first-hand. I imagine if I'd had an experience where I'd used it to great advantage I'd be wishing it was in the C++ standard too :)