Skip to content

Commit e55c278

Browse files
committed
Define LOCK Flags
1 parent d9e5416 commit e55c278

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

Src/IronPython.Modules/fcntl.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,41 @@ a file object.
163163
#endregion
164164

165165

166+
#region Generated LOCK Flags
167+
168+
// *** BEGIN GENERATED CODE ***
169+
// generated by function: generate_LOCK_flags from: generate_os_codes.py
170+
171+
172+
public static int LOCK_EX => 0x2;
173+
174+
[PythonHidden(PlatformID.MacOSX)]
175+
[SupportedOSPlatform("linux")]
176+
public static int LOCK_MAND => 0x20;
177+
178+
public static int LOCK_NB => 0x4;
179+
180+
[PythonHidden(PlatformID.MacOSX)]
181+
[SupportedOSPlatform("linux")]
182+
public static int LOCK_READ => 0x40;
183+
184+
[PythonHidden(PlatformID.MacOSX)]
185+
[SupportedOSPlatform("linux")]
186+
public static int LOCK_RW => 0xc0;
187+
188+
public static int LOCK_SH => 0x1;
189+
190+
public static int LOCK_UN => 0x8;
191+
192+
[PythonHidden(PlatformID.MacOSX)]
193+
[SupportedOSPlatform("linux")]
194+
public static int LOCK_WRITE => 0x80;
195+
196+
// *** END GENERATED CODE ***
197+
198+
#endregion
199+
200+
166201
// Linux only
167202
#region Generated Directory Notify Flags
168203

Src/Scripts/generate_os_codes.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,24 @@ def generate_DN_flags(cw):
262262
generate_codes(cw, codeval, 'public', hex, unix_only=True)
263263

264264

265+
# python3 -c 'import fcntl;print(dict(sorted((s, getattr(fcntl, s)) for s in dir(fcntl) if s.startswith("LOCK_"))))'
266+
# Python 3.6.15 [GCC 12.2.0] on linux 6.10.14
267+
# Python 3.12.3 [GCC 13.2.0] on linux 6.8.0
268+
LOCK_flags_linux = {'LOCK_EX': 2, 'LOCK_MAND': 32, 'LOCK_NB': 4, 'LOCK_READ': 64, 'LOCK_RW': 192, 'LOCK_SH': 1, 'LOCK_UN': 8, 'LOCK_WRITE': 128}
269+
# Python 3.7.0 [Clang 4.0.1 ] on darwin 24.2.0
270+
# Python 3.12.0 [Clang 14.0.6 ] on darwin 24.2.0
271+
LOCK_flags_darwin = {'LOCK_EX': 2, 'LOCK_NB': 4, 'LOCK_SH': 1, 'LOCK_UN': 8}
272+
273+
def generate_LOCK_flags(cw):
274+
codeval = {}
275+
for name in LOCK_flags_linux:
276+
set_value(codeval, name, LOCK_flags_linux[name], linux_idx)
277+
for name in LOCK_flags_darwin:
278+
set_value(codeval, name, LOCK_flags_darwin[name], darwin_idx)
279+
codeval = OrderedDict(sorted(codeval.items()))
280+
generate_codes(cw, codeval, 'public', hex, unix_only=True)
281+
282+
265283
def main():
266284
return generate(
267285
("Errno Codes", generate_errno_codes),
@@ -271,6 +289,7 @@ def main():
271289
("Common O_Flags", generate_common_O_flags),
272290
("FD Commands", generate_FD_commands),
273291
("Directory Notify Flags", generate_DN_flags),
292+
("LOCK Flags", generate_LOCK_flags),
274293
)
275294

276295
if __name__ == "__main__":

0 commit comments

Comments
 (0)