Skip to content

Commit 9c7c710

Browse files
committed
gh-123797: Check for runtime availability of ptsname_r on macos
1 parent 033510e commit 9c7c710

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Lib/test/test_posix.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,13 @@ def test_stat(self):
21402140
with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
21412141
os.stat("file", dir_fd=0)
21422142

2143+
def test_ptsname_r(self):
2144+
self._verify_available("HAVE_PTSNAME_R")
2145+
if self.mac_ver >= (10, 13, 4):
2146+
self.assertIn("HAVE_PTSNAME_R", posix._have_functions)
2147+
else:
2148+
self.assertNotIn("HAVE_PTSNAME_R", posix._have_functions)
2149+
21432150
def test_access(self):
21442151
self._verify_available("HAVE_FACCESSAT")
21452152
if self.mac_ver >= (10, 10):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Check for runtime availability of ``ptsname_r`` function on macos.

Modules/posixmodule.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
# define HAVE_PWRITEV_RUNTIME __builtin_available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)
126126
# define HAVE_MKFIFOAT_RUNTIME __builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
127127
# define HAVE_MKNODAT_RUNTIME __builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
128+
# define HAVE_PTSNAME_R_RUNTIME __builtin_available(macOS 10.13.4, iOS 11.3, tvOS 11.3, watchOS 4.3, *)
128129

129130
# define HAVE_POSIX_SPAWN_SETSID_RUNTIME __builtin_available(macOS 10.15, *)
130131

@@ -206,6 +207,10 @@
206207
# define HAVE_MKNODAT_RUNTIME (mknodat != NULL)
207208
# endif
208209

210+
# ifdef HAVE_PTSNAME_R
211+
# define HAVE_PTSNAME_R_RUNTIME (ptsname_r != NULL)
212+
# endif
213+
209214
#endif
210215

211216
#ifdef HAVE_FUTIMESAT
@@ -231,6 +236,7 @@
231236
# define HAVE_PWRITEV_RUNTIME 1
232237
# define HAVE_MKFIFOAT_RUNTIME 1
233238
# define HAVE_MKNODAT_RUNTIME 1
239+
# define HAVE_PTSNAME_R_RUNTIME 1
234240
#endif
235241

236242

@@ -8652,7 +8658,7 @@ static PyObject *
86528658
os_ptsname_impl(PyObject *module, int fd)
86538659
/*[clinic end generated code: output=ef300fadc5675872 input=1369ccc0546f3130]*/
86548660
{
8655-
#ifdef HAVE_PTSNAME_R
8661+
#ifdef HAVE_PTSNAME_R_RUNTIME
86568662
int ret;
86578663
char name[MAXPATHLEN+1];
86588664

@@ -17751,6 +17757,9 @@ PROBE(probe_futimens, HAVE_FUTIMENS_RUNTIME)
1775117757
PROBE(probe_utimensat, HAVE_UTIMENSAT_RUNTIME)
1775217758
#endif
1775317759

17760+
#ifdef HAVE_PTSNAME_R
17761+
PROBE(probe_ptsname_r, HAVE_PTSNAME_R_RUNTIME)
17762+
#endif
1775417763

1775517764

1775617765

@@ -17891,6 +17900,10 @@ static const struct have_function {
1789117900
{ "HAVE_UTIMENSAT", probe_utimensat },
1789217901
#endif
1789317902

17903+
#ifdef HAVE_PTSNAME_R
17904+
{ "HAVE_PTSNAME_R", probe_ptsname_r },
17905+
#endif
17906+
1789417907
#ifdef MS_WINDOWS
1789517908
{ "MS_WINDOWS", NULL },
1789617909
#endif

0 commit comments

Comments
 (0)