2005-03-15 19:23:13 +01:00
|
|
|
// POSIX definitions
|
2005-03-18 23:15:49 +01:00
|
|
|
// Copyright (c) 2002-2005 Jan Wassenberg
|
2005-03-15 19:23:13 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// Contact info:
|
|
|
|
// Jan.Wassenberg@stud.uni-karlsruhe.de
|
|
|
|
// http://www.stud.uni-karlsruhe.de/~urkt/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
[KEEP IN SYNC WITH WIKI]
|
|
|
|
|
|
|
|
this header makes available commonly used POSIX (Portable Operating System
|
|
|
|
Interface) definitions, e.g. thread, file I/O and socket APIs.
|
|
|
|
on Linux and OS X we just include the requisite headers; Win32 doesn't really
|
|
|
|
support POSIX (*), so we have to implement everything ourselves.
|
|
|
|
|
|
|
|
rationale: this is preferable to a wrapper for several reasons:
|
|
|
|
- less code (implementation is only needed on Win32)
|
|
|
|
- no lock-in (the abstraction may prevent not-designed-for operations
|
|
|
|
that the POSIX interface would have allowed)
|
|
|
|
- familiarity (many coders already know POSIX)
|
|
|
|
|
|
|
|
if a useful definition is missing, feel free to add it!
|
|
|
|
|
|
|
|
implementation reference is the "Single Unix Specification v3"
|
|
|
|
(http://www.unix.org/online.html) - it's similar to the POSIX standard
|
|
|
|
(superset?) and freely available.
|
|
|
|
|
|
|
|
|
|
|
|
* Win32 does have a POSIX subsystem (mandated by a government contract),
|
|
|
|
but it is crippled. only apps with the PE header 'subsystem' field set to
|
|
|
|
"POSIX" can use the appendant DLL, and then they can't call the regular
|
|
|
|
Windows APIs. this is obviously unacceptable - GDI is needed to set up OpenGL.
|
|
|
|
|
|
|
|
we therefore need to emulate POSIX functions using the Win32 API.
|
|
|
|
fortunately, many POSIX functions are already implemented in the VC CRT and
|
|
|
|
need only be renamed (e.g. _open, _stat).
|
|
|
|
|
|
|
|
*/
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2004-03-03 01:44:06 +01:00
|
|
|
#ifdef _WIN32
|
2003-11-06 21:10:37 +01:00
|
|
|
|
2004-03-03 01:44:06 +01:00
|
|
|
#include "sysdep/win/wposix.h"
|
|
|
|
#include "sysdep/win/win.h"
|
|
|
|
|
|
|
|
#else
|
2003-11-03 17:22:45 +01:00
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
// unix/linux/glibc/gcc says that this macro has to be defined when including
|
|
|
|
// stdint.h from C++ for stdint.h to define SIZE_MAX and friends
|
|
|
|
#ifndef __STDC_LIMIT_MACROS
|
|
|
|
#define __STDC_LIMIT_MACROS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2003-11-03 17:22:45 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <fcntl.h>
|
2004-03-04 21:36:31 +01:00
|
|
|
#include <sys/ioctl.h>
|
2003-11-03 17:22:45 +01:00
|
|
|
#include <pthread.h>
|
2005-03-09 16:52:35 +01:00
|
|
|
#include <semaphore.h>
|
2003-11-03 17:22:45 +01:00
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <aio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <sys/utsname.h>
|
2004-03-04 21:36:31 +01:00
|
|
|
#include <sys/socket.h>
|
2003-11-03 17:22:45 +01:00
|
|
|
#include <netdb.h>
|
|
|
|
#include <netinet/in.h>
|
2004-03-04 21:36:31 +01:00
|
|
|
#include <netinet/tcp.h>
|
2003-11-03 17:22:45 +01:00
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2005-03-15 19:23:13 +01:00
|
|
|
#endif // #ifdef _WIN32
|