diff options
Diffstat (limited to 'include/stdlib.h')
| -rw-r--r-- | include/stdlib.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/stdlib.h b/include/stdlib.h index 5d89c9c..4a5cfde 100644 --- a/include/stdlib.h +++ b/include/stdlib.h | |||
| @@ -37,6 +37,23 @@ __extension__ | |||
| 37 | extern "C" { | 37 | extern "C" { |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | #undef qsort | ||
| 41 | #if __has_builtin(__builtin_qsort) | ||
| 42 | __diagnose_as_builtin(__builtin_qsort, 1, 2, 3, 4) | ||
| 43 | #endif | ||
| 44 | __access(read_write, 1) | ||
| 45 | _FORTIFY_FN(qsort) void qsort(void * _FORTIFY_POS0 base, size_t nmemb, size_t size, | ||
| 46 | int (*compar)(const void *, const void *)) | ||
| 47 | { | ||
| 48 | size_t __b = __bos(base, 0); | ||
| 49 | |||
| 50 | if (__bmo(nmemb, size)) | ||
| 51 | __builtin_trap(); | ||
| 52 | if (nmemb * size> __b) | ||
| 53 | __builtin_trap(); | ||
| 54 | |||
| 55 | return __orig_qsort(base, nmemb, size, compar); | ||
| 56 | } | ||
| 40 | 57 | ||
| 41 | /* FIXME clang */ | 58 | /* FIXME clang */ |
| 42 | #if !defined(__clang__) | 59 | #if !defined(__clang__) |
