[Ffmpeg-devel] No llrint() in Cygwin
Víctor Paesa
wzrlpy
Tue Sep 26 15:39:35 CEST 2006
Hi,
> Vi?ctor Paesa said:
>> Hi,
>>>
>>> SVN r6290 brought llrint(), but that function is not defined in Cygwin
>>> (because it uses newlib for math.h).
>>>
>>> I found this LGPL code that defines llrint() as inline for x86:
>>>
>>> http://sourceware.org/ml/cygwin/2002-12/msg01146/mathinline.h
>>>
>>> Would it be acceptable to copy that llrint() implementation
>>> into libavcodec/i386/mathops.h ?
>>>
>>
>> Maybe this patch will ignite some comments:
>>
>> ===================================================================
>> --- ffmpeg/libavcodec/i386/mathops.h (revision 6329)
>> +++ ffmpeg/libavcodec/i386/mathops.h (working copy)
>> @@ -37,3 +37,16 @@
>> asm ("imull %2\n\t" : "=A"(rt) : "a" (ra), "g" (rb));\
>> rt; })
>>
>> +#ifndef llrint
>> +#define __llrint_code \
>> + long long int __llrintres;\
>> + __asm__ \
>> + ("fistpll %0" \
>> + : "=m" (__llrintres) : "t" (__x) : "st"); \
>> + return __llrintres
>> +
>> +__inline long long int llrint (double __x)
>> +{
>> + __llrint_code;
>> +}
>> +#endif
>
> Identifiers starting with __ are reserved for the system.
OK
> What's the purpose of the macro?
In the original code it had a meaning, the macro was
reused by llrint(), llrintf(), llrintl().
Since I'm not familiar at all with inline assembler
I tried to minimize changes.
What about this new version:
===================================================================
--- ffmpeg/libavcodec/i386/mathops.h (revision 6329)
+++ ffmpeg/libavcodec/i386/mathops.h (working copy)
@@ -37,3 +37,13 @@
asm ("imull %2\n\t" : "=A"(rt) : "a" (ra), "g" (rb));\
rt; })
+#ifndef llrint
+inline long long int llrint (double x)
+{
+ long long int llrintres;
+ asm
+ ("fistpll %0"
+ : "=m" (llrintres) : "t" (x) : "st");
+ return llrintres;
+}
+#endif
Thanks for your review,
V?ctor Paesa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg.cygwin.llrint.2.diff
Type: text/x-patch
Size: 503 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060926/fc14cdeb/attachment.bin>
More information about the ffmpeg-devel
mailing list