--- upstream/dynamips-0.2.5/utils.h 2007/10/06 16:01:44 1 +++ upstream/dynamips-0.2.6-RC3/utils.h 2007/10/06 16:06:49 4 @@ -223,6 +223,34 @@ return(((m_tmcnt_t)tvp.tv_sec * 1000000) + (m_tmcnt_t)tvp.tv_usec); } +#ifdef __CYGWIN__ +#define GET_TIMEZONE _timezone +#else +#define GET_TIMEZONE timezone +#endif + +/* Get current time in number of ms (localtime) */ +static inline m_tmcnt_t m_gettime_adj(void) +{ + struct timeval tvp; + struct tm tmx; + time_t gmt_adjust; + time_t ct; + + gettimeofday(&tvp,NULL); + ct = tvp.tv_sec; + localtime_r(&ct,&tmx); + +#if defined(__CYGWIN__) || defined(SUNOS) + gmt_adjust = -(tmx.tm_isdst ? GET_TIMEZONE - 3600 : GET_TIMEZONE); +#else + gmt_adjust = tmx.tm_gmtoff; +#endif + + tvp.tv_sec += gmt_adjust; + return(((m_tmcnt_t)tvp.tv_sec * 1000) + ((m_tmcnt_t)tvp.tv_usec / 1000)); +} + /* Add an element to a list */ m_list_t *m_list_add(m_list_t **head,void *data); @@ -256,4 +284,31 @@ /* Allocate aligned memory */ void *m_memalign(size_t boundary,size_t size); +/* Block specified signal for calling thread */ +int m_signal_block(int sig); + +/* Unblock specified signal for calling thread */ +int m_signal_unblock(int sig); + +/* Set non-blocking mode on a file descriptor */ +int m_fd_set_non_block(int fd); + +/* Map a memory zone from a file */ +u_char *memzone_map_file(int fd,size_t len); + +/* Map a memory zone from a file, with copy-on-write (COW) */ +u_char *memzone_map_cow_file(int fd,size_t len); + +/* Create a file to serve as a memory zone */ +int memzone_create_file(char *filename,size_t len,u_char **ptr); + +/* Open a file to serve as a COW memory zone */ +int memzone_open_cow_file(char *filename,size_t len,u_char **ptr); + +/* Open a file and map it in memory */ +int memzone_open_file(char *filename,u_char **ptr,off_t *fsize); + +/* Compute NVRAM checksum */ +m_uint16_t nvram_cksum(m_uint16_t *ptr,size_t count); + #endif