On Fri, 2007-10-05 at 22:26 +0200, Vitus Jensen wrote:
> Hej!
> 
> I'm trying to port a small testprogramm from embedded Visual C 4 to 
> mingw32ce (cegcc-mingw32ce-0.50-1.i586.rpm).  It's text mode, 2 threads, 
> some printf, some files, nothing fancy but ... it has to use 2 object 
> libraries (3rd party) and a DLL (my own).
> 
> I'm able to compile and link this programm but when I call the 3rd party 
> library an important call fails.  It's the only call with several 
> parameters so I suspect different calling conventions.
> 
> Goes like this:
> 
> extern int libconfig(int hd, int subfct, void * parameter);
> 
> test()
> {
>       hd = libopen();
>       res = libconfig(hd, 1, (void *)0815);
>       res = libconfig(hd, 2, (void *)15);
>       ...
>       libclose(hd);
> }
> 
> Result code indicates "invalid subfunction" :-(
> 
> The prototype shows no "__syscall" or the like, the object library works 
> when used with eVC.  I've looked at the produced assembler code in the eVC 
> debugger and it seems parameters are transfered via r0, r1 and r2.  Isn't 
> this the same as in mingw32ce?  In my opinion all this indicates that the 
> program should work.  It doesn't :-(

This is probably a silly remark but "0815" is an invalid number. The GNU
C compiler will treat any number that starts with a 0 as octal. In
octal, there's no 8, so the compiler issues an error :
  tt.c:8:33: error: invalid digit "8" in octal constant

In case that that isn't your problem, I've attached a source and
assembler file generated by arm-wince-mingw32ce-gcc . Which assembler
instructions does eVC generate for this file ?

        Danny
-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
extern int libconfig(int, int, void *);

int test(void)
{
	int hd, res;

	hd = libopen();
	res = libconfig(hd, 1, (void *)815);
	res = libconfig(hd, 2, (void *)15);
	libclose(hd);
}
        .file   "tt.c"
        .text
        .align  0
        .global test
        .def    test;   .scl    2;      .type   32;     .endef
test:
        @ args = 0, pretend = 0, frame = 8
        @ frame_needed = 1, uses_anonymous_args = 0
        mov     ip, sp
        stmfd   sp!, {fp, ip, lr, pc}
        sub     fp, ip, #4
        sub     sp, sp, #8
        bl      libopen
        mov     r3, r0
        str     r3, [fp, #-20]
        ldr     r0, [fp, #-20]
        mov     r1, #1
        ldr     r2, .L3
        bl      libconfig
        mov     r3, r0
        str     r3, [fp, #-16]
        ldr     r0, [fp, #-20]
        mov     r1, #2
        mov     r2, #15
        bl      libconfig
        mov     r3, r0
        str     r3, [fp, #-16]
        ldr     r0, [fp, #-20]
        bl      libclose
        sub     sp, fp, #12
        ldmfd   sp, {fp, sp, pc}
.L4:
        .align  0
.L3:
        .word   815
        .def    libclose;       .scl    2;      .type   32;     .endef
        .def    libconfig;      .scl    2;      .type   32;     .endef
        .def    libopen;        .scl    2;      .type   32;     .endef

Attachment: signature.asc
Description: This is a digitally signed message part

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to