fix TTS_DTOR_ITERATIONS with bits file

This commit is contained in:
auronandace
2026-06-26 12:42:35 +01:00
parent fec9d49c18
commit 3cc24ddaee
7 changed files with 41 additions and 5 deletions
+13
View File
@@ -0,0 +1,13 @@
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/limits.h.html
#
# These types are split out to avoid importing all of limits.h into other headers.
#
# POSIX headers that require PTHREAD_DESTRUCTOR_ITERATIONS:
# - limits.h (where it should be defined)
# - threads.h (for TSS_DTOR_ITERATIONS)
include_guard = "_RELIBC_BITS_LIMITS_PTDI_H"
language = "C"
no_includes = true
cpp_compat = true
[enum]
prefix_with_name = true
+12
View File
@@ -0,0 +1,12 @@
//! `PTHREAD_DESTRUCTOR_ITERATIONS` for `limits.h` implementation.
//!
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/limits.h.html>.
use crate::platform::types::c_long;
/// Minimum required value for `PTHREAD_DESTRUCTOR_ITERATIONS`.
pub const _POSIX_THREAD_DESTRUCTOR_ITERATIONS: c_long = 4;
/// Maximum number of attempts made to destroy a thread's thread-specific data
/// values on thread exit.
pub const PTHREAD_DESTRUCTOR_ITERATIONS: c_long = _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
+3
View File
@@ -2,6 +2,9 @@
#
# There are no spec quotations relating to includes
include_guard = "_RELIBC_LIMITS_H"
after_includes = """
#include <bits/limits/ptdi.h> // for PTHREAD_DESTRUCTOR_ITERATIONS
"""
language = "C"
no_includes = true
cpp_compat = true
+6 -2
View File
@@ -7,6 +7,10 @@ use crate::platform::types::{
c_ushort, ssize_t,
};
pub use crate::header::bits_limits_ptdi::{
_POSIX_THREAD_DESTRUCTOR_ITERATIONS, PTHREAD_DESTRUCTOR_ITERATIONS,
};
/// Maximum number of bytes in a filename (not including the terminating null
/// of a filename string).
pub const NAME_MAX: usize = 255;
@@ -103,7 +107,7 @@ pub const _POSIX_STREAM_MAX: c_long = 8;
pub const _POSIX_SYMLINK_MAX: c_long = 255;
/// Minimum required value for `SYMLOOP_MAX`.
pub const _POSIX_SYMLOOP_MAX: c_long = 8;
pub const _POSIX_THREAD_DESTRUCTOR_ITERATIONS: c_long = 4;
// _POSIX_THREAD_DESTRUCTOR_ITERATIONS defined in bits file
pub const _POSIX_THREAD_KEYS_MAX: c_long = 128;
pub const _POSIX_THREAD_THREADS_MAX: c_long = 64;
pub const _POSIX_TIMER_MAX: c_long = 32;
@@ -142,7 +146,7 @@ pub const MAX_INPUT: c_long = _POSIX_MAX_INPUT;
pub const SYMLINK_MAX: c_long = _POSIX_SYMLINK_MAX;
pub const POSIX_ALLOC_SIZE_MIN: c_long = 4096;
pub const PTHREAD_DESTRUCTOR_ITERATIONS: c_long = _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
// PTHREAD_DESTRUCTOR_ITERATIONS defined in bits file
// TODO: What should this limit be? Both glibc and musl have it as 1024
pub const PTHREAD_KEYS_MAX: c_long = 4096 * 32;
pub const PTHREAD_STACK_MIN: c_long = 65536;
+1
View File
@@ -23,6 +23,7 @@ pub mod bits_intptr_t;
pub mod bits_iovec;
#[path = "bits_key-t/mod.rs"]
pub mod bits_key_t;
pub mod bits_limits_ptdi;
#[path = "bits_locale-t/mod.rs"]
pub mod bits_locale_t;
#[path = "bits_mode-t/mod.rs"]
+4 -1
View File
@@ -3,6 +3,8 @@
# Spec quotations relating to includes:
# - "Inclusion of the <threads.h> header shall make symbols defined in the header <time.h> visible."
#
# TODO split out required pthread types
#
# time.h brings in features.h
# features.h required for Rust never type (no return)
sys_includes = ["time.h"]
@@ -12,7 +14,8 @@ style = "tag"
no_includes = true
cpp_compat = true
after_includes = """
#include <bits/pthread.h> // for pthread-related types
#include <bits/pthread.h> // for pthread-related types
#include <bits/limits/ptdi.h> // for PTHREAD_DESTRUCTOR_ITERATIONS
#ifndef __cplusplus
#define thread_local _Thread_local
+2 -2
View File
@@ -5,9 +5,9 @@
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
use super::{
bits_limits_ptdi::PTHREAD_DESTRUCTOR_ITERATIONS,
bits_pthread::{self, pthread_cond_t, pthread_key_t, pthread_mutex_t, pthread_mutexattr_t},
errno::{EBUSY, EINTR, ENOMEM, ETIMEDOUT},
limits,
pthread::{
self, PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_RECURSIVE, RlctCond, pthread_cond_broadcast,
pthread_cond_destroy, pthread_cond_signal, pthread_cond_timedwait, pthread_cond_wait,
@@ -45,7 +45,7 @@ pub const mtx_plain: c_int = 0;
pub const mtx_recursive: c_int = 1;
pub const mtx_timed: c_int = 2;
pub const TSS_DTOR_ITERATIONS: c_long = limits::PTHREAD_DESTRUCTOR_ITERATIONS;
pub const TSS_DTOR_ITERATIONS: c_long = PTHREAD_DESTRUCTOR_ITERATIONS;
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/call_once.html>.
#[unsafe(no_mangle)]