forked from KolibriOS/kolibrios
newlib: bugfixes
git-svn-id: svn://kolibrios.org@2827 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
21140b30f2
commit
b3ffd0487f
@ -1,11 +1,14 @@
|
||||
|
||||
.global ___chkstk
|
||||
.global ___chkstk_ms
|
||||
.global __alloca
|
||||
|
||||
.section .text
|
||||
|
||||
#.def ___chkstk; .scl 2; .type 32; .endef
|
||||
#.def __alloca; .scl 2; .type 32; .endef
|
||||
#.def ___chkstk; .scl 2; .type 32; .endef
|
||||
#.def ___chkstk_ms; .scl 2; .type 32; .endef
|
||||
#.def __alloca; .scl 2; .type 32; .endef
|
||||
|
||||
___chkstk:
|
||||
__alloca:
|
||||
pushl %ecx /* save temp */
|
||||
@ -29,3 +32,30 @@ __alloca:
|
||||
.ascii "Stack overflow"
|
||||
|
||||
|
||||
___chkstk_ms:
|
||||
pushl %ecx /* save temp */
|
||||
pushl %eax
|
||||
cmpl $0x1000, %eax /* > 4k ?*/
|
||||
leal 12(%esp), %ecx /* point past return addr */
|
||||
jb 2f
|
||||
|
||||
1:
|
||||
subl $0x1000, %ecx /* yes, move pointer down 4k*/
|
||||
cmpl %fs:4, %ecx /* check low stack limit */
|
||||
jb 3f
|
||||
|
||||
orl $0x0, (%ecx) /* probe there */
|
||||
subl $0x1000, %eax /* decrement count */
|
||||
cmpl $0x1000, %eax
|
||||
ja 1b /* and do it again */
|
||||
|
||||
2:
|
||||
subl %eax, %ecx
|
||||
orl $0x0, (%ecx) /* less than 4k, just peek here */
|
||||
|
||||
popl %eax
|
||||
popl %ecx
|
||||
ret
|
||||
3:
|
||||
int3 #trap to debugger
|
||||
.ascii "Stack overflow"
|
||||
|
@ -25,7 +25,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <malloc.h>
|
||||
#include <errno.h>
|
||||
#include <gthr.h>
|
||||
|
@ -35,6 +35,7 @@ extern "C" {
|
||||
#define __have_long64 1
|
||||
#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
|
||||
#define __have_long32 1
|
||||
#define __have_long64 0
|
||||
#endif
|
||||
|
||||
#if __STDINT_EXP(SCHAR_MAX) == 0x7f
|
||||
@ -177,6 +178,8 @@ typedef uint64_t uint_least32_t;
|
||||
typedef signed int int_fast64_t;
|
||||
typedef unsigned int uint_fast64_t;
|
||||
#define __int_fast64_t_defined 1
|
||||
#else
|
||||
#define __int_fast64_t_defined 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -212,6 +215,7 @@ typedef uint64_t uint_least32_t;
|
||||
#if __int_least64_t_defined
|
||||
typedef int_least64_t int_fast64_t;
|
||||
typedef uint_least64_t uint_fast64_t;
|
||||
#undef __int_fast64_t_defined
|
||||
#define __int_fast64_t_defined 1
|
||||
#endif
|
||||
#endif
|
||||
|
@ -42,6 +42,15 @@ extern "C" {
|
||||
/* O_NDELAY _FNBIO set in include/fcntl.h */
|
||||
#define O_NONBLOCK _FNONBLOCK
|
||||
#define O_NOCTTY _FNOCTTY
|
||||
|
||||
#define _FBINARY 0x10000
|
||||
#define _FTEXT 0x20000
|
||||
#define _FNOINHERIT 0x40000
|
||||
|
||||
#define O_BINARY _FBINARY
|
||||
#define O_TEXT _FTEXT
|
||||
#define O_NOINHERIT _FNOINHERIT
|
||||
|
||||
/* For machines which care - */
|
||||
#if defined (_WIN32) || defined (__CYGWIN__)
|
||||
#define _FBINARY 0x10000
|
||||
|
@ -73,7 +73,7 @@ static inline int user_free(void *mem)
|
||||
int val;
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
:"=eax"(val)
|
||||
:"=a"(val)
|
||||
:"a"(68),"b"(12),"c"(mem));
|
||||
return val;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ void *user_alloc(size_t size)
|
||||
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
:"=eax"(val)
|
||||
:"=a"(val)
|
||||
:"a"(68),"b"(12),"c"(size));
|
||||
return val;
|
||||
}
|
||||
@ -82,7 +82,7 @@ int user_free(void *mem)
|
||||
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
:"=eax"(val)
|
||||
:"=a"(val)
|
||||
:"a"(68),"b"(13),"c"(mem));
|
||||
return val;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user