Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
ntpsec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
NTPsec
ntpsec
Commits
f18a1134
Commit
f18a1134
authored
7 years ago
by
Gary E. Miller
Browse files
Options
Downloads
Patches
Plain Diff
ieee754io: remove now pointless, and broken, standalone shim.
No need with working tests.
parent
521c7270
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libparse/ieee754io.c
+0
-176
0 additions, 176 deletions
libparse/ieee754io.c
with
0 additions
and
176 deletions
libparse/ieee754io.c
+
0
−
176
View file @
f18a1134
...
...
@@ -376,182 +376,6 @@ fetch_ieee754(
}
}
#if defined(DEBUG) && defined(DEBUG_PARSELIB)
#include
<stdlib.h>
static
int
put_ieee754
(
unsigned
char
**
bufpp
,
int
size
,
l_fp
*
lfpp
,
offsets_t
offsets
)
{
l_fp
outlfp
;
#ifdef DEBUG_PARSELIB
unsigned
int
sign
;
unsigned
int
bias
;
#endif
/*unsigned int maxexp;*/
int
mbits
;
int
msb
;
unsigned
long
mantissa_low
=
0
;
unsigned
long
mantissa_high
=
0
;
#ifdef DEBUG_PARSELIB
unsigned
long
characteristic
=
0
;
long
exponent
;
#endif
/*int length;*/
unsigned
long
mask
;
UNUSED_ARG
(
bufpp
);
UNUSED_ARG
(
offsets
);
outlfp
=
*
lfpp
;
switch
(
size
)
{
case
IEEE_DOUBLE
:
/*length = 8;*/
mbits
=
52
;
#ifdef DEBUG_PARSELIB
bias
=
1023
;
#endif
/*maxexp = 2047;*/
break
;
case
IEEE_SINGLE
:
/*length = 4;*/
mbits
=
23
;
#ifdef DEBUG_PARSELIB
bias
=
127
;
#endif
/*maxexp = 255;*/
break
;
default:
return
IEEE_BADCALL
;
}
/*
* find sign
*/
if
(
L_ISNEG
(
outlfp
))
{
L_NEG
(
outlfp
);
#ifdef DEBUG_PARSELIB
sign
=
1
;
#endif
}
else
{
#ifdef DEBUG_PARSELIB
sign
=
0
;
#endif
}
if
(
outlfp
==
0
)
{
#ifdef DEBUG_PARSELIB
exponent
=
mantissa_high
=
mantissa_low
=
0
;
/* true zero */
#endif
}
else
{
/*
* find number of significant integer bits
*/
mask
=
0x80000000
;
if
(
lfpuint
(
outlfp
))
{
msb
=
63
;
while
(
mask
&&
((
lfpuint
(
outlfp
)
&
mask
)
==
0
))
{
mask
>>=
1
;
msb
--
;
}
}
else
{
msb
=
31
;
while
(
mask
&&
((
lfpfrac
(
outlfp
)
&
mask
)
==
0
))
{
mask
>>=
1
;
msb
--
;
}
}
switch
(
size
)
{
case
IEEE_SINGLE
:
mantissa_high
=
0
;
if
(
msb
>=
32
)
{
mantissa_low
=
(
lfpuint
(
outlfp
)
&
((
1
<<
(
msb
-
32
))
-
1
))
<<
(
mbits
-
(
msb
-
32
));
mantissa_low
|=
lfpfrac
(
outlfp
)
>>
(
mbits
-
(
msb
-
32
));
}
else
{
mantissa_low
=
(
lfpfrac
(
outlfp
)
<<
(
mbits
-
msb
))
&
((
1
<<
mbits
)
-
1
);
}
break
;
case
IEEE_DOUBLE
:
if
(
msb
>=
32
)
{
mantissa_high
=
(
lfpuint
(
outlfp
)
<<
(
mbits
-
msb
))
&
((
1
<<
(
mbits
-
32
))
-
1
);
mantissa_high
|=
lfpfrac
(
outlfp
)
>>
(
32
-
(
mbits
-
msb
));
mantissa_low
=
(
lfpuint
(
outlfp
)
&
((
1
<<
(
msb
-
mbits
))
-
1
))
<<
(
32
-
(
msb
-
mbits
));
/* coverity[negative_shift] */
mantissa_low
|=
lfpfrac
(
outlfp
)
>>
(
msb
-
mbits
);
}
else
{
mantissa_high
=
lfpfrac
(
outlfp
)
<<
(
mbits
-
32
-
msb
);
mantissa_low
=
lfpfrac
(
outlfp
)
<<
(
mbits
-
32
);
}
}
#ifdef DEBUG_PARSELIB
exponent
=
msb
-
32
;
characteristic
=
exponent
+
bias
;
if
(
debug
>
4
)
printf
(
"FP: %s
\n
"
,
fmt_flt
(
sign
,
mantissa_high
,
mantissa_low
,
characteristic
));
#endif
}
return
IEEE_OK
;
}
int
main
(
int
argc
,
char
**
argv
)
{
static
offsets_t
native_off
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
};
double
f
=
1
.
0
;
double
*
f_p
=
&
f
;
l_fp
fp
;
if
(
argc
==
2
)
{
if
(
sscanf
(
argv
[
1
],
"%lf"
,
&
f
)
!=
1
)
{
printf
(
"cannot convert %s to a float
\n
"
,
argv
[
1
]);
return
EXIT_FAILURE
;
}
}
printf
(
"double: %s %s
\n
"
,
fmt_blong
(
*
(
unsigned
long
*
)
&
f
,
32
),
fmt_blong
(
*
(
unsigned
long
*
)((
char
*
)(
&
f
)
+
4
),
32
));
printf
(
"fetch from %f = %d
\n
"
,
f
,
fetch_ieee754
((
void
*
)
&
f_p
,
IEEE_DOUBLE
,
&
fp
,
native_off
));
printf
(
"fp [%s %s] = %s
\n
"
,
fmt_blong
(
lfpuint
(
fp
),
32
),
fmt_blong
(
lfpfrac
(
fp
),
32
),
mfptoa
(
lfpuint
(
fp
),
lfpfrac
(
fp
),
15
));
f_p
=
&
f
;
put_ieee754
((
void
*
)
&
f_p
,
IEEE_DOUBLE
,
&
fp
,
native_off
);
return
EXIT_SUCCESS
;
}
#endif
/*
* History:
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment