Annotation of parser3/src/include/pa_os.h, revision 1.18

1.1       paf         1: /** @file
                      2:        Parser: commonly used functions.
                      3: 
1.15      moko        4:        Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com)
1.13      moko        5:        Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru>
1.1       paf         6: */
                      7: 
                      8: #ifndef PA_OS_H
                      9: #define PA_OS_H
                     10: 
1.18    ! moko       11: #define IDENT_PA_OS_H "$Id: pa_os.h,v 1.17 2026/10/23 20:48:48 moko Exp $"
1.6       misha      12: 
1.7       misha      13: #define PA_LOCK_ATTEMPTS 20
                     14: #define PA_LOCK_WAIT_TIMEOUT_SECS 0
                     15: #define PA_LOCK_WAIT_TIMEOUT_USECS 500000
1.6       misha      16: 
1.17      moko       17: extern unsigned int pa_lock_attempts; // not thread local: never changes
1.10      moko       18: 
1.6       misha      19: // 'blocking' mean we will wait till other process release lock 
                     20: // but we'll make PA_LOCK_ATTEMPTS attempts with PA_LOCK_WAIT_TIMEOUT secs delaus between attempts 
                     21: // 'nonblocking' mean we will make only 1 attempt without waiting
1.1       paf        22: 
                     23: int pa_lock_shared_blocking(int fd);
                     24: int pa_lock_exclusive_blocking(int fd);
                     25: int pa_lock_exclusive_nonblocking(int fd);
                     26: int pa_unlock(int fd);
                     27: 
1.2       paf        28: /// yields to OS for secs secs and usecs microseconds (1E-6)
1.1       paf        29: int pa_sleep(unsigned long secs, unsigned long usecs);
                     30: 
1.18    ! moko       31: /// ctime in the buffer of the calling thread, valid till the next call; empty string on error
        !            32: const char *pa_ctime(time_t t);
        !            33: 
        !            34: /// timer started with pa_timer_start
        !            35: typedef void *pa_timer;
        !            36: 
        !            37: /// calls the signal handler in the calling thread after secs seconds and then every interval seconds if it is not 0
        !            38: /// The handler interrupts the blocking calls (EINTR), it must be async-signal-safe, one handler is used by all timers
        !            39: /// Linux only, returns false elsewhere or on error
        !            40: bool pa_timer_start(pa_timer *timer, int secs, int interval, void (*handler)(int));
        !            41: void pa_timer_stop(pa_timer timer);
        !            42: 
1.16      moko       43: #ifdef _MSC_VER
                     44: /// sets errno from GetLastError(), as CRT does, if the passed windows api call result is zero; returns it
                     45: int pa_set_errno(int status);
                     46: #endif
                     47: 
1.1       paf        48: #endif

E-mail: