Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


fcntl2.h
001: /* Checking macros for fcntl functions.
002:    Copyright (C) 2007 Free Software Foundation, Inc.
003:    This file is part of the GNU C Library.
004: 
005:    The GNU C Library is free software; you can redistribute it and/or
006:    modify it under the terms of the GNU Lesser General Public
007:    License as published by the Free Software Foundation; either
008:    version 2.1 of the License, or (at your option) any later version.
009: 
010:    The GNU C Library is distributed in the hope that it will be useful,
011:    but WITHOUT ANY WARRANTY; without even the implied warranty of
012:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:    Lesser General Public License for more details.
014: 
015:    You should have received a copy of the GNU Lesser General Public
016:    License along with the GNU C Library; if not, write to the Free
017:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
018:    02111-1307 USA.  */
019: 
020: #ifndef _FCNTL_H
021: # error "Never include <bits/fcntl2.h> directly; use <fcntl.h> instead."
022: #endif
023: 
024: /* Check that calls to open and openat with O_CREAT set have an
025:    appropriate third/fourth parameter.  */
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: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/