Skip to content

Commit

Permalink
Fix warnings on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Sep 17, 2024
1 parent c2d8693 commit b104782
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Include/cpython/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ typedef struct {
*/
typedef struct {
Py_ssize_t size;
char *entries[];
char *entries[1];
} _PyCodeArray;

#define _PyCode_DEF_THREAD_LOCAL_BYTECODE() \
Expand Down
4 changes: 3 additions & 1 deletion Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,9 @@ extern _Py_CODEUNIT *_PyCode_GetTLBC(PyCodeObject *co);

// Reserve an index for the current thread into thread-local bytecode
// arrays
extern int _Py_ReserveTLBCIndex(PyInterpreterState *interp);
//
// Returns the reserved index or -1 on error.
extern Py_ssize_t _Py_ReserveTLBCIndex(PyInterpreterState *interp);

// Release the current thread's index into thread-local bytecode arrays
extern void _Py_ClearTLBCIndex(_PyThreadStateImpl *tstate);
Expand Down
11 changes: 6 additions & 5 deletions Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,7 @@ _PyCode_Fini(PyInterpreterState *interp)
// interpreter and instrumentation use atomics, with specialization taking care
// not to overwrite an instruction that was instrumented concurrently.

int
Py_ssize_t
_Py_ReserveTLBCIndex(PyInterpreterState *interp)
{
return _PyIndexPool_AllocIndex(&interp->tlbc_indices);
Expand All @@ -2716,8 +2716,8 @@ _Py_ClearTLBCIndex(_PyThreadStateImpl *tstate)
static _PyCodeArray *
_PyCodeArray_New(Py_ssize_t size)
{
_PyCodeArray *arr =
PyMem_Calloc(1, sizeof(_PyCodeArray) + sizeof(void *) * size);
_PyCodeArray *arr = PyMem_Calloc(
1, offsetof(_PyCodeArray, entries) + sizeof(void *) * size);
if (arr == NULL) {
PyErr_NoMemory();
return NULL;
Expand All @@ -2729,8 +2729,9 @@ _PyCodeArray_New(Py_ssize_t size)
static void
copy_code(_Py_CODEUNIT *dst, PyCodeObject *co)
{
int code_len = Py_SIZE(co);
for (int i = 0; i < code_len; i += _PyInstruction_GetLength(co, i)) {
Py_ssize_t code_len = Py_SIZE(co);
for (Py_ssize_t i = 0; i < code_len;
i += _PyInstruction_GetLength(co, i)) {
dst[i] = _Py_GetBaseCodeUnit(co, i);
}
_PyCode_Quicken(dst, code_len);
Expand Down
2 changes: 1 addition & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
goto error;
}
if (frame->bytecode != bytecode) {
int off = frame->instr_ptr - frame->bytecode;
ptrdiff_t off = frame->instr_ptr - frame->bytecode;
frame->bytecode = bytecode;
frame->instr_ptr = frame->bytecode + off;
}
Expand Down

0 comments on commit b104782

Please sign in to comment.