1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef VCOS_STDINT_H
29#define VCOS_STDINT_H
30
31/** \file
32 * Attempt to provide the types defined in stdint.h.
33 *
34 * Except for use with lcc, this simply includes stdint.h, which should find
35 * the system/toolchain version if present, otherwise falling back to the
36 * version in interface/vcos/<platform>.
37 */
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43#if defined (VCMODS_LCC)
44
45#include <limits.h>
46
47typedef signed char int8_t;
48typedef unsigned char uint8_t;
49
50typedef signed short int16_t;
51typedef unsigned short uint16_t;
52
53typedef signed long int32_t;
54typedef unsigned long uint32_t;
55
56typedef int32_t intptr_t;
57typedef uint32_t uintptr_t;
58
59typedef int32_t intmax_t;
60typedef uint32_t uintmax_t;
61
62typedef int8_t int_least8_t;
63typedef int16_t int_least16_t;
64typedef int32_t int_least32_t;
65typedef uint8_t uint_least8_t;
66typedef uint16_t uint_least16_t;
67typedef uint32_t uint_least32_t;
68
69#define INT8_MIN SCHAR_MIN
70#define INT8_MAX SCHAR_MAX
71#define UINT8_MAX UCHAR_MAX
72
73#define INT16_MIN SHRT_MIN
74#define INT16_MAX SHRT_MAX
75#define UINT16_MAX USHRT_MAX
76
77#define INT32_MIN LONG_MIN
78#define INT32_MAX LONG_MAX
79#define UINT32_MAX ULONG_MAX
80
81#define INTPTR_MIN INT32_MIN
82#define INTPTR_MAX INT32_MAX
83#define UINTPTR_MAX UINT32_MAX
84
85#define INTMAX_MIN INT32_MIN
86#define INTMAX_MAX INT32_MAX
87#define UINTMAX_MAX UINT32_MAX
88
89/* N.B. 64-bit integer types are not currently supported by lcc.
90 * However, these symbols are referenced in header files included by files
91 * compiled by lcc for VCE, so removing them would break the build.
92 * The solution here then is to define them, as the correct size, but in a
93 * way that should make them unusable in normal arithmetic operations.
94 */
95typedef struct { uint32_t a; uint32_t b; } int64_t;
96typedef struct { uint32_t a; uint32_t b; } uint64_t;
97
98#else
99
100#include <stdint.h>
101
102#endif
103
104#ifdef __cplusplus
105}
106#endif
107#endif /* VCOS_STDINT_H */
108