Path: utzoo!attcan!utgpu!utstat!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!uunet!munnari.oz.au!bruce!cechew From: cechew@bruce.OZ (Earl Chew) Newsgroups: comp.os.minix Subject: Re: New wait.h Message-ID: <1684@bruce.OZ> Date: 10 Nov 89 13:33:25 GMT References: <4463@ast.cs.vu.nl> Organization: Monash Uni. Computer Science, Australia Lines: 26 From article <4463@ast.cs.vu.nl>, by ast@cs.vu.nl (Andy Tanenbaum): > Does this one look better? I think I have the case of both bytes 0 Umm... well, everything except for: > #define _HIGH(__v) ( (__v >> 8) & 0377) Would be safer to protect __v in parentheses: #define _HIGH(__v) ( ((__v) >> 8) & 0377) > #define WIFSIGNALED(__s) (_HIGH(__s) == 0 && __s != 0) /* signaled */ You can get by without evaluating __s _twice_ (macros with side-effects and all that) (and again, you didn't protect (__s) != 0 in parentheses): #define WIFSIGNALED(__s) ((unsigned int) ((__s) - 1 & 0xffff) < 0xff) __s is evaluated only once. I don't know if Posix allows these macros to be `unsafe' (ie evaluate arguments more than once). In any event, it's safer this way (probably more efficient also --- only one test required instead of two). Earl -- Earl Chew, Dept of Computer Science, Monash University, Australia 3168 ARPA: cechew%bruce.cs.monash.oz.au@uunet.uu.net ACS : cechew@bruce.oz ----------------------------------------------------------------------