mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Tweaks to keep the Microsoft compiler quier.
This commit is contained in:
parent
8017767420
commit
644a12b00c
8 changed files with 36 additions and 19 deletions
|
@ -255,7 +255,7 @@ audioop_avg(self, args)
|
||||||
signed char *cp;
|
signed char *cp;
|
||||||
int len, size, val = 0;
|
int len, size, val = 0;
|
||||||
int i;
|
int i;
|
||||||
float avg = 0.0;
|
double avg = 0.0;
|
||||||
|
|
||||||
if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) )
|
if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -272,7 +272,7 @@ audioop_avg(self, args)
|
||||||
if ( len == 0 )
|
if ( len == 0 )
|
||||||
val = 0;
|
val = 0;
|
||||||
else
|
else
|
||||||
val = (int)(avg / (float)(len/size));
|
val = (int)(avg / (double)(len/size));
|
||||||
return PyInt_FromLong(val);
|
return PyInt_FromLong(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ audioop_rms(self, args)
|
||||||
signed char *cp;
|
signed char *cp;
|
||||||
int len, size, val = 0;
|
int len, size, val = 0;
|
||||||
int i;
|
int i;
|
||||||
float sum_squares = 0.0;
|
double sum_squares = 0.0;
|
||||||
|
|
||||||
if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) )
|
if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -296,12 +296,12 @@ audioop_rms(self, args)
|
||||||
if ( size == 1 ) val = (int)*CHARP(cp, i);
|
if ( size == 1 ) val = (int)*CHARP(cp, i);
|
||||||
else if ( size == 2 ) val = (int)*SHORTP(cp, i);
|
else if ( size == 2 ) val = (int)*SHORTP(cp, i);
|
||||||
else if ( size == 4 ) val = (int)*LONGP(cp, i);
|
else if ( size == 4 ) val = (int)*LONGP(cp, i);
|
||||||
sum_squares += (float)val*(float)val;
|
sum_squares += (double)val*(double)val;
|
||||||
}
|
}
|
||||||
if ( len == 0 )
|
if ( len == 0 )
|
||||||
val = 0;
|
val = 0;
|
||||||
else
|
else
|
||||||
val = (int)sqrt(sum_squares / (float)(len/size));
|
val = (int)sqrt(sum_squares / (double)(len/size));
|
||||||
return PyInt_FromLong(val);
|
return PyInt_FromLong(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ audioop_avgpp(self, args)
|
||||||
int len, size, val = 0, prevval = 0, prevextremevalid = 0,
|
int len, size, val = 0, prevval = 0, prevextremevalid = 0,
|
||||||
prevextreme = 0;
|
prevextreme = 0;
|
||||||
int i;
|
int i;
|
||||||
float avg = 0.0;
|
double avg = 0.0;
|
||||||
int diff, prevdiff, extremediff, nextreme = 0;
|
int diff, prevdiff, extremediff, nextreme = 0;
|
||||||
|
|
||||||
if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) )
|
if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) )
|
||||||
|
@ -544,7 +544,7 @@ audioop_avgpp(self, args)
|
||||||
if ( nextreme == 0 )
|
if ( nextreme == 0 )
|
||||||
val = 0;
|
val = 0;
|
||||||
else
|
else
|
||||||
val = (int)(avg / (float)nextreme);
|
val = (int)(avg / (double)nextreme);
|
||||||
return PyInt_FromLong(val);
|
return PyInt_FromLong(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -572,7 +572,7 @@ PyObject *args;
|
||||||
b = (int) (((value >> 16) & 0xff) / 255. * 3. + .5);
|
b = (int) (((value >> 16) & 0xff) / 255. * 3. + .5);
|
||||||
#endif
|
#endif
|
||||||
nvalue = (r<<5) | (b<<3) | g;
|
nvalue = (r<<5) | (b<<3) | g;
|
||||||
*ncp++ = nvalue;
|
*ncp++ = (unsigned char)nvalue;
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -653,7 +653,7 @@ PyObject *args;
|
||||||
b = (value >> 16) & 0xff;
|
b = (value >> 16) & 0xff;
|
||||||
nvalue = (int)(0.30*r + 0.59*g + 0.11*b);
|
nvalue = (int)(0.30*r + 0.59*g + 0.11*b);
|
||||||
if ( nvalue > 255 ) nvalue = 255;
|
if ( nvalue > 255 ) nvalue = 255;
|
||||||
*ncp++ = nvalue;
|
*ncp++ = (unsigned char)nvalue;
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,15 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
/* Signal module -- many thanks to Lance Ellinghaus */
|
/* Signal module -- many thanks to Lance Ellinghaus */
|
||||||
|
|
||||||
|
/* XXX Signals should be recorded per thread, now we have thread state. */
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "intrcheck.h"
|
#include "intrcheck.h"
|
||||||
|
|
||||||
|
#ifdef MS_WIN32
|
||||||
|
#include <process.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -119,7 +125,8 @@ signal_handler(sig_num)
|
||||||
#endif
|
#endif
|
||||||
is_tripped++;
|
is_tripped++;
|
||||||
Handlers[sig_num].tripped = 1;
|
Handlers[sig_num].tripped = 1;
|
||||||
Py_AddPendingCall((int (*) Py_PROTO((ANY *)))PyErr_CheckSignals, NULL);
|
Py_AddPendingCall(
|
||||||
|
(int (*) Py_PROTO((ANY *)))PyErr_CheckSignals, NULL);
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -417,7 +417,7 @@ getsockaddrarg,PySocketSockObject *,s, PyObject *,args, struct sockaddr **,addr_
|
||||||
if (setipaddr(host, addr) < 0)
|
if (setipaddr(host, addr) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
addr->sin_family = AF_INET;
|
addr->sin_family = AF_INET;
|
||||||
addr->sin_port = htons(port);
|
addr->sin_port = htons((short)port);
|
||||||
*addr_ret = (struct sockaddr *) addr;
|
*addr_ret = (struct sockaddr *) addr;
|
||||||
*len_ret = sizeof *addr;
|
*len_ret = sizeof *addr;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -516,7 +516,9 @@ static PyObject *
|
||||||
BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
|
BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
|
||||||
{
|
{
|
||||||
int block;
|
int block;
|
||||||
|
#ifndef MS_WINDOWS
|
||||||
int delay_flag;
|
int delay_flag;
|
||||||
|
#endif
|
||||||
if (!PyArg_GetInt(args, &block))
|
if (!PyArg_GetInt(args, &block))
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
|
|
@ -182,6 +182,9 @@ typeobject Codetype = {
|
||||||
(hashfunc)code_hash, /*tp_hash*/
|
(hashfunc)code_hash, /*tp_hash*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define NAME_CHARS \
|
||||||
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
|
||||||
|
|
||||||
codeobject *
|
codeobject *
|
||||||
newcodeobject(argcount, nlocals, stacksize, flags,
|
newcodeobject(argcount, nlocals, stacksize, flags,
|
||||||
code, consts, names, varnames, filename, name,
|
code, consts, names, varnames, filename, name,
|
||||||
|
@ -237,7 +240,7 @@ newcodeobject(argcount, nlocals, stacksize, flags,
|
||||||
if (!is_stringobject(v))
|
if (!is_stringobject(v))
|
||||||
continue;
|
continue;
|
||||||
p = getstringvalue(v);
|
p = getstringvalue(v);
|
||||||
if (strspn(p, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz")
|
if ((int)strspn(p, NAME_CHARS)
|
||||||
!= getstringsize(v))
|
!= getstringsize(v))
|
||||||
continue;
|
continue;
|
||||||
PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i));
|
PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i));
|
||||||
|
|
|
@ -503,13 +503,16 @@ load_dynamic_module(name, pathname, fp)
|
||||||
perror(funcname);
|
perror(funcname);
|
||||||
}
|
}
|
||||||
#endif /* hpux */
|
#endif /* hpux */
|
||||||
|
#ifdef USE_SHLIB
|
||||||
got_it:
|
got_it:
|
||||||
|
#endif
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
err_setstr(ImportError,
|
err_setstr(ImportError,
|
||||||
"dynamic module does not define init function");
|
"dynamic module does not define init function");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
(*p)();
|
(*p)();
|
||||||
|
/* XXX Need check for err_occurred() here */
|
||||||
|
|
||||||
m = dictlookup(import_modules, name);
|
m = dictlookup(import_modules, name);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
|
|
|
@ -141,7 +141,7 @@ int base;
|
||||||
*ptr = str;
|
*ptr = str;
|
||||||
if (ovf)
|
if (ovf)
|
||||||
{
|
{
|
||||||
result = ~0;
|
result = (unsigned long) ~0L;
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -186,7 +186,7 @@ setmember(addr, mlist, name, v)
|
||||||
err_badarg();
|
err_badarg();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*(char*)addr = getintvalue(v);
|
*(char*)addr = (char) getintvalue(v);
|
||||||
break;
|
break;
|
||||||
case T_SHORT:
|
case T_SHORT:
|
||||||
case T_USHORT:
|
case T_USHORT:
|
||||||
|
@ -194,7 +194,7 @@ setmember(addr, mlist, name, v)
|
||||||
err_badarg();
|
err_badarg();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*(short*)addr = getintvalue(v);
|
*(short*)addr = (short) getintvalue(v);
|
||||||
break;
|
break;
|
||||||
case T_UINT:
|
case T_UINT:
|
||||||
case T_INT:
|
case T_INT:
|
||||||
|
@ -202,7 +202,7 @@ setmember(addr, mlist, name, v)
|
||||||
err_badarg();
|
err_badarg();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*(int*)addr = getintvalue(v);
|
*(int*)addr = (int) getintvalue(v);
|
||||||
break;
|
break;
|
||||||
case T_LONG:
|
case T_LONG:
|
||||||
if (!is_intobject(v)) {
|
if (!is_intobject(v)) {
|
||||||
|
@ -223,9 +223,10 @@ setmember(addr, mlist, name, v)
|
||||||
break;
|
break;
|
||||||
case T_FLOAT:
|
case T_FLOAT:
|
||||||
if (is_intobject(v))
|
if (is_intobject(v))
|
||||||
*(float*)addr = getintvalue(v);
|
*(float*)addr = (float) getintvalue(v);
|
||||||
else if (is_floatobject(v))
|
else if (is_floatobject(v))
|
||||||
*(float*)addr = getfloatvalue(v);
|
*(float*)addr =
|
||||||
|
(float) getfloatvalue(v);
|
||||||
else {
|
else {
|
||||||
err_badarg();
|
err_badarg();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -233,7 +234,8 @@ setmember(addr, mlist, name, v)
|
||||||
break;
|
break;
|
||||||
case T_DOUBLE:
|
case T_DOUBLE:
|
||||||
if (is_intobject(v))
|
if (is_intobject(v))
|
||||||
*(double*)addr = getintvalue(v);
|
*(double*)addr =
|
||||||
|
(double) getintvalue(v);
|
||||||
else if (is_floatobject(v))
|
else if (is_floatobject(v))
|
||||||
*(double*)addr = getfloatvalue(v);
|
*(double*)addr = getfloatvalue(v);
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue