Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • a3483c2
  • /
  • ntrulpr761
  • /
  • m4f
  • /
  • uint32_sort.c
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:4b547a6584d5668bf6bea02587d0b86072f1cb31
directory badge Iframe embedding
swh:1:dir:5f3a51315c7e41718a82b21f7948f737326c1616
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
uint32_sort.c
/*********************************
*
* Implementation of djbsort for unsigned 32-bit integer arrays
* 
***********************************/

//#include "crypto_sort_int32.h"
#include "crypto_sort.h"
#include "uint32.h"
typedef uint32 crypto_uint32;

/* can save time by vectorizing xor loops */
/* can save time by integrating xor loops with int32_sort */
void uint32_sort(void *array,long long n);
void uint32_sort(void *array,long long n)
{
  crypto_uint32 *x = array;
  long long j;
  for (j = 0;j < n;++j) x[j] ^= 0x80000000;
  crypto_sort(array,n);
  for (j = 0;j < n;++j) x[j] ^= 0x80000000;
}

// static void minmax(uint32 *x,uint32 *y)
// {
//   uint32 xi = *x;
//   uint32 yi = *y;
//   uint32 xy = xi ^ yi;
//   uint32 c = yi - xi;
//   c ^= xy & (c ^ yi ^ 0x80000000);
//   c >>= 31;
//   c = -c;
//   c &= xy;
//   *x = xi ^ c;
//   *y = yi ^ c;
// }

// void uint32_sort(uint32 *x,int n)
// {
//   int top,p,q,i;

//   if (n < 2) return;
//   top = 1;
//   while (top < n - top) top += top;

//   for (p = top;p > 0;p >>= 1) {
//     for (i = 0;i < n - p;++i)
//       if (!(i & p))
//         minmax(x + i,x + i + p);
//     for (q = top;q > p;q >>= 1)
//       for (i = 0;i < n - q;++i)
//         if (!(i & p))
//           minmax(x + i + p,x + i + q);
//   }
// }

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top