Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a6ca8ee

Browse filesBrowse files
authored
bpo-46315: Add ifdef HAVE_ feature checks for WASI compatibility (GH-30507)
1 parent 1de6015 commit a6ca8ee
Copy full SHA for a6ca8ee

14 files changed

+90-14Lines changed: 90 additions & 14 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Include/internal/pycore_condvar.h‎

Copy file name to clipboardExpand all lines: Include/internal/pycore_condvar.h
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
*/
2121
#define Py_HAVE_CONDVAR
2222

23-
#include <pthread.h>
23+
#ifdef HAVE_PTHREAD_H
24+
# include <pthread.h>
25+
#endif
2426

2527
#define PyMUTEX_T pthread_mutex_t
2628
#define PyCOND_T pthread_cond_t
Collapse file

‎Include/pythread.h‎

Copy file name to clipboardExpand all lines: Include/pythread.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_ReInitTLS(void);
125125
typedef struct _Py_tss_t Py_tss_t; /* opaque */
126126

127127
#ifndef Py_LIMITED_API
128-
#if defined(_POSIX_THREADS)
128+
#ifdef HAVE_PTHREAD_H
129129
/* Darwin needs pthread.h to know type name the pthread_key_t. */
130130
# include <pthread.h>
131131
# define NATIVE_TSS_KEY_T pthread_key_t
Collapse file
+2Lines changed: 2 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added and fixed ``#ifdef HAVE_FEATURE`` checks for functionality that is not
2+
available on WASI platform.
Collapse file

‎Modules/_randommodule.c‎

Copy file name to clipboardExpand all lines: Modules/_randommodule.c
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ random_seed_time_pid(RandomObject *self)
258258
key[0] = (uint32_t)(now & 0xffffffffU);
259259
key[1] = (uint32_t)(now >> 32);
260260

261+
#ifdef HAVE_GETPID
261262
key[2] = (uint32_t)getpid();
263+
#else
264+
key[2] = 0;
265+
#endif
262266

263267
now = _PyTime_GetMonotonicClock();
264268
key[3] = (uint32_t)(now & 0xffffffffU);
Collapse file

‎Modules/clinic/posixmodule.c.h‎

Copy file name to clipboardExpand all lines: Modules/clinic/posixmodule.c.h
+9-1Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎Modules/faulthandler.c‎

Copy file name to clipboardExpand all lines: Modules/faulthandler.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <signal.h>
1111
#include <signal.h>
1212
#include <stdlib.h> // abort()
13-
#if defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK)
13+
#if defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK) && defined(HAVE_PTHREAD_H)
1414
# include <pthread.h>
1515
#endif
1616
#ifdef MS_WINDOWS
Collapse file

‎Modules/posixmodule.c‎

Copy file name to clipboardExpand all lines: Modules/posixmodule.c
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,7 +3292,14 @@ os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
32923292
}
32933293
else
32943294
#endif /* HAVE_FHCMODAT */
3295+
{
3296+
#ifdef HAVE_CHMOD
32953297
result = chmod(path->narrow, mode);
3298+
#else
3299+
result = -1;
3300+
errno = ENOSYS;
3301+
#endif
3302+
}
32963303
Py_END_ALLOW_THREADS
32973304

32983305
if (result) {
@@ -4885,6 +4892,7 @@ os_system_impl(PyObject *module, PyObject *command)
48854892
#endif /* HAVE_SYSTEM */
48864893

48874894

4895+
#ifdef HAVE_UMASK
48884896
/*[clinic input]
48894897
os.umask
48904898
@@ -4903,6 +4911,7 @@ os_umask_impl(PyObject *module, int mask)
49034911
return posix_error();
49044912
return PyLong_FromLong((long)i);
49054913
}
4914+
#endif
49064915

49074916
#ifdef MS_WINDOWS
49084917

Collapse file

‎Modules/xxsubtype.c‎

Copy file name to clipboardExpand all lines: Modules/xxsubtype.c
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,11 @@ spam_bench(PyObject *self, PyObject *args)
237237
{
238238
PyObject *obj, *name, *res;
239239
int n = 1000;
240-
time_t t0, t1;
240+
time_t t0 = 0, t1 = 0;
241241

242242
if (!PyArg_ParseTuple(args, "OU|i", &obj, &name, &n))
243243
return NULL;
244+
#ifdef HAVE_CLOCK
244245
t0 = clock();
245246
while (--n >= 0) {
246247
res = PyObject_GetAttr(obj, name);
@@ -249,6 +250,7 @@ spam_bench(PyObject *self, PyObject *args)
249250
Py_DECREF(res);
250251
}
251252
t1 = clock();
253+
#endif
252254
return PyFloat_FromDouble((double)(t1-t0) / CLOCKS_PER_SEC);
253255
}
254256

Collapse file

‎PC/pyconfig.h‎

Copy file name to clipboardExpand all lines: PC/pyconfig.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
529529
/* Define if you have times. */
530530
/* #undef HAVE_TIMES */
531531

532+
/* Define to 1 if you have the `umask' function. */
533+
#define HAVE_UMASK 1
534+
532535
/* Define if you have uname. */
533536
/* #undef HAVE_UNAME */
534537

Collapse file

‎Python/pyfpe.c‎

Copy file name to clipboardExpand all lines: Python/pyfpe.c
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
* though, because they may be referenced by extensions using the stable ABI.
44
*/
55

6-
#include "setjmp.h"
6+
#ifdef HAVE_SETJMP_H
7+
#include <setjmp.h>
78

89
jmp_buf PyFPE_jbuf;
10+
#endif
11+
912
int PyFPE_counter;
1013

1114
double

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.