OSDN Git Service

Correct project name references in mingwrt source files.
[mingw/mingw-org-wsl.git] / mingwrt / mingwex / math / log2_generic.sx
1 /*
2  * log2_generic.sx
3  *
4  * Generic wrapper for implementation entry stubs for each of the log2(),
5  * log2l(), and log2f() functions.
6  *
7  * $Id$
8  *
9  * Written by Keith Marshall <keith@users.osdn.me>
10  * Copyright (C) 2016, 2022, MinGW.OSDN Project
11  *
12  * Adapted from original code written by J. T. Conklin <jtc@netbsd.org>,
13  * with modifications by Ulrich Drepper <drepper@cygnus.com>, to improve
14  * accuracy in the computation of log2(x) as x --> 1.0.  This wrapper
15  * provides only definitions for derivation of the implementations by
16  * inclusion of the log_generic.sx source file.
17  *
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining a
20  * copy of this software and associated documentation files (the "Software"),
21  * to deal in the Software without restriction, including without limitation
22  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
23  * and/or sell copies of the Software, and to permit persons to whom the
24  * Software is furnished to do so, subject to the following conditions:
25  *
26  * The above copyright notice and this permission notice (including the next
27  * paragraph) shall be included in all copies or substantial portions of the
28  * Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
35  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
36  * DEALINGS IN THE SOFTWARE.
37  *
38  */
39 #undef ___function
40
41 /* Each of the log2(), log2f(), and log2l() functions returns a base-2
42  * logarithm; this may be computed directly, using either the FYL2X, or
43  * the FYL2X1P instruction, by setting the scaling factor (y) to one.
44  */
45 #define __fldy  fld1
46
47 /* The first step is to identify the primary entry point name, and associated
48  * back-end names, for each of the three supported functions, (each of which
49  * to be assembled separately, using a GCC command of the form:
50  *
51  *    gcc -c -D_<function>_source log10_generic.sx -o <function>.o
52  *
53  * to create the three entry stubs, with appropriate mappings to the back-end
54  * implementation provided by log_generic.sx
55  */
56 #if defined _log2_source
57 # define ___function     _log2          /* log2() function entry point name */
58 # define ___x87cvt     ___x87cvt        /* return value conversion helper */
59 # define __fldx           fldl          /* FLD instruction to load x value */
60
61 #elif defined _log2l_source
62 # define ___function     _log2l         /* log2l() function entry point name */
63 # define __fldx           fldt          /* FLD instruction to load x value */
64
65 #elif defined _log2f_source
66 # define ___function     _log2f         /* log2f() function entry point name */
67 # define ___x87cvt     ___x87cvtf       /* return value conversion helper */
68 # define __fldx           flds          /* FLD instruction to load x value */
69 #endif
70
71 /* Actual implementation of the entry point stubs, in terms of the preceding
72  * definitions, is delegated to the log_generic.sx source file.
73  */
74 #include "log_generic.sx"
75
76 /* vim: set autoindent filetype=asm formatoptions=croql: */
77 /* $RCSfile$: end of file */