Attachment "tclDToA.c" to
ticket [722737ffff]
added by
kennykb
2003-12-20 00:23:36.
/*
*----------------------------------------------------------------------
*
* tclDToA.c --
* File defining external procedures 'Tcl_DToA', 'Tcl_StrToD',
* and 'Tcl_FreeDToA' for conversion between floating point and
* decimal.
*
* Copyright (c) 2003 by Kevin B. Kenny. All rights reserved.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclListObj.c,v 1.13 2002/01/07 23:09:13 dgp Exp $
*
*----------------------------------------------------------------------
*
*/
#include <tclInt.h>
#include <stdlib.h>
#include <string.h>
/*
*----------------------------------------------------------------------
*
* localMalloc --
*
* Alias function for Tcl_Alloc with the type signature of
* 'malloc', used as a macro substituent for MALLOC in Gay's
* 'dtoa.c'.
*
* Results:
* Returns a pointer to a newly allocated block of memory.
*
* Side effects:
* Manipulates the heap to allocate memory.
*
*----------------------------------------------------------------------
*/
static void* localMalloc (size_t n)
/* n - size of block to allocate */
{
return (void*) Tcl_Alloc( n );
}
/*
* Define endian-ness of the target machine for dtoa.c
*/
#ifdef WORDS_BIGENDIAN
#define IEEE_MC68k 1
#else
#define IEEE_8087 1
#endif
/*
* Define 32-bit integer types for dtoa.c
*/
#ifdef TCL_WIDE_INT_IS_LONG
#define Long int
#define ULong unsigned int
#endif
/*
* Define 64-bit integer types for dtoa.c
*/
#define Llong Tcl_WideInt
#define ULLong Tcl_WideUInt
/*
* Define memory allocator for dtoa.c
*/
#define MALLOC localMalloc
/*
* dtoa.c should check for Infinity and Nan on output.
*/
#define INFNAN_CHECK 1
/*
* Define synchronization primitives for dtoa.c
*/
#define MULTIPLE_THREADS TCL_THREADED
#ifdef TCL_THREADED
TCL_DECLARE_MUTEX(dtoaMutex0)
TCL_DECLARE_MUTEX(dtoaMutex1)
#define ACQUIRE_DTOA_LOCK(n) Tcl_MutexLock( JOIN(dtoaMutex,n) )
#define FREE_DTOA_LOCK(n) Tcl_MutexUnlock( JOIN(dtoaMutex,n) )
#else
#define ACQUIRE_DTOA_LOCK(n) /* empty */
#define FREE_DTOA_LOCK(n) /* empty */
#endif
/*
* Rename the supplied functions dtoa, strtod, and freedtoa to
* appropriate names in the Tcl internal Stubs table.
*/
#define dtoa TclDToA
#define strtod TclStrToD
#define freedtoa TclFreeDToA
/*
* Bring in Gay's double-to-ASCII code.
*/
#include "dtoa.c"