Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
b51024fc
Commit
b51024fc
authored
Apr 24, 2000
by
Mark Mitchell
Committed by
Mark Mitchell
Apr 24, 2000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* sort.c (sort_pointers): Fix endianness bugs.
From-SVN: r33368
parent
a3fbf5c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
libiberty/ChangeLog
+2
-0
libiberty/sort.c
+10
-8
No files found.
libiberty/ChangeLog
View file @
b51024fc
2000-04-23 Mark Mitchell <mark@codesourcery.com>
* sort.c (sort_pointers): Fix endianness bugs.
* sort.c: New file.
* Makefile.in (CFILES): Add sort.c
(REQUIRED_OFILES): Add sort.o.
...
...
libiberty/sort.c
View file @
b51024fc
...
...
@@ -29,9 +29,8 @@ Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#endif
/* POINTERSP and WORKP both point to arrays of N pointers. When
this function returns POINTERSP will point to a sorted version of
the original array pointed to by POINTERSP. */
/* POINTERS and WORK are both arrays of N pointers. When this
function returns POINTERS will be sorted in ascending order. */
void
sort_pointers
(
n
,
pointers
,
work
)
size_t
n
;
...
...
@@ -63,8 +62,11 @@ void sort_pointers (n, pointers, work)
abort
();
/* Figure out the endianness of the machine. */
for
(
i
=
0
;
i
<
sizeof
(
size_t
);
++
i
)
((
char
*
)
&
j
)[
i
]
=
i
;
for
(
i
=
0
,
j
=
0
;
i
<
sizeof
(
size_t
);
++
i
)
{
j
*=
(
UCHAR_MAX
+
1
);
j
+=
i
;
}
big_endian_p
=
(((
char
*
)
&
j
)[
0
]
==
0
);
/* Move through the pointer values from least significant to most
...
...
@@ -91,8 +93,8 @@ void sort_pointers (n, pointers, work)
/* Compute the address of the appropriate digit in the first and
one-past-the-end elements of the array. On a little-endian
machine, the least-significant digit is closest to the front. */
bias
=
((
digit_t
*
)
pointers
)
+
i
;
top
=
((
digit_t
*
)
(
pointers
+
n
))
+
i
;
bias
=
((
digit_t
*
)
pointers
)
+
j
;
top
=
((
digit_t
*
)
(
pointers
+
n
))
+
j
;
/* Count how many there are of each value. At the end of this
loop, COUNT[K] will contain the number of pointers whose Ith
...
...
@@ -109,7 +111,7 @@ void sort_pointers (n, pointers, work)
/* Now, drop the pointers into their correct locations. */
for
(
pointerp
=
pointers
+
n
-
1
;
pointerp
>=
pointers
;
--
pointerp
)
work
[
--
count
[((
digit_t
*
)
pointerp
)[
i
]]]
=
*
pointerp
;
work
[
--
count
[((
digit_t
*
)
pointerp
)[
j
]]]
=
*
pointerp
;
/* Swap WORK and POINTERS so that POINTERS contains the sorted
array. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment