9 # error The POSIX.1-1990 API has no C++ binding!
24 # error Never include this header more than once!
37 #if CFG_USE_POSIX_API >= 202405L
38 # define _POSIX_C_SOURCE 202405L
39 #elif CFG_USE_POSIX_API == 200809L
40 # define _POSIX_C_SOURCE 200809L
41 #elif CFG_USE_POSIX_API == 200112L
46 # define _POSIX_C_SOURCE 200112L
53 # define _POSIX_C_SOURCE 199506L
57 # if CFG_USE_POSIX_API == 202405L
63 # define _XOPEN_SOURCE 800
64 # elif CFG_USE_POSIX_API == 200809L
70 # define _XOPEN_SOURCE 700
71 # elif CFG_USE_POSIX_API == 200112L
77 # define _XOPEN_SOURCE 600
84 # define _XOPEN_SOURCE 500
92 #if defined(__hpux) && CFG_USE_XSI
93 # define _HPUX_ALT_XOPEN_SOCKET_API 1
96 #include <sys/types.h>
110 #define api_posix_struct_timespec struct timespec
112 #define api_posix_nanosleep nanosleep
115 # define api_posix_fsync fsync
117 int api_posix_fsync(
int);
124 #define API_POSIX_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
125 #define API_POSIX_PTHREAD_COND_INITIALIZER PTHREAD_COND_INITIALIZER
126 #define API_POSIX_PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
128 #define api_posix_pthread_t pthread_t
129 #define api_posix_pthread_mutex_t pthread_mutex_t
130 #define api_posix_pthread_cond_t pthread_cond_t
132 #define api_posix_pthread_create pthread_create
133 #define api_posix_pthread_cancel pthread_cancel
134 #define api_posix_pthread_setcancelstate pthread_setcancelstate
135 #define api_posix_pthread_join pthread_join
136 #define api_posix_pthread_self pthread_self
137 #define api_posix_pthread_equal pthread_equal
138 #define api_posix_pthread_sigmask pthread_sigmask
139 #define api_posix_pthread_cleanup_push pthread_cleanup_push
140 #define api_posix_pthread_cleanup_pop pthread_cleanup_pop
141 #define api_posix_pthread_mutex_lock pthread_mutex_lock
142 #define api_posix_pthread_mutex_trylock pthread_mutex_trylock
143 #define api_posix_pthread_mutex_unlock pthread_mutex_unlock
144 #define api_posix_pthread_cond_wait pthread_cond_wait
145 #define api_posix_pthread_cond_signal pthread_cond_signal
153 #define api_posix_popen popen
154 #define api_posix_pclose pclose
160 #if CFG_HDR_INTTYPES_H
161 # include <inttypes.h>
164 #define API_POSIX_INT_MAX INT_MAX
165 #define API_POSIX_UINT_MAX UINT_MAX
166 #define API_POSIX_LONG_MAX LONG_MAX
167 #define API_POSIX_ULONG_MAX ULONG_MAX
168 #define API_POSIX_SSIZE_MAX SSIZE_MAX
170 # define API_POSIX_SIZE_MAX SIZE_MAX
172 # define API_POSIX_SIZE_MAX ((size_t) API_POSIX_SSIZE_MAX * (size_t) 2)
180 extern char** environ;
181 #define api_posix_environ environ
184 #define API_POSIX_EXIT_SUCCESS EXIT_SUCCESS
185 #define API_POSIX_EXIT_FAILURE EXIT_FAILURE
191 #include <sys/utsname.h>
193 #define api_posix_struct_utsname struct utsname
195 #define api_posix_uname uname
201 #define API_POSIX_EACCES EACCES
202 #define API_POSIX_EAFNOSUPPORT EAFNOSUPPORT
203 #define API_POSIX_EAGAIN EAGAIN
204 #define API_POSIX_EBADF EBADF
205 #define API_POSIX_ECONNREFUSED ECONNREFUSED
206 #define API_POSIX_EEXIST EEXIST
207 #define API_POSIX_EINTR EINTR
208 #define API_POSIX_EINPROGRESS EINPROGRESS
209 #define API_POSIX_EINVAL EINVAL
210 #define API_POSIX_EIO EIO
211 #define API_POSIX_ENOENT ENOENT
212 #define API_POSIX_ENOMEM ENOMEM
213 #define API_POSIX_ENOPROTOOPT ENOPROTOOPT
214 #define API_POSIX_ENOSYS ENOSYS
215 #define API_POSIX_ENOTSOCK ENOTSOCK
216 #define API_POSIX_EOVERFLOW EOVERFLOW
218 #define api_posix_errno errno
226 #define api_posix_sig_atomic_t sig_atomic_t
228 #define api_posix_struct_sigaction struct sigaction
230 #define API_POSIX_SIGHUP SIGHUP
231 #define API_POSIX_SIGINT SIGINT
232 #define API_POSIX_SIGPIPE SIGPIPE
233 #define API_POSIX_SIGQUIT SIGQUIT
234 #define API_POSIX_SIGTERM SIGTERM
236 #define API_POSIX_SIG_DFL SIG_DFL
237 #define API_POSIX_SIG_IGN SIG_IGN
239 #define API_POSIX_SIG_BLOCK SIG_BLOCK
240 #define API_POSIX_SIG_SETMASK SIG_SETMASK
242 #define api_posix_sigset_t sigset_t
244 #define api_posix_kill kill
245 #define api_posix_sigemptyset sigemptyset
246 #define api_posix_sigaddset sigaddset
247 #define api_posix_sigaction sigaction
253 #include <sys/wait.h>
255 #define api_posix_pid_t pid_t
257 #define API_POSIX_WIFEXITED WIFEXITED
258 #define API_POSIX_WEXITSTATUS WEXITSTATUS
260 #define API_POSIX_WNOHANG WNOHANG
262 #define api_posix_fork fork
263 #define api_posix_execl execl
264 #define api_posix_execlp execlp
265 #define api_posix_waitpid waitpid
266 #define api_posix_getpid getpid
272 #define api_posix_time_t time_t
273 #define api_posix_struct_tm struct tm
275 #define api_posix_time time
277 #define api_posix_gmtime_r gmtime_r
278 #define api_posix_localtime_r localtime_r
281 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI
282 # define api_posix_strftime strftime
286 # include <sys/time.h>
288 # define api_posix_time_t time_t
289 # define api_posix_suseconds_t suseconds_t
290 # define api_posix_struct_timeval struct timeval
292 # define api_posix_suseconds_t long int
294 struct api_posix_timeval
296 api_posix_time_t tv_sec;
297 api_posix_suseconds_t tv_usec;
300 # define api_posix_struct_timeval struct api_posix_timeval
308 void* api_posix_malloc(
size_t);
309 void* api_posix_realloc(
void*,
size_t);
310 void api_posix_free(
void*);
312 # define api_posix_malloc malloc
313 # define api_posix_realloc realloc
314 # define api_posix_free free
322 # define api_posix_srandom srandom
323 # define api_posix_random random
325 void api_posix_srandom(
unsigned int);
326 long int api_posix_random(
void);
333 #include <sys/stat.h>
338 #define api_posix_off_t off_t
340 #define API_POSIX_SEEK_SET SEEK_SET
342 #define API_POSIX_FD_CLOEXEC FD_CLOEXEC
344 #define API_POSIX_O_NONBLOCK O_NONBLOCK
345 #define API_POSIX_O_CREAT O_CREAT
346 #define API_POSIX_O_TRUNC O_TRUNC
347 #define API_POSIX_O_RDONLY O_RDONLY
348 #define API_POSIX_O_WRONLY O_WRONLY
349 #define API_POSIX_O_RDWR O_RDWR
350 #define API_POSIX_O_EXCL O_EXCL
352 #define API_POSIX_S_IRWXU S_IRWXU
353 #define API_POSIX_S_IRWXG S_IRWXG
354 #define API_POSIX_S_IRWXO S_IRWXO
355 #define API_POSIX_S_IRUSR S_IRUSR
356 #define API_POSIX_S_IWUSR S_IWUSR
357 #define API_POSIX_S_IXUSR S_IXUSR
358 #define API_POSIX_S_IRGRP S_IRGRP
359 #define API_POSIX_S_IWGRP S_IWGRP
360 #define API_POSIX_S_IROTH S_IROTH
361 #define API_POSIX_S_IWOTH S_IWOTH
363 #define API_POSIX_F_GETFL F_GETFL
364 #define API_POSIX_F_SETFL F_SETFL
365 #define API_POSIX_F_WRLCK F_WRLCK
366 #define API_POSIX_F_SETLK F_SETLK
367 #define API_POSIX_F_SETFD F_SETFD
369 #define API_POSIX_STDIN_FILENO STDIN_FILENO
370 #define API_POSIX_STDOUT_FILENO STDOUT_FILENO
372 #define API_POSIX_DIR DIR
374 #define API_POSIX_S_ISREG S_ISREG
375 #define API_POSIX_S_ISDIR S_ISDIR
377 #define api_posix_mode_t mode_t
378 #define api_posix_struct_flock struct flock
379 #define api_posix_struct_stat struct stat
380 #define api_posix_struct_dirent struct dirent
382 #define api_posix_dup2 dup2
383 #define api_posix_pipe pipe
384 #define api_posix_unlink unlink
385 #define api_posix_rename rename
386 #define api_posix_open open
387 #define api_posix_fdopen fdopen
388 #define api_posix_close close
389 #define api_posix_lseek lseek
390 #define api_posix_read read
391 #define api_posix_write write
392 #define api_posix_fcntl fcntl
393 #define api_posix_fgetc fgetc
394 #define api_posix_mkdir mkdir
395 #define api_posix_rmdir rmdir
396 #define api_posix_opendir opendir
397 #define api_posix_readdir readdir
398 #define api_posix_closedir closedir
399 #define api_posix_stat stat
401 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI
402 # define api_posix_ftruncate ftruncate
403 # define api_posix_lstat lstat
404 # define api_posix_symlink symlink
408 #if CFG_USE_POSIX_API >= 200809 || CFG_USE_XSI
409 # define api_posix_mkstemp mkstemp
411 int api_posix_mkstemp(
char*);
414 #if CFG_USE_POSIX_API >= 200809
415 # define api_posix_scandir scandir
417 int api_posix_scandir(
const char*, api_posix_struct_dirent***,
418 int (*sel)(api_posix_struct_dirent*),
419 int (*compar)(
const api_posix_struct_dirent**,
420 const api_posix_struct_dirent**));
427 # define API_POSIX_PC_NAME_MAX _PC_NAME_MAX
428 # define API_POSIX_PC_PATH_MAX _PC_PATH_MAX
430 # define api_posix_pathconf pathconf
436 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI
439 # define API_POSIX_LC_ALL LC_ALL
440 # define API_POSIX_LC_CTYPE LC_CTYPE
441 # define API_POSIX_LC_MESSAGES LC_MESSAGES
443 # define api_posix_setlocale setlocale
446 #if CFG_USE_POSIX_API >= 200809 || CFG_USE_XSI
447 # include <nl_types.h>
448 # include <langinfo.h>
450 # define API_POSIX_NL_MSGMAX NL_MSGMAX
451 # define API_POSIX_NL_CAT_LOCALE NL_CAT_LOCALE
453 # define api_posix_nl_catd nl_catd
455 # define api_posix_nl_langinfo nl_langinfo
456 # define api_posix_catopen catopen
457 # define api_posix_catgets catgets
458 # define api_posix_catclose catclose
462 #if CFG_USE_POSIX_API >= 200809
463 # include <strings.h>
465 # define API_POSIX_LC_CTYPE_MASK LC_CTYPE_MASK
467 # define api_posix_locale_t locale_t
469 # define api_posix_newlocale newlocale
470 # define api_posix_freelocale freelocale
471 # define api_posix_strcasecmp_l strcasecmp_l
472 # define api_posix_strncasecmp_l strncasecmp_l
474 # define API_POSIX_LC_CTYPE_MASK 0
476 typedef int api_posix_locale_t;
478 api_posix_locale_t api_posix_newlocale(
int,
const char*, api_posix_locale_t);
479 void api_posix_freelocale(api_posix_locale_t);
480 int api_posix_strcasecmp_l(
const char*,
const char*, api_posix_locale_t);
481 int api_posix_strncasecmp_l(
const char*,
const char*,
size_t,
493 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI || CFG_USE_IP6
494 # include <netinet/in.h>
495 # include <arpa/inet.h>
497 # define API_POSIX_AF_UNSPEC AF_UNSPEC
498 # define API_POSIX_AF_INET AF_INET
500 # define API_POSIX_AF_INET6 AF_INET6
503 # define API_POSIX_MSG_PEEK MSG_PEEK
505 # define api_posix_ssize_t ssize_t
508 # if CFG_HDR_INTTYPES_H
509 # include <inttypes.h>
510 typedef uint16_t api_posix_in_port_t;
511 typedef uint32_t api_posix_in_addr_t;
513 typedef CFG_UINT16_TYPE api_posix_in_port_t;
514 typedef CFG_UINT32_TYPE api_posix_in_addr_t;
517 # define api_posix_struct_in_addr struct in_addr
518 # define api_posix_struct_sockaddr_in struct sockaddr_in
521 # define api_posix_struct_in6_addr struct in6_addr
522 # define api_posix_struct_sockaddr_in6 struct sockaddr_in6
526 # define api_posix_htons htons
527 # define api_posix_htonl htonl
528 # define api_posix_ntohs ntohs
529 # define api_posix_ntohl ntohl
531 # define api_posix_inet_addr inet_addr
532 # if CFG_USE_POSIX_API >= 200112
533 # define api_posix_inet_pton inet_pton
535 int api_posix_inet_pton(
int,
const char*,
void*);
538 # include <sys/socket.h>
540 # define api_posix_sa_family_t sa_family_t
541 # define api_posix_socklen_t socklen_t
547 # define api_posix_struct_sockaddr_storage struct sockaddr_storage
548 # define api_posix_struct_sockaddr struct sockaddr
550 # define api_posix_struct_servent struct servent
551 # define api_posix_struct_hostent struct hostent
553 # define api_posix_getservbyname getservbyname
555 # if CFG_USE_POSIX_API >= 200809
562 # define api_posix_gethostbyname gethostbyname
565 # define api_posix_socket socket
567 # define API_POSIX_SOCK_STREAM SOCK_STREAM
569 # define api_posix_connect connect
571 # define API_POSIX_SOL_SOCKET SOL_SOCKET
573 # define API_POSIX_SO_ERROR SO_ERROR
574 # define API_POSIX_SO_RCVTIMEO SO_RCVTIMEO
575 # define API_POSIX_SO_SNDTIMEO SO_SNDTIMEO
577 # define api_posix_getsockopt getsockopt
578 # define api_posix_setsockopt setsockopt
580 # define api_posix_send send
581 # define api_posix_recv recv
585 # define API_POSIX_POLLIN POLLIN
586 # define API_POSIX_POLLOUT POLLOUT
587 # define API_POSIX_POLLERR POLLERR
589 # define api_posix_struct_pollfd struct pollfd
591 # define api_posix_poll poll
594 # define BSD_FOR_POSIX
613 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_IP6
614 # define API_POSIX_AI_ADDRCONFIG AI_ADDRCONFIG
616 # define API_POSIX_EAI_AGAIN EAI_AGAIN
617 # define API_POSIX_EAI_BADFLAGS EAI_BADFLAGS
618 # define API_POSIX_EAI_FAIL EAI_FAIL
619 # define API_POSIX_EAI_FAMILY EAI_FAMILY
620 # define API_POSIX_EAI_MEMORY EAI_MEMORY
621 # define API_POSIX_EAI_NONAME EAI_NONAME
622 # define API_POSIX_EAI_OVERFLOW EAI_OVERFLOW
623 # define API_POSIX_EAI_SERVICE EAI_SERVICE
624 # define API_POSIX_EAI_SOCKTYPE EAI_SOCKTYPE
625 # define API_POSIX_EAI_SYSTEM EAI_SYSTEM
627 # define api_posix_struct_addrinfo struct addrinfo
629 # define api_posix_freeaddrinfo freeaddrinfo
630 # define api_posix_getaddrinfo getaddrinfo
631 # define api_posix_gai_strerror gai_strerror
633 # define API_POSIX_AI_ADDRCONFIG 0x0001
635 # define API_POSIX_EAI_AGAIN -1
636 # define API_POSIX_EAI_BADFLAGS -2
637 # define API_POSIX_EAI_FAIL -3
638 # define API_POSIX_EAI_FAMILY -4
639 # define API_POSIX_EAI_MEMORY -5
640 # define API_POSIX_EAI_NONAME -6
641 # define API_POSIX_EAI_OVERFLOW -7
642 # define API_POSIX_EAI_SERVICE -8
643 # define API_POSIX_EAI_SOCKTYPE -9
644 # define API_POSIX_EAI_SYSTEM -10
646 struct api_posix_addrinfo
652 api_posix_socklen_t ai_addrlen;
653 api_posix_struct_sockaddr* ai_addr;
655 struct api_posix_addrinfo* ai_next;
658 # define api_posix_struct_addrinfo struct api_posix_addrinfo
660 void api_posix_freeaddrinfo(api_posix_struct_addrinfo*);
661 int api_posix_getaddrinfo(
const char*,
const char*,
662 const api_posix_struct_addrinfo*,
663 api_posix_struct_addrinfo**);
664 const char* api_posix_gai_strerror(
int);
679 #if CFG_USE_POSIX_API >= 200112
680 # define api_posix_snprintf snprintf
682 int api_posix_snprintf(
char*,
size_t,
const char*, ...);
686 #if CFG_USE_POSIX_API >= 200809
687 # define api_posix_getline getline
689 api_posix_ssize_t api_posix_getline(
char**,
size_t*, FILE*);
696 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI || CFG_USE_CLB
699 # define API_POSIX_REG_EXTENDED REG_EXTENDED
700 # define API_POSIX_REG_ICASE REG_ICASE
701 # define API_POSIX_REG_NOSUB REG_NOSUB
702 # define API_POSIX_REG_NEWLINE REG_NEWLINE
704 # define api_posix_regex_t regex_t
706 # define api_posix_regcomp regcomp
707 # define api_posix_regerror regerror
708 # define api_posix_regexec regexec
709 # define api_posix_regfree regfree
729 #if CFG_USE_POSIX_API >= 202405L
732 # define api_posix_iconv_open iconv_open
733 # define api_posix_iconv_close iconv_close
734 # define api_posix_iconv iconv