Thread overview | |||||
---|---|---|---|---|---|
|
April 05, 2015 [Bug 172] Add support for GCC's weak attribute | ||||
---|---|---|---|---|
| ||||
Attachments:
| http://bugzilla.gdcproject.org/show_bug.cgi?id=172 Jens Bauer <jens-bugzilla@gpio.dk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jens-bugzilla@gpio.dk --- Comment #1 from Jens Bauer <jens-bugzilla@gpio.dk> --- Having support for this will be highly appreciated. Especially weak,alias is important on microcontrollers, which have exception vectors. Small C Example (this one is for ARM Cortex-M microcontrollers): ---8<-----8<-----8<----- #define WA(a) __attribute__((weak, alias(#a))) #define WE WA(defaultExceptionHandler) #define WR WA(defaultResetHandler) typedef void (*const VectorFunc)(void); static void defaultResetHandler(void) __attribute__((__interrupt__)); /* $0000 System Exception Vector Handlers: */ void WR Reset_Handler(void); /* 1 $0004 Reset */ void WE NMI_Handler(void); /* 2 $0008 Non Maskable Interrupt */ void WE HardFault_Handler(void); /* 3 $000c Hard Fault */ ... ... /* Vector Table */ __attribute__((section(".isr_vector"))) VectorFunc g_pfnVectors[] = { (VectorFunc)STACK_ADDRESS, /* 0 $0000 Initial Stack Pointer */ Reset_Handler, /* 1 $0004 Reset Vector */ NMI_Handler, /* 2 $0008 Non Maskable Interrupt Vector */ HardFault_Handler, /* 3 $000c Hard Fault Vector */ ... ... }; static void defaultResetHandler(void) { while(1){ asm volatile("wfi"); } } --->8----->8----->8----- The above example demonstrates the use of the section attribute and the use of the weak+alias attribute. The weak+alias is used for having default implementations of all the exception handlers (including Reset_Handler). This means that the user can just start writing code, but allows customization in case an implementation, which is either simpler or more advanced than the provided one is required. -- You are receiving this mail because: You are watching all bug changes. |
April 05, 2015 [Bug 172] Add support for GCC's weak attribute | ||||
---|---|---|---|---|
| ||||
Attachments:
| http://bugzilla.gdcproject.org/show_bug.cgi?id=172 Johannes Pfau <johannespfau@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |johannespfau@gmail.com --- Comment #2 from Johannes Pfau <johannespfau@gmail.com> --- https://github.com/D-Programming-GDC/GDC/pull/96 -- You are receiving this mail because: You are watching all bug changes. |
April 07, 2015 [Bug 172] Add support for GCC's weak attribute | ||||
---|---|---|---|---|
| ||||
Attachments:
| http://bugzilla.gdcproject.org/show_bug.cgi?id=172 Johannes Pfau <johannespfau@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #3 from Johannes Pfau <johannespfau@gmail.com> --- https://github.com/D-Programming-GDC/GDC/commit/48384612969fe90bdf88f562d1017bd8c5ec8612 -- You are receiving this mail because: You are watching all bug changes. |
Copyright © 1999-2021 by the D Language Foundation