| 1 |
// { dg-do assemble } |
| 2 |
// { dg-xfail-if "" { xstormy16-*-* } } |
| 3 |
// { dg-require-effective-target size20plus } |
| 4 |
// { dg-skip-if "requires hosted libstdc++ for stdlib qsort" { ! hostedlib } } |
| 5 |
|
| 6 |
#include <stdio.h> |
| 7 |
#include <stdlib.h> |
| 8 |
|
| 9 |
#define MAX 256 |
| 10 |
#define MAXSTATE 1000000 |
| 11 |
|
| 12 |
struct R { |
| 13 |
int count; |
| 14 |
int state1; |
| 15 |
int state2; |
| 16 |
}; |
| 17 |
|
| 18 |
int cmp_d(const R* a, const R* b) { |
| 19 |
return a->count > b->count; |
| 20 |
} |
| 21 |
|
| 22 |
namespace CXX { |
| 23 |
template<class T, long i1, long i2> |
| 24 |
inline void qsort (T b[i1][i2], int (*cmp)(const T*, const T*)) { |
| 25 |
::qsort ((void*)b, i1*i2, sizeof(T), (int (*)(const void *, const void *))cmp); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
using namespace CXX; |
| 30 |
|
| 31 |
void sort_machine() { |
| 32 |
struct R d[MAX][MAX]; |
| 33 |
qsort<R,MAX> (d, cmp_d); |
| 34 |
} |