1 /* Filter driver - utility functions */
7 static clock_t next_alarm
;
9 /*===========================================================================*
11 *===========================================================================*/
12 char *flt_malloc(size_t size
, char *sbuf
, size_t ssize
)
14 /* Allocate a buffer for 'size' bytes. If 'size' is equal to or less
15 * than 'ssize', return the static buffer 'sbuf', otherwise, use
16 * malloc() to allocate memory dynamically.
23 if(!(p
= alloc_contig(size
, 0, NULL
)))
24 panic("out of memory: %d", size
);
29 /*===========================================================================*
31 *===========================================================================*/
32 void flt_free(char *buf
, size_t size
, const char *sbuf
)
34 /* Free a buffer previously allocated with flt_malloc().
38 free_contig(buf
, size
);
41 /*===========================================================================*
43 *===========================================================================*/
44 char *print64(u64_t p
)
48 static char buf
[NB
][100];
49 u32_t lo
= ex64lo(p
), hi
= ex64hi(p
);
51 if(!hi
) sprintf(buf
[n
], "%lx", lo
);
52 else sprintf(buf
[n
], "%lx%08lx", hi
, lo
);
56 /*===========================================================================*
58 *===========================================================================*/
59 clock_t flt_alarm(clock_t dt
)
66 r
= sys_setalarm(dt
, 0);
69 panic("sys_setalarm failed: %d", r
);
73 panic("clearing unset alarm: %d", r
);
77 panic("overwriting alarm: %d", r
);
78 if ((r
= getuptime(&next_alarm
)) != OK
)
79 panic("getuptime failed: %d", r
);
86 /*===========================================================================*
88 *===========================================================================*/
89 static void got_alarm(int sig
)