blob: 1a8781f207495521b8e83d95b90f979ad4c3e32c [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"
Tim Northover4cfed272014-10-08 17:28:37 +000037# elif defined(__arm) || defined(__arm64)
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
Stephen Hines2d1fdb22014-05-28 23:58:16 -070042# error "unrecognized architecture for targeting OS X"
Daniel Dunbar67588922011-11-16 22:40:57 +000043# 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"
Tim Northover4cfed272014-10-08 17:28:37 +000049# elif defined(__arm) || defined(__arm64)
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
Stephen Hines2d1fdb22014-05-28 23:58:16 -070054# error "unrecognized architecture for targeting iOS"
Daniel Dunbar67588922011-11-16 22:40:57 +000055# endif
56#else
Stephen Hines2d1fdb22014-05-28 23:58:16 -070057# error "unrecognized architecture for targeting Darwin"
Daniel Dunbar67588922011-11-16 22:40:57 +000058#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, ...);
Stephen Hines2d1fdb22014-05-28 23:58:16 -070078int fputc(int, FILE *);
Richard Smith4a4ef702012-11-13 23:55:06 +000079size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict)
Daniel Dunbar67588922011-11-16 22:40:57 +000080 __asm(__FWRITE_NAME);
Bill Wendling843f3592012-09-14 18:55:32 +000081size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
82long ftell(FILE *);
83int fseek(FILE *, long, int);
Richard Smith4a4ef702012-11-13 23:55:06 +000084int snprintf(char * __restrict, size_t, const char * __restrict, ...);
85
86#if defined(__cplusplus)
87}
88#endif
89
Daniel Dunbar67588922011-11-16 22:40:57 +000090#endif /* __STDIO_H__ */