@@ -148,15 +148,14 @@ Calling functions
148148^^^^^^^^^^^^^^^^^
149149
150150You can call these functions like any other Python callable. This example uses
151- the ``time() `` function, which returns system time in seconds since the Unix
152- epoch, and the ``GetModuleHandleA() `` function, which returns a win32 module
153- handle.
151+ the ``rand() `` function, which takes no arguments and returns a pseudo-random integer::
154152
155- This example calls both functions with a ``NULL `` pointer (``None `` should be used
156- as the ``NULL `` pointer)::
153+ >>> print(libc.rand()) # doctest: +SKIP
154+ 1804289383
155+
156+ On Windows, you can call the ``GetModuleHandleA() `` function, which returns a win32 module
157+ handle (passing ``None `` as single argument to call it with a ``NULL `` pointer)::
157158
158- >>> print(libc.time(None)) # doctest: +SKIP
159- 1150640792
160159 >>> print(hex(windll.kernel32.GetModuleHandleA(None))) # doctest: +WINDOWS
161160 0x1d000000
162161 >>>
@@ -247,6 +246,8 @@ Fundamental data types
247246| :class: `c_ssize_t ` | :c:type: `ssize_t ` or | int |
248247| | :c:type: `Py_ssize_t ` | |
249248+----------------------+------------------------------------------+----------------------------+
249+ | :class: `c_time_t ` | :c:type: `time_t ` | int |
250+ +----------------------+------------------------------------------+----------------------------+
250251| :class: `c_float ` | :c:type: `float ` | float |
251252+----------------------+------------------------------------------+----------------------------+
252253| :class: `c_double ` | :c:type: `double ` | float |
@@ -447,6 +448,21 @@ By default functions are assumed to return the C :c:type:`int` type. Other
447448return types can be specified by setting the :attr: `restype ` attribute of the
448449function object.
449450
451+ The C prototype of ``time() `` is ``time_t time(time_t *) ``. Because ``time_t ``
452+ might be of a different type than the default return type ``int ``, you should
453+ specify the ``restype ``::
454+
455+ >>> libc.time.restype = c_time_t
456+
457+ The argument types can be specified using ``argtypes ``::
458+
459+ >>> libc.time.argtypes = (POINTER(c_time_t),)
460+
461+ To call the function with a ``NULL `` pointer as first argument, use ``None ``::
462+
463+ >>> print(libc.time(None)) # doctest: +SKIP
464+ 1150640792
465+
450466Here is a more advanced example, it uses the ``strchr `` function, which expects
451467a string pointer and a char, and returns a pointer to a string::
452468
@@ -2275,6 +2291,13 @@ These are the fundamental ctypes data types:
22752291 .. versionadded :: 3.2
22762292
22772293
2294+ .. class :: c_time_t
2295+
2296+ Represents the C :c:type: `time_t ` datatype.
2297+
2298+ .. versionadded :: 3.12
2299+
2300+
22782301.. class :: c_ubyte
22792302
22802303 Represents the C :c:type: `unsigned char ` datatype, it interprets the value as
0 commit comments