From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8256 invoked from network); 30 Jul 2021 06:18:43 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 30 Jul 2021 06:18:43 -0000 Received: from mail-pl1-f172.google.com ([209.85.214.172]) by 1ess; Thu Jul 29 20:17:08 -0400 2021 Received: by mail-pl1-f172.google.com with SMTP id t3so6828210plg.9 for <9front@9front.org>; Thu, 29 Jul 2021 17:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=offblast-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=fvni3MMVYRlxmYJL5QFqsaaa/RlGYGCWTkhz1xxfISM=; b=SwA1flN/5lEWUbdwv6ONzDfU2uN4Lv/hQjYTQZfgQy89V/xKf1pvmw3mY0siQXHO8f VEM2moXzWtmNvClOvnpBINgOOLn8e9q8E+JTc3JD3m7zYq14sKhOPu1LRVtlKPP4KnbP 4AN6QEbr+jOVF1o36wcPFJ6NKC72Ts+3ZVLdayfCgjqxqt1m2V9gjxApllTGHex7+mLe f2YMHqlhcSLEsM54a939W2aazLGTAalULPfIwo+3dmLdvA6hDQUZlrjXWl4LyFTXWxjN 6GJOQYAQvzFTdk311pdCfXrjCDwkS8C1zO3IK+6diH9AmkRCeWuteKMKS+NfZwKWsklD eO3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=fvni3MMVYRlxmYJL5QFqsaaa/RlGYGCWTkhz1xxfISM=; b=FVGo2nFIEzm1INpS/XfTXdxgsgUgn95KOhEMgW4sNUydoZjErOeRhEF6Wc2kmRsNp2 aI5xsXw3MAmKG6IiMb2mFhjzHHn+WZwjzSimO6M9m6Ggf0BKCGQzxc522Vje1tIODDk/ gcjo8H380zQlEZlYB6x+0BWACd+lKMekIjxBn1beHIY82fqCj4a2LWKLghB0A71njf5Q E1m+oh/nORk/uIfqrdaAdpSIB5E+SxAZp+XDVftmo+FvNnoQkVRlpiYJKiE3MkZco12M damgTqDnrR+eLNm3u4iL7X34Zgx84XlH9q3jo2ciQc/GULpR+OK259MZTVk67PmrfG5x sMoQ== X-Gm-Message-State: AOAM530MOPJGWQIKnFleHMJntJCTmRIRJRV5i/b5mFv8+DGUuuoHsFNx I4gRgLKXYbKulAyEsXafMaDniEuggLTyExN1T7qUC2kv858= X-Google-Smtp-Source: ABdhPJyQNx/vCPSWPnT8J/8JdNK5h8omQZFsmvBZlTI5roBZSGl60gGXZqvndKyL9b8OIbXzF8zLujAgUfmWFwxoH+4= X-Received: by 2002:a5e:8d03:: with SMTP id m3mr161022ioj.200.1627600513483; Thu, 29 Jul 2021 16:15:13 -0700 (PDT) MIME-Version: 1.0 References: <52826367713E2C7C877494CDD97A05E7@eigenstate.org> In-Reply-To: <52826367713E2C7C877494CDD97A05E7@eigenstate.org> From: Nick Owens Date: Thu, 29 Jul 2021 16:15:02 -0700 Message-ID: To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: extensible proven API table-aware component-aware self-signing manager Subject: Re: [9front] make arrays big: qsort edition Reply-To: 9front@9front.org Precedence: bulk are you able to test this change with a very large array? On Thu, Jul 29, 2021 at 10:17 AM wrote: > > Since usize exists, and is now 64 bit, we > should start slowly going through our code > and finding the places where we're using > int, short, etc in unexpected ways, so > that we can start allowing big arrays. > > In some cases -- function parameters, > mainly, this is just a matter of switching > the types. > > In others, like strlen, we may need to go > through all possible callers and make sure > that a new, bigger, return type doesn't get > silently truncated and cause issues. > > This change does qsort. > > --- /dist/plan9front/.git/fs/object/84b77568cda98a21dd4f3403a94c56724fbd5b37/tree//sys/include/libc.h > +++ /sys/include/libc.h > @@ -424,7 +424,7 @@ > extern int postnote(int, int, char *); > extern double pow10(int); > extern int putenv(char*, char*); > -extern void qsort(void*, long, long, int (*)(void*, void*)); > +extern void qsort(void*, usize, usize, int (*)(void*, void*)); > extern int setjmp(jmp_buf); > extern double strtod(char*, char**); > extern long strtol(char*, char**, int); > --- /dist/plan9front/.git/fs/object/84b77568cda98a21dd4f3403a94c56724fbd5b37/tree//sys/src/libc/port/qsort.c > +++ /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; > >