~ubuntu-branches/ubuntu/trusty/virtualbox-lts-xenial/trusty-proposed

« back to all changes in this revision

Viewing changes to src/VBox/Devices/EFI/Firmware/StdLib/LibC/gdtoa/strtopx.c

  • Committer: Package Import Robot
  • Author(s): Gianfranco Costamagna
  • Date: 2016-02-23 14:28:26 UTC
  • Revision ID: package-import@ubuntu.com-20160223142826-bdu69el2z6wa2a44
Tags: upstream-4.3.36-dfsg
ImportĀ upstreamĀ versionĀ 4.3.36-dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $NetBSD: strtopx.c,v 1.3.14.1 2008/04/08 21:10:55 jdc Exp $ */
 
2
 
 
3
/****************************************************************
 
4
 
 
5
The author of this software is David M. Gay.
 
6
 
 
7
Copyright (C) 1998, 2000 by Lucent Technologies
 
8
All Rights Reserved
 
9
 
 
10
Permission to use, copy, modify, and distribute this software and
 
11
its documentation for any purpose and without fee is hereby
 
12
granted, provided that the above copyright notice appear in all
 
13
copies and that both that the copyright notice and this
 
14
permission notice and warranty disclaimer appear in supporting
 
15
documentation, and that the name of Lucent or any of its entities
 
16
not be used in advertising or publicity pertaining to
 
17
distribution of the software without specific, written prior
 
18
permission.
 
19
 
 
20
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
21
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
 
22
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
 
23
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 
24
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
 
25
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
26
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
 
27
THIS SOFTWARE.
 
28
 
 
29
****************************************************************/
 
30
 
 
31
/* Please send bug reports to David M. Gay (dmg at acm dot org,
 
32
 * with " at " changed at "@" and " dot " changed to ".").  */
 
33
#include  <LibConfig.h>
 
34
 
 
35
#include "gdtoaimp.h"
 
36
 
 
37
#undef _0
 
38
#undef _1
 
39
 
 
40
/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */
 
41
 
 
42
#ifdef IEEE_BIG_ENDIAN
 
43
#define _0 0
 
44
#define _1 1
 
45
#define _2 2
 
46
#define _3 3
 
47
#define _4 4
 
48
#endif
 
49
#ifdef IEEE_LITTLE_ENDIAN
 
50
#define _0 4
 
51
#define _1 3
 
52
#define _2 2
 
53
#define _3 1
 
54
#define _4 0
 
55
#endif
 
56
 
 
57
 int
 
58
#ifdef KR_headers
 
59
strtopx(s, sp, V) CONST char *s; char **sp; void *V;
 
60
#else
 
61
strtopx(CONST char *s, char **sp, void *V)
 
62
#endif
 
63
{
 
64
  static CONST FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
 
65
  ULong bits[2];
 
66
  Long expt;
 
67
  int k;
 
68
  UShort *L = (UShort*)V;
 
69
 
 
70
  k = strtodg(s, sp, &fpi, &expt, bits);
 
71
  if (k == STRTOG_NoMemory)
 
72
    return k;
 
73
  switch(k & STRTOG_Retmask) {
 
74
    case STRTOG_NoNumber:
 
75
    case STRTOG_Zero:
 
76
    L[0] = L[1] = L[2] = L[3] = L[4] = 0;
 
77
    break;
 
78
 
 
79
    case STRTOG_Denormal:
 
80
    L[_0] = 0;
 
81
    goto normal_bits;
 
82
 
 
83
    case STRTOG_Normal:
 
84
    case STRTOG_NaNbits:
 
85
    L[_0] = (UShort)(expt + 0x3fff + 63);
 
86
 normal_bits:
 
87
    L[_4] = (UShort)bits[0];
 
88
    L[_3] = (UShort)(bits[0] >> 16);
 
89
    L[_2] = (UShort)bits[1];
 
90
    L[_1] = (UShort)(bits[1] >> 16);
 
91
    break;
 
92
 
 
93
    case STRTOG_Infinite:
 
94
    L[_0] = 0x7fff;
 
95
    L[_1] = L[_2] = L[_3] = L[_4] = 0;
 
96
    break;
 
97
 
 
98
    case STRTOG_NaN:
 
99
    L[0] = ldus_QNAN0;
 
100
    L[1] = ldus_QNAN1;
 
101
    L[2] = ldus_QNAN2;
 
102
    L[3] = ldus_QNAN3;
 
103
    L[4] = ldus_QNAN4;
 
104
    }
 
105
  if (k & STRTOG_Neg)
 
106
    L[_0] |= 0x8000;
 
107
  return k;
 
108
  }