2 * Creation Date: <2002/10/19 21:05:07 samuel>
3 * Time-stamp: <2002/10/22 22:29:18 samuel>
9 * Copyright (C) 2002, 2003 Samuel Rydh (samuel@ibrium.se)
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation
18 #include "libc/string.h"
23 qsort( void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void*) )
25 unsigned int worked, i, j;
27 /* even more inefficient than the glibc variant :-) */
31 for( i=0; i<nmemb-1; i++, p+= size ) {
32 if( compar( p, p + size ) > 0 ) {
34 for( j=0; j<size; j++ ) {
46 strtol( const char *nptr, char **endptr, int base )
49 while( isspace(*nptr) )
52 if( *nptr == '-' || *nptr == '+' )
53 sign = (*nptr++ == '-') ? -1 : 1;
55 if( base == 16 || base == 0) {
57 base = (nptr[0] == '0')? 8 : 10;
58 if( nptr[0] == '0' && nptr[1] == 'x' ) {
63 for( sum=0 ;; nptr++ ) {
67 n = isdigit(ch) ? ch - '0' : toupper(ch) - 'A' + 10;
68 if( n >= base || n < 0 )
74 *endptr = (char*)nptr;
80 strtoll( const char *nptr, char **endptr, int base )
84 while( isspace(*nptr) )
87 if( *nptr == '-' || *nptr == '+' )
88 sign = (*nptr++ == '-') ? -1 : 1;
90 if( base == 16 || base == 0) {
92 base = (nptr[0] == '0')? 8 : 10;
93 if( nptr[0] == '0' && nptr[1] == 'x' ) {
98 for( sum=0 ;; nptr++ ) {
102 n = isdigit(ch) ? ch - '0' : toupper(ch) - 'A' + 10;
103 if( n >= base || n < 0 )
109 *endptr = (char*)nptr;
116 #ifdef CONFIG_BIG_ENDIAN
117 (0 << 24) | (0 << 16) | ('\n' << 8) | 255,
119 (255 << 24) | ('\n' << 16) | (0 << 8) | 0,
124 static void freeze(void)
127 // XXX: Disable interrupts?
132 void __stack_smash_handler(const char *func, int damaged)
134 printk("Propolice detected a stack smashing attack %x at function %s,"
135 " freezing\n", damaged, func);
139 void __stack_chk_fail(void)
141 printk("Propolice detected a stack smashing attack, freezing\n");