Kompilieren unter OpenSolaris



  • Hallo,

    ich versuche gerade, spasseshalber, PrettyOS 107er Version unter OpenSolaris zu kompilieren. Der Compiler is der Sun Compiler:

    $ cc -V
    cc: Sun C 5.10 SunOS_i386 2009/06/03
    

    Bekomme folgende Ausgabe:

    ~/nasm/nasm-2.07/nasm -O32 -f elf kernel.asm -o kernel.o
    No errors for asm.
    ~/nasm/nasm-2.07/nasm -O32 -f elf data.asm -o data.o
    No errors for asm.
    ~/nasm/nasm-2.07/nasm -O32 -f elf flush.asm -o flush.o
    No errors for asm.
    ~/nasm/nasm-2.07/nasm -O32 -f elf isr.asm -o isr.o
    No errors for asm.
    ~/nasm/nasm-2.07/nasm -O32 -f elf process.asm -o process.o
    No errors for asm.
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o ckernel.o ckernel.c
    "ckernel.c", line 209: warning: statement not reached
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o descriptor_tables.o descriptor_tables.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o flpydsk.o flpydsk.c
    "flpydsk.c", line 180: void function cannot return value
    cc: acomp failed for flpydsk.c
    make: *** [flpydsk.o] Error 1
    

    Und das ist die Funktion, wo der Fehler auftritt:

    void flpydsk_send_command (unsigned char cmd)
    {
        // wait until data register is ready. We send commands to the data register
    	int i;
    	for(i=0; i<500; ++i)
    		if( flpydsk_read_status() & FLPYDSK_MSR_MASK_DATAREG )
    			return outportb(FLPYDSK_FIFO, cmd);
    }
    

    ­čÖé



  • Probiers mal so:

    if( flpydsk_read_status() & FLPYDSK_MSR_MASK_DATAREG )
    {
        outportb(FLPYDSK_FIFO, cmd);
        return;
    }
    

    Der gcc scheint das durchzulassen weil outportb void ist und daher nichts zur├╝ck gibt. Der Sun Compiler scheint sich daran aber zu st├Âren.



  • Interessant, warum der gcc Compiler es durchl├Ąsst. Es ist auch lustig, was fricky mal hier http://www.c-plusplus.net/forum/viewtopic-var-t-is-246723-and-start-is-60.html geschrieben hat:

    abc.w schrieb:

    MISRA macht keine Verbote. Da haben sich "einfach" einige Spezialisten zusammengesetzt...

    aber C spezialisten waren's wohl nicht
    Zitat:

    79 (req): The value returned by void functions shall not be used

    ^^was soll den dieser 'value' sein? wie kommt man da ran?

    ­čśâ



  • Habe die Funktion wie folgt ge├Ąndert:

    void flpydsk_send_command (unsigned char cmd)
    {
    	// wait until data register is ready. We send commands to the data register
    	int i = 0;
    
    	for (i = 0; i < 500; ++i)
    	{
    		if (FLPYDSK_MSR_MASK_DATAREG != (flpydsk_read_status() & FLPYDSK_MSR_MASK_DATAREG))
    		{
    			outportb(FLPYDSK_FIFO, cmd);
    			return;
    		}
    	}
    
    	return;
    }
    

    Es gibt noch ein Paar Funktionen in fs.c, hab sie auch ├Ąhnlich ge├Ąndert:

    void open_fs(fs_node_t* node, unsigned char read, unsigned char write)
    {
    	if (node->open != 0) // Has the node got an open callback?
    	{
    		node->open(node);
    	}
    
    	return;
    }
    
    void close_fs(fs_node_t* node)
    {
    	if (node->close != 0) // Has the node got a close callback?
    	{
    		node->close(node);
    	}
    
    	return;
    }
    


  • Das ist der aktuelle Stand:

    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o fs.o fs.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o gdt.o gdt.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o idt.o idt.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o initrd.o initrd.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o irq.o irq.c
    "irq.c", line 15: warning: assignment type mismatch:
    	pointer to void "=" pointer to function(pointer to struct regs {unsigned long gs, unsigned long fs, unsigned long es, unsigned long ds, unsigned long edi, unsigned long esi, unsigned long ebp, unsigned long ebx, unsigned long edx, unsigned long ecx, unsigned long eax, unsigned long int_no, unsigned long err_code, unsigned long eip, unsigned long cs, unsigned long eflags, unsigned long useresp, unsigned long ss}) returning void
    "irq.c", line 61: warning: assignment type mismatch:
    	pointer to function(pointer to struct regs {unsigned long gs, unsigned long fs, unsigned long es, unsigned long ds, unsigned long edi, unsigned long esi, unsigned long ebp, unsigned long ebx, unsigned long edx, unsigned long ecx, unsigned long eax, unsigned long int_no, unsigned long err_code, unsigned long eip, unsigned long cs, unsigned long eflags, unsigned long useresp, unsigned long ss}) returning void "=" pointer to void
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o isrs.o isrs.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o keyboard.o keyboard.c
    "keyboard.c", line 20: warning: syntax error:  empty declaration
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o kheap.o kheap.c
    "kheap.c", line 168: warning: initializer will be sign-extended: -1
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o math.o math.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o ordered_array.o ordered_array.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o paging.o paging.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o shared_pages.o shared_pages.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o syscall.o syscall.c
    "syscall.c", line 23: warning: initialization type mismatch
    "syscall.c", line 24: warning: initialization type mismatch
    "syscall.c", line 25: warning: initialization type mismatch
    "syscall.c", line 26: warning: initialization type mismatch
    "syscall.c", line 27: warning: initialization type mismatch
    "syscall.c", line 28: warning: initialization type mismatch
    "syscall.c", line 29: warning: initialization type mismatch
    "syscall.c", line 30: warning: initialization type mismatch
    "syscall.c", line 31: warning: initialization type mismatch
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o task.o task.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o timer.o timer.c
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o util.o util.c
    "util.c", line 44: syntax error before or at: asm
    "util.c", line 49: warning: old-style declaration or incorrect type for: ULONG
    "util.c", line 49: identifier redeclared: ULONG
    	current : int
    	previous: unsigned long : "include/os.h", line 13
    "util.c", line 49: syntax error before or at: fetchCS
    "util.c", line 49: warning: old-style declaration or incorrect type for: fetchCS
    "util.c", line 49: identifier redeclared: fetchCS
    	current : function() returning int
    	previous: function() returning unsigned long : "include/os.h", line 107
    "util.c", line 51: warning: no explicit type given
    "util.c", line 51: syntax error before or at: eax
    "util.c", line 53: undefined symbol: eax
    "util.c", line 56: warning: old-style declaration or incorrect type for: ULONG
    "util.c", line 56: syntax error before or at: fetchDS
    "util.c", line 56: warning: old-style declaration or incorrect type for: fetchDS
    "util.c", line 56: identifier redeclared: fetchDS
    	current : function() returning int
    	previous: function() returning unsigned long : "include/os.h", line 108
    "util.c", line 58: warning: no explicit type given
    "util.c", line 58: syntax error before or at: eax
    "util.c", line 60: undefined symbol: eax
    "util.c", line 75: syntax error before or at: ULONG
    "util.c", line 75: warning: undefined or missing type for: ULONG
    "util.c", line 75: warning: undefined or missing type for: const
    "util.c", line 75: warning: parameter mismatch: 3 declared, 0 defined
    "util.c", line 79: undefined symbol: desc
    "util.c", line 83: undefined symbol: line
    "util.c", line 91: warning: pointer to void or function used in arithmetic
    cc: acomp failed for util.c
    make: *** [util.o] Error 1
    alex@blackie:~/PrettyOS_107/kernel$ make -f makefile_opensolaris 
    cc -O -m32 -xc99 -Bstatic -Iinclude   -c -o util.o util.c
    "util.c", line 44: syntax error before or at: asm
    "util.c", line 49: warning: old-style declaration or incorrect type for: ULONG
    "util.c", line 49: identifier redeclared: ULONG
    	current : int
    	previous: unsigned long : "include/os.h", line 13
    "util.c", line 49: syntax error before or at: fetchCS
    "util.c", line 49: warning: old-style declaration or incorrect type for: fetchCS
    "util.c", line 49: identifier redeclared: fetchCS
    	current : function() returning int
    	previous: function() returning unsigned long : "include/os.h", line 107
    "util.c", line 51: warning: no explicit type given
    "util.c", line 51: syntax error before or at: eax
    "util.c", line 53: undefined symbol: eax
    "util.c", line 56: warning: old-style declaration or incorrect type for: ULONG
    "util.c", line 56: syntax error before or at: fetchDS
    "util.c", line 56: warning: old-style declaration or incorrect type for: fetchDS
    "util.c", line 56: identifier redeclared: fetchDS
    	current : function() returning int
    	previous: function() returning unsigned long : "include/os.h", line 108
    "util.c", line 58: warning: no explicit type given
    "util.c", line 58: syntax error before or at: eax
    "util.c", line 60: undefined symbol: eax
    "util.c", line 75: syntax error before or at: ULONG
    "util.c", line 75: warning: undefined or missing type for: ULONG
    "util.c", line 75: warning: undefined or missing type for: const
    "util.c", line 75: warning: parameter mismatch: 3 declared, 0 defined
    "util.c", line 79: undefined symbol: desc
    "util.c", line 83: undefined symbol: line
    "util.c", line 91: warning: pointer to void or function used in arithmetic
    cc: acomp failed for util.c
    make: *** [util.o] Error 1
    


  • Die Fehler d├╝rften dem inline Assembler Teil betreffen. Ich wei├č nicht ob und in welcher Form der Sun Compiler inline Assembler unterst├╝tzt. Man m├╝sste im Extremfall den ganzen Assembler Code auslagern, durch nasm jagen und dann dazu linken.

    abc.w schrieb:

    Interessant, warum der gcc Compiler es durchl├Ąsst. Es ist auch lustig, was fricky mal hier http://www.c-plusplus.net/forum/viewtopic-var-t-is-246723-and-start-is-60.html geschrieben hat:

    Man k├Ânnte die Parameter und den R├╝ckgabetyp einfach als Mengen ansehen. Dann ist void einfach die leere Menge.

    So wie ich den C99 Standard verstehe, w├╝rde ich es allerdings auch nicht unbedingt durchlassen. Da steht direkt drin, dass bei einer Funktion mit R├╝ckgabetyp void kein Ausdruck hinter dem return stehen darf.


Log in to reply