Commit db3968cc authored by Thomas Wouters's avatar Thomas Wouters

Use 'void' directly instead of the ANY #define, now that all code is ANSI C.

Leave the actual #define in for API compatibility.
parent 58e68019
...@@ -40,7 +40,7 @@ DL_IMPORT(int) PyEval_GetRestricted(void); ...@@ -40,7 +40,7 @@ DL_IMPORT(int) PyEval_GetRestricted(void);
DL_IMPORT(int) Py_FlushLine(void); DL_IMPORT(int) Py_FlushLine(void);
DL_IMPORT(int) Py_AddPendingCall(int (*func)(ANY *), ANY *arg); DL_IMPORT(int) Py_AddPendingCall(int (*func)(void *), void *arg);
DL_IMPORT(int) Py_MakePendingCalls(void); DL_IMPORT(int) Py_MakePendingCalls(void);
......
...@@ -12,25 +12,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -12,25 +12,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* Lowest-level memory allocation interface */ /* Lowest-level memory allocation interface */
#ifdef macintosh #define ANY void /* For API compatibility only. Obsolete, do not use. */
#define ANY void
#endif
#ifdef __STDC__
#define ANY void
#endif
#ifdef __TURBOC__
#define ANY void
#endif
#ifdef __GNUC__
#define ANY void
#endif
#ifndef ANY
#define ANY char
#endif
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
...@@ -49,7 +31,7 @@ extern "C" { ...@@ -49,7 +31,7 @@ extern "C" {
#endif #endif
#ifndef NULL #ifndef NULL
#define NULL ((ANY *)0) #define NULL ((void *)0)
#endif #endif
#ifdef MALLOC_ZERO_RETURNS_NULL #ifdef MALLOC_ZERO_RETURNS_NULL
...@@ -87,13 +69,13 @@ extern "C" { ...@@ -87,13 +69,13 @@ extern "C" {
#undef PyCore_REALLOC_PROTO #undef PyCore_REALLOC_PROTO
#undef PyCore_FREE_PROTO #undef PyCore_FREE_PROTO
#define PyCore_MALLOC_PROTO (size_t) #define PyCore_MALLOC_PROTO (size_t)
#define PyCore_REALLOC_PROTO (ANY *, size_t) #define PyCore_REALLOC_PROTO (void *, size_t)
#define PyCore_FREE_PROTO (ANY *) #define PyCore_FREE_PROTO (void *)
#endif #endif
#ifdef NEED_TO_DECLARE_MALLOC_AND_FRIEND #ifdef NEED_TO_DECLARE_MALLOC_AND_FRIEND
extern ANY *PyCore_MALLOC_FUNC PyCore_MALLOC_PROTO; extern void *PyCore_MALLOC_FUNC PyCore_MALLOC_PROTO;
extern ANY *PyCore_REALLOC_FUNC PyCore_REALLOC_PROTO; extern void *PyCore_REALLOC_FUNC PyCore_REALLOC_PROTO;
extern void PyCore_FREE_FUNC PyCore_FREE_PROTO; extern void PyCore_FREE_FUNC PyCore_FREE_PROTO;
#endif #endif
...@@ -134,17 +116,17 @@ extern void PyCore_FREE_FUNC PyCore_FREE_PROTO; ...@@ -134,17 +116,17 @@ extern void PyCore_FREE_FUNC PyCore_FREE_PROTO;
returns a non-NULL pointer, even if the underlying malloc returns a non-NULL pointer, even if the underlying malloc
doesn't. Returned pointers must be checked for NULL explicitly. doesn't. Returned pointers must be checked for NULL explicitly.
No action is performed on failure. */ No action is performed on failure. */
extern DL_IMPORT(ANY *) PyMem_Malloc(size_t); extern DL_IMPORT(void *) PyMem_Malloc(size_t);
extern DL_IMPORT(ANY *) PyMem_Realloc(ANY *, size_t); extern DL_IMPORT(void *) PyMem_Realloc(void *, size_t);
extern DL_IMPORT(void) PyMem_Free(ANY *); extern DL_IMPORT(void) PyMem_Free(void *);
/* Starting from Python 1.6, the wrappers Py_{Malloc,Realloc,Free} are /* Starting from Python 1.6, the wrappers Py_{Malloc,Realloc,Free} are
no longer supported. They used to call PyErr_NoMemory() on failure. */ no longer supported. They used to call PyErr_NoMemory() on failure. */
/* Macros */ /* Macros */
#define PyMem_MALLOC(n) PyCore_MALLOC(n) #define PyMem_MALLOC(n) PyCore_MALLOC(n)
#define PyMem_REALLOC(p, n) PyCore_REALLOC((ANY *)(p), (n)) #define PyMem_REALLOC(p, n) PyCore_REALLOC((void *)(p), (n))
#define PyMem_FREE(p) PyCore_FREE((ANY *)(p)) #define PyMem_FREE(p) PyCore_FREE((void *)(p))
/* /*
* Type-oriented memory interface * Type-oriented memory interface
......
...@@ -101,8 +101,8 @@ recommended to use PyObject_{New, NewVar, Del}. */ ...@@ -101,8 +101,8 @@ recommended to use PyObject_{New, NewVar, Del}. */
#endif #endif
#ifdef NEED_TO_DECLARE_OBJECT_MALLOC_AND_FRIEND #ifdef NEED_TO_DECLARE_OBJECT_MALLOC_AND_FRIEND
extern ANY *PyCore_OBJECT_MALLOC_FUNC PyCore_OBJECT_MALLOC_PROTO; extern void *PyCore_OBJECT_MALLOC_FUNC PyCore_OBJECT_MALLOC_PROTO;
extern ANY *PyCore_OBJECT_REALLOC_FUNC PyCore_OBJECT_REALLOC_PROTO; extern void *PyCore_OBJECT_REALLOC_FUNC PyCore_OBJECT_REALLOC_PROTO;
extern void PyCore_OBJECT_FREE_FUNC PyCore_OBJECT_FREE_PROTO; extern void PyCore_OBJECT_FREE_FUNC PyCore_OBJECT_FREE_PROTO;
#endif #endif
...@@ -137,14 +137,14 @@ extern void PyCore_OBJECT_FREE_FUNC PyCore_OBJECT_FREE_PROTO; ...@@ -137,14 +137,14 @@ extern void PyCore_OBJECT_FREE_FUNC PyCore_OBJECT_FREE_PROTO;
as Python. These wrappers *do not* make sure that allocating 0 as Python. These wrappers *do not* make sure that allocating 0
bytes returns a non-NULL pointer. Returned pointers must be checked bytes returns a non-NULL pointer. Returned pointers must be checked
for NULL explicitly; no action is performed on failure. */ for NULL explicitly; no action is performed on failure. */
extern DL_IMPORT(ANY *) PyObject_Malloc(size_t); extern DL_IMPORT(void *) PyObject_Malloc(size_t);
extern DL_IMPORT(ANY *) PyObject_Realloc(ANY *, size_t); extern DL_IMPORT(void *) PyObject_Realloc(void *, size_t);
extern DL_IMPORT(void) PyObject_Free(ANY *); extern DL_IMPORT(void) PyObject_Free(void *);
/* Macros */ /* Macros */
#define PyObject_MALLOC(n) PyCore_OBJECT_MALLOC(n) #define PyObject_MALLOC(n) PyCore_OBJECT_MALLOC(n)
#define PyObject_REALLOC(op, n) PyCore_OBJECT_REALLOC((ANY *)(op), (n)) #define PyObject_REALLOC(op, n) PyCore_OBJECT_REALLOC((void *)(op), (n))
#define PyObject_FREE(op) PyCore_OBJECT_FREE((ANY *)(op)) #define PyObject_FREE(op) PyCore_OBJECT_FREE((void *)(op))
/* /*
* Generic object allocator interface * Generic object allocator interface
......
...@@ -18,7 +18,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -18,7 +18,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#define RTLD_LAZY 1 #define RTLD_LAZY 1
#endif #endif
typedef ANY *PyUnivPtr; typedef void *PyUnivPtr;
typedef struct { typedef struct {
PyObject_HEAD PyObject_HEAD
PyUnivPtr *dl_handle; PyUnivPtr *dl_handle;
......
...@@ -633,7 +633,7 @@ PyErr_SetInterrupt(void) ...@@ -633,7 +633,7 @@ PyErr_SetInterrupt(void)
{ {
is_tripped++; is_tripped++;
Handlers[SIGINT].tripped = 1; Handlers[SIGINT].tripped = 1;
Py_AddPendingCall((int (*)(ANY *))PyErr_CheckSignals, NULL); Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL);
} }
void void
......
...@@ -799,7 +799,7 @@ PySocketSock_setsockopt(PySocketSockObject *s, PyObject *args) ...@@ -799,7 +799,7 @@ PySocketSock_setsockopt(PySocketSockObject *s, PyObject *args)
&level, &optname, &buf, &buflen)) &level, &optname, &buf, &buflen))
return NULL; return NULL;
} }
res = setsockopt(s->sock_fd, level, optname, (ANY *)buf, buflen); res = setsockopt(s->sock_fd, level, optname, (void *)buf, buflen);
if (res < 0) if (res < 0)
return PySocket_Err(); return PySocket_Err();
Py_INCREF(Py_None); Py_INCREF(Py_None);
...@@ -841,7 +841,7 @@ PySocketSock_getsockopt(PySocketSockObject *s, PyObject *args) ...@@ -841,7 +841,7 @@ PySocketSock_getsockopt(PySocketSockObject *s, PyObject *args)
int flag = 0; int flag = 0;
socklen_t flagsize = sizeof flag; socklen_t flagsize = sizeof flag;
res = getsockopt(s->sock_fd, level, optname, res = getsockopt(s->sock_fd, level, optname,
(ANY *)&flag, &flagsize); (void *)&flag, &flagsize);
if (res < 0) if (res < 0)
return PySocket_Err(); return PySocket_Err();
return PyInt_FromLong(flag); return PyInt_FromLong(flag);
...@@ -855,7 +855,7 @@ PySocketSock_getsockopt(PySocketSockObject *s, PyObject *args) ...@@ -855,7 +855,7 @@ PySocketSock_getsockopt(PySocketSockObject *s, PyObject *args)
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
res = getsockopt(s->sock_fd, level, optname, res = getsockopt(s->sock_fd, level, optname,
(ANY *)PyString_AsString(buf), &buflen); (void *)PyString_AsString(buf), &buflen);
if (res < 0) { if (res < 0) {
Py_DECREF(buf); Py_DECREF(buf);
return PySocket_Err(); return PySocket_Err();
...@@ -1230,7 +1230,7 @@ PySocketSock_recvfrom(PySocketSockObject *s, PyObject *args) ...@@ -1230,7 +1230,7 @@ PySocketSock_recvfrom(PySocketSockObject *s, PyObject *args)
#if defined(PYOS_OS2) #if defined(PYOS_OS2)
(struct sockaddr *)addrbuf, &addrlen (struct sockaddr *)addrbuf, &addrlen
#else #else
(ANY *)addrbuf, &addrlen (void *)addrbuf, &addrlen
#endif #endif
#else #else
(struct sockaddr *)addrbuf, &addrlen (struct sockaddr *)addrbuf, &addrlen
......
...@@ -293,7 +293,7 @@ static int ...@@ -293,7 +293,7 @@ static int
gettmarg(PyObject *args, struct tm *p) gettmarg(PyObject *args, struct tm *p)
{ {
int y; int y;
memset((ANY *) p, '\0', sizeof(struct tm)); memset((void *) p, '\0', sizeof(struct tm));
if (!PyArg_Parse(args, "(iiiiiiiii)", if (!PyArg_Parse(args, "(iiiiiiiii)",
&y, &y,
...@@ -343,7 +343,7 @@ time_strftime(PyObject *self, PyObject *args) ...@@ -343,7 +343,7 @@ time_strftime(PyObject *self, PyObject *args)
char *outbuf = 0; char *outbuf = 0;
size_t i; size_t i;
memset((ANY *) &buf, '\0', sizeof(buf)); memset((void *) &buf, '\0', sizeof(buf));
if (!PyArg_ParseTuple(args, "sO:strftime", &fmt, &tup) if (!PyArg_ParseTuple(args, "sO:strftime", &fmt, &tup)
|| !gettmarg(tup, &buf)) || !gettmarg(tup, &buf))
...@@ -398,7 +398,7 @@ time_strptime(PyObject *self, PyObject *args) ...@@ -398,7 +398,7 @@ time_strptime(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s|s:strptime", &buf, &fmt)) if (!PyArg_ParseTuple(args, "s|s:strptime", &buf, &fmt))
return NULL; return NULL;
memset((ANY *) &tm, '\0', sizeof(tm)); memset((void *) &tm, '\0', sizeof(tm));
s = strptime(buf, fmt, &tm); s = strptime(buf, fmt, &tm);
if (s == NULL) { if (s == NULL) {
PyErr_SetString(PyExc_ValueError, "format mismatch"); PyErr_SetString(PyExc_ValueError, "format mismatch");
......
...@@ -1258,8 +1258,8 @@ PyList_AsTuple(PyObject *v) ...@@ -1258,8 +1258,8 @@ PyList_AsTuple(PyObject *v)
if (w == NULL) if (w == NULL)
return NULL; return NULL;
p = ((PyTupleObject *)w)->ob_item; p = ((PyTupleObject *)w)->ob_item;
memcpy((ANY *)p, memcpy((void *)p,
(ANY *)((PyListObject *)v)->ob_item, (void *)((PyListObject *)v)->ob_item,
n*sizeof(PyObject *)); n*sizeof(PyObject *));
while (--n >= 0) { while (--n >= 0) {
Py_INCREF(*p); Py_INCREF(*p);
......
...@@ -962,7 +962,7 @@ int (*_Py_abstract_hack)(PyObject *) = &PyObject_Size; ...@@ -962,7 +962,7 @@ int (*_Py_abstract_hack)(PyObject *) = &PyObject_Size;
/* Python's malloc wrappers (see mymalloc.h) */ /* Python's malloc wrappers (see mymalloc.h) */
ANY * void *
PyMem_Malloc(size_t nbytes) PyMem_Malloc(size_t nbytes)
{ {
#if _PyMem_EXTRA > 0 #if _PyMem_EXTRA > 0
...@@ -972,8 +972,8 @@ PyMem_Malloc(size_t nbytes) ...@@ -972,8 +972,8 @@ PyMem_Malloc(size_t nbytes)
return PyMem_MALLOC(nbytes); return PyMem_MALLOC(nbytes);
} }
ANY * void *
PyMem_Realloc(ANY *p, size_t nbytes) PyMem_Realloc(void *p, size_t nbytes)
{ {
#if _PyMem_EXTRA > 0 #if _PyMem_EXTRA > 0
if (nbytes == 0) if (nbytes == 0)
...@@ -983,7 +983,7 @@ PyMem_Realloc(ANY *p, size_t nbytes) ...@@ -983,7 +983,7 @@ PyMem_Realloc(ANY *p, size_t nbytes)
} }
void void
PyMem_Free(ANY *p) PyMem_Free(void *p)
{ {
PyMem_FREE(p); PyMem_FREE(p);
} }
...@@ -991,20 +991,20 @@ PyMem_Free(ANY *p) ...@@ -991,20 +991,20 @@ PyMem_Free(ANY *p)
/* Python's object malloc wrappers (see objimpl.h) */ /* Python's object malloc wrappers (see objimpl.h) */
ANY * void *
PyObject_Malloc(size_t nbytes) PyObject_Malloc(size_t nbytes)
{ {
return PyObject_MALLOC(nbytes); return PyObject_MALLOC(nbytes);
} }
ANY * void *
PyObject_Realloc(ANY *p, size_t nbytes) PyObject_Realloc(void *p, size_t nbytes)
{ {
return PyObject_REALLOC(p, nbytes); return PyObject_REALLOC(p, nbytes);
} }
void void
PyObject_Free(ANY *p) PyObject_Free(void *p)
{ {
PyObject_FREE(p); PyObject_FREE(p);
} }
......
...@@ -18,11 +18,10 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -18,11 +18,10 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#endif #endif
#include "myproto.h" #include "myproto.h"
#include "mymalloc.h" /* For ANY */
#include "intrcheck.h" #include "intrcheck.h"
/* Copied here from ceval.h -- can't include that file. */ /* Copied here from ceval.h -- can't include that file. */
int Py_AddPendingCall(int (*func)(ANY *), ANY *arg); int Py_AddPendingCall(int (*func)(void *), void *arg);
#ifdef QUICKWIN #ifdef QUICKWIN
......
...@@ -210,15 +210,15 @@ PyEval_RestoreThread(PyThreadState *tstate) ...@@ -210,15 +210,15 @@ PyEval_RestoreThread(PyThreadState *tstate)
#define NPENDINGCALLS 32 #define NPENDINGCALLS 32
static struct { static struct {
int (*func)(ANY *); int (*func)(void *);
ANY *arg; void *arg;
} pendingcalls[NPENDINGCALLS]; } pendingcalls[NPENDINGCALLS];
static volatile int pendingfirst = 0; static volatile int pendingfirst = 0;
static volatile int pendinglast = 0; static volatile int pendinglast = 0;
static volatile int things_to_do = 0; static volatile int things_to_do = 0;
int int
Py_AddPendingCall(int (*func)(ANY *), ANY *arg) Py_AddPendingCall(int (*func)(void *), void *arg)
{ {
static int busy = 0; static int busy = 0;
int i, j; int i, j;
...@@ -255,8 +255,8 @@ Py_MakePendingCalls(void) ...@@ -255,8 +255,8 @@ Py_MakePendingCalls(void)
things_to_do = 0; things_to_do = 0;
for (;;) { for (;;) {
int i; int i;
int (*func)(ANY *); int (*func)(void *);
ANY *arg; void *arg;
i = pendingfirst; i = pendingfirst;
if (i == pendinglast) if (i == pendinglast)
break; /* Queue empty */ break; /* Queue empty */
......
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