fcntl2.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020: #ifndef _FCNTL_H
021: # error "Never include <bits/fcntl2.h> directly; use <fcntl.h> instead."
022: #endif
023:
024:
025:
026: #ifndef __USE_FILE_OFFSET64
027: extern int __open_2 (__const char *__path, int __oflag) __nonnull ((1));
028: extern int __REDIRECT (__open_alias, (__const char *__path, int __oflag, ...),
029: open) __nonnull ((1));
030: #else
031: extern int __REDIRECT (__open_2, (__const char *__path, int __oflag),
032: __open64_2) __nonnull ((1));
033: extern int __REDIRECT (__open_alias, (__const char *__path, int __oflag, ...),
034: open64) __nonnull ((1));
035: #endif
036: __errordecl (__open_too_many_args,
037: "open can be called either with 2 or 3 arguments, not more");
038: __errordecl (__open_missing_mode,
039: "open with O_CREAT in second argument needs 3 arguments");
040:
041: __extern_always_inline int
042: open (__const char *__path, int __oflag, ...)
043: {
044: if (__va_arg_pack_len () > 1)
045: __open_too_many_args ();
046:
047: if (__builtin_constant_p (__oflag))
048: {
049: if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () < 1)
050: {
051: __open_missing_mode ();
052: return __open_2 (__path, __oflag);
053: }
054: return __open_alias (__path, __oflag, __va_arg_pack ());
055: }
056:
057: if (__va_arg_pack_len () < 1)
058: return __open_2 (__path, __oflag);
059:
060: return __open_alias (__path, __oflag, __va_arg_pack ());
061: }
062:
063:
064: #ifdef __USE_LARGEFILE64
065: extern int __open64_2 (__const char *__path, int __oflag) __nonnull ((1));
066: extern int __REDIRECT (__open64_alias, (__const char *__path, int __oflag,
067: ...), open64) __nonnull ((1));
068: __errordecl (__open64_too_many_args,
069: "open64 can be called either with 2 or 3 arguments, not more");
070: __errordecl (__open64_missing_mode,
071: "open64 with O_CREAT in second argument needs 3 arguments");
072:
073: __extern_always_inline int
074: open64 (__const char *__path, int __oflag, ...)
075: {
076: if (__va_arg_pack_len () > 1)
077: __open64_too_many_args ();
078:
079: if (__builtin_constant_p (__oflag))
080: {
081: if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () < 1)
082: {
083: __open64_missing_mode ();
084: return __open64_2 (__path, __oflag);
085: }
086: return __open64_alias (__path, __oflag, __va_arg_pack ());
087: }
088:
089: if (__va_arg_pack_len () < 1)
090: return __open64_2 (__path, __oflag);
091:
092: return __open64_alias (__path, __oflag, __va_arg_pack ());
093: }
094: #endif
095:
096:
097: #ifdef __USE_ATFILE
098: # ifndef __USE_FILE_OFFSET64
099: extern int __openat_2 (int __fd, __const char *__path, int __oflag)
100: __nonnull ((2));
101: extern int __REDIRECT (__openat_alias, (int __fd, __const char *__path,
102: int __oflag, ...), openat)
103: __nonnull ((2));
104: # else
105: extern int __REDIRECT (__openat_2, (int __fd, __const char *__path,
106: int __oflag), __openat64_2)
107: __nonnull ((2));
108: extern int __REDIRECT (__openat_alias, (int __fd, __const char *__path,
109: int __oflag, ...), openat64)
110: __nonnull ((2));
111: # endif
112: __errordecl (__openat_too_many_args,
113: "openat can be called either with 3 or 4 arguments, not more");
114: __errordecl (__openat_missing_mode,
115: "openat with O_CREAT in third argument needs 4 arguments");
116:
117: __extern_always_inline int
118: openat (int __fd, __const char *__path, int __oflag, ...)
119: {
120: if (__va_arg_pack_len () > 1)
121: __openat_too_many_args ();
122:
123: if (__builtin_constant_p (__oflag))
124: {
125: if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () < 1)
126: {
127: __openat_missing_mode ();
128: return __openat_2 (__fd, __path, __oflag);
129: }
130: return __openat_alias (__fd, __path, __oflag, __va_arg_pack ());
131: }
132:
133: if (__va_arg_pack_len () < 1)
134: return __openat_2 (__fd, __path, __oflag);
135:
136: return __openat_alias (__fd, __path, __oflag, __va_arg_pack ());
137: }
138:
139:
140: # ifdef __USE_LARGEFILE64
141: extern int __openat64_2 (int __fd, __const char *__path, int __oflag)
142: __nonnull ((2));
143: extern int __REDIRECT (__openat64_alias, (int __fd, __const char *__path,
144: int __oflag, ...), openat64)
145: __nonnull ((2));
146: __errordecl (__openat64_too_many_args,
147: "openat64 can be called either with 3 or 4 arguments, not more");
148: __errordecl (__openat64_missing_mode,
149: "openat64 with O_CREAT in third argument needs 4 arguments");
150:
151: __extern_always_inline int
152: openat64 (int __fd, __const char *__path, int __oflag, ...)
153: {
154: if (__va_arg_pack_len () > 1)
155: __openat64_too_many_args ();
156:
157: if (__builtin_constant_p (__oflag))
158: {
159: if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () < 1)
160: {
161: __openat64_missing_mode ();
162: return __openat64_2 (__fd, __path, __oflag);
163: }
164: return __openat64_alias (__fd, __path, __oflag, __va_arg_pack ());
165: }
166:
167: if (__va_arg_pack_len () < 1)
168: return __openat64_2 (__fd, __path, __oflag);
169:
170: return __openat64_alias (__fd, __path, __oflag, __va_arg_pack ());
171: }
172: # endif
173: #endif
174:
© Andrew Scott 2006 -
2025,
All Rights Reserved