Hi, I have created wiki page http://wiki.osdev.org/C%2B%2B_Exception_Support , it's about how to add exception support for Itanium C++ ABI compiles. Currenty it's an orphaned page.
Feel free to correct any errors and make any improvements.
C++ exception support
Re: C++ exception support
Maybe a little off topic, but this caught my eye:
I wonder why that is.File scope static variable is slightly faster than function scope static variable
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: C++ exception support
File scope static is initialized at load time; function scope static is initialized at first call time with the resultant implication that there is a need to check if the variable is initialized on each callHobbes wrote:Maybe a little off topic, but this caught my eye:I wonder why that is.File scope static variable is slightly faster than function scope static variable
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: C++ exception support
Your example is a trivial case involving a POD type. Try a non-POD type with a non-trivial constructor, or a non trivial initializer. For example,
Code: Select all
struct Test { Test(); };
// Test() is not defined in this file, cannot be inlined, initialization code cannot be eliminated
static Test* getTest()
{
static Test t;
return &t;
}
// Also has non trivial initializer: "new int"
static int* getInteger()
{
static int* myInt = new int;
return myInt;
}
Re: C++ exception support
Before I ported libgcc_eh, I succeeded (partially) in porting libunwind. Yes, it's kinda big, compiled binaries is about 200k, so I gave it up. I ported it in a similar way as I ported libgcc_eh. First try to compile all the source files under libunwind/src/unwind, then try to solve all the undefined references and missing headers. Delete some unnecessary funtions. The most difficult two depended headers are <elf.h> & <sys/ucontext.h>. You also need to implement a full-blown dl_iterate_phdr() and rewrite two libunwind asm files: getcontext.S & setcontext.S. All in all it's not that difficult to port libunwind. If you don't need multi-thread support, it can be done within 8 hoursberkus wrote:Thanks, torshie, this looks really helpful. I thought about implementing some exception support for my IDL stubs, and native C++ support seems like a reasonable idea. libcxxrt is indeed very clean and simple, but libunwind is kinda big. I will look into ripping off only relevant parts of it into a simple package for kernel exceptions support. (LGPL is not an option, unfortunately).torshie wrote:Hi, I have created wiki page http://wiki.osdev.org/C%2B%2B_Exception_Support , it's about how to add exception support for Itanium C++ ABI compiles. Currenty it's an orphaned page.
Feel free to correct any errors and make any improvements.
Re: C++ exception support
You're right, just checked the generated assembly, with trivial initializer, the generated assembly is the same. I have modified the wiki page.Owen wrote:Your example is a trivial case involving a POD type. Try a non-POD type with a non-trivial constructor, or a non trivial initializer. For example,
Code: Select all
struct Test { Test(); }; // Test() is not defined in this file, cannot be inlined, initialization code cannot be eliminated static Test* getTest() { static Test t; return &t; } // Also has non trivial initializer: "new int" static int* getInteger() { static int* myInt = new int; return myInt; }
Re: C++ exception support
Okay, got it. Thank you guys.