diff options
Diffstat (limited to 'makewrappers')
-rwxr-xr-x | makewrappers | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/makewrappers b/makewrappers index e84607d..cf5ad60 100755 --- a/makewrappers +++ b/makewrappers @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2008-2011,2013 Wind River Systems, Inc. # @@ -11,6 +11,7 @@ import glob import sys import re import os.path +import platform import string import subprocess from templatefile import TemplateFile @@ -228,6 +229,8 @@ class Function: self.real_func = None self.paths_to_munge = [] self.specific_dirfds = {} + self.fd_arg = False + self.noignore_path = False self.hand_wrapped = None self.async_skip = None # used for the copyright date when creating stub functions @@ -267,6 +270,11 @@ class Function: self.flags = '(flags & AT_SYMLINK_NOFOLLOW)' elif arg.name.endswith('path'): self.paths_to_munge.append(arg.name) + elif arg.name == 'fd': + self.fd_arg = "fd" + elif arg.name == 'filedes': + self.fd_arg = "filedes" + # pick default values if self.type == 'void': @@ -283,10 +291,18 @@ class Function: # handle special comments, such as flags=AT_SYMLINK_NOFOLLOW if self.comments: - modifiers = self.comments.split(', ') - for mod in modifiers: - key, value = mod.split('=') - value = value.rstrip() + # Build a dictionary of key=value, key=value pairs + modifiers = dict(mod.split("=") for mod in self.comments.split(',')) + # Strip all leading/trailing whitespace + modifiers = {k.strip():v.strip() for k, v in modifiers.items()} + + arch = "-" + platform.machine() + # Sorted so that versions-foo appear after versions, so overrides are easy + for key in sorted(modifiers): + value = modifiers[key] + # If the key is version-arm64 and we're on arm64 then rename this to version + if key.endswith(arch): + key = key.replace(arch, "") setattr(self, key, value) def maybe_inode64(self): @@ -356,11 +372,39 @@ class Function: prefix = path[:-4] if prefix not in self.specific_dirfds: prefix = '' + if self.dirfd != "AT_FDCWD" and "flags" in self.flags \ + and "AT_SYMLINK_NOFOLLOW" in self.flags: + fix_paths.append( + # Reference the variable inside a noop inline-asm to stop + # the compiler from eliminating the null pointer check + # on parameters marked nonnull + "asm(\"\" : \"+r\"(%s));" + "if (%s && !*%s && (flags & AT_EMPTY_PATH))\n" + "\t\t\tflags |= AT_SYMLINK_NOFOLLOW;" % (path, path, path)) fix_paths.append( "%s = pseudo_root_path(__func__, __LINE__, %s%s, %s, %s);" % (path, prefix, self.dirfd, path, self.flags)) return "\n\t\t".join(fix_paths) + def ignore_paths(self): + if self.noignore_path: + return "0" + + mainpath = None + if "oldpath" in self.paths_to_munge: + mainpath = "oldpath" + elif "newpath" in self.paths_to_munge: + mainpath = "newpath" + elif "path" in self.paths_to_munge: + mainpath = "path" + + if mainpath: + return "pseudo_client_ignore_path(%s)" % mainpath + if self.fd_arg: + return "pseudo_client_ignore_fd(%s)" % self.fd_arg + + return "0" + def real_predecl(self): if self.real_func: return self.decl().replace(self.name, self.real_func, 1) + ";" @@ -567,7 +611,7 @@ def process_wrapfuncs(port): func.directory = directory funcs[func.name] = func sys.stdout.write(".") - except Exception(e): + except Exception as e: print("Parsing failed:", e) exit(1) funclist.close() |