microsoft / jacdac-c

Jacdac C Firmware library
https://aka.ms/jacdac
MIT License
13 stars 15 forks source link

API pruning #1

Closed jamesadevine closed 3 years ago

jamesadevine commented 4 years ago

@mmoskal I'm now going though the library and pruning APIs that I think are perhaps implementation specific.

It would be great if you could tell me if the API calls I refer to in the comments of this issue make sense to bring out as apis.

jamesadevine commented 4 years ago

https://github.com/microsoft/jacdac-c/blob/master/inc/interfaces/jd_alloc.h#L9

void jd_alloc_stack_check(void); This API is used once in jdapp.c from jacdac-tiny.

void *jd_alloc_emergency_area(uint32_t size); This API is not used at all by jacdac-tiny

mmoskal commented 4 years ago

The emergency area can go, it was for in-flash settings storage, which I nuked later (no space for it anyways).

I guess the stack check can go into platform. It would be the same for most MCUs though, so maybe just put an ifdef around the body? It's there to check that stack doesn't extend into heap.

jamesadevine commented 4 years ago

Thanks, removed emergency stack check.

QQ: I would say that a stack/heap collision check only needs to be performed during memory allocation right? Is it really necessary that we expose this as an external API?

https://github.com/microsoft/jacdac-c/blob/master/inc/jd_services.h#L104

Have you any idea of how to nicely obtain the device class? Perhaps it should just be an externed variable? I think that would be problematic for the bootloader though, right?

mmoskal commented 4 years ago

I only do one allocation at the beginning typically, and the stack can grow at any point.

For device class, I would go with #define, and let the user define it however they want.