/*************************************************************** ** ** Broadcom Corp. Confidential ** Copyright 1998-2000 Broadcom Corp. All Rights Reserved. ** ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED ** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM. ** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT ** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. ** ** File: ministd.h ** Description: subset of standard c functions. ** ** Created: 06/07/04 by Jeff Fisher ** ** ** ****************************************************************/ #ifndef __BCM_MINISTD_H__ #define __BCM_MINISTD_H__ #include "bos.h" #ifdef __cplusplus extern "C" { #endif #ifdef __NEWLIB__ #include #include #include #include #include #include #define b_timeval struct timeval #define b_tm struct tm #define GETTIMEOFDAY(tv) gettimeofday(tv,NULL) #ifdef LINUX #include #endif #else /* __NEWLIB__ */ typedef struct jmp_buf { #if SUPPORT_DST_PLATFORM unsigned int word[12]; /* 11 words, 44 bytes */ //BKTODO: in case of newcon2 11->12 (11->12) #else unsigned int word[11]; /* 11 words, 44 bytes */ #endif }jmp_buf; typedef struct b_tm { int tm_sec; /* Seconds. [0-60] (1 leap second) */ int tm_min; /* Minutes. [0-59] */ int tm_hour; /* Hours. [0-23] */ int tm_mday; /* Day. [1-31] */ int tm_mon; /* Month. [0-11] */ int tm_year; /* Year - 1980. */ int tm_wday; /* Day of week. [0-6] */ int tm_yday; /* Days in year.[0-365] */ }b_tm; #define GETTIMEOFDAY(tv) gettimeofday(tv) int setjmp(jmp_buf *p_jmp_buf); int longjmp(jmp_buf *p_jmp_buf,int val); int printf(const char *format, ...); int snprintf(char *str, size_t size, const char *format, ...); int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); void *memset(void *s, int c, size_t n); int memcmp(const void *src,const void *dest,size_t count); void *memcpy(void *dest, const void *src, size_t n); char *strcpy(char *dest, const char *src); char *strncpy(char *dest, const char *src, size_t n); size_t strlen(const char * str); int getchar(void); char *gets(char *s); char *ngets(char *s,int len); int sscanf(char* buf, char* fmt, unsigned int * val); int strcmp( const char * first,const char * last); int strncmp(const char *s1, const char *s2, int n); size_t strnlen(const char * s, size_t count); int perror(const char *str); void gettimeofday(b_timeval *tv); int fprintf(int* f, const char *format, ...); #define getc getchar #if 0 unsigned int ReadReg32(unsigned int offset); void WriteReg32(unsigned int offset, unsigned int value); #endif #define RAND_MAX 1000 unsigned int rand(void); void srand(unsigned int seed); #ifndef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) #endif #endif /* __NEWLIB__ */ #ifndef NEXUS_LINUXUSER #ifdef BCM_DEBUG void *malloc_align_dbg(size_t size,char alignbits, char* file, int line); void *malloc_dbg(size_t size, char* file, int line); void free_dbg(void *ptr, char* file, int line); #define malloc(size) malloc_dbg(size,__FILE__,__LINE__) #define malloc_align(size,align) malloc_align_dbg(size,align,__FILE__,__LINE__) #define free(ptr) free_dbg(ptr,__FILE__,__LINE__) #else void *malloc_align(size_t size,char alignbits); void *malloc(size_t size); void free(void *ptr); #endif #endif void console_init(volatile void *uart); void console_shutdown(void); void console_flush(void); void m_report(void); int m_uncompress(unsigned char *in_buf, unsigned int in_size, unsigned char * out_buf, unsigned int out_size); void utctime(unsigned int secs, b_tm *p_tm); #if SUPPORT_DST_PLATFORM void *memmove(void *dest, const void *src, size_t n); char *strchr(const char *str, int c); int sprintf(char *str, const char *format, ...); char *strcat(char *dest, const char *src); char *strstr(const char *s, const char *s2); //int getch(int timeout_ms); #define stderr 1 typedef void *FILE; int fprintf(int* f, const char *format, ...); size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); FILE *fopen(const char *path, const char *mode); int fclose(FILE *stream); int fseek(FILE *stream, long offset, int whence); long ftell(FILE *stream); int fflush(FILE *stream); #ifndef EOF #define EOF (-1) #endif #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ #endif #ifndef SEEK_CUR # define SEEK_CUR 1 /* Seek from current position. */ #endif #ifndef SEEK_END # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #define vsprintf(buf,fmt,args) vsnprintf(buf,4096,fmt,args) #endif #define RAND_INT(x) (((x) * rand())/RAND_MAX) #ifdef __cplusplus } #endif #endif /* __BCM_MINISTD_H__ */