bpo-6532: Make the thread id an unsigned integer. (#781) · python/cpython@aefa7eb (original) (raw)

`@@ -267,7 +267,7 @@ static PyTypeObject Locktype = {

`

267

267

`typedef struct {

`

268

268

`PyObject_HEAD

`

269

269

`PyThread_type_lock rlock_lock;

`

270

``

`-

long rlock_owner;

`

``

270

`+

unsigned long rlock_owner;

`

271

271

`unsigned long rlock_count;

`

272

272

`PyObject *in_weakreflist;

`

273

273

`} rlockobject;

`

`@@ -293,7 +293,7 @@ static PyObject *

`

293

293

`rlock_acquire(rlockobject *self, PyObject *args, PyObject *kwds)

`

294

294

`{

`

295

295

`_PyTime_t timeout;

`

296

``

`-

long tid;

`

``

296

`+

unsigned long tid;

`

297

297

`PyLockStatus r = PY_LOCK_ACQUIRED;

`

298

298

``

299

299

`if (lock_acquire_parse_args(args, kwds, &timeout) < 0)

`

`@@ -342,7 +342,7 @@ the lock is taken and its internal counter initialized to 1.");

`

342

342

`static PyObject *

`

343

343

`rlock_release(rlockobject *self)

`

344

344

`{

`

345

``

`-

long tid = PyThread_get_thread_ident();

`

``

345

`+

unsigned long tid = PyThread_get_thread_ident();

`

346

346

``

347

347

`if (self->rlock_count == 0 || self->rlock_owner != tid) {

`

348

348

`PyErr_SetString(PyExc_RuntimeError,

`

`@@ -371,11 +371,11 @@ to be available for other threads.");

`

371

371

`static PyObject *

`

372

372

`rlock_acquire_restore(rlockobject *self, PyObject *args)

`

373

373

`{

`

374

``

`-

long owner;

`

``

374

`+

unsigned long owner;

`

375

375

`unsigned long count;

`

376

376

`int r = 1;

`

377

377

``

378

``

`-

if (!PyArg_ParseTuple(args, "(kl):_acquire_restore", &count, &owner))

`

``

378

`+

if (!PyArg_ParseTuple(args, "(kk):_acquire_restore", &count, &owner))

`

379

379

`return NULL;

`

380

380

``

381

381

`if (!PyThread_acquire_lock(self->rlock_lock, 0)) {

`

`` @@ -401,7 +401,7 @@ For internal use by threading.Condition.");

``

401

401

`static PyObject *

`

402

402

`rlock_release_save(rlockobject *self)

`

403

403

`{

`

404

``

`-

long owner;

`

``

404

`+

unsigned long owner;

`

405

405

`unsigned long count;

`

406

406

``

407

407

`if (self->rlock_count == 0) {

`

`@@ -415,7 +415,7 @@ rlock_release_save(rlockobject *self)

`

415

415

`self->rlock_count = 0;

`

416

416

`self->rlock_owner = 0;

`

417

417

`PyThread_release_lock(self->rlock_lock);

`

418

``

`-

return Py_BuildValue("kl", count, owner);

`

``

418

`+

return Py_BuildValue("kk", count, owner);

`

419

419

`}

`

420

420

``

421

421

`PyDoc_STRVAR(rlock_release_save_doc,

`

`` @@ -427,7 +427,7 @@ For internal use by threading.Condition.");

``

427

427

`static PyObject *

`

428

428

`rlock_is_owned(rlockobject *self)

`

429

429

`{

`

430

``

`-

long tid = PyThread_get_thread_ident();

`

``

430

`+

unsigned long tid = PyThread_get_thread_ident();

`

431

431

``

432

432

`if (self->rlock_count > 0 && self->rlock_owner == tid) {

`

433

433

`Py_RETURN_TRUE;

`

`@@ -1031,7 +1031,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)

`

1031

1031

`{

`

1032

1032

`PyObject *func, *args, *keyw = NULL;

`

1033

1033

`struct bootstate *boot;

`

1034

``

`-

long ident;

`

``

1034

`+

unsigned long ident;

`

1035

1035

``

1036

1036

`if (!PyArg_UnpackTuple(fargs, "start_new_thread", 2, 3,

`

1037

1037

`&func, &args, &keyw))

`

`@@ -1068,7 +1068,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)

`

1068

1068

`Py_XINCREF(keyw);

`

1069

1069

`PyEval_InitThreads(); /* Start the interpreter's thread-awareness */

`

1070

1070

`ident = PyThread_start_new_thread(t_bootstrap, (void*) boot);

`

1071

``

`-

if (ident == -1) {

`

``

1071

`+

if (ident == PYTHREAD_INVALID_THREAD_ID) {

`

1072

1072

`PyErr_SetString(ThreadError, "can't start new thread");

`

1073

1073

`Py_DECREF(func);

`

1074

1074

`Py_DECREF(args);

`

`@@ -1077,7 +1077,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)

`

1077

1077

`PyMem_DEL(boot);

`

1078

1078

`return NULL;

`

1079

1079

` }

`

1080

``

`-

return PyLong_FromLong(ident);

`

``

1080

`+

return PyLong_FromUnsignedLong(ident);

`

1081

1081

`}

`

1082

1082

``

1083

1083

`PyDoc_STRVAR(start_new_doc,

`

`@@ -1137,13 +1137,12 @@ information about locks.");

`

1137

1137

`static PyObject *

`

1138

1138

`thread_get_ident(PyObject *self)

`

1139

1139

`{

`

1140

``

`-

long ident;

`

1141

``

`-

ident = PyThread_get_thread_ident();

`

1142

``

`-

if (ident == -1) {

`

``

1140

`+

unsigned long ident = PyThread_get_thread_ident();

`

``

1141

`+

if (ident == PYTHREAD_INVALID_THREAD_ID) {

`

1143

1142

`PyErr_SetString(ThreadError, "no current thread ident");

`

1144

1143

`return NULL;

`

1145

1144

` }

`

1146

``

`-

return PyLong_FromLong(ident);

`

``

1145

`+

return PyLong_FromUnsignedLong(ident);

`

1147

1146

`}

`

1148

1147

``

1149

1148

`PyDoc_STRVAR(get_ident_doc,

`