summaryrefslogtreecommitdiff
path: root/docs/examples/userguide/external_C_code/platform_adaptation.pyx
blob: fa193f83d9cc39d5a3115d4e9808f7a032d13187 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cdef extern from *:
    """
    #if defined(_WIN32) || defined(MS_WINDOWS) || defined(_MSC_VER)
      #define WIN32_LEAN_AND_MEAN
      #include <windows.h>
      #define myapp_sleep(m)  Sleep(m)
    #else
      #include <unistd.h>
      #define myapp_sleep(m)  ((void) usleep((m) * 1000))
    #endif
    """
    # using "myapp_" prefix in the C code to prevent C naming conflicts
    void msleep "myapp_sleep"(int milliseconds) nogil

msleep(milliseconds=1)