Re: [AD] Indexed datafiles

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


On Wed, 2005-12-28 at 12:08 +0100, Elias Pschernig wrote:
> We do check for DLL compatibility in allegro_init:
> 
> if (MAKE_VERSION(ALLEGRO_VERSION, ALLEGRO_SUB_VERSION, ALLEGRO_WIP_VERSION) !=
>        _get_allegro_version()) {
>       ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Library version mismatch"));
>       return !0;
>    }
> 
> Right now, this won't catch the 4.2.1 -> 4.2.0 case, since
> _get_allegro_version will return the same number for all stable version
> - guess we should adjust that.
> 

I think the attached patch updates the version matching for the new
4.2.x policy. For example:

- You compile with 4.1.12, then only linking against 4.1.12 is ok. For
WIP versions, we provide no binary compatibility at all.

- You compile with 4.2.1, then linking against 4.2.1, 4.2.2, ... are ok,
but against 4.2.0 is not. (I.e. we do not provide forward binary
compatibility anymore, so you can link against a newer DLL, but not
against an older.)

-- 
Elias Pschernig
Index: include/allegro/system.h
===================================================================
--- include/allegro/system.h	(revision 5626)
+++ include/allegro/system.h	(working copy)
@@ -71,19 +71,30 @@
 #define SYSTEM_AUTODETECT  0
 #define SYSTEM_NONE        AL_ID('N','O','N','E')
 
-#if (ALLEGRO_SUB_VERSION&1)
 #define MAKE_VERSION(a, b, c) (((a)<<16)|((b)<<8)|(c))
-#else
-#define MAKE_VERSION(a, b, c) (((a)<<16)|((b)<<8))
-#endif
 
 AL_FUNC(int, _get_allegro_version, (void));
 AL_FUNC(int, _install_allegro, (int system_id, int *errno_ptr, AL_METHOD(int, atexit_ptr, (AL_METHOD(void, func, (void))))));
-
 AL_INLINE(int, install_allegro, (int system_id, int *errno_ptr, AL_METHOD(int, atexit_ptr, (AL_METHOD(void, func, (void))))),
 {
-   if (MAKE_VERSION(ALLEGRO_VERSION, ALLEGRO_SUB_VERSION, ALLEGRO_WIP_VERSION) !=
-       _get_allegro_version()) {
+   int wrong = 0;
+   int v = _get_allegro_version(); /* This comes from the DLL. */
+   int wv = v & 255;
+   int sv = (v >> 8) & 255;
+   v >>= 16;
+   if (ALLEGRO_VERSION != v || ALLEGRO_SUB_VERSION != sv)
+      /* 4.x.y and 5.x.y are not compatible and
+         4.0.y and 4.1.y are not compatible */
+      wrong = 1;
+   else
+      if (ALLEGRO_SUB_VERSION > 0)
+         if (!(ALLEGRO_WIP_VERSION <= wv && !(ALLEGRO_SUB_VERSION & 1)))
+            /* 4.2.1 is not forward compatible to 4.2.0 and
+             * 4.1.x is not compatible with any other 4.1.x' */
+            wrong = 1;
+         /* else - 4.2.1 is backward compatible to 4.2.0 */
+      /* else - all 4.0.x are back and forward compatible */
+   if (wrong) {
       ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Library version mismatch"));
       return !0;
    }


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