[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: [rtl] Constructor/Destructor



Colin Leister wrote:

> Did you guys (Richard/Daniele) ever get the C++ constructor/destructor
> calls to work?
>

Dear Colin,
my rt module has several global objects and I construct them by
explicitly calling the constructors in init_module, as I did before. I
haven't been able to use your method with __do_global_?tors_aux. Here is
an example which compiles but does not load on my system. As said before,
there are two problems:
1) __do_global_ctors_aux and __do_global_dtors_aux are not found even if
I include crtbegin.o and crtend.o in the link.
2) I get "free undefined" if I have a destructor. I don't need
destructors really because my global objects have the same lifetime as
the module and do not need to do anything special before leaving, but
anyway it would be interesting to know what is "free" doing for an object
which is not allocated on the heap.
By the way, I have seen the example of Richard, and I keep my idea that
kmalloc/kfree could be dangerous in an rt task.

Best regards, Daniele

X bitmap

MODULEFLAGS= -D__KERNEL__ -D__RT__ -I/usr/src/linux/include
RTFLAGS= -O2 -Wall
GCCLDFLAGS= -L/usr/lib/gcc-lib/i386-linux/2.7.2.1 -lgcc

module.o: module.c++
	gcc $(MODULEFLAGS) $(RTFLAGS) -c -o module.tmp.o module.c++
	ld -Ur -static -o module.o\
	/usr/lib/crtbegin.o\
	module.tmp.o\
	/usr/lib/crtend.o\
	$(GCCLDFLAGS)

insert:
	insmod /usr/src/linux/modules/rt_fifo_new.o
	insmod module.o

remove:
	rmmod module
	rmmod rt_fifo_new