Issue 91602

Summary: provide ersatz for expm1 and log1p
Product: porting Reporter: Regina Henschel <rb.henschel>
Component: codeAssignee: ooo
Status: CLOSED FIXED QA Contact: issues@porting <issues>
Severity: Trivial    
Priority: P3 CC: issues, ooo, stephan.bergmann.secondary
Version: DEV300m20   
Target Milestone: OOo 3.1   
Hardware: All   
OS: Windows XP   
Issue Type: PATCH Latest Confirmation in: ---
Developer Difficulty: ---
Issue Depends on:    
Issue Blocks: 91547, 91870    
Attachments:
Description Flags
ersatz for expm1 and log1p, and test values
none
changes in patch form none

Description Regina Henschel 2008-07-12 18:02:29 UTC
Working for Calc for BETADIST, I need the functions expm1 and log1p. But I
noticed, that they are not provided by MS Visual C++ 9.0 Express edition. (At
least I do not found them.) I have used a local ersatz. But I think such a
ersatz should be placed in a common place in a way that I can use expm1 and
log1p in my code and if a compiler has got them, the original version is used,
and if a compiler hasn't got them, the ersatz is used.

I'll attach a file with the ersatz, that works for me with MS Visual C++ 9.0
Express edition on WinXP home. But I don't know, which scenarios will need it
too and whether the ersatz will work there too.
Comment 1 Regina Henschel 2008-07-12 18:05:06 UTC
Created attachment 55086 [details]
ersatz for expm1 and log1p, and test values
Comment 2 ooo 2008-07-17 14:13:46 UTC
I think this should go into ::rtl::math where a wrapper would call either the
compiler provided function or the replacement. Stephan, what do you think?

Btw, is there a way to detect at compilation time whether a compiler supports
these functions, other than using #ifdef __MSC_VER or similar respectively the
usual configure attempt to test compile a function call?
Comment 3 Stephan Bergmann 2008-07-17 17:33:52 UTC
@er:  Yes, adding something to sal/inc/sal/math.h seems reasonable.  I am not
aware of a good way to test for existence of those functions in math.h; #if
__STDC_VERSION__ >= 199901L would work for C (conservatively), but not
necessarily for C++.
Comment 4 ooo 2008-07-17 18:32:19 UTC
Grabbing issue.
Comment 5 Regina Henschel 2008-12-03 13:34:41 UTC
Created attachment 58470 [details]
changes in patch form
Comment 6 ooo 2008-12-04 21:58:02 UTC
In cws odff05:

revision 264877
sal/inc/rtl/math.h
sal/inc/rtl/math.hxx
sal/rtl/source/math.cxx
sal/util/sal.map

A slightly different approach than the attached patch. This makes the functions
available to C sources as well, and provides one single point to change in case
we wanted to replace the replacements with compiler-builtins for specific platforms.
Comment 7 ooo 2008-12-11 13:54:21 UTC
Code present in CWS build.
Comment 8 ooo 2009-07-03 21:19:11 UTC
Available in masters, closing.