From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,582dff0b3f065a52 X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,582dff0b3f065a52 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,bc1361a952ec75ca X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-06 20:06:09 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!netnews.com!wn1feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3B6F5BB2.A879B933@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ Subject: Re: How Ada could have prevented the Red Code distributed denial of service attack. References: <3b690498.1111845720@news.worldonline.nl> <9kbu15$9bj@augusta.math.psu.edu> <3b6a453c.1193942215@news.worldonline.nl> <9keejl$fhj@augusta.math.psu.edu> <3c30da40.0108060848.796d9bd9@posting.google.com> <3B6F3216.F410BBFF@home.com> <3B6F3FAE.B9B9FFCF@globetrotter.qc.ca> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 07 Aug 2001 03:06:09 GMT NNTP-Posting-Host: 12.74.161.12 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 997153569 12.74.161.12 (Tue, 07 Aug 2001 03:06:09 GMT) NNTP-Posting-Date: Tue, 07 Aug 2001 03:06:09 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:11442 comp.lang.c:72609 comp.lang.c++:80522 Date: 2001-08-07T03:06:09+00:00 List-Id: Chris Wolfe wrote: > > It does not require any overwhelming work to convert an Ada > program directly into a functionally identical C++ program using > appropriate (non-standard) templates. Amazingly these templates > also tend to spawn safe versions of the standard C functions. > What was that drivel about pipe again? > Be careful about such expansive statements. It is easy to read your reply to imply that you can convert ANY Ada program to C++ without overwhelming work. It is true that you can make such conversions for some Ada programs. It is not true that all Ada programs can be converted to C++ wihtout overwhelming work. Specifically, how would you code the C++ program to contain all the checks built in by the Ada compiler, including the checks done at compile time? How would you, without overwhelming work, convert an Ada multi-tasking program using Ada protected objects for asynchronous task communication, into C++? For example, how would you, without overwhelming work, convert the following Ada code: ----------------------------------------------------------------------------- -- Inventory -- Protected object for use of production lines ----------------------------------------------------------------------------- generic Max_Size : Positive; type Items is private; package Inventory is subtype Buf_Index is Positive range 1..Max_Size; type Parts_Buffer is array(Buf_Index) of Items; protected type Parts_Buf is Entry Put(Item : in Items); Entry Get(Item : out Items); private Buffer : Parts_Buffer; Oldest : Positive := 1; Newest : Positive := 1; Size : Natural := 0; end Parts_Buf; type Parts_Buf_Ptr is access Parts_Buf; end Inventory; package body Inventory is --------------- -- Parts_Buf -- --------------- protected body Parts_Buf is --------- -- Get -- --------- entry Get (Item : out Items) when Size > 0 is begin Item := Buffer(Oldest); if Oldest < Buffer'Last then Oldest := Oldest + 1; else Oldest := Buffer'First; end if; Size := Size - 1; end Get; --------- -- Put -- --------- entry Put (Item : in Items) when Size < Buffer'Last is begin Buffer(Newest) := Item; if Newest < Buffer'Last then Newest := Newest + 1; else Newest := Buffer'First; end if; Size := Size + 1; end Put; end Parts_Buf; end Inventory; You will need to implement the full functionality of protected objects including entry queuing, object locking, and boundary conditions. You will also need to implement the integer range bounds limitations created by the definition of the Positive subtype. It would be nice if you could also define arrays with a beginning index of 1 rather than 0, but you would probably assert that 0 based indexing is equivalent to 1 based indexing. Curious, if it is equivalent, then why can't C++ implement such an array directly? Oh yes, when calling the Put and Get entries, your code must execute in the calling thread. That thread must suspend until the entry executes. The entry may only execute when the boundary condition is true, and no other entry is concurrently accessing the protected object. You will have to implement the protected object as a template to be equivalent. This means that you must find some way to specify that one of the generic parameters is an integer greater than or equal to 1. If the parameter does not meet this requirement the code must not compile. Putting the check in runtime code is not equivalent. To make the code truly equivalent you must not define your data to be dynamically allocated. All items placed on the buffer must be statically allocated. Jim Rogers Colorado Springs, Colorado USA