1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
# $Id: systemfuncs.py 11565 2010-06-30 18:17:37Z m9710797 $
class SystemFunction(object):
name = None
@classmethod
def getFunctionName(cls):
return cls.name
@classmethod
def getMakeName(cls):
return cls.name.upper()
@classmethod
def iterHeaders(cls, targetPlatform):
raise NotImplementedError
class FTruncateFunction(SystemFunction):
name = 'ftruncate'
@classmethod
def iterHeaders(cls, targetPlatform):
yield '<unistd.h>'
class ClockGetTimeFunction(SystemFunction):
name = 'clock_gettime'
@classmethod
def iterHeaders(cls, targetPlatform):
yield '<time.h>'
class MMapFunction(SystemFunction):
name = 'mmap'
@classmethod
def iterHeaders(cls, targetPlatform):
if targetPlatform in ('darwin', 'openbsd'):
yield '<sys/types.h>'
yield '<sys/mman.h>'
class PosixMemAlignFunction(SystemFunction):
name = 'posix_memalign'
@classmethod
def iterHeaders(cls, targetPlatform):
yield '<stdlib.h>'
class USleepFunction(SystemFunction):
name = 'usleep'
@classmethod
def iterHeaders(cls, targetPlatform):
yield '<unistd.h>'
# Build a list of system functions using introspection.
def _discoverSystemFunctions(localObjects):
for obj in localObjects:
if isinstance(obj, type) and issubclass(obj, SystemFunction):
if obj is not SystemFunction:
yield obj
systemFunctions = list(_discoverSystemFunctions(locals().itervalues()))
|