On 1/14/22, Alexei Podtelezhnikov <apodt...@gmail.com> wrote: >> #if defined(_MSC_VER) && defined(_M_IX86) > > I think this is appropriate, it makes it clear which compiler is intended.
OK, as you wish. > As for `near`, I found the undefine option > https://users.pja.edu.pl/~jms/qnx/help/watcom/compiler-tools/cpopts.html#SWu Ah, nothing specific for near macro itself, but the standart '-U' like many other compilers. > Do you use any special build tools/scripts to insert it? I use a makefile for os/2, so I can add -Unear to CFLAGS (tested and works.) > Finally, does Watcom have 64-bit types these days? We could insert it in > https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/include/freetype/config/integer-types.h As of version 11.0, it supports long long: You can check like: #if (__WATCOMC__ >= 1100) It also supports __int64 but don't know as of which version. > Do you know of any fast most-significnat-bit functions, like > __builtin_clz, for Watcom? You can inline-asm the bsr instruction with Watcom's aux pragma for _BitScanReverse behavior, provided that you handle x==0 special case, (replace uint32_t with unsigned long if you like). Like: #if defined(__WATCOMC__) && defined(__386__) extern __inline int _bsr_watcom(uint32_t); #pragma aux _bsr_watcom = \ "bsr eax, eax" \ parm [eax] nomemory \ value [eax] \ modify exact [eax] nomemory; #endif Or, if you specifically want __builtin_clz-like behavior, here is a version which xors the result with 31: static __inline int _clz_watcom(uint32_t); #pragma aux _clz_watcom = \ "bsr eax, eax" \ "xor eax, 31" \ parm [eax] nomemory \ value [eax] \ modify exact [eax] nomemory; #endif -- O.S.