blob: 006652fb9b8897d63dcfaddb9ce4420ce610d210 [file] [log] [blame]
Daniel Dunbar67588922011-11-16 22:40:57 +00001/* ===-- stdio.h - stub SDK header for compiler-rt --------------------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
7 *
8 * ===-----------------------------------------------------------------------===
9 *
10 * This is a stub SDK header file. This file is not part of the interface of
11 * this library nor an official version of the appropriate SDK header. It is
12 * intended only to stub the features of this header required by compiler-rt.
13 *
14 * ===-----------------------------------------------------------------------===
15 */
16
17#ifndef __STDIO_H__
18#define __STDIO_H__
19
Richard Smith4a4ef702012-11-13 23:55:06 +000020#if defined(__cplusplus)
21extern "C" {
22#endif
23
Daniel Dunbar67588922011-11-16 22:40:57 +000024typedef struct __sFILE FILE;
25typedef __SIZE_TYPE__ size_t;
26
Bill Wendlingd06f2fc2013-05-23 07:18:59 +000027/* Determine the appropriate fdopen, fopen(), and fwrite() functions. */
Daniel Dunbar67588922011-11-16 22:40:57 +000028#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
29# if defined(__i386)
Bill Wendlingd06f2fc2013-05-23 07:18:59 +000030# define __FDOPEN_NAME "_fdopen$UNIX2003"
Daniel Dunbar67588922011-11-16 22:40:57 +000031# define __FOPEN_NAME "_fopen$UNIX2003"
32# define __FWRITE_NAME "_fwrite$UNIX2003"
33# elif defined(__x86_64__)
Bill Wendlingd06f2fc2013-05-23 07:18:59 +000034# define __FDOPEN_NAME "_fdopen"
Daniel Dunbar67588922011-11-16 22:40:57 +000035# define __FOPEN_NAME "_fopen"
36# define __FWRITE_NAME "_fwrite"
37# elif defined(__arm)
Bill Wendlingd06f2fc2013-05-23 07:18:59 +000038# define __FDOPEN_NAME "_fdopen"
Daniel Dunbar67588922011-11-16 22:40:57 +000039# define __FOPEN_NAME "_fopen"
40# define __FWRITE_NAME "_fwrite"
41# else
42# error "unrecognized architecture for targetting OS X"
43# endif
44#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
45# if defined(__i386) || defined (__x86_64)
Bill Wendlingd06f2fc2013-05-23 07:18:59 +000046# define __FDOPEN_NAME "_fdopen"
Daniel Dunbar67588922011-11-16 22:40:57 +000047# define __FOPEN_NAME "_fopen"
48# define __FWRITE_NAME "_fwrite"
49# elif defined(__arm)
Bill Wendlingd06f2fc2013-05-23 07:18:59 +000050# define __FDOPEN_NAME "_fdopen"
Daniel Dunbar67588922011-11-16 22:40:57 +000051# define __FOPEN_NAME "_fopen"
52# define __FWRITE_NAME "_fwrite"
53# else
54# error "unrecognized architecture for targetting iOS"
55# endif
56#else
57# error "unrecognized architecture for targetting Darwin"
58#endif
59
60# define stderr __stderrp
61extern FILE *__stderrp;
62
Bill Wendling843f3592012-09-14 18:55:32 +000063#ifndef SEEK_SET
64#define SEEK_SET 0 /* set file offset to offset */
65#endif
66#ifndef SEEK_CUR
67#define SEEK_CUR 1 /* set file offset to current plus offset */
68#endif
69#ifndef SEEK_END
70#define SEEK_END 2 /* set file offset to EOF plus offset */
71#endif
72
Daniel Dunbar67588922011-11-16 22:40:57 +000073int fclose(FILE *);
74int fflush(FILE *);
Richard Smith4a4ef702012-11-13 23:55:06 +000075FILE *fopen(const char * __restrict, const char * __restrict) __asm(__FOPEN_NAME);
Bill Wendlingd06f2fc2013-05-23 07:18:59 +000076FILE *fdopen(int, const char *) __asm(__FDOPEN_NAME);
Richard Smith4a4ef702012-11-13 23:55:06 +000077int fprintf(FILE * __restrict, const char * __restrict, ...);
78size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict)
Daniel Dunbar67588922011-11-16 22:40:57 +000079 __asm(__FWRITE_NAME);
Bill Wendling843f3592012-09-14 18:55:32 +000080size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
81long ftell(FILE *);
82int fseek(FILE *, long, int);
Richard Smith4a4ef702012-11-13 23:55:06 +000083int snprintf(char * __restrict, size_t, const char * __restrict, ...);
84
85#if defined(__cplusplus)
86}
87#endif
88
Daniel Dunbar67588922011-11-16 22:40:57 +000089#endif /* __STDIO_H__ */