Path: utzoo!attcan!telly!lethe!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!ogicse!orstcs!usenet!jacobs.CS.ORST.EDU!bailey From: bailey@jacobs.CS.ORST.EDU (Kirk Bailey) Newsgroups: comp.sys.transputer Subject: Re: Transputer C compiler efficiency - results (long) Message-ID: Date: 21 Dec 90 12:31:29 GMT References: Sender: @usenet@scion.CS.ORST.EDU Organization: Oregon State University, Computer Science Dept Lines: 56 Nntp-Posting-Host: jacobs.cs.orst.edu Dear Net Community, I'm posting in response to the recent (excellent), "C" compiler review by Jeremy Webber. I wanted to mention a technique which may be used with the current (V89.1), Logical Systems "C" compiler to implement stack bounds checking (and the like): Write a small "C" function such as: void stack_check(int dummy) { if(((char *) ((&dummy) + 3)) < BOTTOM_OF_STACK) { printf("Stack Underflow\n"); exit(1); } } Where BOTTOM_OF_STACK is the desired stack minimum address. After compiling this routine it may be linked in with the application code and calls to it inserted automatically by using the "-ti" TCX command flag (see TCX manual for detailed information). The same technique may be used to implement a function trace-in/trace-out facility: void trace_in(int ws_size) { printf("Trace entry of function starting near %p\n", *((&ws_size) - 1)); printf("\tFunction needs %u word(s) of workspace (current WS = %p)\n", ws_size,(&ws_size) + 3); } void trace_out(int dummy) { printf("Trace exit of function ending near %p\n",*((&dummy) - 1)); } Note that calls to "trace_in" would again be inserted with the TCX "-ti" option while calls to "trace_out" would require the "-to" option. In the "REAL SOON NOW" category: the upcoming version of the Logical Systems "C" package has a more automatic way to accomplish stack underflow checking (plus addressing many of the other concerns the review mentioned). As I'm sure is the case with the other vendors, we welcome feedback and ideas of what should be changed in the future, whether in the form of a comprehensive review or just a quick EMAIL note. Keep the cards and bricks coming... Hope everyone has a excellent new year! Cheers, Kirk Bailey Logical Systems