Re: [AD] Non C program accessing Allegro on OS X

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]



Elias Pschernig wrote:

On Mon, 2005-10-24 at 23:48 -0400, Jon Rafkind wrote:
Im using Allegro with bindings written in Scheme( MzScheme ) but am running into problems on OS X. This works fine on Linux, though. Basically how its set up is I load allegro.so( or in this case allegro.dylib ) and extract functions from it which I can then call just like I would from C. In this way the "magic main" in OS X isnt run and things dont seem to work right when this is the case. Im not very familiar with the OS X internals and KittyCat was telling me it wasnt really possible to run Allegro on OS X without the magic main but Im hoping this can be changed so it works the same on Linux.

I did a bunch of debugging by adding printf's into the Allegro internals but couldnt really come up with anything since I think two or more threads are doing stuff once I activate allegro via install_allegro. One thing I did come up with is that if I dont have a main then __crt0_argv isnt set and in system.m line 489 will crash. This should read

else if ( __crt0_argv != NULL ){
     do_uconvert(__crt0_argv[0], U_ASCII, output, U_CURRENT, size);
  }

instead.

Any OS X have any insight into this problem?


Basically, you must give control of the main thread to Allegro. You can
see what Allegro does at startup in src/macosx/main.m. The main()
function in there is the main function of any standalone Allegro
program, the main() in your code gets basically renamed to something
else with END_OF_MAIN.

While hacking the crap out of the OS X code I discovered that a Bus error would occur if rest(1) was called while the usleep( 100000 / refresh_rate ) happened. Im about to goto sleep and dont have to to investigate it now but does it sound like that might be a race condition?

Anyway, I think I may have solved my previous question but I will have to hack a bit more to know for sure. I will let you know if it works as Im sure someone is interested in this.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/