bebbo / amiga-gcc

The GNU C-Compiler with Binutils and other useful tools for cross development for Amiga
GNU General Public License v2.0
312 stars 66 forks source link

NT_INTERRUPT issues #369

Open Bearsoft749 opened 8 months ago

Bearsoft749 commented 8 months ago

This code works in GCC 6.5 but does not work in GCC 13.1. I must use "m68k-amigaos-strip" to get it to be executable in GCC 13.1.

include

include

include <proto/exec.h>

include <exec/execbase.h>

include <hardware/intbits.h>

struct Interrupt *vbint2; int counter; int quit; int value=0; int valueEnd=60;

void startInterrupt(void *interruptFuncton) { vbint2=NULL;

if (vbint2 = (struct Interrupt *)AllocMem(sizeof(struct Interrupt), MEMF_PUBLIC|MEMF_CLEAR))
{
    vbint2->is_Node.ln_Type = NT_INTERRUPT;

    vbint2->is_Node.ln_Pri = -60;   //-60
    vbint2->is_Node.ln_Name = "VertB";
    vbint2->is_Data = (APTR)&counter;
    vbint2->is_Code = (void (*)())interruptFuncton;

    AddIntServer(INTB_VERTB, vbint2); 
}
else 
{
    printf("Can't allocate memory for interrupt node\n");   
}

}

void endInterrupt() { quit=1;

 if (vbint2 != NULL)
 {
    RemIntServer(INTB_VERTB, vbint2);
    FreeMem(vbint2, sizeof(struct Interrupt));

// printf("%ld vertical blanks occurred\nRemoving server\n", counter); } }

int waitInterrupt() { if (quit==2) { quit=0; }

int tempQuit=quit;
quit++;

return tempQuit;

}

int interruptLoop() { while(!waitInterrupt()) { value++;

    if (value>=valueEnd)
    {
        value=valueEnd;
    }
}

}

int main() { startInterrupt((void*)interruptLoop);

while(value<valueEnd)
{
    sleep(3);
}

endInterrupt();

printf("value %d\n", value);

return 0;

}

Bearsoft749 commented 8 months ago

I forgot... m68k-amigaos-g++ -w -O3 -mno-align-int -funsafe-math-optimizations -ffast-math -mhard-float -fomit-frame-pointer -m68060 -noixemul -o main main.cpp