Skip to content

Commit d907cf7

Browse files
committed
Inline fileutils.h
2 parents 97411e4 + 4a7e313 commit d907cf7

File tree

3 files changed

+208
-0
lines changed

3 files changed

+208
-0
lines changed

graalpython/com.oracle.graal.python.cext/include/Python.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
#include "typeslots.h"
124124
#include "weakrefobject.h"
125125
#include "sysmodule.h"
126+
#include "fileutils.h"
126127

127128
// TODO: we must extend the refcounting behavior to support handles to managed objects
128129
#undef Py_DECREF
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
/* Copyright (c) 2019, Oracle and/or its affiliates.
2+
* Copyright (C) 1996-2017 Python Software Foundation
3+
*
4+
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
5+
*/
6+
#ifndef Py_FILEUTILS_H
7+
#define Py_FILEUTILS_H
8+
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
14+
PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
15+
const char *arg,
16+
size_t *size);
17+
18+
PyAPI_FUNC(char*) Py_EncodeLocale(
19+
const wchar_t *text,
20+
size_t *error_pos);
21+
22+
PyAPI_FUNC(char*) _Py_EncodeLocaleRaw(
23+
const wchar_t *text,
24+
size_t *error_pos);
25+
#endif
26+
27+
#ifdef Py_BUILD_CORE
28+
PyAPI_FUNC(int) _Py_DecodeUTF8Ex(
29+
const char *arg,
30+
Py_ssize_t arglen,
31+
wchar_t **wstr,
32+
size_t *wlen,
33+
const char **reason,
34+
int surrogateescape);
35+
36+
PyAPI_FUNC(int) _Py_EncodeUTF8Ex(
37+
const wchar_t *text,
38+
char **str,
39+
size_t *error_pos,
40+
const char **reason,
41+
int raw_malloc,
42+
int surrogateescape);
43+
44+
PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape(
45+
const char *arg,
46+
Py_ssize_t arglen);
47+
48+
PyAPI_FUNC(int) _Py_DecodeLocaleEx(
49+
const char *arg,
50+
wchar_t **wstr,
51+
size_t *wlen,
52+
const char **reason,
53+
int current_locale,
54+
int surrogateescape);
55+
56+
PyAPI_FUNC(int) _Py_EncodeLocaleEx(
57+
const wchar_t *text,
58+
char **str,
59+
size_t *error_pos,
60+
const char **reason,
61+
int current_locale,
62+
int surrogateescape);
63+
#endif
64+
65+
#ifndef Py_LIMITED_API
66+
PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
67+
68+
#if defined(MS_WINDOWS) || defined(__APPLE__)
69+
/* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611).
70+
On macOS 10.13, read() and write() with more than INT_MAX bytes
71+
fail with EINVAL (bpo-24658). */
72+
# define _PY_READ_MAX INT_MAX
73+
# define _PY_WRITE_MAX INT_MAX
74+
#else
75+
/* write() should truncate the input to PY_SSIZE_T_MAX bytes,
76+
but it's safer to do it ourself to have a portable behaviour */
77+
# define _PY_READ_MAX PY_SSIZE_T_MAX
78+
# define _PY_WRITE_MAX PY_SSIZE_T_MAX
79+
#endif
80+
81+
#ifdef MS_WINDOWS
82+
struct _Py_stat_struct {
83+
unsigned long st_dev;
84+
uint64_t st_ino;
85+
unsigned short st_mode;
86+
int st_nlink;
87+
int st_uid;
88+
int st_gid;
89+
unsigned long st_rdev;
90+
__int64 st_size;
91+
time_t st_atime;
92+
int st_atime_nsec;
93+
time_t st_mtime;
94+
int st_mtime_nsec;
95+
time_t st_ctime;
96+
int st_ctime_nsec;
97+
unsigned long st_file_attributes;
98+
};
99+
#else
100+
# define _Py_stat_struct stat
101+
#endif
102+
103+
PyAPI_FUNC(int) _Py_fstat(
104+
int fd,
105+
struct _Py_stat_struct *status);
106+
107+
PyAPI_FUNC(int) _Py_fstat_noraise(
108+
int fd,
109+
struct _Py_stat_struct *status);
110+
111+
PyAPI_FUNC(int) _Py_stat(
112+
PyObject *path,
113+
struct stat *status);
114+
115+
PyAPI_FUNC(int) _Py_open(
116+
const char *pathname,
117+
int flags);
118+
119+
PyAPI_FUNC(int) _Py_open_noraise(
120+
const char *pathname,
121+
int flags);
122+
123+
PyAPI_FUNC(FILE *) _Py_wfopen(
124+
const wchar_t *path,
125+
const wchar_t *mode);
126+
127+
PyAPI_FUNC(FILE*) _Py_fopen(
128+
const char *pathname,
129+
const char *mode);
130+
131+
PyAPI_FUNC(FILE*) _Py_fopen_obj(
132+
PyObject *path,
133+
const char *mode);
134+
135+
PyAPI_FUNC(Py_ssize_t) _Py_read(
136+
int fd,
137+
void *buf,
138+
size_t count);
139+
140+
PyAPI_FUNC(Py_ssize_t) _Py_write(
141+
int fd,
142+
const void *buf,
143+
size_t count);
144+
145+
PyAPI_FUNC(Py_ssize_t) _Py_write_noraise(
146+
int fd,
147+
const void *buf,
148+
size_t count);
149+
150+
#ifdef HAVE_READLINK
151+
PyAPI_FUNC(int) _Py_wreadlink(
152+
const wchar_t *path,
153+
wchar_t *buf,
154+
size_t bufsiz);
155+
#endif
156+
157+
#ifdef HAVE_REALPATH
158+
PyAPI_FUNC(wchar_t*) _Py_wrealpath(
159+
const wchar_t *path,
160+
wchar_t *resolved_path,
161+
size_t resolved_path_size);
162+
#endif
163+
164+
PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
165+
wchar_t *buf,
166+
size_t size);
167+
168+
PyAPI_FUNC(int) _Py_get_inheritable(int fd);
169+
170+
PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,
171+
int *atomic_flag_works);
172+
173+
PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable,
174+
int *atomic_flag_works);
175+
176+
PyAPI_FUNC(int) _Py_dup(int fd);
177+
178+
#ifndef MS_WINDOWS
179+
PyAPI_FUNC(int) _Py_get_blocking(int fd);
180+
181+
PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking);
182+
#endif /* !MS_WINDOWS */
183+
184+
PyAPI_FUNC(int) _Py_GetLocaleconvNumeric(
185+
PyObject **decimal_point,
186+
PyObject **thousands_sep,
187+
const char **grouping);
188+
189+
#endif /* Py_LIMITED_API */
190+
191+
#ifdef Py_BUILD_CORE
192+
PyAPI_FUNC(int) _Py_GetForceASCII(void);
193+
194+
/* Reset "force ASCII" mode (if it was initialized).
195+
196+
This function should be called when Python changes the LC_CTYPE locale,
197+
so the "force ASCII" mode can be detected again on the new locale
198+
encoding. */
199+
PyAPI_FUNC(void) _Py_ResetForceASCII(void);
200+
#endif
201+
202+
#ifdef __cplusplus
203+
}
204+
#endif
205+
206+
#endif /* !Py_FILEUTILS_H */

mx.graalpython/copyrights/overrides

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ graalpython/com.oracle.graal.python.cext/include/datetime.h,python.copyright
6161
graalpython/com.oracle.graal.python.cext/include/descrobject.h,python.copyright
6262
graalpython/com.oracle.graal.python.cext/include/dictobject.h,python.copyright
6363
graalpython/com.oracle.graal.python.cext/include/fileobject.h,python.copyright
64+
graalpython/com.oracle.graal.python.cext/include/fileutils.h,python.copyright
6465
graalpython/com.oracle.graal.python.cext/include/floatobject.h,python.copyright
6566
graalpython/com.oracle.graal.python.cext/include/frameobject.h,python.copyright
6667
graalpython/com.oracle.graal.python.cext/include/funcobject.h,python.copyright

0 commit comments

Comments
 (0)