source: svn/trunk/newcon3bcm2_21bu/dta/src/ministd.h @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 4.8 KB
Line 
1/***************************************************************
2**
3** Broadcom Corp. Confidential
4** Copyright 1998-2000 Broadcom Corp. All Rights Reserved.
5**
6** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED
7** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM.
8** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT
9** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
10**
11** File:                ministd.h
12** Description: subset of standard c functions.
13**
14** Created: 06/07/04 by Jeff Fisher
15**
16**
17**
18****************************************************************/
19
20#ifndef __BCM_MINISTD_H__
21#define __BCM_MINISTD_H__
22
23#include "bos.h"
24
25#ifdef __cplusplus
26extern "C"
27{
28#endif
29
30#ifdef __NEWLIB__
31#include <stdlib.h>
32#include <stdio.h>
33#include <string.h>
34#include <malloc.h>
35#include <sys/time.h>
36#include <time.h>
37#define b_timeval struct timeval
38#define b_tm struct tm
39#define  GETTIMEOFDAY(tv)   gettimeofday(tv,NULL)
40#ifdef LINUX
41#include <setjmp.h>
42#endif
43#else /* __NEWLIB__ */
44
45typedef struct jmp_buf
46{
47#if SUPPORT_DST_PLATFORM
48        unsigned int word[12]; /* 11 words, 44 bytes */ //BKTODO: in case of newcon2 11->12 (11->12)
49#else
50        unsigned int word[11]; /* 11 words, 44 bytes */
51#endif
52}jmp_buf;
53
54typedef struct b_tm
55{
56  int tm_sec;                   /* Seconds.     [0-60] (1 leap second) */
57  int tm_min;                   /* Minutes.     [0-59] */
58  int tm_hour;                  /* Hours.       [0-23] */
59  int tm_mday;                  /* Day.         [1-31] */
60  int tm_mon;                   /* Month.       [0-11] */
61  int tm_year;                  /* Year - 1980.  */
62  int tm_wday;                  /* Day of week. [0-6] */
63  int tm_yday;                  /* Days in year.[0-365] */
64}b_tm;
65
66#define  GETTIMEOFDAY(tv)   gettimeofday(tv)
67
68int setjmp(jmp_buf *p_jmp_buf);
69int longjmp(jmp_buf *p_jmp_buf,int val);
70int printf(const char *format, ...);
71int snprintf(char *str, size_t size, const char *format, ...);
72int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
73void *memset(void *s, int c, size_t n);
74int memcmp(const void *src,const void *dest,size_t count);
75void *memcpy(void *dest, const void *src, size_t n);
76char *strcpy(char *dest, const char *src);
77char *strncpy(char *dest, const char *src, size_t n);
78size_t strlen(const char * str);
79int getchar(void);
80char *gets(char *s);
81char *ngets(char *s,int len);
82int sscanf(char* buf, char* fmt, unsigned int * val);
83int strcmp( const char * first,const char * last);
84int strncmp(const char *s1, const char *s2, int n);
85size_t strnlen(const char * s, size_t count);
86int perror(const char *str);
87void gettimeofday(b_timeval *tv);
88int fprintf(int* f, const char *format, ...);
89
90#define getc                                    getchar
91#if 0
92unsigned int ReadReg32(unsigned int offset);
93void WriteReg32(unsigned int offset, unsigned int value);
94#endif
95
96#define RAND_MAX    1000
97unsigned int rand(void);
98void srand(unsigned int seed);
99
100#ifndef offsetof
101#define offsetof(TYPE, MEMBER)  ((size_t) &((TYPE *) 0)->MEMBER)
102#endif
103
104#endif /* __NEWLIB__ */
105
106#ifndef NEXUS_LINUXUSER
107#ifdef BCM_DEBUG
108        void *malloc_align_dbg(size_t size,char alignbits, char* file, int line);
109        void *malloc_dbg(size_t size, char* file, int line);
110        void free_dbg(void *ptr, char* file, int line);
111        #define malloc(size)                    malloc_dbg(size,__FILE__,__LINE__)
112        #define malloc_align(size,align)                malloc_align_dbg(size,align,__FILE__,__LINE__)
113        #define free(ptr)                               free_dbg(ptr,__FILE__,__LINE__)
114#else
115        void *malloc_align(size_t size,char alignbits);
116        void *malloc(size_t size);
117        void free(void *ptr);
118#endif
119#endif
120
121void console_init(volatile void *uart);
122void console_shutdown(void);
123void console_flush(void);
124void m_report(void);
125int m_uncompress(unsigned char *in_buf, unsigned int in_size,
126                                                unsigned char * out_buf, unsigned int out_size);
127void utctime(unsigned int secs, b_tm *p_tm);
128
129#if SUPPORT_DST_PLATFORM
130void *memmove(void *dest, const void *src, size_t n);
131char *strchr(const char *str, int c);
132int sprintf(char *str, const char *format, ...);
133char *strcat(char *dest, const char *src);
134char *strstr(const char *s, const char *s2);
135//int getch(int timeout_ms);
136#define stderr 1
137typedef void *FILE;
138int fprintf(int* f, const char *format, ...);
139size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
140size_t   fwrite(const  void  *ptr,  size_t  size,  size_t  nmemb,  FILE *stream);
141FILE *fopen(const char *path, const char *mode);
142int fclose(FILE *stream);
143int fseek(FILE *stream, long offset, int whence);
144long ftell(FILE *stream);
145int fflush(FILE *stream);
146#ifndef EOF
147#define EOF         (-1)
148#endif
149#ifndef SEEK_SET
150#  define SEEK_SET        0       /* Seek from beginning of file.  */
151#endif
152#ifndef SEEK_CUR
153#  define SEEK_CUR        1       /* Seek from current position.  */
154#endif
155#ifndef SEEK_END
156#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
157#endif
158
159#define vsprintf(buf,fmt,args) vsnprintf(buf,4096,fmt,args)
160
161
162#endif
163
164#define RAND_INT(x) (((x) * rand())/RAND_MAX)
165
166#ifdef __cplusplus
167}
168#endif
169
170#endif /* __BCM_MINISTD_H__ */
171
Note: See TracBrowser for help on using the repository browser.