2 * prototypes for functions defined in bcmstdlib.c
3 * Copyright (C) 2010, Broadcom Corporation. All Rights Reserved.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
14 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
15 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 * $Id: bcmstdlib.h,v 13.31 2009-06-26 22:48:10 Exp $:
20 * bcmstdlib.h file should be used only to construct an OSL or alone without any OSL
21 * It should not be used with any orbitarary OSL's as there could be a conflict
22 * with some of the routines defined here.
33 #define INT_MAX 2147483647 /* from limits.h */
37 /* For backwards compatibility, define "BWL_NO_INTERNAL_STDLIB_SUPPORT" to
38 * exclude support for the BRCM stdlib APIs. This should be cleaned-up such
39 * that platforms that require the BRCM stdlib API should simply define
40 * "BWL_INTERNAL_STDLIB_SUPPORT". This would eliminate the need for the
41 * following #ifndef check.
43 #ifndef BWL_NO_INTERNAL_STDLIB_SUPPORT
44 #define BWL_INTERNAL_STDLIB_SUPPORT
47 #ifdef BWL_INTERNAL_STDLIB_SUPPORT
48 /* This should be cleaned-up such that platforms that require the BRCM stdlib
49 * API should simply define "BWL_INTERNAL_STDLIB_SUPPORT". This would eliminate
50 * the need for the following #ifdef check.
52 #if !defined(_WIN32) && !defined(_CFE_) && !defined(EFI)
55 #define stdout ((FILE *)1)
56 #define stderr ((FILE *)2)
59 extern int fputc(int c
, FILE *stream
);
60 extern void putc(int c
);
61 /* extern int putc(int c, FILE *stream); */
62 #define putchar(c) putc(c)
63 extern int fputs(const char *s
, FILE *stream
);
64 extern int puts(const char *s
);
65 extern int getc(void);
66 extern bool keypressed(void);
68 /* bcopy, bcmp, and bzero */
69 #define bcopy(src, dst, len) memcpy((dst), (src), (len))
70 #define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
71 #define bzero(b, len) memset((b), '\0', (len))
73 extern unsigned long rand(void);
75 #define atoi(s) ((int)(strtoul((s), NULL, 10)))
79 #if !defined(_WIN32) || defined(EFI)
80 /* string functions */
81 #define PRINTF_BUFLEN 512
82 extern int printf(const char *fmt
, ...);
83 extern int BCMROMFN(sprintf
)(char *buf
, const char *fmt
, ...);
85 extern char *BCMROMFN(index
)(const char *s
, int c
);
87 extern int BCMROMFN(strcmp
)(const char *s1
, const char *s2
);
88 extern size_t BCMROMFN(strlen
)(const char *s
);
89 extern char *BCMROMFN(strcpy
)(char *dest
, const char *src
);
90 extern char *BCMROMFN(strstr
)(const char *s
, const char *find
);
91 extern char *BCMROMFN(strncpy
)(char *dest
, const char *src
, size_t n
);
92 extern char *BCMROMFN(strcat
)(char *d
, const char *s
);
94 extern int BCMROMFN(strncmp
)(const char *s1
, const char *s2
, size_t n
);
95 extern char *BCMROMFN(strchr
)(const char *str
, int c
);
96 extern char *BCMROMFN(strrchr
)(const char *str
, int c
);
97 extern size_t BCMROMFN(strspn
)(const char *s1
, const char *s2
);
98 extern size_t BCMROMFN(strcspn
)(const char *s1
, const char *s2
);
99 extern unsigned long BCMROMFN(strtoul
)(const char *cp
, char **endp
, int base
);
100 #define strtol(nptr, endptr, base) ((long)strtoul((nptr), (endptr), (base)))
102 extern void *BCMROMFN(memmove
)(void *dest
, const void *src
, size_t n
);
103 extern void *BCMROMFN(memchr
)(const void *s
, int c
, size_t n
);
105 extern int BCMROMFN(vsprintf
)(char *buf
, const char *fmt
, va_list ap
);
107 /* For EFI, using EFIDriverLib versions */
108 /* Cannot use memmem in ROM because of character array initialization wiht "" in gcc */
109 extern void *memset(void *dest
, int c
, size_t n
);
110 /* Cannot use memcpy in ROM because of structure assignmnets in gcc */
111 extern void *memcpy(void *dest
, const void *src
, size_t n
);
112 extern int BCMROMFN(memcmp
)(const void *s1
, const void *s2
, size_t n
);
114 #endif /* !_WIN32 || EFI */
115 #endif /* BWL_INTERNAL_STDLIB_SUPPORT */
117 extern int BCMROMFN(snprintf
)(char *str
, size_t n
, char const *fmt
, ...);
118 extern int BCMROMFN(vsnprintf
)(char *buf
, size_t size
, const char *fmt
, va_list ap
);
120 #endif /* _BCMSTDLIB_H */