@@ -385,3 +385,51 @@ __CPROVER_HIDE:;
385
385
// Thus, modelling it as non-deterministic.
386
386
return retval ;
387
387
}
388
+
389
+ /* FUNCTION: syscall */
390
+
391
+ #ifndef __CPROVER_ERRNO_H_INCLUDED
392
+ # include <errno.h>
393
+ # define __CPROVER_ERRNO_H_INCLUDED
394
+ #endif
395
+
396
+ long int __VERIFIER_nondet_long_int (void );
397
+ int __VERIFIER_nondet_int (void );
398
+
399
+ // This overapproximation is based on the syscall specification available at
400
+ // https://man7.org/linux/man-pages/man2/syscall.2.html and
401
+ // https://www.gnu.org/software/libc/manual/html_node/System-Calls.html.
402
+ //
403
+ // sysno is the system call number. The remaining arguments are the arguments
404
+ // for the system call. Each kind of system call has a definite number of
405
+ // arguments, from zero to five. If you code more arguments than the system
406
+ // call takes, the extra ones to the right are ignored.
407
+ #ifdef __APPLE__
408
+ int syscall (int sysno , ...);
409
+ int syscall (int sysno , ...)
410
+ #else
411
+ long int syscall (long int sysno , ...);
412
+ long int syscall (long int sysno , ...)
413
+ #endif
414
+ {
415
+ __CPROVER_HIDE :;
416
+ (void )sysno ;
417
+
418
+ #ifdef __APPLE__
419
+ int retval = __VERIFIER_nondet_int ();
420
+ #else
421
+ long int retval = __VERIFIER_nondet_long_int ();
422
+ #endif
423
+
424
+ if (retval == -1 )
425
+ {
426
+ // We should keep errno as non-deterministic as possible, since this model
427
+ // never takes into account any input.
428
+ errno = __VERIFIER_nondet_int ();
429
+ }
430
+
431
+ // The return value is the return value from the system call, unless the
432
+ // system call failed. This over-approximation doesn't take into account
433
+ // any system call operation, so we leave the return value as non-det.
434
+ return retval ;
435
+ }
0 commit comments