libsodium update: 1.0.0
[tomato.git] / release / src / include / bcmstdlib.h
blobb29015806a22b6ed8cd42f6746bfac5a8c9eb9ec
1 /*
2 * prototypes for functions defined in bcmstdlib.c
3 * Copyright 2007, Broadcom Corporation
4 * All Rights Reserved.
5 *
6 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10 * $Id$:
14 * bcmstdlib.h file should be used only to construct an OSL or alone without any OSL
15 * It should not be used with any orbitarary OSL's as there could be a conflict
16 * with some of the routines defined here.
19 #ifndef _BCMSTDLIB_H
20 #define _BCMSTDLIB_H
22 #include <typedefs.h>
23 #include <bcmdefs.h>
24 #include <stdarg.h>
26 #ifndef INT_MAX
27 #define INT_MAX 2147483647 /* from limits.h */
28 #endif
30 #if (!defined(_WIN32) || defined(EFI)) && !defined(_CFE_)
32 typedef int FILE;
33 #define stdout ((FILE *)1)
34 #define stderr ((FILE *)2)
36 /* i/o functions */
37 extern int fputc(int c, FILE *stream);
38 extern void putc(int c);
39 /* extern int putc(int c, FILE *stream); */
40 #define putchar(c) putc(c)
41 extern int fputs(const char *s, FILE *stream);
42 extern int puts(const char *s);
43 extern int getc(void);
44 extern bool keypressed(void);
46 /* string functions */
47 #define PRINTF_BUFLEN 512
48 extern int printf(const char *fmt, ...);
49 extern int BCMROMFN(sprintf)(char *buf, const char *fmt, ...);
51 extern char *BCMROMFN(index)(const char *s, int c);
53 /* For EFI, use some of the common EFI Driver Library functions
54 * to reduce final size and improve efficiency
56 #ifndef EFI
57 extern int BCMROMFN(strcmp)(const char *s1, const char *s2);
58 extern size_t BCMROMFN(strlen)(const char *s);
59 extern char *BCMROMFN(strcpy)(char *dest, const char *src);
60 extern char *BCMROMFN(strstr)(const char *s, const char *find);
61 extern char *BCMROMFN(strncpy)(char *dest, const char *src, size_t n);
62 extern char *BCMROMFN(strcat)(char *d, const char *s);
63 #endif /* EFI */
65 extern int BCMROMFN(strncmp)(const char *s1, const char *s2, size_t n);
66 extern char *BCMROMFN(strchr)(const char *str, int c);
67 extern char *BCMROMFN(strrchr)(const char *str, int c);
68 extern size_t BCMROMFN(strspn)(const char *s1, const char *s2);
69 extern size_t BCMROMFN(strcspn)(const char *s1, const char *s2);
70 extern unsigned long BCMROMFN(strtoul)(const char *cp, char **endp, int base);
71 #define strtol(nptr, endptr, base) ((long)strtoul((nptr), (endptr), (base)))
72 #define atoi(s) ((int)(strtoul((s), NULL, 10)))
74 extern void *BCMROMFN(memmove)(void *dest, const void *src, size_t n);
75 extern void *BCMROMFN(memchr)(const void *s, int c, size_t n);
77 extern int BCMROMFN(vsprintf)(char *buf, const char *fmt, va_list ap);
78 /* mem functions */
79 #ifndef EFI
80 /* For EFI, using EFIDriverLib versions */
81 /* Cannot use memmem in ROM because of character array initialization wiht "" in gcc */
82 extern void *memset(void *dest, int c, size_t n);
83 /* Cannot use memcpy in ROM because of structure assignmnets in gcc */
84 extern void *memcpy(void *dest, const void *src, size_t n);
85 extern int BCMROMFN(memcmp)(const void *s1, const void *s2, size_t n);
87 /* bcopy, bcmp, and bzero */
88 #define bcopy(src, dst, len) memcpy((dst), (src), (len))
89 #define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
90 #define bzero(b, len) memset((b), '\0', (len))
91 #endif /* EFI */
93 extern unsigned long rand(void);
95 #endif
97 extern int BCMROMFN(snprintf)(char *str, size_t n, char const *fmt, ...);
98 extern int BCMROMFN(vsnprintf)(char *buf, size_t size, const char *fmt, va_list ap);
100 #endif /* _BCMSTDLIB_H */