1/* Header: util.h,v 7.0 86/10/08 15:14:37 lwall Exp */ 2 3/* Log: util.h,v 4 * Revision 7.0 86/10/08 15:14:37 lwall 5 * Split into separate files. Added amoebas and pirates. 6 * 7 */ 8 9#define RANDRAND 1152921504606846976.0 /* that's 2**60 */ 10#define HALFRAND 0x40000000 /* that's 2**30 */ 11#define myrand() (int)random() 12#define rand_mod(m) ((myrand() / 37) % (m)) /* pick number in 0..m-1 */ 13/* 14 * The reason for the /37 above is that our random number generator yields 15 * successive evens and odds, for some reason. This makes strange star maps. 16 */ 17 18 /* we get fractions of seconds from calling ftime on timebuf */ 19 20extern struct timespec timebuf; 21#define roundsleep(x) (clock_gettime(CLOCK_REALTIME, &timebuf),sleep(timebuf.tv_nsec > (500 * 1000 * 1000) ?x+1:x)) 22 23#define waiting 0 24 25#ifdef NOTDEF 26EXT int len_last_line_got INIT(0); 27 /* strlen of some_buf after */ 28 /* some_buf = get_a_line(bufptr,buffersize,fp) */ 29#endif 30 31#ifdef NOTDEF 32/* is the string for makedir a directory name or a filename? */ 33 34#define MD_DIR 0 35#define MD_FILE 1 36#endif 37 38void util_init(void); 39void movc3(int, char *, char *); 40__dead void no_can_do(const char *); 41int exdis(int); 42void *safemalloc(size_t size); 43char *safecpy(char *, const char *, size_t); 44char *cpytill(char *, const char *, int); 45char *instr(const char *, const char *); 46#ifdef SETUIDGID 47int eaccess(const char *, mode_t); 48#endif 49__dead void prexit(const char *); 50char *savestr(const char *); 51char *getval(const char *, const char *); 52