| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | #! /bin/sh - | | 1 | #! /bin/sh - |
2 | # $NetBSD: makesyscalls.sh,v 1.91 2009/11/26 17:23:48 pooka Exp $ | | 2 | # $NetBSD: makesyscalls.sh,v 1.92 2009/12/13 04:47:45 matt Exp $ |
3 | # | | 3 | # |
4 | # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou | | 4 | # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou |
5 | # All rights reserved. | | 5 | # All rights reserved. |
6 | # | | 6 | # |
7 | # Redistribution and use in source and binary forms, with or without | | 7 | # Redistribution and use in source and binary forms, with or without |
8 | # modification, are permitted provided that the following conditions | | 8 | # modification, are permitted provided that the following conditions |
9 | # are met: | | 9 | # are met: |
10 | # 1. Redistributions of source code must retain the above copyright | | 10 | # 1. Redistributions of source code must retain the above copyright |
11 | # notice, this list of conditions and the following disclaimer. | | 11 | # notice, this list of conditions and the following disclaimer. |
12 | # 2. Redistributions in binary form must reproduce the above copyright | | 12 | # 2. Redistributions in binary form must reproduce the above copyright |
13 | # notice, this list of conditions and the following disclaimer in the | | 13 | # notice, this list of conditions and the following disclaimer in the |
14 | # documentation and/or other materials provided with the distribution. | | 14 | # documentation and/or other materials provided with the distribution. |
15 | # 3. All advertising materials mentioning features or use of this software | | 15 | # 3. All advertising materials mentioning features or use of this software |
| @@ -430,26 +430,32 @@ function parseline() { | | | @@ -430,26 +430,32 @@ function parseline() { |
430 | if (rumpable == 1 && fbase == "pipe") { | | 430 | if (rumpable == 1 && fbase == "pipe") { |
431 | rumpable = 0; | | 431 | rumpable = 0; |
432 | rumphaspipe = 1; | | 432 | rumphaspipe = 1; |
433 | } | | 433 | } |
434 | | | 434 | |
435 | funcstdname=fprefix "_" fbase | | 435 | funcstdname=fprefix "_" fbase |
436 | if (fcompat != "") { | | 436 | if (fcompat != "") { |
437 | funcname=fprefix "___" fbase "" fcompat | | 437 | funcname=fprefix "___" fbase "" fcompat |
438 | wantrename=1 | | 438 | wantrename=1 |
439 | } else { | | 439 | } else { |
440 | funcname=funcstdname | | 440 | funcname=funcstdname |
441 | wantrename=0 | | 441 | wantrename=0 |
442 | } | | 442 | } |
| | | 443 | if (returntype == "quad_t" || returntype == "off_t") { |
| | | 444 | if (sycall_flags == "0") |
| | | 445 | sycall_flags = "SYCALL_RET_64"; |
| | | 446 | else |
| | | 447 | sycall_flags = "SYCALL_RET_64 | " sycall_flags; |
| | | 448 | } |
443 | | | 449 | |
444 | if (funcalias == "") { | | 450 | if (funcalias == "") { |
445 | funcalias=funcname | | 451 | funcalias=funcname |
446 | sub(/^([^_]+_)*sys_/, "", funcalias) | | 452 | sub(/^([^_]+_)*sys_/, "", funcalias) |
447 | } | | 453 | } |
448 | f++ | | 454 | f++ |
449 | | | 455 | |
450 | if ($f != "(") | | 456 | if ($f != "(") |
451 | parserr($f, "(") | | 457 | parserr($f, "(") |
452 | f++ | | 458 | f++ |
453 | | | 459 | |
454 | argc=0; | | 460 | argc=0; |
455 | argalign=0; | | 461 | argalign=0; |
| @@ -463,26 +469,27 @@ function parseline() { | | | @@ -463,26 +469,27 @@ function parseline() { |
463 | } | | 469 | } |
464 | | | 470 | |
465 | # some system calls (open() and fcntl()) can accept a variable | | 471 | # some system calls (open() and fcntl()) can accept a variable |
466 | # number of arguments. If syscalls accept a variable number of | | 472 | # number of arguments. If syscalls accept a variable number of |
467 | # arguments, they must still have arguments specified for | | 473 | # arguments, they must still have arguments specified for |
468 | # the remaining argument "positions," because of the way the | | 474 | # the remaining argument "positions," because of the way the |
469 | # kernel system call argument handling works. | | 475 | # kernel system call argument handling works. |
470 | # | | 476 | # |
471 | # Indirect system calls, e.g. syscall(), are exceptions to this | | 477 | # Indirect system calls, e.g. syscall(), are exceptions to this |
472 | # rule, since they are handled entirely by machine-dependent code | | 478 | # rule, since they are handled entirely by machine-dependent code |
473 | # and do not need argument structures built. | | 479 | # and do not need argument structures built. |
474 | | | 480 | |
475 | isvarargs = 0; | | 481 | isvarargs = 0; |
| | | 482 | args64 = 0; |
476 | while (f <= end) { | | 483 | while (f <= end) { |
477 | if ($f == "...") { | | 484 | if ($f == "...") { |
478 | f++; | | 485 | f++; |
479 | isvarargs = 1; | | 486 | isvarargs = 1; |
480 | varargc = argc; | | 487 | varargc = argc; |
481 | continue; | | 488 | continue; |
482 | } | | 489 | } |
483 | argc++ | | 490 | argc++ |
484 | argtype[argc]="" | | 491 | argtype[argc]="" |
485 | oldf="" | | 492 | oldf="" |
486 | while (f < end && $(f+1) != ",") { | | 493 | while (f < end && $(f+1) != ",") { |
487 | if (argtype[argc] != "" && oldf != "*") | | 494 | if (argtype[argc] != "" && oldf != "*") |
488 | argtype[argc] = argtype[argc]" "; | | 495 | argtype[argc] = argtype[argc]" "; |
| @@ -491,29 +498,38 @@ function parseline() { | | | @@ -491,29 +498,38 @@ function parseline() { |
491 | f++ | | 498 | f++ |
492 | } | | 499 | } |
493 | if (argtype[argc] == "") | | 500 | if (argtype[argc] == "") |
494 | parserr($f, "argument definition") | | 501 | parserr($f, "argument definition") |
495 | if (argtype[argc] == "off_t" \ | | 502 | if (argtype[argc] == "off_t" \ |
496 | || argtype[argc] == "dev_t" \ | | 503 | || argtype[argc] == "dev_t" \ |
497 | || argtype[argc] == "time_t") { | | 504 | || argtype[argc] == "time_t") { |
498 | if ((argalign % 2) != 0 && sysalign && | | 505 | if ((argalign % 2) != 0 && sysalign && |
499 | funcname != "sys_posix_fadvise") # XXX for now | | 506 | funcname != "sys_posix_fadvise") # XXX for now |
500 | parserr($f, "a padding argument") | | 507 | parserr($f, "a padding argument") |
501 | } else { | | 508 | } else { |
502 | argalign++; | | 509 | argalign++; |
503 | } | | 510 | } |
| | | 511 | if (argtype[argc] == "quad_t" || argtype[argc] == "off_t") { |
| | | 512 | if (sycall_flags == "0") |
| | | 513 | sycall_flags = "SYCALL_ARG"argc-1"_64"; |
| | | 514 | else |
| | | 515 | sycall_flags = "SYCALL_ARG"argc-1"_64 | " sycall_flags; |
| | | 516 | args64++; |
| | | 517 | } |
504 | argname[argc]=$f; | | 518 | argname[argc]=$f; |
505 | f += 2; # skip name, and any comma | | 519 | f += 2; # skip name, and any comma |
506 | } | | 520 | } |
| | | 521 | if (args64 > 0) |
| | | 522 | sycall_flags = "SYCALL_NARGS64_VAL("args64") | " sycall_flags; |
507 | # must see another argument after varargs notice. | | 523 | # must see another argument after varargs notice. |
508 | if (isvarargs) { | | 524 | if (isvarargs) { |
509 | if (argc == varargc) | | 525 | if (argc == varargc) |
510 | parserr($f, "argument definition") | | 526 | parserr($f, "argument definition") |
511 | } else | | 527 | } else |
512 | varargc = argc; | | 528 | varargc = argc; |
513 | } | | 529 | } |
514 | | | 530 | |
515 | function printproto(wrap) { | | 531 | function printproto(wrap) { |
516 | printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias, | | 532 | printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias, |
517 | returntype) > sysnumhdr | | 533 | returntype) > sysnumhdr |
518 | for (i = 1; i <= varargc; i++) | | 534 | for (i = 1; i <= varargc; i++) |
519 | printf(" \"%s\"", argtype[i]) > sysnumhdr | | 535 | printf(" \"%s\"", argtype[i]) > sysnumhdr |