[AD] mingw, static, tls

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


In an attempt to profile the slow allegro fonts, I've finally gotten
allegro to actually compile a usable profile mode. (Man vs Machine).
Shared profile didn't seem to give me any profile information, despite
-pg being passed everywhere (after manually editing some link.txt
files).

So I went with a static profile, and noticed that mingw32 static
doesn't work. I assume this is a known bug because it just crashes on
the display code, but it took me a while to figure out what was going
on since I'm not familiar with A5's internals.

Anyway, I altered the function as follows. Obviously this isn't at all
correct, but the hack works for my purposes. I assume the problem is
the DllMain thing doesn't get called, so the tls data never gets
initialized.

static thread_local_state *tls_get(void)
{
	static int foo = 0;
	if (!foo )
	{
		foo = 1;
		tls_index = TlsAlloc();

		  thread_local_state *data = _AL_MALLOC(sizeof(*data));
          if (data != NULL) {
             memset(data, 0, sizeof(*data));

             data->new_bitmap_format = ALLEGRO_PIXEL_FORMAT_ANY;
             data->blend_source = ALLEGRO_ALPHA;
             data->blend_dest = ALLEGRO_INVERSE_ALPHA;
             data->blend_alpha_source = ALLEGRO_ONE;
             data->blend_alpha_dest = ALLEGRO_ONE;
             data->blend_color.r = data->blend_color.g = data->blend_color.b
                = data->blend_color.a = 1.0f;
             //data->memory_blender = _al_blender_alpha_inverse_alpha;
             TlsSetValue(tls_index, data);
             _al_fill_display_settings(&data->new_display_settings);
          }
		
	}
   thread_local_state *t = TlsGetValue(tls_index);
   return t;
}

--
Matthew Leverton




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