Commit 7b782b61 authored by Anthony Baxter's avatar Anthony Baxter

more low-hanging fruit to make code compile under a C++ compiler. Not

entirely happy with the two new VISIT macros in compile.c, but I
couldn't see a better approach.
parent 9176fc14
...@@ -136,7 +136,7 @@ char * ...@@ -136,7 +136,7 @@ char *
PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
{ {
size_t n = 1000; size_t n = 1000;
char *p = PyMem_MALLOC(n); char *p = (char *)PyMem_MALLOC(n);
char *q; char *q;
if (p == NULL) if (p == NULL)
return NULL; return NULL;
...@@ -149,7 +149,7 @@ PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) ...@@ -149,7 +149,7 @@ PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
n = strlen(p); n = strlen(p);
if (n > 0 && p[n-1] != '\n') if (n > 0 && p[n-1] != '\n')
p[n-1] = '\n'; p[n-1] = '\n';
return PyMem_REALLOC(p, n+1); return (char *)PyMem_REALLOC(p, n+1);
} }
/* No-nonsense fgets */ /* No-nonsense fgets */
......
This diff is collapsed.
...@@ -19,7 +19,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename) ...@@ -19,7 +19,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
names = s->v.ImportFrom.names; names = s->v.ImportFrom.names;
for (i = 0; i < asdl_seq_LEN(names); i++) { for (i = 0; i < asdl_seq_LEN(names); i++) {
alias_ty name = asdl_seq_GET(names, i); alias_ty name = (alias_ty)asdl_seq_GET(names, i);
const char *feature = PyString_AsString(name->name); const char *feature = PyString_AsString(name->name);
if (!feature) if (!feature)
return 0; return 0;
...@@ -73,7 +73,7 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) ...@@ -73,7 +73,7 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
for (i = 0; i < asdl_seq_LEN(mod->v.Module.body); i++) { for (i = 0; i < asdl_seq_LEN(mod->v.Module.body); i++) {
stmt_ty s = asdl_seq_GET(mod->v.Module.body, i); stmt_ty s = (stmt_ty)asdl_seq_GET(mod->v.Module.body, i);
if (done && s->lineno > prev_line) if (done && s->lineno > prev_line)
return 1; return 1;
......
...@@ -105,14 +105,14 @@ block_alloc(block *b, size_t size) ...@@ -105,14 +105,14 @@ block_alloc(block *b, size_t size)
the default block, allocate a one-off block that is the default block, allocate a one-off block that is
exactly the right size. */ exactly the right size. */
/* TODO(jhylton): Think about space waste at end of block */ /* TODO(jhylton): Think about space waste at end of block */
block *new = block_new( block *newbl = block_new(
size < DEFAULT_BLOCK_SIZE ? size < DEFAULT_BLOCK_SIZE ?
DEFAULT_BLOCK_SIZE : size); DEFAULT_BLOCK_SIZE : size);
if (!new) if (!newbl)
return NULL; return NULL;
assert(!b->ab_next); assert(!b->ab_next);
b->ab_next = new; b->ab_next = newbl;
b = new; b = newbl;
} }
assert(b->ab_offset + size <= b->ab_size); assert(b->ab_offset + size <= b->ab_size);
......
...@@ -297,23 +297,23 @@ PyThreadState_Get(void) ...@@ -297,23 +297,23 @@ PyThreadState_Get(void)
PyThreadState * PyThreadState *
PyThreadState_Swap(PyThreadState *new) PyThreadState_Swap(PyThreadState *newts)
{ {
PyThreadState *old = _PyThreadState_Current; PyThreadState *oldts = _PyThreadState_Current;
_PyThreadState_Current = new; _PyThreadState_Current = newts;
/* It should not be possible for more than one thread state /* It should not be possible for more than one thread state
to be used for a thread. Check this the best we can in debug to be used for a thread. Check this the best we can in debug
builds. builds.
*/ */
#if defined(Py_DEBUG) && defined(WITH_THREAD) #if defined(Py_DEBUG) && defined(WITH_THREAD)
if (new) { if (newts) {
PyThreadState *check = PyGILState_GetThisThreadState(); PyThreadState *check = PyGILState_GetThisThreadState();
if (check && check->interp == new->interp && check != new) if (check && check->interp == newts->interp && check != newts)
Py_FatalError("Invalid thread state for this thread"); Py_FatalError("Invalid thread state for this thread");
} }
#endif #endif
return old; return oldts;
} }
/* An extension mechanism to store arbitrary additional per-thread state. /* An extension mechanism to store arbitrary additional per-thread state.
...@@ -491,7 +491,7 @@ PyGILState_Ensure(void) ...@@ -491,7 +491,7 @@ PyGILState_Ensure(void)
called Py_Initialize() and usually PyEval_InitThreads(). called Py_Initialize() and usually PyEval_InitThreads().
*/ */
assert(autoInterpreterState); /* Py_Initialize() hasn't been called! */ assert(autoInterpreterState); /* Py_Initialize() hasn't been called! */
tcur = PyThread_get_key_value(autoTLSkey); tcur = (PyThreadState *)PyThread_get_key_value(autoTLSkey);
if (tcur == NULL) { if (tcur == NULL) {
/* Create a new thread state for this thread */ /* Create a new thread state for this thread */
tcur = PyThreadState_New(autoInterpreterState); tcur = PyThreadState_New(autoInterpreterState);
...@@ -518,7 +518,8 @@ PyGILState_Ensure(void) ...@@ -518,7 +518,8 @@ PyGILState_Ensure(void)
void void
PyGILState_Release(PyGILState_STATE oldstate) PyGILState_Release(PyGILState_STATE oldstate)
{ {
PyThreadState *tcur = PyThread_get_key_value(autoTLSkey); PyThreadState *tcur = (PyThreadState *)PyThread_get_key_value(
autoTLSkey);
if (tcur == NULL) if (tcur == NULL)
Py_FatalError("auto-releasing thread-state, " Py_FatalError("auto-releasing thread-state, "
"but no thread-state for this thread"); "but no thread-state for this thread");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment