Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
etc
config
src
UNISTD_DECL.cpp
Go to the documentation of this file.
1
// checking the contents of <unistd.h>
2
3
25
#include "config.h"
26
27
#include <sys/types.h>
28
#include <fcntl.h>
29
#include <
stdio.h
>
30
31
#if defined (_WIN32) && !defined (__CYGWIN__)
32
# include <io.h>
33
#else
34
# include <unistd.h>
35
#endif
// _WIN32
36
37
// Windows defines the equivalent SSIZE_T in the platform SDK
38
// as the signed equivalent of size_t which is defined as long
39
// on WIN32 and long long/__int64 on WIN64
40
#if defined (_WIN64)
41
# define ssize_t __int64
42
#elif defined (_WIN32)
43
# define ssize_t long
44
#endif
45
46
#if !defined (STDIN_FILENO)
47
# define STDIN_FILENO 0
48
# define STDOUT_FILENO 1
49
# define STDERR_FILENO 2
50
#endif
// STDIN_FILENO
51
52
53
static
void
print_macros ()
54
{
55
struct
{
56
int
value
;
57
const
char
*
name
;
58
}
macros
[] = {
59
60
#define MACRO(name) { name, #name }
61
MACRO
(
STDIN_FILENO
),
62
MACRO
(
STDOUT_FILENO
),
63
MACRO
(
STDERR_FILENO
),
64
65
// open(2) oflag constants
66
MACRO
(O_RDONLY),
67
MACRO
(O_WRONLY),
68
MACRO
(O_RDWR),
69
70
#if defined (O_ACCMODE)
71
// fcntl(2) file access mask
72
MACRO
(O_ACCMODE),
73
#endif
// O_ACCMODE
74
75
MACRO
(O_APPEND),
76
MACRO
(O_EXCL),
77
MACRO
(O_CREAT),
78
MACRO
(O_TRUNC),
79
80
// lseek(2) whence constants
81
MACRO
(
SEEK_SET
),
82
MACRO
(
SEEK_CUR
),
83
MACRO
(
SEEK_END
)
84
85
#if defined (F_GETFL)
86
// fcntl(2) cmd argument
87
,
MACRO
(F_GETFL)
88
#endif
// F_GETFL
89
};
90
91
for
(
unsigned
i
= 0;
i
!=
sizeof
macros
/
sizeof
*
macros
; ++
i
)
92
printf
(
"#define _RWSTD_%-20s %#8x // %s\n"
,
93
macros
[
i
].
name
,
macros
[
i
].
value
,
macros
[
i
].
name
);
94
}
95
96
// POSIX: off_t is a signed integral type
97
const
char
*
off_t_name
(
short
) {
return
"short"
; }
98
const
char
*
off_t_name
(
int
) {
return
"int"
; }
99
const
char
*
off_t_name
(
long
) {
return
"long"
; }
100
101
// POSIX: ssize_t is a signed integral type
102
const
char
*
ssize_t_name
(
short
) {
return
"short"
; }
103
const
char
*
ssize_t_name
(
unsigned
short
) {
return
"unsigned short"
; }
104
const
char
*
ssize_t_name
(
int
) {
return
"int"
; }
105
const
char
*
ssize_t_name
(
unsigned
int
) {
return
"unsigned int"
; }
106
const
char
*
ssize_t_name
(
long
) {
return
"long"
; }
107
const
char
*
ssize_t_name
(
unsigned
long
) {
return
"unsigned long"
; }
108
109
#ifndef _RWSTD_NO_LONG_LONG
110
# define LONG_LONG long long
111
#elif defined (_WIN32)
112
# define LONG_LONG __int64
113
#endif
// _RWSTD_NO_LONG_LONG, _WIN32
114
115
116
#if defined (LONG_LONG)
117
118
# define STRSTR(x) #x
119
# define STR(x) STRSTR (x)
120
121
const
char
*
off_t_name
(
LONG_LONG
)
122
{
123
return
STR
(
LONG_LONG
);
124
}
125
126
const
char
*
ssize_t_name
(
LONG_LONG
)
127
{
128
return
STR
(
LONG_LONG
);
129
}
130
131
const
char
*
ssize_t_name
(
unsigned
LONG_LONG
)
132
{
133
return
STR
(
unsigned
LONG_LONG
);
134
}
135
136
#endif
// LONG_LONG
137
138
139
int
main
()
140
{
141
print_macros ();
142
143
off_t
off
= 0;
144
printf
(
"#define _RWSTD_OFF_T %s // off_t\n"
,
off_t_name
(
off
));
145
146
ssize_t
s
= 0;
147
printf
(
"#define _RWSTD_SSIZE_T %s // ssize_t\n"
,
ssize_t_name
(
s
));
148
149
return
0;
150
}
i
#define i
Definition
17.names.cpp:126
off
#define off
Definition
17.names.cpp:507
s
#define s
Definition
rw_alg_test.h:221
macros
macros
Definition
18.cstdint.cpp:31
value
T value(const T &val)
Definition
26.valarray.cassign.cpp:139
printf
IMPORT_C SInt32 printf(const Char *,...)
STR
#define STR(x)
Definition
UNISTD_DECL.cpp:119
MACRO
#define MACRO(name)
off_t_name
const char * off_t_name(short)
Definition
UNISTD_DECL.cpp:97
ssize_t_name
const char * ssize_t_name(short)
Definition
UNISTD_DECL.cpp:102
STDOUT_FILENO
#define STDOUT_FILENO
Definition
UNISTD_DECL.cpp:48
STDERR_FILENO
#define STDERR_FILENO
Definition
UNISTD_DECL.cpp:49
main
int main()
Definition
UNISTD_DECL.cpp:139
LONG_LONG
#define LONG_LONG
Definition
UNISTD_DECL.cpp:110
STDIN_FILENO
#define STDIN_FILENO
Definition
UNISTD_DECL.cpp:47
SEEK_SET
#define SEEK_SET
SEEK_CUR
#define SEEK_CUR
SEEK_END
#define SEEK_END
name
const char * name
Definition
codecvt1.cpp:72
stdio.h
Generated by
1.9.8