[flac-dev] os/2 support using Watcom

Ozkan Sezer sezeroz at gmail.com
Sun Jan 22 22:00:51 UTC 2017


On 1/22/17, Dave Yeo <dave.r.yeo at gmail.com> wrote:
> On 01/22/17 09:57 AM, Ozkan Sezer wrote:
>> On 1/22/17, Dave Yeo <dave.r.yeo at gmail.com> wrote:
>>> On 01/22/17 05:35 AM, Ozkan Sezer wrote:
>>>> The attached set of patches adds support for OS/2 using Watcom compiler
>>>> (tested with Open Watcom 1.9).  My only interest was building a working
>>>> dll (the last patch in the set adds a makefile for it), therefore I did
>>>> not touch other places: If there is interest, I can do so.
>>>
>>
>> Disclaimer: I don't know much about EMX.  That aside,
>>
>>> Most of the patches can have s/__EMX__/__OS2__/
>>
>> I intentionally kept __EMX__ checks because, IIRC, old gcc versions
>> (2.8?? can't remember) did define __EMX__ but not __OS2__
>
> Flac won't compile with old EMX, if only due to the lack of the stdint
> types. Pretty sure it's missing other math stuff as well.

I see (but keeping the EMX checks won't hurt either)

>
>>
>>>   excepting the nasm.h one.
>>> nasm.h should test for OBJ_FORMAT_obj as obj is also correct when
>>> building with GCC flags -Zomf.
>>
>> OK, that can easily be added to configury, but..
>
> Please.

Will cook something for it,

>
>>
>>>   Not sure about the assembly prefix as
>>> generally cdecl is correct for OS/2, perhaps test for defined
>>> (__WATCOMC__) && defined (__OS2__)
>>
>> Yeah: Default calling convention for Watcom is not __cdecl
>> it is, IIRC, __watcall and it doesn't prepend underscore to the
>> symbols
>
> Yes, why it should only be used by Watcom.
>
>>
>>>
>>> Will the GCC built flac8.dll link with Watcom with something like
>>> diff --git a/include/FLAC/export.h b/include/FLAC/export.h
>>> index d52f0bb..96d5422 100644
>>> --- a/include/FLAC/export.h
>>> +++ b/include/FLAC/export.h
>>> @@ -69,6 +69,9 @@
>>>    #elif defined(FLAC__USE_VISIBILITY_ATTR)
>>>    #define FLAC_API __attribute__ ((visibility ("default")))
>>>
>>> +#elif defined (__WATCOMC__) && defined (__OS2__)
>>> +#define FLAC_API __declspec(__cdecl)
>>> +
>>>    #else
>>>    #define FLAC_API
>>
>> As I said, I don't know much about emx, but the wrong thing
>> about the above is that it doesn't use dllexport therefore nothing
>> will be exported with this.
>
> It should work with an import library (untested), namely adding flac.lib
> to the linker directive for whatever is using flac8.dll.
> Just to be clear, I don't mean to recompile flac with the above patch,
> rather to install
> http://hobbes.nmsu.edu/h-search.php?button=Search&key=flac-1.3.2.zip&dir=%2F
>
> and patch the installed header as well as create the import library as
> below.
>
> R:\tmp>wlib flac.lib +FLAC8.dll
> Open Watcom Library Manager Version 2.0beta1 Limited Availability
> Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
> Source code is available under the Sybase Open Watcom Public License.
> See http://www.openwatcom.org/ for details.
> Warning! Cannot open 'flac.lib' - library will be created
>
> Better would be for Flac to incorporate something like attached patch
> (needs testing) and add
> #define FLAC_API __declspec(__cdecl)
> before including FLAC/all.h

OK, I changed the patch to exports.h to be like the following:

diff --git a/include/FLAC/export.h b/include/FLAC/export.h
index d52f0bb..27b70af 100644
--- a/include/FLAC/export.h
+++ b/include/FLAC/export.h
@@ -57,7 +57,11 @@
  */

 #if defined(FLAC__NO_DLL)
+#ifndef __OS2__
 #define FLAC_API
+#else
+#define FLAC_API __declspec(__cdecl)
+#endif

 #elif defined(_MSC_VER)
 #ifdef FLAC_API_EXPORTS
@@ -66,6 +70,13 @@
 #define FLAC_API __declspec(dllimport)
 #endif

+#elif defined(__OS2__)
+#if defined(FLAC_API_EXPORTS) && defined(__WATCOMC__) && defined(__SW_BD)
+#define FLAC_API __declspec(__cdecl) __declspec(dllexport)
+#else
+#define FLAC_API __declspec(__cdecl)
+#endif
+
 #elif defined(FLAC__USE_VISIBILITY_ATTR)
 #define FLAC_API __attribute__ ((visibility ("default")))


It compiles with watcom OK. Apps link to it OK using watcom provided
that exports.h is changed like above. Using the same exports.h, apps
link to the import lib generated from the emx-compiled dll too.

Question: Does emx support __declspec(dllexport) so I can adjust
these changes? Because the emx build of the dll seems to have
exported _everything_ :(

--
O.S.


More information about the flac-dev mailing list