ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/MinGW/include/unistd.h
Revision: 1046
Committed: Mon Aug 29 13:19:38 2016 UTC (9 years, 1 month ago) by alloc
Content type: text/x-chdr
File size: 5404 byte(s)
Log Message:
Daodan: Added Windows MinGW and build batch file

File Contents

# Content
1 /*
2 * unistd.h
3 *
4 * Standard header file declaring MinGW's POSIX compatibility features.
5 *
6 * $Id: unistd.h,v c3ebd36f8211 2016/02/16 16:05:39 keithmarshall $
7 *
8 * Written by Rob Savoye <rob@cygnus.com>
9 * Modified by Earnie Boyd <earnie@users.sourceforge.net>
10 * Danny Smith <dannysmith@users.sourceforge.net>
11 * Ramiro Polla <ramiro@lisha.ufsc.br>
12 * Gregory McGarry <gregorymcgarry@users.sourceforge.net>
13 * Keith Marshall <keithmarshall@users.sourceforge.net>
14 * Copyright (C) 1997, 1999, 2002-2004, 2007-2009, 2014-2016,
15 * MinGW.org Project.
16 *
17 *
18 * Permission is hereby granted, free of charge, to any person obtaining a
19 * copy of this software and associated documentation files (the "Software"),
20 * to deal in the Software without restriction, including without limitation
21 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
22 * and/or sell copies of the Software, and to permit persons to whom the
23 * Software is furnished to do so, subject to the following conditions:
24 *
25 * The above copyright notice, this permission notice, and the following
26 * disclaimer shall be included in all copies or substantial portions of
27 * the Software.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
30 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
32 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
35 * DEALINGS IN THE SOFTWARE.
36 *
37 */
38 #ifndef _UNISTD_H
39 #define _UNISTD_H 1
40 #pragma GCC system_header
41
42 /* All MinGW headers MUST include _mingw.h before anything else,
43 * to ensure proper initialization of feature test macros.
44 */
45 #include <_mingw.h>
46
47 /* unistd.h maps (roughly) to Microsoft's <io.h>
48 * Other headers included by <unistd.h> may be selectively processed;
49 * __UNISTD_H_SOURCED__ enables such selective processing.
50 */
51 #define __UNISTD_H_SOURCED__ 1
52
53 #include <io.h>
54 #include <process.h>
55 #include <getopt.h>
56
57 /* These are defined in stdio.h. POSIX also requires that they
58 * are to be consistently defined here; don't guard against prior
59 * definitions, as this might conceal inconsistencies.
60 */
61 #define SEEK_SET 0
62 #define SEEK_CUR 1
63 #define SEEK_END 2
64
65 #if _POSIX_C_SOURCE
66 /* POSIX process/thread suspension functions; all are supported by a
67 * common MinGW API in libmingwex.a, providing for suspension periods
68 * ranging from mean values of ~7.5 milliseconds, (see the comments in
69 * <time.h>), extending up to a maximum of ~136 years.
70 *
71 * Note that, whereas POSIX supports early wake-up of any suspended
72 * process/thread, in response to a signal, this implementation makes
73 * no attempt to emulate this signalling behaviour, (since signals are
74 * not well supported by Windows); thus, unless impeded by an invalid
75 * argument, this implementation always returns an indication as if
76 * the sleeping period ran to completion.
77 */
78 _BEGIN_C_DECLS
79
80 __cdecl __MINGW_NOTHROW
81 int __mingw_sleep( unsigned long, unsigned long );
82
83 /* The nanosleep() function provides the most general purpose API for
84 * process/thread suspension; it is declared in <time.h>, (where it is
85 * accompanied by an in-line implementation), rather than here, and it
86 * provides for specification of suspension periods in the range from
87 * ~7.5 ms mean, (on WinNT derivatives; ~27.5 ms on Win9x), extending
88 * up to ~136 years, (effectively eternity).
89 *
90 * The usleep() function, and its associated useconds_t type specifier
91 * were made obsolete in POSIX.1-2008; declared here, only for backward
92 * compatibility, its continued use is not recommended. (It is limited
93 * to specification of suspension periods ranging from ~7.5 ms mean up
94 * to a maximum of 999,999 microseconds only).
95 */
96 typedef unsigned long useconds_t __MINGW_ATTRIB_DEPRECATED;
97 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
98
99 #ifndef __NO_INLINE__
100 __CRT_INLINE __LIBIMPL__(( FUNCTION = usleep ))
101 int usleep( useconds_t period ){ return __mingw_sleep( 0, 1000 * period ); }
102 #endif
103
104 /* The sleep() function is, perhaps, the most commonly used of all the
105 * process/thread suspension APIs; it provides support for specification
106 * of suspension periods ranging from 1 second to ~136 years. (However,
107 * POSIX recommends limiting the maximum period to 65535 seconds, to
108 * maintain portability to platforms with only 16-bit ints).
109 */
110 unsigned __cdecl __MINGW_NOTHROW sleep( unsigned );
111
112 #ifndef __NO_INLINE__
113 __CRT_INLINE __LIBIMPL__(( FUNCTION = sleep ))
114 unsigned sleep( unsigned period ){ return __mingw_sleep( period, 0 ); }
115 #endif
116
117
118 /* POSIX ftruncate() function.
119 *
120 * Microsoft's _chsize() function is incorrectly described, on MSDN,
121 * as a preferred replacement for the POSIX chsize() function. There
122 * never was any such POSIX function; the actual POSIX equivalent is
123 * the ftruncate() function.
124 */
125 int __cdecl ftruncate( int, off_t );
126
127 #ifndef __NO_INLINE__
128 __CRT_INLINE __JMPSTUB__(( FUNCTION = ftruncate, REMAPPED = _chsize ))
129 int ftruncate( int __fd, off_t __length ){ return _chsize( __fd, __length ); }
130 #endif
131
132 _END_C_DECLS
133
134 #endif /* _POSIX_C_SOURCE */
135
136 #undef __UNISTD_H_SOURCED__
137 #endif /* ! _UNISTD_H: $RCSfile: unistd.h,v $: end of file */