8000 GH-131238: Core header refactor by markshannon · Pull Request #131250 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-131238: Core header refactor #131250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 17, 2025
Merged
Prev Previous commit
Next Next commit
Move functions back to their original header
  • Loading branch information
markshannon committed Mar 17, 2025
commit 4ab21f7c3c46bb5fd809854cfd19f4e708944c77
24 changes: 0 additions & 24 deletions Include/internal/pycore_runtime_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,35 +86,11 @@ struct _parser_runtime_state {
struct _expr dummy_name;
};


// --- _PyTimeFraction -------------------------------------------------------

typedef struct {
PyTime_t numer;
PyTime_t denom;
} _PyTimeFraction;

// Set a fraction.
// Return 0 on success.
// Return -1 if the fraction is invalid.
extern int _PyTimeFraction_Set(
_PyTimeFraction *frac,
PyTime_t numer,
PyTime_t denom);

// Compute ticks * frac.numer / frac.denom.
// Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
extern PyTime_t _PyTimeFraction_Mul(
PyTime_t ticks,
const _PyTimeFraction *frac);

// Compute a clock resolution: frac.numer / frac.denom / 1e9.
extern double _PyTimeFraction_Resolution(
const _PyTimeFraction *frac);


// --- _Py_time_runtime_state ------------------------------------------------

struct _Py_time_runtime_state {
#if defined(MS_WINDOWS) || defined(__APPLE__)
_PyTimeFraction base;
Expand Down
19 changes: 19 additions & 0 deletions Include/internal/pycore_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,25 @@ PyAPI_FUNC(PyTime_t) _PyDeadline_Init(PyTime_t timeout);
PyAPI_FUNC(PyTime_t) _PyDeadline_Get(PyTime_t deadline);


// --- _PyTimeFraction -------------------------------------------------------

// Set a fraction.
// Return 0 on success.
// Return -1 if the fraction is invalid.
extern int _PyTimeFraction_Set(
_PyTimeFraction *frac,
PyTime_t numer,
PyTime_t denom);

// Compute ticks * frac.numer / frac.denom.
// Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
extern PyTime_t _PyTimeFraction_Mul(
PyTime_t ticks,
const _PyTimeFraction *frac);

// Compute a clock resolution: frac.numer / frac.denom / 1e9.
extern double _PyTimeFraction_Resolution(
const _PyTimeFraction *frac);

extern PyStatus _PyTime_Init(struct _Py_time_runtime_state *state);

Expand Down
0