Loading...
libsyscall/xcodescripts/create-syscalls.pl xnu-12377.121.6 xnu-4570.71.2
--- xnu/xnu-12377.121.6/libsyscall/xcodescripts/create-syscalls.pl
+++ xnu/xnu-4570.71.2/libsyscall/xcodescripts/create-syscalls.pl
@@ -63,7 +63,6 @@
     'au_asid_t'		=> 4,
     'sae_associd_t'	=> 4,
     'caddr_t'		=> 4,
-    'caddr_ut'	=> 4,
     'sae_connid_t'	=> 4,
     'gid_t'		=> 4,
     'id_t'		=> 4,
@@ -80,7 +79,6 @@
     'semun_t'		=> 4,
     'sigset_t'		=> 4,
     'size_t'		=> 4,
-    'size_ut'		=> 4,
     'socklen_t'		=> 4,
     'ssize_t'		=> 4,
     'u_int'		=> 4,
@@ -89,26 +87,11 @@
     'uint32_t'		=> 4,
     'uint64_t'		=> 8,
     'user_addr_t'	=> 4,
-    'user_addr_ut'	=> 4,
     'user_long_t'	=> 4,
     'user_size_t'	=> 4,
-    'user_size_ut'	=> 4,
     'user_ssize_t'	=> 4,
     'user_ulong_t'	=> 4,
     'uuid_t'		=> 4,
-);
-
-# Types that potentially have different sizes in user-space compared to
-# kernel-space as well as whether the value should be sign/zero-extended when
-# passing the user/kernel boundary.
-my %UserKernelMismatchTypes = (
-    'long'          => 'SIGN_EXTEND',
-    'size_t'        => 'ZERO_EXTEND',
-    'size_ut'       => 'ZERO_EXTEND',
-    'u_long'        => 'ZERO_EXTEND',
-    'user_size_t'   => 'ZERO_EXTEND',
-    'user_size_ut'  => 'ZERO_EXTEND',
-    'user_ssize_t'  => 'SIGN_EXTEND'
 );
 
 # Moving towards storing all data in this hash, then we always know
@@ -123,7 +106,6 @@
         nargs => 0,
         bytes => 0,
         aliases => {},
-        mismatch_args => {}, # Arguments that might need to be zero/sign-extended
     },
 );
 
@@ -139,7 +121,7 @@
 	link linkat lseek lstat
 	msgrcv msgsnd msync
 	open openat
-	pathconf peeloff poll posix_spawn pread preadv pselect pwrite pwritev
+	pathconf peeloff poll posix_spawn pread pselect pwrite
 	read readv recvfrom recvmsg rename renameat
 	rename_ext
 	__semwait_signal __sigwait
@@ -156,10 +138,8 @@
 # Read the syscall.master file and collect the system call names and number
 # of arguments.  It looks for the NO_SYSCALL_STUB quailifier following the
 # prototype to determine if no automatic stub should be created by Libsystem.
-#
-# The `sys_` prefix is stripped from syscall names, and is only kept for
-# the kernel symbol in order to avoid namespace clashes and identify
-# syscalls more easily.
+# System call name that are already prefixed with double-underbar are set as
+# if the NO_SYSCALL_STUB qualifier were specified (whether it is or not).
 #
 # For the #if lines in syscall.master, all macros are assumed to be defined,
 # except COMPAT_GETFSSTAT (assumed undefined).
@@ -171,24 +151,17 @@
     die "$MyName: $file: $!\n" unless defined($f);
     my $line = 0;
     my $skip = 0;
-    my $allow_missing = 0;
     while(<$f>) {
         $line++;
         if(/^#\s*endif/) {
             $skip = 0;
-            $allow_missing = 0;
             next;
         }
         if(/^#\s*else/) {
             $skip = -$skip;
-            $allow_missing = 0;
             next;
         }
         chomp;
-        if(/^#\s*ifndef\s+(RC_HIDE\S+)$/) {
-            $skip = 1;
-            $allow_missing = 1;
-        }
         if(/^#\s*if\s+(\S+)$/) {
             $skip = ($1 eq 'COMPAT_GETFSSTAT') ? -1 : 1;
             next;
@@ -201,20 +174,16 @@
         my $no_syscall_stub = /\)\s*NO_SYSCALL_STUB\s*;/;
         my($name, $args) = /\s(\S+)\s*\(([^)]*)\)/;
         next if $name =~ /e?nosys/;
-        $name =~ s/^sys_//;
         $args =~ s/^\s+//;
         $args =~ s/\s+$//;
         my $argbytes = 0;
         my $nargs = 0;
-        my %mismatch_args;
         if($args ne '' && $args ne 'void') {
             my @a = split(',', $args);
             $nargs = scalar(@a);
-            my $index = 0;
+            # Calculate the size of all the arguments (only used for i386)
             for my $type (@a) {
                 $type =~ s/\s*\w+$//; # remove the argument name
-
-                # Calculate the size of all the arguments (only used for i386)
                 if($type =~ /\*$/) {
                     $argbytes += 4; # a pointer type
                 } else {
@@ -223,12 +192,6 @@
                     die "$MyName: $name: unknown type '$type'\n" unless defined($b);
                     $argbytes += $b;
                 }
-                # Determine which arguments might need to be zero/sign-extended
-                if(exists $UserKernelMismatchTypes{$type}) {
-                    $mismatch_args{$index} = $UserKernelMismatchTypes{$type};
-                }
-
-                $index++;
             }
         }
         $Symbols{$name} = {
@@ -240,9 +203,7 @@
             nargs => $nargs,
             bytes => $argbytes,
             aliases => {},
-            mismatch_args => \%mismatch_args, # Arguments that might need to be zero/sign-extended
             except => [],
-            allow_missing => $allow_missing,
         };
     }
 }
@@ -338,52 +299,25 @@
 ##########################################################################
 sub writeStubForSymbol {
     my ($f, $symbol) = @_;
-
+    
     my @conditions;
-    my $has_arm64 = 0;
     for my $subarch (@Architectures) {
         (my $arch = $subarch) =~ s/arm(v.*)/arm/;
         $arch =~ s/x86_64(.*)/x86_64/;
         $arch =~ s/arm64(.*)/arm64/;
         push(@conditions, "defined(__${arch}__)") unless grep { $_ eq $arch } @{$$symbol{except}};
-
-        if($arch eq "arm64") {
-            $has_arm64 = 1 unless grep { $_ eq $arch } @{$$symbol{except}};
-        }
-    }
-
-    my %is_cancel;
-    for (@Cancelable) { $is_cancel{$_} = 1 };
-
+    }
+
+	my %is_cancel;
+	for (@Cancelable) { $is_cancel{$_} = 1 };
+    
     print $f "#define __SYSCALL_32BIT_ARG_BYTES $$symbol{bytes}\n";
     print $f "#include \"SYS.h\"\n\n";
-    if ($$symbol{allow_missing}) {
-        printf $f "#ifdef SYS_%s\n", $$symbol{syscall};
-    }
-
     if (scalar(@conditions)) {
         printf $f "#ifndef SYS_%s\n", $$symbol{syscall};
         printf $f "#error \"SYS_%s not defined. The header files libsyscall is building against do not match syscalls.master.\"\n", $$symbol{syscall};
-        printf $f "#endif\n\n";
-    }
-
-    my $nc = ($is_cancel{$$symbol{syscall}} ? "cerror" : "cerror_nocancel");
-
-    if($has_arm64) {
-        printf $f "#if defined(__arm64__)\n";
-        printf $f "MI_ENTRY_POINT(%s)\n", $$symbol{asm_sym};
-        if(keys %{$$symbol{mismatch_args}}) {
-            while(my($argnum, $extend) = each %{$$symbol{mismatch_args}}) {
-                printf $f "%s(%d)\n", $extend, $argnum;
-            }
-        }
-
-        printf $f "SYSCALL_NONAME(%s, %d, %s)\n", $$symbol{syscall}, $$symbol{nargs}, $nc;
-        printf $f "ret\n";
-        printf $f "#else\n";
-    }
-
-    if (scalar(@conditions)) {
+        printf $f "#endif\n\n";    
+        my $nc = ($is_cancel{$$symbol{syscall}} ? "cerror" : "cerror_nocancel");
         printf $f "#if " . join(" || ", @conditions) . "\n";
         printf $f "__SYSCALL2(%s, %s, %d, %s)\n", $$symbol{asm_sym}, $$symbol{syscall}, $$symbol{nargs}, $nc;
         if (!$$symbol{is_private} && (scalar(@conditions) < scalar(@Architectures))) {
@@ -395,23 +329,11 @@
         # actually this isnt an inconsistency. kernel can expose what it wants but if all our arches
         # override it we need to honour that.
     }
-
-    if ($$symbol{allow_missing}) {
-        printf $f "#endif\n";
-    }
-
-    if($has_arm64) {
-        printf $f "#endif\n\n";
-    }
 }
 
 sub writeAliasesForSymbol {
     my ($f, $symbol) = @_;
-
-    if ($$symbol{allow_missing}) {
-        printf $f "#ifdef SYS_%s\n", $$symbol{syscall};
-    }
-
+    
     foreach my $subarch (@Architectures) {
         (my $arch = $subarch) =~ s/arm(v.*)/arm/;
         $arch =~ s/x86_64(.*)/x86_64/;
@@ -427,9 +349,6 @@
 						printf $f "\t.set\t$alias_sym, $sym\n";
         }
 				printf $f "#endif\n\n";
-    }
-    if ($$symbol{allow_missing}) {
-        printf $f "#endif\n";
     }
 }