+ os_once(&ptsname_once, NULL, ptsname_once_init);
+ char *ptsnamebuf = pthread_getspecific(ptsname_buffer_specific_key);
+
+ if (ptsnamebuf == NULL) {
+ ptsnamebuf = malloc(PTSNAME_MAX_SIZE);
+ os_assert(ptsnamebuf);
+
+ int error = pthread_setspecific(ptsname_buffer_specific_key, ptsnamebuf);
+ os_assert_zero(error);
+ }
+
+ int error = ptsname_r(fd, ptsnamebuf, PTSNAME_MAX_SIZE);
+
+ return error ? NULL : ptsnamebuf;
+}
+
+int
+ptsname_r(int fd, char *buffer, size_t buflen)
+{