Changeset 3778:1c21eee2b90d in roaraudio
- Timestamp:
- 05/07/10 12:18:55 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroaross/libroaross.c
r3777 r3778 59 59 #include <sys/stat.h> 60 60 #include <dlfcn.h> 61 #include <stdarg.h> 61 62 62 63 #if defined(RTLD_NEXT) … … 147 148 int (*select)(int nfds, fd_set *readfds, fd_set *writefds, 148 149 fd_set *exceptfds, struct timeval *timeout); 150 int (*fcntl)(int fd, int cmd, ...); 149 151 } _os; 150 152 … … 247 249 _os.dup2 = dlsym(REAL_LIBC, "dup2"); 248 250 _os.select = dlsym(REAL_LIBC, "select"); 251 _os.fcntl = dlsym(REAL_LIBC, "fcntl"); 249 252 } 250 253 … … 1522 1525 } 1523 1526 1527 int fcntl(int fd, int cmd, ...) { 1528 enum { NONE, UNKNOWN, LONG, POINTER } type = NONE; 1529 struct pointer * pointer; 1530 va_list ap; 1531 long argl = -1; 1532 void * vp = NULL; 1533 1534 switch (cmd) { 1535 case F_DUPFD: 1536 case F_SETFD: 1537 case F_SETFL: 1538 case F_SETOWN: 1539 case F_SETSIG: 1540 case F_SETLEASE: 1541 case F_NOTIFY: 1542 type = LONG; 1543 break; 1544 case F_GETFD: 1545 case F_GETFL: 1546 case F_GETOWN: 1547 case F_GETSIG: 1548 case F_GETLEASE: 1549 type = NONE; 1550 break; 1551 case F_GETLK: 1552 case F_SETLK: 1553 case F_SETLKW: 1554 type = POINTER; 1555 break; 1556 /* 1557 case F_EXLCK: 1558 case F_GETLK64: 1559 case F_SETLK64: 1560 case F_SETLKW64: 1561 case F_SHLCK: 1562 case F_LINUX_SPECIFIC_BASE: 1563 case F_INPROGRESS: 1564 */ 1565 default: 1566 type = UNKNOWN; 1567 } 1568 1569 if ( type == UNKNOWN ) { 1570 errno = EINVAL; 1571 return -1; 1572 } 1573 1574 if ( type != NONE ) { 1575 va_start(ap, cmd); 1576 switch (type) { 1577 case LONG: 1578 argl = va_arg(ap, long); 1579 break; 1580 case POINTER: 1581 vp = va_arg(ap, void*); 1582 break; 1583 default: /* make compiler happy */ 1584 break; 1585 } 1586 va_end(ap); 1587 } 1588 1589 if ( (pointer = _get_pointer_by_fh(fd)) == NULL ) { 1590 switch (type) { 1591 case NONE: 1592 return _os.fcntl(fd, cmd); 1593 break; 1594 case LONG: 1595 return _os.fcntl(fd, cmd, argl); 1596 break; 1597 case POINTER: 1598 return _os.fcntl(fd, cmd, vp); 1599 break; 1600 default: /* make compiler happy */ 1601 break; 1602 } 1603 } 1604 1605 errno = ENOSYS; 1606 return -1; 1607 } 1608 1524 1609 // ------------------------------------- 1525 1610 // emulated stdio functions follow:
Note: See TracChangeset
for help on using the changeset viewer.