~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xfree86/os-support/misc/xf86_Util.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

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