First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / os-support / misc / xf86_Util.c
blob9e690591d61d8f65ed6a96a7cd985ad08481ad85
1 /*
2 * Copyright 1993 by David Wexelblat <dwex@goblin.org>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of David Wexelblat not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. David Wexelblat makes no representations
11 * about the suitability of this software for any purpose. It is provided
12 * "as is" without express or implied warranty.
14 * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
25 * This file is for utility functions that will be shared by other pieces
26 * of the system. Putting things here ensure that all the linking order
27 * dependencies are dealt with, as this library will be linked in last.
30 #ifdef HAVE_XORG_CONFIG_H
31 #include <xorg-config.h>
32 #endif
34 #include <ctype.h>
36 /* To prevent empty source file warnings */
37 int _xf86misc;
39 #if 0
40 /* For use only with gcc */
41 #ifdef __GNUC__
43 #include "os.h"
45 char *
46 debug_alloca(char *file, int line, int size)
48 char *ptr;
50 ptr = Xalloc(size);
51 ErrorF("Alloc: %s line %d; ptr = 0x%x, length = %d\n", file, line,
52 ptr, size);
53 return ptr;
56 void
57 debug_dealloca(char *file, int line, char *ptr)
59 ErrorF("Dealloc: %s line %d; ptr = 0x%x\n", file, line, ptr);
60 Xfree(ptr);
62 #endif
63 #endif
65 #if defined(ISC) || defined(Lynx)
67 #include <math.h>
69 /* Needed for apm_driver.c */
70 /* These functions are modeled after the functions inside gnu's libc */
72 static double
73 copysign(double x, double y)
75 x = fabs(x);
76 return y < 0 ? - x : x;
79 double
80 RInt(double x)
82 double s,t;
83 const double one = 1.0;
84 const static double L = 4503599627370496.0E0;
86 if (x!=x)
87 return(x);
88 if (copysign(x,one) >= L)
89 return(x);
90 s = copysign(L,x);
91 t = x + s;
92 return (t - s);
94 #endif