shithub: riscv

Download patch

ref: a9bccf9e9b1bd408629edaac277f6b3a3a4ab6fb
parent: c6a9c55de7e5d1d510a717cffd42648d249269db
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Aug 10 22:27:48 EDT 2021

qsort: allow usize-sized arrays.

As part of the transition to 64 bit userspace
APIs, we need to make our libc functions which
take arrays all accept and deal with large sizes.

This does the work for qsort.

--- a/sys/src/libc/port/qsort.c
+++ b/sys/src/libc/port/qsort.c
@@ -8,12 +8,12 @@
 struct
 {
 	int	(*cmp)(void*, void*);
-	void	(*swap)(char*, char*, long);
-	long	es;
+	void	(*swap)(char*, char*, usize);
+	usize	es;
 } Sort;
 
 static	void
-swapb(char *i, char *j, long es)
+swapb(char *i, char *j, usize es)
 {
 	char c;
 
@@ -27,7 +27,7 @@
 }
 
 static	void
-swapi(char *ii, char *ij, long es)
+swapi(char *ii, char *ij, usize es)
 {
 	long *i, *j, c;
 
@@ -42,9 +42,9 @@
 }
 
 static	char*
-pivot(char *a, long n, Sort *p)
+pivot(char *a, usize n, Sort *p)
 {
-	long j;
+	usize j;
 	char *pi, *pj, *pk;
 
 	j = n/6 * p->es;
@@ -69,9 +69,9 @@
 }
 
 static	void
-qsorts(char *a, long n, Sort *p)
+qsorts(char *a, usize n, Sort *p)
 {
-	long j, es;
+	usize j, es;
 	char *pi, *pj, *pn;
 
 	es = p->es;
@@ -111,7 +111,7 @@
 }
 
 void
-qsort(void *va, long n, long es, int (*cmp)(void*, void*))
+qsort(void *va, usize n, usize es, int (*cmp)(void*, void*))
 {
 	Sort s;