yasm/libyasm/floatnum.h
Peter Johnson 3de47f7b4d Add \rcs, \endrcs, \license, and \endlicense wrappers around $IdPath$ and
copyright/license portions to shorten Doxygen output.  Comment only change.

svn path=/trunk/yasm/; revision=985
2003-06-28 17:38:08 +00:00

114 lines
4.5 KiB
C

/**
* \file libyasm/floatnum.h
* \brief YASM floating point (IEEE) interface.
*
* \rcs
* $IdPath$
* \endrcs
*
* \license
* Copyright (C) 2001 Peter Johnson
*
* Based on public-domain x86 assembly code by Randall Hyde (8/28/91).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* \endlicense
*/
#ifndef YASM_FLOATNUM_H
#define YASM_FLOATNUM_H
/** Initialize floatnum internal data structures. */
void yasm_floatnum_initialize(void);
/** Clean up internal floatnum allocations. */
void yasm_floatnum_cleanup(void);
/** Create a new floatnum from a decimal string. The input string must be in
* standard C representation ([+-]123.456e[-+]789).
* \param str floating point decimal string
* \return Newly allocated floatnum.
*/
/*@only@*/ yasm_floatnum *yasm_floatnum_new(const char *str);
/** Duplicate a floatnum.
* \param flt floatnum
* \return Newly allocated floatnum with the same value as flt.
*/
/*@only@*/ yasm_floatnum *yasm_floatnum_copy(const yasm_floatnum *flt);
/** Destroy (free allocated memory for) a floatnum.
* \param flt floatnum
*/
void yasm_floatnum_delete(/*@only@*/ yasm_floatnum *flt);
/** Floating point calculation function: acc = acc op operand.
* \note Not all operations in yasm_expr_op may be supported; unsupported
* operations will result in an error.
* \param acc floatnum accumulator
* \param op operation
* \param operand floatnum operand
* \param lindex line index (of expression)
*/
void yasm_floatnum_calc(yasm_floatnum *acc, yasm_expr_op op,
yasm_floatnum *operand, unsigned long lindex);
/** Convert a floatnum to single-precision and return as 32-bit value.
* The 32-bit value is a "standard" C value (eg, of unknown endian).
* \param flt floatnum
* \param ret_val pointer to storage for 32-bit output
* \return Nonzero if flt can't fit into single precision: -1 if underflow
* occurred, 1 if overflow occurred.
*/
int yasm_floatnum_get_int(const yasm_floatnum *flt,
/*@out@*/ unsigned long *ret_val);
/** Convert a floatnum to Intel-format little-endian byte string.
* [0] should be the first byte output to an Intel-format file.
* \note Not all sizes are valid. Currently, only 4 (single-precision), 8
* (double-precision), and 10 (extended-precision) are valid sizes.
* Use yasm_floatnum_check_size() to check for supported sizes.
* \param flt floatnum
* \param ptr pointer to storage for size bytes of output
* \param size size (in bytes) of desired output.
* \return Nonzero if flt can't fit into the specified precision: -1 if
* underflow occurred, 1 if overflow occurred.
*/
int yasm_floatnum_get_sized(const yasm_floatnum *flt,
/*@out@*/ unsigned char *ptr, size_t size);
/** Basic check to see if size is valid for flt conversion (using
* yasm_floatnum_get_sized()). Doesn't actually check for underflow/overflow
* but rather checks for size=4,8,10
* (at present).
* \param flt floatnum
* \param size size (in bytes) of desired conversion output
* \return 1 if valid size, 0 if invalid size.
*/
int yasm_floatnum_check_size(const yasm_floatnum *flt, size_t size);
/** Print various representations of a floatnum. For debugging purposes only.
* \param f file
* \param flt floatnum
*/
void yasm_floatnum_print(FILE *f, const yasm_floatnum *flt);
#endif