comparison src/syscalls.cc @ 5749:26beffa9f66f

[project @ 2006-04-07 20:35:07 by jwe]
author jwe
date Fri, 07 Apr 2006 20:35:08 +0000
parents 07a5d0d930e0
children ace8d8d26933
comparison
equal deleted inserted replaced
5748:8510034588a7 5749:26beffa9f66f
1424 print_usage ("canonicalize_file_name"); 1424 print_usage ("canonicalize_file_name");
1425 1425
1426 return retval; 1426 return retval;
1427 } 1427 }
1428 1428
1429 static octave_value
1430 const_value (const char *nm, const octave_value_list& args, int val)
1431 {
1432 octave_value retval;
1433
1434 int nargin = args.length ();
1435
1436 if (nargin == 0)
1437 retval = val;
1438 else
1439 print_usage (nm);
1440
1441 return retval;
1442 }
1443
1429 #if !defined (O_NONBLOCK) && defined (O_NDELAY) 1444 #if !defined (O_NONBLOCK) && defined (O_NDELAY)
1430 #define O_NONBLOCK O_NDELAY 1445 #define O_NONBLOCK O_NDELAY
1431 #endif 1446 #endif
1432 1447
1433 void
1434 symbols_of_syscalls (void)
1435 {
1436 #if defined (F_DUPFD) 1448 #if defined (F_DUPFD)
1437 DEFCONSTX ("F_DUPFD", SBV_F_DUPFD, F_DUPFD, 1449 DEFUNX ("F_DUPFD", FF_DUPFD, args, ,
1438 "-*- texinfo -*-\n\ 1450 "-*- texinfo -*-\n\
1439 @defvr {Built-in Constant} F_DUPFD\n\ 1451 @deftypefn {Built-in Function} {} F_DUPFD ()\n\
1440 Request to @code{fcntl} to return a duplicate file descriptor.\n\ 1452 Return the value required to request that @code{fcntl} return a\n\
1453 duplicate file descriptor.\n\
1441 @seealso{fcntl, F_GETFD, F_GETFL, F_SETFD, F_SETFL}\n\ 1454 @seealso{fcntl, F_GETFD, F_GETFL, F_SETFD, F_SETFL}\n\
1442 @end defvr"); 1455 @end deftypefn")
1456 {
1457 return const_value ("F_DUPFD", args, F_DUPFD);
1458 }
1443 #endif 1459 #endif
1444 1460
1445 #if defined (F_GETFD) 1461 #if defined (F_GETFD)
1446 DEFCONSTX ("F_GETFD", SBV_F_GETFD, F_GETFD, 1462 DEFUNX ("F_GETFD", FF_GETFD, args, ,
1447 "-*- texinfo -*-\n\ 1463 "-*- texinfo -*-\n\
1448 @defvr {Built-in Constant} F_GETFD\n\ 1464 @deftypefn {Built-in Function} {} F_GETFD ()\n\
1449 Request to @code{fcntl} to return the file descriptor flags.\n\ 1465 Return the value required to request that @code{fcntl} to return the\n\
1466 file descriptor flags.\n\
1450 @seealso{fcntl, F_DUPFD, F_GETFL, F_SETFD, F_SETFL}\n\ 1467 @seealso{fcntl, F_DUPFD, F_GETFL, F_SETFD, F_SETFL}\n\
1451 @end defvr"); 1468 @end deftypefn")
1469 {
1470 return const_value ("F_GETFD", args, F_GETFD);
1471 }
1452 #endif 1472 #endif
1453 1473
1454 #if defined (F_GETFL) 1474 #if defined (F_GETFL)
1455 DEFCONSTX ("F_GETFL", SBV_F_GETFL, F_GETFL, 1475 DEFUNX ("F_GETFL", FF_GETFL, args, ,
1456 "-*- texinfo -*-\n\ 1476 "-*- texinfo -*-\n\
1457 @defvr {Built-in Constant} F_GETFL\n\ 1477 @deftypefn {Built-in Function} {} F_GETFL ()\n\
1458 Request to @code{fcntl} to return the file status flags.\n\ 1478 Return the value required to request that @code{fcntl} to return the\n\
1479 file status flags.\n\
1459 @seealso{fcntl, F_DUPFD, F_GETFD, F_SETFD, F_SETFL}\n\ 1480 @seealso{fcntl, F_DUPFD, F_GETFD, F_SETFD, F_SETFL}\n\
1460 @end defvr"); 1481 @end deftypefn")
1482 {
1483 return const_value ("F_GETFL", args, F_GETFL);
1484 }
1461 #endif 1485 #endif
1462 1486
1463 #if defined (F_SETFD) 1487 #if defined (F_SETFD)
1464 DEFCONSTX ("F_SETFD", SBV_F_SETFD, F_SETFD, 1488 DEFUNX ("F_SETFD", FF_SETFD, args, ,
1465 "-*- texinfo -*-\n\ 1489 "-*- texinfo -*-\n\
1466 @defvr {Built-in Constant} F_SETFD\n\ 1490 @deftypefn {Built-in Function} {} F_SETFD ()\n\
1467 Request to @code{fcntl} to set the file descriptor flags.\n\ 1491 Return the value required to request that @code{fcntl} to set the file\n\
1492 descriptor flags.\n\
1468 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFL}\n\ 1493 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFL}\n\
1469 @end defvr"); 1494 @end deftypefn")
1495 {
1496 return const_value ("F_SETFD", args, F_SETFD);
1497 }
1470 #endif 1498 #endif
1471 1499
1472 #if defined (F_SETFL) 1500 #if defined (F_SETFL)
1473 DEFCONSTX ("F_SETFL", SBV_F_SETFL, F_SETFL, 1501 DEFUNX ("F_SETFL", FF_SETFL, args, ,
1474 "-*- texinfo -*-\n\ 1502 "-*- texinfo -*-\n\
1475 @defvr {Built-in Constant} F_SETFL\n\ 1503 @deftypefn {Built-in Function} {} F_SETFL ()\n\
1476 Request to @code{fcntl} to set the file status flags.\n\ 1504 Return the value required to request that @code{fcntl} to set the file\n\
1505 status flags.\n\
1477 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFD}\n\ 1506 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFD}\n\
1478 @end defvr"); 1507 @end deftypefn")
1508 {
1509 return const_value ("F_SETFL", args, F_SETFL);
1510 }
1479 #endif 1511 #endif
1480 1512
1481 #if defined (O_APPEND) 1513 #if defined (O_APPEND)
1482 DEFCONSTX ("O_APPEND", SBV_O_APPEND, O_APPEND, 1514 DEFUNX ("O_APPEND", FO_APPEND, args, ,
1483 "-*- texinfo -*-\n\ 1515 "-*- texinfo -*-\n\
1484 @defvr {Built-in Constant} O_APPEND\n\ 1516 @deftypefn {Built-in Function} {} O_APPEND ()\n\
1485 File status flag, append on each write.\n\ 1517 Return the numerical value of the file status flag that may be\n\
1518 returned by @code{fcntl} to indicate each write operation appends,\n\
1519 or that may be passed to @code{fcntl} to set the write mode to append.\
1486 @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ 1520 @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
1487 @end defvr"); 1521 @end deftypefn")
1522 {
1523 return const_value ("O_APPEND", args, O_APPEND);
1524 }
1488 #endif 1525 #endif
1489 1526
1490 #if defined (O_ASYNC) 1527 #if defined (O_ASYNC)
1491 DEFCONSTX ("O_ASYNC", SBV_O_ASYNC, O_ASYNC, 1528 DEFUNX ("O_ASYNC", FO_ASYNC, args, ,
1492 "-*- texinfo -*-\n\ 1529 "-*- texinfo -*-\n\
1493 @defvr {Built-in Constant} O_ASYNC\n\ 1530 @deftypefn {Built-in Function} {} O_ASYNC ()\n\
1494 File status flag, asynchronous I/O.\n\ 1531 Return the numerical value of the file status flag that may be\n\
1532 returned by @code{fcntl} to indicate asynchronous I/O.\n\
1495 @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ 1533 @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
1496 @end defvr"); 1534 @end deftypefn")
1535 {
1536 return const_value ("O_ASYNC", args, O_ASYNC);
1537 }
1497 #endif 1538 #endif
1498 1539
1499 #if defined (O_CREAT) 1540 #if defined (O_CREAT)
1500 DEFCONSTX ("O_CREAT", SBV_O_CREAT, O_CREAT, 1541 DEFUNX ("O_CREAT", FO_CREAT, args, ,
1501 "-*- texinfo -*-\n\ 1542 "-*- texinfo -*-\n\
1502 @defvr {Built-in Constant} O_CREAT\n\ 1543 @deftypefn {Built-in Function} {} O_CREAT ()\n\
1503 File status flag, create file if it does not exist.\n\ 1544 Return the numerical value of the file status flag that may be\n\
1545 returned by @code{fcntl} to indicate that a file should be\n\
1546 created if it does not exist.\n\
1504 @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ 1547 @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
1505 @end defvr"); 1548 @end deftypefn")
1549 {
1550 return const_value ("O_CREAT", args, O_CREAT);
1551 }
1506 #endif 1552 #endif
1507 1553
1508 #if defined (O_EXCL) 1554 #if defined (O_EXCL)
1509 DEFCONSTX ("O_EXCL", SBV_O_EXCL, O_EXCL, 1555 DEFUNX ("O_EXCL", FO_EXCL, args, ,
1510 "-*- texinfo -*-\n\ 1556 "-*- texinfo -*-\n\
1511 @defvr {Built-in Constant} O_EXCL\n\ 1557 @deftypefn {Built-in Function} {} O_EXCL ()\n\
1512 File status flag, file locking.\n\ 1558 Return the numerical value of the file status flag that may be\n\
1559 returned by @code{fcntl} to indicate that file locking is used.\n\
1513 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ 1560 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
1514 @end defvr"); 1561 @end deftypefn")
1562 {
1563 return const_value ("O_EXCL", args, O_EXCL);
1564 }
1515 #endif 1565 #endif
1516 1566
1517 #if defined (O_NONBLOCK) 1567 #if defined (O_NONBLOCK)
1518 DEFCONSTX ("O_NONBLOCK", SBV_O_NONBLOCK, O_NONBLOCK, 1568 DEFUNX ("O_NONBLOCK", FO_NONBLOCK, args, ,
1519 "-*- texinfo -*-\n\ 1569 "-*- texinfo -*-\n\
1520 @defvr {Built-in Constant} O_NONBLOCK\n\ 1570 @deftypefn {Built-in Function} {} O_NONBLOCK ()\n\
1521 File status flag, non-blocking I/O.\n\ 1571 Return the numerical value of the file status flag that may be\n\
1572 returned by @code{fcntl} to indicate that non-blocking I/O is in use,\n\
1573 or that may be passsed to @code{fcntl} to set non-blocking I/O.\n\
1522 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ 1574 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
1523 @end defvr"); 1575 @end deftypefn")
1576 {
1577 return const_value ("O_NONBLOCK", args, O_NONBLOCK);
1578 }
1524 #endif 1579 #endif
1525 1580
1526 #if defined (O_RDONLY) 1581 #if defined (O_RDONLY)
1527 DEFCONSTX ("O_RDONLY", SBV_O_RDONLY, O_RDONLY, 1582 DEFUNX ("O_RDONLY", FO_RDONLY, args, ,
1528 "-*- texinfo -*-\n\ 1583 "-*- texinfo -*-\n\
1529 @defvr {Built-in Constant} O_RDONLY\n\ 1584 @deftypefn {Built-in Function} {} O_RDONLY ()\n\
1530 File status flag, file opened for reading only.\n\ 1585 Return the numerical value of the file status flag that may be\n\
1586 returned by @code{fcntl} to indicate that a file is open for\n\
1587 reading only.\n\
1531 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ 1588 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
1532 @end defvr"); 1589 @end deftypefn")
1590 {
1591 return const_value ("O_RDONLY", args, O_RDONLY);
1592 }
1533 #endif 1593 #endif
1534 1594
1535 #if defined (O_RDWR) 1595 #if defined (O_RDWR)
1536 DEFCONSTX ("O_RDWR", SBV_O_RDWR, O_RDWR, 1596 DEFUNX ("O_RDWR", FO_RDWR, args, ,
1537 "-*- texinfo -*-\n\ 1597 "-*- texinfo -*-\n\
1538 @defvr {Built-in Constant} O_RDWR\n\ 1598 @deftypefn {Built-in Function} {} O_RDWR ()\n\
1539 File status flag, file open for both reading and writing.\n\ 1599 Return the numerical value of the file status flag that may be\n\
1600 returned by @code{fcntl} to indicate that a file is open for both\n\
1601 reading and writing.\n\
1540 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_SYNC, O_TRUNC, O_WRONLY}\n\ 1602 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_SYNC, O_TRUNC, O_WRONLY}\n\
1541 @end defvr"); 1603 @end deftypefn")
1604 {
1605 return const_value ("O_RDWR", args, O_RDWR);
1606 }
1542 #endif 1607 #endif
1543 1608
1544 #if defined (O_SYNC) 1609 #if defined (O_SYNC)
1545 DEFCONSTX ("O_SYNC", SBV_O_SYNC, O_SYNC, 1610 DEFUNX ("O_SYNC", FO_SYNC, args, ,
1546 "-*- texinfo -*-\n\ 1611 "-*- texinfo -*-\n\
1547 @defvr {Built-in Constant} O_SYNC\n\ 1612 @deftypefn {Built-in Function} {} O_SYNC ()\n\
1548 File status flag, file opened for synchronous I/O.\n\ 1613 Return the numerical value of the file status flag that may be\n\
1614 returned by @code{fcntl} to indicate that a file is open for\n\
1615 synchronous I/O.\n\
1549 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}\n\ 1616 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}\n\
1550 @end defvr"); 1617 @end deftypefn")
1618 {
1619 return const_value ("O_SYNC", args, O_SYNC);
1620 }
1551 #endif 1621 #endif
1552 1622
1553 #if defined (O_TRUNC) 1623 #if defined (O_TRUNC)
1554 DEFCONSTX ("O_TRUNC", SBV_O_TRUNC, O_TRUNC, 1624 DEFUNX ("O_TRUNC", FO_TRUNC, args, ,
1555 "-*- texinfo -*-\n\ 1625 "-*- texinfo -*-\n\
1556 @defvr {Built-in Variable} O_TRUNC\n\ 1626 @deftypefn {Built-in Variable} O_TRUNC ()\n\
1557 File status flag, if file exists, truncate it when writing.\n\ 1627 Return the numerical value of the file status flag that may be\n\
1628 returned by @code{fcntl} to indicate that if file exists, it should\n\
1629 be truncated when writing.\n\
1558 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_WRONLY}\n\ 1630 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_WRONLY}\n\
1559 @end defvr"); 1631 @end deftypefn")
1632 {
1633 return const_value ("O_TRUNC", args, O_TRUNC);
1634 }
1560 #endif 1635 #endif
1561 1636
1562 #if defined (O_WRONLY) 1637 #if defined (O_WRONLY)
1563 DEFCONSTX ("O_WRONLY", SBV_O_WRONLY, O_WRONLY, 1638 DEFUNX ("O_WRONLY", FO_WRONLY, args, ,
1564 "-*- texinfo -*-\n\ 1639 "-*- texinfo -*-\n\
1565 @defvr {Built-in Constant} O_WRONLY\n\ 1640 @deftypefn {Built-in Function} {} O_WRONLY ()\n\
1566 File status flag, file opened for writing only.\n\ 1641 Return the numerical value of the file status flag that may be\n\
1642 returned by @code{fcntl} to indicate that a file is open for\n\
1643 writing only.\n\
1567 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC}\n\ 1644 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC}\n\
1568 @end defvr"); 1645 @end deftypefn")
1646 {
1647 return const_value ("O_WRONLY", args, O_WRONLY);
1648 }
1569 #endif 1649 #endif
1570 1650
1571 #if !defined (WNOHANG) 1651 #if !defined (WNOHANG)
1572 #define WNOHANG 0 1652 #define WNOHANG 0
1573 #endif 1653 #endif
1574 1654
1575 DEFCONSTX ("WNOHANG", SBV_WNOHANG, WNOHANG, 1655 DEFUNX ("WNOHANG", FWNOHANG, args, ,
1576 "-*- texinfo -*-\n\ 1656 "-*- texinfo -*-\n\
1577 @defvr {Built-in Constant} WNOHANG\n\ 1657 @deftypefn {Built-in Function} {} WNOHANG ()\n\
1578 Option value for @code{waitpid}.\n\ 1658 Return the numerical value of the option argument that may be\n\
1659 passed to @code{waitpid} to indicate that it should return its\n\
1660 status immediately instead of waiting for a process to exit.\n\
1579 @seealso{waitpid, WUNTRACED, WCONTINUE}\n\ 1661 @seealso{waitpid, WUNTRACED, WCONTINUE}\n\
1580 @end defvr"); 1662 @end deftypefn")
1663 {
1664 return const_value ("WNOHANG", args, WNOHANG);
1665 }
1581 1666
1582 #if !defined (WUNTRACED) 1667 #if !defined (WUNTRACED)
1583 #define WUNTRACED 0 1668 #define WUNTRACED 0
1584 #endif 1669 #endif
1585 1670
1586 DEFCONSTX ("WUNTRACED", SBV_WUNTRACED, WUNTRACED, 1671 DEFUNX ("WUNTRACED", FWUNTRACED, args, ,
1587 "-*- texinfo -*-\n\ 1672 "-*- texinfo -*-\n\
1588 @defvr {Built-in Constant} WUNTRACED\n\ 1673 @deftypefn {Built-in Function} {} WUNTRACED ()\n\
1589 Option value for @code{waitpid}.\n\ 1674 Return the numerical value of the option argument that may be\n\
1675 passed to @code{waitpid} to indicate that it should also return\n\
1676 if the child process has stopped but is not traced via the\n\
1677 @code{ptrace} system call\n\
1590 @seealso{waitpid, WNOHANG, WCONTINUE}\n\ 1678 @seealso{waitpid, WNOHANG, WCONTINUE}\n\
1591 @end defvr"); 1679 @end deftypefn")
1680 {
1681 return const_value ("WUNTRACED", args, WUNTRACED);
1682 }
1592 1683
1593 #if !defined (WCONTINUE) 1684 #if !defined (WCONTINUE)
1594 #define WCONTINUE 0 1685 #define WCONTINUE 0
1595 #endif 1686 #endif
1596 1687
1597 DEFCONSTX ("WCONTINUE", SBV_WCONTINUE, WCONTINUE, 1688 DEFUNX ("WCONTINUE", FWCONTINUE, args, ,
1598 "-*- texinfo -*-\n\ 1689 "-*- texinfo -*-\n\
1599 @defvr {Built-in Constant} WCONINTUE\n\ 1690 @deftypefn {Built-in Function} WCONINTUE ()\n\
1600 Option value for @code{waitpid}.\n\ 1691 Return the numerical value of the option argument that may be\n\
1692 passed to @code{waitpid} to indicate that it should also return\n\
1693 if a stopped child has been resumed by delivery of a @code{SIGCONT}\n\
1694 signal.\n\
1601 @seealso{waitpid, WNOHANG, WUNTRACED}\n\ 1695 @seealso{waitpid, WNOHANG, WUNTRACED}\n\
1602 @end defvr"); 1696 @end deftypefn")
1603 1697 {
1698 return const_value ("WCONTINUE", args, WCONTINUE);
1604 } 1699 }
1605 1700
1606 /* 1701 /*
1607 ;;; Local Variables: *** 1702 ;;; Local Variables: ***
1608 ;;; mode: C++ *** 1703 ;;; mode: C++ ***