From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <0662c118779db0f0ac85f3ce711dcbb9@quanstro.net> From: erik quanstrom Date: Tue, 1 Sep 2009 11:08:06 -0400 To: 9fans@9fans.net MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] lowest valid stack address Topicbox-Message-UUID: 5ddb0ef8-ead5-11e9-9d60-3106f5b1d025 assuming no thread library, is there a way of determining the lowest valid stack address from userspace? the purpose is to create a test onstack() so that it can be asserted that a given pointer is !onstack. thread library knows. is it fair to assume that the stack can be up to 256mb? how does this generalize to 64 bits? how bogus is this code, and why? void initbos(int x) { uint m; uintptr p; p = (uintptr)&x; m = 1 << sizeof p*8 - 4; m -= 1; p &= ~m; print("%p\n", p); } uintptr bos; #define onstack(x) ((uintptr)(x) >= bos) #define threadonstack(x) /* thread library knows */ - erik