-2

how to support to vendor libraries. Apart from file changes, and APIs, the new version is 64 bit whereas the old is 32 bit

What's the best design and implementation effort to support two version of a library. Lets call them Lib_v1, and Lib_v2. We want to reduce the amount of code base changes that call the existing 'Lib_v1 APIs for two specific platforms--OS_A and OS_B--but have the underlying library be Lib_v2. As mentioned, we want to keep a lot of the existing API names, but the internal library use would be dependent on the OS. For the third OS, call it OS_C, we want to use the old Lib_v1 library.

Summary:

OS_A and OS_B:
   -use Lib_v2

OS_C:
   -use Lib_v1

What kind of design should I look at, and what kind of implementation effort should I steer myself to doing.

Edit: yes, I've done some preliminary search. I am lacking a lot of SWE design principles. I should note, that we use different compilers for the various platforms.

1
  • 2
    Have you done some basic research? That's expected before asking questions here. In case you didn't find an appropriate search term, "configure script" is it, and it leads to en.m.wikipedia.org/wiki/Configure_script which should give you answers. Commented Apr 5, 2023 at 4:50

1 Answer 1

0

Typically the dynamic link editor ldd would work out details related to bumping the major version from 1 to 2, assuming that some functions continue to work the same. But upgrading all functions to accept wider integers is more like sun-setting "Product32" and launching "Product64".

It sounds like you want to write app code which is portable across three operating systems and oblivious to the v1 / v2 schism. Decide on whether you have a 32 or 64 bit app. Prohibit the app code from calling either product. Write an adapter layer for the app to call.

There's no need to support all of Product32 -- just the subset of its functions that your app relies on. Start stubbing them out, and compile / link errors will immediately tell you about any that you've not yet gotten to. Soon you will have them all.

The adapter will accept application calls and on OS_C will change width and make the corresponding Product32 v1 call. On OS_A and OS_B the adapter layer will instead change width and make a Product64 v2 call.

Changing width probably means casting int32 to a wider integer prior to the call as needed, and of course adapting any result widths, too. If you choose to make your app uniformly 32-bit, then changing width is pretty straightforward except for any large 64-bit values that come back from v2. In general for unsigned args or return value, when downcasting to a narrower integer you'll need to check for overflow and signal an error on magnitudes greater than four billion.

Not the answer you're looking for? Browse other questions tagged or ask your own question.