mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	and a couple of functions that were missed in the previous batches. Not
terribly tested, but very carefully scrutinized, three times.
All these were found by the little findkrc.py that I posted to python-dev,
which means there might be more lurking. Cases such as this:
long
func(a, b)
	long a;
	long b; /* flagword */
{
and other cases where the last ; in the argument list isn't followed by a
newline and an opening curly bracket. Regexps to catch all are welcome, of
course ;)
		
	
			
		
			
				
	
	
		
			77 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * Author: George V. Neville-Neil
 | 
						|
 */
 | 
						|
 | 
						|
#include "Python.h"
 | 
						|
 | 
						|
/* Our stuff... */
 | 
						|
#include "timing.h"
 | 
						|
 | 
						|
static PyObject *
 | 
						|
start_timing(PyObject *self, PyObject *args)
 | 
						|
{
 | 
						|
	if (!PyArg_Parse(args, ""))
 | 
						|
		return NULL;
 | 
						|
 | 
						|
	Py_INCREF(Py_None);
 | 
						|
	BEGINTIMING;
 | 
						|
	return Py_None;
 | 
						|
}
 | 
						|
 | 
						|
static PyObject *
 | 
						|
finish_timing(PyObject *self, PyObject *args)
 | 
						|
{
 | 
						|
	if (!PyArg_Parse(args, ""))
 | 
						|
		return NULL;
 | 
						|
 | 
						|
	ENDTIMING    
 | 
						|
	Py_INCREF(Py_None);
 | 
						|
	return Py_None;
 | 
						|
}
 | 
						|
 | 
						|
static PyObject *
 | 
						|
seconds(PyObject *self, PyObject *args)
 | 
						|
{
 | 
						|
	if (!PyArg_Parse(args, ""))
 | 
						|
		return NULL;
 | 
						|
 | 
						|
	return PyInt_FromLong(TIMINGS);
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
static PyObject *
 | 
						|
milli(PyObject *self, PyObject *args)
 | 
						|
{
 | 
						|
	if (!PyArg_Parse(args, ""))
 | 
						|
		return NULL;
 | 
						|
 | 
						|
	return PyInt_FromLong(TIMINGMS);
 | 
						|
 | 
						|
}
 | 
						|
static PyObject *
 | 
						|
micro(PyObject *self, PyObject *args)
 | 
						|
{
 | 
						|
	if (!PyArg_Parse(args, ""))
 | 
						|
		return NULL;
 | 
						|
 | 
						|
	return PyInt_FromLong(TIMINGUS);
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
static PyMethodDef timing_methods[] = {
 | 
						|
	{"start",   start_timing},
 | 
						|
	{"finish",  finish_timing},
 | 
						|
	{"seconds", seconds},
 | 
						|
	{"milli",   milli},
 | 
						|
	{"micro",   micro},
 | 
						|
	{NULL,      NULL}
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
DL_EXPORT(void) inittiming(void)
 | 
						|
{
 | 
						|
	(void)Py_InitModule("timing", timing_methods);
 | 
						|
	if (PyErr_Occurred())
 | 
						|
		Py_FatalError("can't initialize module timing");
 | 
						|
}
 |