2016-11-25 17:18:40 +01:00
|
|
|
|
|
|
|
#include <u.h>
|
2017-04-19 23:33:14 +02:00
|
|
|
#include <lib9.h>
|
2016-11-25 17:18:40 +01:00
|
|
|
|
2017-08-11 02:01:55 +02:00
|
|
|
// from kernel's mem.h
|
|
|
|
#define MiB (1024*1024)
|
|
|
|
#define TSTKTOP (0x00007ffffffff000ull)
|
|
|
|
#define USTKSIZE (16*MiB) /* size of user stack */
|
|
|
|
#define USTKTOP (TSTKTOP-USTKSIZE) /* end of new stack in sysexec */
|
|
|
|
|
2016-11-25 17:18:40 +01:00
|
|
|
enum {
|
|
|
|
Njmps = 10000
|
|
|
|
};
|
|
|
|
|
|
|
|
void foo(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
int i, njmp;
|
|
|
|
int fail = 0;
|
|
|
|
jmp_buf label;
|
|
|
|
|
|
|
|
njmp = 0;
|
|
|
|
while((njmp = setjmp(label)) < Njmps)
|
|
|
|
longjmp(label, njmp+1);
|
|
|
|
|
|
|
|
for(i = 0; i < nelem(label); i++)
|
|
|
|
fprint(2, "label[%d] = %p\n", i, label[i]);
|
|
|
|
fprint(2, "main: %p foo: %p\n", main, foo);
|
|
|
|
|
2017-08-11 02:01:55 +02:00
|
|
|
if(njmp != Njmps){
|
|
|
|
print("error: njmp = %d\n", njmp);
|
2016-11-25 17:18:40 +01:00
|
|
|
fail++;
|
2017-08-11 02:01:55 +02:00
|
|
|
}
|
|
|
|
if(label[JMPBUFPC] < (uintptr_t)main){
|
|
|
|
print("error: label[JMPBUFPC] = %#p\n", label[JMPBUFPC]);
|
2016-11-25 17:18:40 +01:00
|
|
|
fail++;
|
2017-08-11 02:01:55 +02:00
|
|
|
}
|
|
|
|
if(label[JMPBUFPC] > (uintptr_t)foo){
|
|
|
|
print("error: label[JMPBUFPC] = %#p\n", label[JMPBUFPC]);
|
2016-11-25 17:18:40 +01:00
|
|
|
fail++;
|
2017-08-11 02:01:55 +02:00
|
|
|
}
|
|
|
|
if(label[JMPBUFSP] > (uintptr_t)&label[nelem(label)]){
|
|
|
|
print("error: label[JMPBUFSP] (%#p) is greater then &label[nelem(label)] (%#p) \n", label[JMPBUFPC], &label[nelem(label)]);
|
2016-11-25 17:18:40 +01:00
|
|
|
fail++;
|
2017-08-11 02:01:55 +02:00
|
|
|
}
|
|
|
|
if(label[JMPBUFSP] < USTKTOP-USTKSIZE){
|
|
|
|
print("error: label[JMPBUFSP] (%#p) is lower then USTKTOP-USTKSIZE \n", label[JMPBUFSP]);
|
2016-11-25 17:18:40 +01:00
|
|
|
fail++;
|
2017-08-11 02:01:55 +02:00
|
|
|
}
|
2016-11-25 17:18:40 +01:00
|
|
|
|
|
|
|
if(fail == 0){
|
|
|
|
print("PASS\n");
|
|
|
|
exits("PASS");
|
|
|
|
}
|
|
|
|
print("FAIL\n");
|
|
|
|
exits("FAIL");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
foo(void)
|
|
|
|
{
|
|
|
|
}
|