home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-008 < prev    next >
Text File  |  2010-09-21  |  29KB  |  762 lines

  1. Received-Date: Sun, 3 Apr 1994 22:39:12 +0200
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-008
  4. To: csmp-digest@ens.fr
  5. Date: Sun, 3 Apr 94 22:39:07 MET DST
  6. X-Mailer: ELM [version 2.3 PL11]
  7. Errors-To: listman@ens.fr
  8. Reply-To: pottier@clipper.ens.fr
  9. X-Sequence: 10
  10.  
  11. C.S.M.P. Digest             Sun, 03 Apr 94       Volume 3 : Issue 8
  12.  
  13. Today's Topics:
  14.  
  15.         ?Time manager code for pascal!
  16.         Copying with a mask
  17.         Macsbug for PowerMac?
  18.         Math on PowerMacs (was Re: PowerMac emulate a 68LC040??)
  19.         Passing data through to completion procs?
  20.         Sending AppleEvents To Eudora
  21.  
  22.  
  23.  
  24. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  25. (pottier@clipper.ens.fr).
  26.  
  27. The digest is a collection of article threads from the internet newsgroup
  28. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  29. regularly and want an archive of the discussions.  If you don't know what a
  30. newsgroup is, you probably don't have access to it.  Ask your systems
  31. administrator(s) for details.  If you don't have access to news, you may
  32. still be able to post messages to the group by using a mail server like
  33. anon.penet.fi (mail help@anon.penet.fi for more information).
  34.  
  35. Each issue of the digest contains one or more sets of articles (called
  36. threads), with each set corresponding to a 'discussion' of a particular
  37. subject.  The articles are not edited; all articles included in this digest
  38. are in their original posted form (as received by our news server at
  39. nef.ens.fr).  Article threads are not added to the digest until the last
  40. article added to the thread is at least two weeks old (this is to ensure that
  41. the thread is dead before adding it to the digest).  Article threads that
  42. consist of only one message are generally not included in the digest.
  43.  
  44. The digest is officially distributed by two means, by email and ftp.
  45.  
  46. If you want to receive the digest by mail, send email to listserv@ens.fr
  47. with no subject and one of the following commands as body:
  48.     help                        Sends you a summary of commands
  49.     subscribe csmp-digest Your Name    Adds you to the mailing list
  50.     signoff csmp-digest            Removes you from the list
  51. Once you have subscribed, you will automatically receive each new
  52. issue as it is created.
  53.  
  54. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  55. Questions related to the ftp site should be directed to
  56. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  57. digest are available there.
  58.  
  59. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  60.  
  61.  
  62. -------------------------------------------------------
  63.  
  64. >From dln2@cornell.edu (David Negro)
  65. Subject: ?Time manager code for pascal!
  66. Date: 18 Mar 1994 08:40:11 GMT
  67. Organization: Cornell University
  68.  
  69. Hi,
  70. I was wondering if any of you had any code that I could take a quick look
  71. at on the time manager.  I have the NIM Processes and have tried following
  72. the examples but with no luck whatsoever.  It seems that when I run my test
  73. program to try to learn the time manager, that the program runs, seems to
  74. install the task, and then when it comes time for the task to execute it
  75. CRASHES ;-(
  76. When I pass a nil pointer for the task it seems to work fine as far as I
  77. can tell.  But when I pass a pointer to a procedure  (even one with nothing
  78. in it!) it seems to crash.  I would post what is probably a pitiful piece
  79. of code for some of you to take a look, but at the moment I am so
  80. frustrated with having my sytem crash so many times that I don't want to
  81. look at it myself.  So if anybody out there can just send me a snippet on
  82. how to install a task with instime and primetime I would greatly appreciate
  83. it!
  84.  
  85. Thanks in advance,
  86. Dave Negro
  87. dln2@cornell.edu
  88.  
  89. +++++++++++++++++++++++++++
  90.  
  91. >From zhfzc@zh014.ubs.ubs.ch (Christian Franz)
  92. Date: Fri, 18 Mar 1994 11:17:27 GMT
  93. Organization: Union Bank Switzerland, CH
  94.  
  95. In article 180394033426@j30265153.reslife.cornell.edu, dln2@cornell.edu (David Negro) writes:
  96. >Hi,
  97. >I was wondering if any of you had any code that I could take a quick look
  98. >at on the time manager.  I have the NIM Processes and have tried following
  99. >the examples but with no luck whatsoever.  It seems that when I run my test
  100. >program to try to learn the time manager, that the program runs, seems to
  101. >install the task, and then when it comes time for the task to execute it
  102. >CRASHES ;-(
  103. >When I pass a nil pointer for the task it seems to work fine as far as I
  104. >can tell.  But when I pass a pointer to a procedure  (even one with nothing
  105. >in it!) it seems to crash.  I would post what is probably a pitiful piece
  106. >of code for some of you to take a look, but at the moment I am so
  107. >frustrated with having my sytem crash so many times that I don't want to
  108. >look at it myself.  
  109.  
  110. I wager you are using THINK Pascal and have turned debugging on. That's a 
  111. no-no since the TM callback proc will be called during interrupt-time where
  112. you are not allowed to do anything that moves memory... TP's Debugger does.
  113.  
  114. I've had the same problem and they went away when I switched debugging off
  115. for the callback procedure. 
  116. The catch is of course that you can't debug your callback. So what I did was
  117. to set a 'TimedOut' boolean flag in the callback proc and nothing else.
  118. >From the main program I monitored the timedOut flag and did all processing
  119. the was required when it did. 
  120.  
  121.  
  122. >So if anybody out there can just send me a snippet on
  123. >how to install a task with instime and primetime I would greatly appreciate
  124. >it!
  125.  
  126. Try disabeling debugging. If it still doesn't work, I'll send you some code.
  127.  
  128. >
  129. >Thanks in advance,
  130. >Dave Negro
  131. >dln2@cornell.edu
  132.  
  133. Cheers,
  134. Christian
  135.  
  136.  
  137. --
  138. Christian Franz                        *              Union Bank Of Switzerland
  139. cfranz@home.malg.imp.com         <- at home ->                     +1-261 26 96
  140.  
  141.  
  142. +++++++++++++++++++++++++++
  143.  
  144. >From spector@bach.seattleu.edu (Mitchell S. Spector)
  145. Date: 19 Mar 1994 07:24:34 -0800
  146. Organization: Seattle University, Seattle, Washington, U.S.A.
  147.  
  148. In article <1994Mar18.111727.15370@zh014.ubs.ubs.ch>,
  149. Christian Franz <zhfzc@zh014.ubs.ubs.ch> wrote:
  150.  >In article 180394033426@j30265153.reslife.cornell.edu, dln2@cornell.edu (David Negro) writes:
  151.  >> [Time Manager crashes, even when the task is an empty procedure.]
  152.  >
  153.  >I wager you are using THINK Pascal and have turned debugging on. That's a 
  154.  >no-no since the TM callback proc will be called during interrupt-time where
  155.  >you are not allowed to do anything that moves memory... TP's Debugger does.
  156.  
  157.    Yes.  And, even with debugging off, if you are running your program in the
  158. Think Pascal environment (rather than as a stand-alone application), there
  159. may be a limit on how frequently you can have the Time Manager execute a
  160. task.  This limit will depend on the speed of the computer you are using.
  161. You ought to be safe if you make sure that your period is at least
  162. 1/30 sec; I've been able to use the Time Manager with that period even
  163. on an old Mac II, but 1/60 sec didn't work.  Or else build a stand-alone
  164. application -- you can then use any time interval you want.
  165.  
  166.    Also, be sure that you're setting and restoring A5; Inside Macintosh
  167. shows how to do this.
  168.  
  169.                             Mitchell
  170.  
  171.  
  172.  >>Dave Negro
  173.  >>dln2@cornell.edu
  174.  
  175.  >Christian Franz                        *              Union Bank Of Switzerland
  176.  >cfranz@home.malg.imp.com         <- at home ->                     +1-261 26 96
  177.  
  178. --
  179. Mitchell Spector
  180. spector@seattleu.edu
  181.  
  182.  
  183. ---------------------------
  184.  
  185. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  186. Subject: Copying with a mask
  187. Date: Sun, 20 Mar 1994 13:27:27 GMT
  188. Organization: Demon Internet
  189.  
  190.  
  191.      I'm looking for an efficient way to do a mask copy between offscreen
  192. graphics worlds. I have a solution which works, but it MUST be possible to
  193. do it faster!
  194.  
  195.      Here's the code (all variables are in registers, BTW):
  196.  
  197. if (*tMaskMemPtr++)
  198. {
  199.      *tDestMemPtr++ = *tSourceMemPtr++;
  200. } else
  201. {
  202.      *tDestMemPtr++;
  203.      *tSourceMemPtr++;
  204. }
  205.  
  206.      tMaskMemPtr, tDestMemPtr, and tSourceMemPtr are each pointers to chars
  207. to separate offscreen worlds (mask, destination, and source worlds,
  208. respectively).
  209.  
  210.      It's being done in 8-bit (so one byte/pixel), and the mask is either
  211. black or white. I'm checking the mask world pixel: if it's black, I'm
  212. copying the source pixel to the destination pixel; otherwise, I'm leaving
  213. the destination alone.
  214.  
  215.      I couldn't think of a way to do it using pointers to longs, but if
  216. there was a way it would be much faster! Anyone got any ideas? I'd prefer C
  217. code rather than assembler, but both are appreciated.
  218.  
  219.      Thanks,
  220.  
  221.  
  222.      Alex
  223.  
  224. --
  225. Alex Metcalf, Mac programmer in C, C++, HyperTalk, assembler
  226.  
  227. Internet, AOL, BIX: alex@metcalf.demon.co.uk            "Surely you
  228. AppleLink:          alex@metcalf.demon.co.uk@internet#   can't be
  229. CompuServe:         INTERNET:alex@metcalf.demon.co.uk    serious?"
  230. Delphi:             alex@metcalf.demon.co.uk@inet#
  231. FirstClass:         alex@metcalf.demon.co.uk,Internet   "I'm serious...
  232. Fax (UK):           (0570) 45636                         and don't call
  233. Fax (US / Canada):  011 44 570 45636                     me Shirley."
  234.  
  235. +++++++++++++++++++++++++++
  236.  
  237. >From al@crucible.powertools.com (Al Evans)
  238. Date: 20 Mar 94 16:54:42 GMT
  239. Organization: PowerTools, Austin, Texas
  240.  
  241. In article <alex-200394132815@metcalf.demon.co.uk> alex@metcalf.demon.co.uk (Alex Metcalf) writes:
  242.  
  243. >     I'm looking for an efficient way to do a mask copy between offscreen
  244. >graphics worlds. I have a solution which works, but it MUST be possible to
  245. >do it faster!
  246.  
  247. >     Here's the code (all variables are in registers, BTW):
  248.  
  249. >if (*tMaskMemPtr++)
  250. >{
  251. >     *tDestMemPtr++ = *tSourceMemPtr++;
  252. >} else
  253. >{
  254. >     *tDestMemPtr++;
  255. >     *tSourceMemPtr++;
  256. >}
  257.  
  258. >     tMaskMemPtr, tDestMemPtr, and tSourceMemPtr are each pointers to chars
  259. >to separate offscreen worlds (mask, destination, and source worlds,
  260. >respectively).
  261.  
  262. >     It's being done in 8-bit (so one byte/pixel), and the mask is either
  263. >black or white. I'm checking the mask world pixel: if it's black, I'm
  264. >copying the source pixel to the destination pixel; otherwise, I'm leaving
  265. >the destination alone.
  266.  
  267. >     I couldn't think of a way to do it using pointers to longs, but if
  268. >there was a way it would be much faster! Anyone got any ideas? I'd prefer C
  269. >code rather than assembler, but both are appreciated.
  270.  
  271. Well, this explanation will be more theoretical than practical, so I'm
  272. more likely to use assembly than C. To my knowledge, there are three
  273. ways to get "just the picture part" of a graphic overlaid into a
  274. background. One uses transparency, and two use masking.
  275.  
  276. The first way is similar to what you are doing now. In fact, if you
  277. guarantee that the "transparent" parts of your image will have some
  278. specified value (for example, 0), you can forego the mask entirely:
  279.  
  280.     if (*tSourceMemPtr) 
  281.         *tDestMemPtr++ = *tSourceMemPtr++;
  282.     else {
  283.         tSourceMemPtr++;
  284.         tDestMemPtr++;
  285.     }
  286.  
  287. The advantage of this approach is that it is memory-efficient. The
  288. disadvantage is that, as you have seen, it only works byte by byte.
  289. The only optimization I have found, in assembly, is to load the source
  290. a long word at a time and add 4 to the destination pointer if the
  291. result of the load is zero, thus avoiding the byte-by-byte check.
  292.  
  293. The second (and fastest) approach also presumes that you control the
  294. source graphics, and that the parts of these graphics to be masked
  295. are set to zero. In this approach, the mask is all zeros where the
  296. source graphic is "on", and all ones in the "transparent" portions.
  297. Under these conditions, you can do a long word as follows:
  298.  
  299.     MOVE.L    (destPtr), D0    ;get "background"
  300.     AND.L    (maskPtr)+, D0    ;keep only the part not covered by graphic
  301.     OR.L    (srcPtr)+, D0    ;add graphic
  302.     MOVE.L    D0, (destPtr)+    ;move to offscreen memory
  303.  
  304. The third (and most general) approach presumes only that you can
  305. make a mask covering the portions of the graphic you wish to transfer.
  306. In this case, the mask is all ones for the parts of the source graphic
  307. you want to copy, and all zeros where you want the background to
  308. show through. In assembly, the transfer looks like this:
  309.  
  310.     MOVE.L    (srcPtr)+, D0    ;Get long word of source
  311.     EOR.L    (destPtr), D0    ;D0 now XOR of source and dest
  312.     AND.L    (maskPtr)+, D0    ;Bkg part now all 0s
  313.     EOR.L     (destPtr), D0    ;Remove bkg bits from graphic while
  314.                 ;adding them to bkg part
  315.     MOVE.L    D0, (destPtr)+    ;move to offscreen memory
  316.  
  317. Of course, all of these transfer operations can be done the same
  318. way in C. I just think the assembly notation makes them more clear.
  319.  
  320.                     --Al Evans--
  321. -- 
  322.  
  323. Al Evans                         Tu causes, tu causes
  324. al@crucible.powertools.com               C'est tout ce que tu sais faire
  325. cs.utexas.edu!crucible!al                     -- LaVerdure
  326.  
  327. ---------------------------
  328.  
  329. >From johnsone@uxh.cso.uiuc.edu (Erik A. Johnson)
  330. Subject: Macsbug for PowerMac?
  331. Date: 17 Mar 1994 22:51:42 GMT
  332. Organization: University of Illinois at Urbana
  333.  
  334. Anyone know if Apple has a debugger (a la Macsbug) for the
  335. PowerMacs, either in existence, in development, or planned?
  336.  
  337.  
  338. Erik A. Johnson        \    Internet: johnsone@uxh.cso.uiuc.edu     \       |
  339. - ----------------------\    AmericaOnline: ErikAJ                   \    --+--
  340. Graduate Student         \--------------------------------------------\     |
  341. Aero/Astro Engineering    \  "Jesus said to him, 'I am the way, and    \    |
  342. University of Illinois at  \  the truth, and the life; no one comes to  \   |
  343.    Urbana-Champaign (UIUC)  \  the Father except through me.'" (Jn14:6)  \
  344.  
  345. +++++++++++++++++++++++++++
  346.  
  347. >From somogyi@macuser.ziff.com (Stephan Somogyi)
  348. Date: Fri, 18 Mar 1994 01:02:38 GMT
  349. Organization: MacUser Magazine US
  350.  
  351. In article <2mamtu$lfe@vixen.cso.uiuc.edu>, johnsone@uxh.cso.uiuc.edu
  352. (Erik A. Johnson) wrote:
  353.  
  354. > Anyone know if Apple has a debugger (a la Macsbug) for the PowerMacs,
  355. > either in existence, in development, or planned?
  356.  
  357. Macsbug works just fine on my Power Mac :-)
  358.  
  359. Apple has a 2-machine debugger for the Power Macs that once was called
  360. R2DB but now has a more whizzy and marketing-oriented name (Macintosh
  361. Debugger for PowerPC?). Metrowerks has a one-machine Power Mac debugger
  362. that comes with CodeWarrior. The current version of Jasik's Debugger also
  363. has a bunch of Power Mac support.
  364.  
  365. __________________________________________________________________________
  366. Stephan Somogyi           "...we shall never surrender."           MacUser
  367.  
  368. +++++++++++++++++++++++++++
  369.  
  370. >From ajr3@quads.uchicago.edu (Alain Roy)
  371. Date: Fri, 18 Mar 1994 02:56:20 GMT
  372. Organization: University of Chicago
  373.  
  374. In article <2mamtu$lfe@vixen.cso.uiuc.edu> johnsone@uxh.cso.uiuc.edu (Erik A. Johnson) writes:
  375. >Anyone know if Apple has a debugger (a la Macsbug) for the
  376. >PowerMacs, either in existence, in development, or planned?
  377.  
  378. believe it or not, macsbug will run on the power mac. i've seen it.
  379. of course, 68K disassembly and stack crawls are meaningless, but it works!
  380.  
  381. though it would be nice if they had "power macsbug" though could
  382. actually be useful for more than "es, rs and g"
  383.  
  384. -alain
  385.  
  386. +++++++++++++++++++++++++++
  387.  
  388. >From mlanett@netcom.com (Mark Lanett)
  389. Date: Fri, 18 Mar 1994 09:58:34 GMT
  390. Organization: Etch-a-Sketch Analysis and Design
  391.  
  392. somogyi@macuser.ziff.com (Stephan Somogyi) writes:
  393.  
  394. >In article <2mamtu$lfe@vixen.cso.uiuc.edu>, johnsone@uxh.cso.uiuc.edu
  395. >(Erik A. Johnson) wrote:
  396.  
  397. >> Anyone know if Apple has a debugger (a la Macsbug) for the PowerMacs,
  398. >> either in existence, in development, or planned?
  399.  
  400. >Macsbug works just fine on my Power Mac :-)
  401.  
  402. The slight problem with Macsbug, as I understand it, is that it's being
  403. emulated (!) and all the 601 stuff is done through dcmds, which makes
  404. them harder to use.
  405. -- 
  406.     Mark Lanett "Have a bajillion brillian Jobsian lithium licks"
  407.  
  408. +++++++++++++++++++++++++++
  409.  
  410. >From amanda@intercon.com (Amanda Walker)
  411. Date: Fri, 18 Mar 1994 16:58:10 -0500
  412. Organization: InterCon Systems Corporation, Herndon, VA USA
  413.  
  414. somogyi@macuser.ziff.com (Stephan Somogyi) writes:
  415. > Apple has a 2-machine debugger for the Power Macs that once was 
  416. > called R2DB but now has a more whizzy and marketing-oriented 
  417. > name (Macintosh Debugger for PowerPC?).
  418.  
  419. Yup.  It's not bad, but it's sllllooooowwwwwww.  What I wish I had is 
  420. something like TMON.  Not TMON Pro--the old small, fast TMON--but updated for 
  421. PowerPC debugging.  I don't even need source debugging if I can get fast
  422. stack crawls and breakpoints.
  423.  
  424. Sigh.
  425.  
  426.  
  427. Amanda Walker
  428. Advanced Projects
  429. InterCon Systems Corporation
  430.  
  431.  
  432.  
  433. +++++++++++++++++++++++++++
  434.  
  435. >From danprice@delphi.com
  436. Date: Sat, 19 Mar 94 00:37:37 -0500
  437. Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
  438.  
  439.  
  440. Ouch!  Does Apple or Motorola plan to release a PPC debugger?  Howbout TMON or
  441. Jasik Systems?
  442.  
  443. Is there a PPC disassembler (like the old DisASM) yet?
  444.     -dp
  445.  
  446. ---------------------------
  447.  
  448. >From rang@winternet.mpls.mn.us (Anton Rang)
  449. Subject: Math on PowerMacs (was Re: PowerMac emulate a 68LC040??)
  450. Date: 19 Mar 1994 16:44:25 GMT
  451. Organization: Minnesota Angsters
  452.  
  453. In article <CMvs2q.Bw0@watserv2.uwaterloo.ca> grstate@zeus (Gavriel State) writes:
  454. >Extrapolating from this leads me to suspect that you might get as much 
  455. >as an 8x speedup over 040/FPU code, or 20-25x improvement over your 
  456. >IIci's 030/FPU. 
  457.  
  458.   Last night I wrote up a simple FP benchmark and ran it on a Quadra
  459. 700 (25MHz 68040) and the 8100.  I took a small (200x201) matrix and
  460. wrote up a quick Gaussian elimination by back-substitution routine.
  461. No optimizations, nothing fancy, just to get an idea of relative
  462. performance.  (I didn't test with SANE; everything was done with the
  463. FPU.)  Unfortunately the matrix would mostly fit in the L2 cache, so
  464. it's not a perfect way to compare performance on large arrays, but for
  465. what it's worth....
  466.  
  467. Times are in seconds.  TC = THINK C 6.0.1, MPW = MPW 3.3,
  468.                MW = Metrowerks 1.0a2,
  469.                SDK = Apple's SDK (Lucid compiler).
  470.  
  471.         Float        Double
  472.   Q700/MPW:    14.57        15.07
  473.   Q700/TC:     5.13         7.47
  474.   8100/MW:     1.07         1.14
  475.   8100/SDK:     0.83         0.72
  476.  
  477. A few remarks --
  478.  
  479.   MPW does very poorly because it doesn't strength-reduce the array
  480. indexing inside loops.  I think it might do that when "-opt full" is
  481. on, but MPW C 3.3 wouldn't generate correct code for this test unless
  482. I used "-opt on" instead.
  483.  
  484.   THINK C does a much better job, applying strength-reduction to the
  485. loops, and thus eliminating almost all integer multiplication.
  486.  
  487.   The Metrowerks compiler doesn't do strength reduction (or at least,
  488. I couldn't get it to), but apparently the 601's integer multiply isn't
  489. as slow as that of the 68040.  It wins on floating-point numbers, even
  490. though the 601 does all arithmetic internally in double precision.  My
  491. guess is that this is because the FP array fits in the L2 cache.
  492.  
  493.   The SDK compiler does a good job of optimization.  Not only does it
  494. do the basic strength reduction for the loops (and eliminate the
  495. now-unneeded induction variables), but it also unrolls the inner loop
  496. (though only in the single-precision case) and changes the operation
  497. inside the inner loop (a[i][j] <- a[i][j] - a[k][j]/F) into a
  498. multiply-negate-add instruction.
  499.  
  500.   So it looks like, even compared to a hypothetical 50MHz 68040
  501. machine, you'd get better performance on the 8100.  I didn't get a
  502. chance to try gcc or another highly optimizing compiler, but I doubt
  503. that it could perform more than a factor of two better on the '040, in
  504. the best case.
  505.  
  506.   I've added comp.sys.mac.programmer because of the compiler
  507. comparison; please followup to the appropriate group.
  508. --
  509. Anton Rang (rang@winternet.mpls.mn.us)
  510.  
  511. ---------------------------
  512.  
  513. >From gewekean@studentg.msu.edu (Andrew Geweke)
  514. Subject: Passing data through to completion procs?
  515. Date: Wed, 16 Mar 1994 22:06:40 -0500
  516. Organization: Michigan State University
  517.  
  518. What I'm doing is writing an interface library to MacTCP; I want it to be 
  519. simple. All routines are async, so I just want to have the caller pass in a 
  520. simple structure pointer; a field in the struct gets changed when the call 
  521. completes. I want to do this rather than having the user ravage through large 
  522. ParamBlocks and so forth for simplicity and so on.
  523.  
  524. My question is this: How can I get the Device Manager to pass four bytes to a 
  525. completion routine that I pass in when I make the call?
  526.  
  527. Basically, I'm having trouble getting a pointer to the structure through to 
  528. the completion routine. Is there any place I can stash this? I'm looking 
  529. through the ParamBlock structure right now, and everything's used or "not 
  530. used" (which, as we all know, means reserved -- I don't want to break rules 
  531. here).
  532.  
  533. Here are my ideas so far:
  534.  
  535. (1) Set the user up with a pointer to the ioResult field. Disadvantage: I 
  536. want to deallocate the parameter-block's memory as soon as the call 
  537. completes. This would require the user to do this.
  538.  
  539. (2) Create a linked list of all outstanding calls with pointers to their 
  540. parameter blocks. This is a roundabout method, though it should work; 
  541. however, I'd rather not.
  542.  
  543. Basically, I'm converting async calls from the beasts that they are into 
  544. simple ones; you pass in a struct with only the specific information that 
  545. gets a flag set when it's done. Any ideas?
  546.  
  547.  
  548.  
  549.  
  550.  
  551. +++++++++++++++++++++++++++
  552.  
  553. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  554. Date: Thu, 17 Mar 1994 01:37:49 -0600
  555. Organization: University of Illinois at Urbana-Champaign
  556.  
  557. In article <9403162206.AA40375@geweke.ppp.msu.edu>,
  558. gewekean@studentg.msu.edu (Andrew Geweke) wrote:
  559.  
  560. >What I'm doing is writing an interface library to MacTCP;
  561. >
  562. >My question is this: How can I get the Device Manager to pass four bytes to a 
  563. >completion routine that I pass in when I make the call?
  564. >
  565. >Basically, I'm having trouble getting a pointer to the structure through to 
  566. >the completion routine. Is there any place I can stash this?
  567.  
  568. Since you're using MacTCP, you're in luck. Every MacTCP param block has a
  569. userDataPtr field, which is exactly where you can store any pointer you
  570. like.
  571.  
  572. Even if this field weren't there, you can do the same thing. Just make
  573. your own personal parameter block which contains everything the real
  574. parameter block does, plus one pointer field tacked onto the end. The
  575. Device Manager and driver are only going to use the fields they specify,
  576. so this is perfectly safe. (How could it not be? It would be quite ugly if
  577. a device driver decided to use some memory past the end of its parameter
  578. block!)
  579.  
  580. pr
  581. -- 
  582. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  583. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  584. System manager - Cognitive Science Group, Beckman Institute, UIUC
  585. Internet: resnick@cogsci.uiuc.edu
  586.  
  587. +++++++++++++++++++++++++++
  588.  
  589. >From zben@ni.umd.edu (Charles B. Cranston)
  590. Date: 18 Mar 1994 00:50:47 GMT
  591. Organization: UMCP Network Infrastructures
  592.  
  593. In article <9403162206.AA40375@geweke.ppp.msu.edu>,
  594. gewekean@studentg.msu.edu (Andrew Geweke) wrote:
  595.  
  596. > What I'm doing is writing an interface library to MacTCP; I want it to be 
  597. > simple. All routines are async, so I just want to have the caller pass in a 
  598. > simple structure pointer; a field in the struct gets changed when the call 
  599. > completes. I want to do this rather than having the user ravage through large 
  600. > ParamBlocks and so forth for simplicity and so on.
  601.  
  602. > My question is this: How can I get the Device Manager to pass four bytes to a 
  603. > completion routine that I pass in when I make the call?
  604.  
  605. Another approach would be to erect a "trampoline" somewhere.  This would
  606. be 8 bytes consisting of a JSr to the real handler followed by the four
  607. data bytes.  The real handler immediately does a Move.L (A7)+,A0 and then
  608. A0 points to the four data bytes, and the stacktop is now the real final
  609. return address.
  610.  
  611. For MacTCP the UserData approach or the embed-IOPB-in-larger-known-block
  612. approaches would both work.  I am thinking about using this trampoline
  613. technique for EtherNet "Protocol Handlers" where the IOPB is not passed
  614. to the callback routine.
  615.  
  616. The cost, of course, is allocating and freeing the memory space for
  617. the trampoline, especially in the asynchronous environment you are
  618. talking about.
  619.  
  620. +++++++++++++++++++++++++++
  621.  
  622. >From markhanrek@aol.com (MarkHanrek)
  623. Date: 18 Mar 1994 12:52:03 -0500
  624. Organization: America Online, Inc. (1-800-827-6364)
  625.  
  626. A similar trick which works is to declare a data structure in which your custom
  627. info is first, and then you pass the address of the record field that is, say,
  628. four bytes from the actual beginning of the record structure to the
  629. asynchronous function.
  630.  
  631. There are situations, such as with the Time Manager, in which you are able to
  632. get the address of the parameter block the completion routine is passing in by
  633. grabbing the value in register A0, and then subtracting four from it to get at
  634. the specisl data value you've stashed.
  635.  
  636. It may be that this is "six of one - half-dozen of the other" with regard to
  637. Pete's excellent suggestion, but then maybe this is a uniform way of dealing
  638. with getting piggy-back data values that will work in every case regardless of
  639. the size of a given routine's parameter blocks.
  640.  
  641. Hope this helps.
  642.  
  643. Mark Hanrek
  644.  
  645.  
  646. +++++++++++++++++++++++++++
  647.  
  648. >From zben@ni.umd.edu (Charles B. Cranston)
  649. Date: 20 Mar 1994 18:41:43 GMT
  650. Organization: UMCP Network Infrastructures
  651.  
  652. In article <2mcpo3$qva@search01.news.aol.com>,
  653. markhanrek@aol.com (MarkHanrek) wrote:
  654.  
  655. > A similar trick which works is to declare a data structure in
  656. > which your custom info is first, and then you pass the address
  657. > of the record field that is, say, four bytes from the actual
  658. > beginning of the record structure to the asynchronous function.
  659.  
  660. Yes, this is exactly the "embed-IOPB-in-larger-known-block" solution
  661. that I alluded to in the article you followed up.  This works for
  662. the Time Manager, the Vertical Retrace Manager, and general IO.
  663. (Except maybe very early systems which don't pass the block in A0,
  664. I no longer remember the specifics.)
  665.  
  666. This works when the system is maintaining TWO pieces of information
  667. for you: the control block (IOPB, Time Manager Block, etc) *AND* the
  668. address of the completion routine.  When the system is only maintaining
  669. ONE piece of information for you (like the EtherNet driver's Protocol
  670. Handler, maybe also the LocalTalk driver's Protocol Handler) then the
  671. "trampoline" technique can be used to compress those two pieces of
  672. information (the REAL completion routine and the data value) into one
  673. (the trampoline's address).
  674.  
  675. > It may be that this is "six of one - half-dozen of the other" with regard to
  676. > Pete's excellent suggestion, but then maybe this is a uniform way of dealing
  677. > with getting piggy-back data values that will work in every case regardless of
  678. > the size of a given routine's parameter blocks.
  679.  
  680. Indeed, this is quite correct.  Also, I blew it when I said 8 bytes
  681. of information.  I believe the minimum would be 10 bytes:
  682.  
  683. 2 byte absolute JSR opcode
  684. 4 byte absolute address of the REAL completion routine
  685. 4 byte data or pointer to data
  686.  
  687. Typical dislexic problem.  Also see my short tip in this month's
  688. MacTutor where I conclude that a 16 bit word has 16384 possible
  689. values (and not 65536).  I'm suprised the editors didn't catch it.
  690.  
  691. Er, ah, that's MacTech magazine.  I'm so old I still say "Megacyles"...
  692. de KE3HE
  693.  
  694. ---------------------------
  695.  
  696. >From Laurent Humbert <laurent@humbert.demon.co.uk>
  697. Subject: Sending AppleEvents To Eudora
  698. Date: Sun, 20 Mar 1994 12:02:23 GMT
  699. Organization: QED Technology Ltd
  700.  
  701. Hi there,
  702.  
  703. In the application I am writting, I would need to tell
  704. Eudora to create a new message window, with a given To and Subject
  705. fields, as well as an initial content.
  706.  
  707. For the moment, I do just like Nuntius, bringing Eudora to the foreground,
  708. then calling PostEvent while I am in the background. Needless to say,
  709. this is a hack.
  710.  
  711. I am no AppleEvent manager expert, so if somebody has already written a
  712. routine
  713. that looks like
  714.  
  715. OSErr NewMessageInEudora( ProcessSerialNumber *eudoraPSN,
  716.                           Str255 to, Str255 subject,
  717.                           Handle initialcontent);
  718.  
  719. then I would be very interested (this is for a shareware application I am
  720. working on).
  721.  
  722. Thank you very much.
  723.  
  724. Laurent
  725.  
  726.                     o     o
  727.                      \|||/
  728. +----------------oOO-(o o)-OOo--------------+
  729. |   Laurent Humbert                         |
  730. |   Internet  : laurent@humbert.demon.co.uk |
  731. |   AppleLink : UK2001    CI$ : 100270,1136 |
  732. +-------------------------------------------+
  733.  
  734. +++++++++++++++++++++++++++
  735.  
  736. >From jonpugh@netcom.com (Jon Pugh)
  737. Date: Sun, 20 Mar 1994 19:49:30 GMT
  738. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  739.  
  740. Laurent Humbert (laurent@humbert.demon.co.uk) wrote:
  741.  
  742. > In the application I am writting, I would need to tell
  743. > Eudora to create a new message window, with a given To and Subject
  744. > fields, as well as an initial content.
  745.  
  746. I would consider using AppleScript's OSA layer to do this if you can get
  747. away with it.  It results in more flexible code since you can run a variety
  748. of scripts with it, whereas your Eduroa routine will only do one thing.
  749. The 2 routines will be about the same complexity to write.
  750.  
  751. Sorry I don't have details on your routine.
  752.  
  753. Jon
  754.  
  755.  
  756. ---------------------------
  757.  
  758. End of C.S.M.P. Digest
  759. **********************
  760.  
  761.  
  762.