home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!agate!doc.ic.ac.uk!warwick!uknet!comlab.ox.ac.uk!pcl
- From: pcl@ox.ac.uk (Paul C Leyland)
- Newsgroups: alt.hackers
- Subject: Re: Stupid macro tricks...
- Message-ID: <PCL.93Jan28095624@rhodium.ox.ac.uk>
- Date: 28 Jan 93 09:56:24 GMT
- References: <C1DnqE.L3u@mentor.cc.purdue.edu>
- Organization: Oxford University Computing Services, 13 Banbury Rd Oxford OX2
- 6NN
- Lines: 41
- Approved: Of course it is approved.
- In-reply-to: daffnelr@mentor.cc.purdue.edu's message of 24 Jan 93 21:30:13 GMT
-
- In article <C1DnqE.L3u@mentor.cc.purdue.edu> daffnelr@mentor.cc.purdue.edu (Throatwarbler Mangrove) writes:
-
- Hey.. anyone out there got really
- ugly/complicated/elegant/interesting macros in any of their programs?
- As for the ugly part, it seems that bit manipulations can get that
- way very easily... Maybe we should have a contest for the ugliest
- macro that works for its intended purpose (that you've actually used
- in a program other than a test prog to see if it works..) Anyone got a
-
-
- Here's what I wrote when modifying dvi2ps to read .pk format fonts. I
- needed to speed up the nybble and bit-addressing functions. Since
- then, I've seen them crop up in other dvi-handling code, usually
- without attribution. 8-(
-
- 8<----------------->8
-
- /* Converted from functions to macros for speed. Pcl 6/8/87 */
- /* return rounded number of pixels */
- #define PixRound(x, conv) (int)(((x) + ((conv) >> 1)) / (conv))
- #define pk_byte(x) (*char_p++)
- #define get_nyb(x) (((nyb_ptr ^= TRUE) ? *char_p >> 4 : *char_p++) & 15)
- #define get_bit(x) (((bit_ptr >>= 1) ? \
- (*char_p & bit_ptr) : \
- (*++char_p & (bit_ptr = 128))) > 0)
-
- 8<----------------->8
-
-
- I particularly liked the get_bit macro.
-
- God. 5.5 years ago! I'm getting old ...
-
-
- Paul
- --
- Paul Leyland <pcl@oxford.ac.uk> | Hanging on in quiet desperation is
- Oxford University Computing Service | the English way.
- 13 Banbury Road, Oxford, OX2 6NN, UK | The time is come, the song is over.
- Tel: +44-865-273200 Fax: +44-865-273275 | Thought I'd something more to say.
- Finger pcl@black.ox.ac.uk for PGP key |
-