1 #define _DEFAULT_SOURCE 2 3 #include <errno.h> 4 #include <string.h> 5 #include <limits.h> 6 #include <unistd.h> 7 #include <termios.h> 8 #include <sys/ioctl.h> 9 10 #ifdef __linux__ 11 #include <linux/serial.h> 12 #endif 13 14 #include "ucode/module.h" 15 16 #ifndef TIOCINQ 17 #define TIOCINQ FIONREAD 18 #endif 19 20 #define err_return(err) do { \ 21 uc_vm_registry_set(vm, "serial.last_error", ucv_int64_new(err)); \ 22 return NULL; \ 23 } while(0) 24 25 static int 26 get_fd(uc_vm_t *vm, uc_value_t *val) 27 { 28 uc_value_t *fn = ucv_property_get(val, "fileno"); 29 int64_t n; 30 31 errno = 0; 32 33 if (ucv_is_callable(fn)) { 34 uc_vm_stack_push(vm, ucv_get(val)); 35 uc_vm_stack_push(vm, ucv_get(fn)); 36 37 if (uc_vm_call(vm, true, 0) != EXCEPTION_NONE) 38 return -1; 39 40 val = uc_vm_stack_pop(vm); 41 n = ucv_int64_get(val); 42 ucv_put(val); 43 } 44 else { 45 n = ucv_int64_get(val); 46 } 47 48 if (errno || n < 0 || n > (int64_t)INT_MAX) 49 return -1; 50 51 return (int)n; 52 } 53 54 static uc_value_t * 55 uc_serial_error(uc_vm_t *vm, size_t nargs) 56 { 57 int last_error = ucv_int64_get(uc_vm_registry_get(vm, "serial.last_error")); 58 59 if (last_error == 0) 60 return NULL; 61 62 uc_vm_registry_set(vm, "serial.last_error", ucv_int64_new(0)); 63 64 return ucv_string_new(strerror(last_error)); 65 } 66 67 static uc_value_t * 68 uc_serial_isatty(uc_vm_t *vm, size_t nargs) 69 { 70 int fd = get_fd(vm, uc_fn_arg(0)); 71 72 if (fd < 0) 73 err_return(EBADF); 74 75 return ucv_boolean_new(isatty(fd) == 1); 76 } 77 78 static uc_value_t * 79 uc_serial_attr(uc_vm_t *vm, size_t nargs) 80 { 81 struct termios t; 82 uc_value_t *rv, *cc; 83 int fd, i; 84 85 fd = get_fd(vm, uc_fn_arg(0)); 86 87 if (fd < 0) 88 err_return(EBADF); 89 90 if (tcgetattr(fd, &t) != 0) 91 err_return(errno); 92 93 rv = ucv_object_new(vm); 94 95 ucv_object_add(rv, "iflag", ucv_uint64_new(t.c_iflag)); 96 ucv_object_add(rv, "oflag", ucv_uint64_new(t.c_oflag)); 97 ucv_object_add(rv, "cflag", ucv_uint64_new(t.c_cflag)); 98 ucv_object_add(rv, "lflag", ucv_uint64_new(t.c_lflag)); 99 ucv_object_add(rv, "ispeed", ucv_uint64_new(cfgetispeed(&t))); 100 ucv_object_add(rv, "ospeed", ucv_uint64_new(cfgetospeed(&t))); 101 102 cc = ucv_array_new(vm); 103 104 for (i = 0; i < NCCS; i++) 105 ucv_array_push(cc, ucv_uint64_new(t.c_cc[i])); 106 107 ucv_object_add(rv, "cc", cc); 108 109 return rv; 110 } 111 112 static uc_value_t * 113 uc_serial_setattr(uc_vm_t *vm, size_t nargs) 114 { 115 uc_value_t *attrs = uc_fn_arg(1); 116 uc_value_t *when = uc_fn_arg(2); 117 uc_value_t *v, *cc; 118 struct termios t; 119 int fd, act; 120 size_t i, n; 121 122 fd = get_fd(vm, uc_fn_arg(0)); 123 124 if (fd < 0) 125 err_return(EBADF); 126 127 if (ucv_type(attrs) != UC_OBJECT) 128 err_return(EINVAL); 129 130 if (tcgetattr(fd, &t) != 0) 131 err_return(errno); 132 133 v = ucv_object_get(attrs, "iflag", NULL); 134 if (v) t.c_iflag = (tcflag_t)ucv_to_unsigned(v); 135 136 v = ucv_object_get(attrs, "oflag", NULL); 137 if (v) t.c_oflag = (tcflag_t)ucv_to_unsigned(v); 138 139 v = ucv_object_get(attrs, "cflag", NULL); 140 if (v) t.c_cflag = (tcflag_t)ucv_to_unsigned(v); 141 142 v = ucv_object_get(attrs, "lflag", NULL); 143 if (v) t.c_lflag = (tcflag_t)ucv_to_unsigned(v); 144 145 v = ucv_object_get(attrs, "ispeed", NULL); 146 if (v) cfsetispeed(&t, (speed_t)ucv_to_unsigned(v)); 147 148 v = ucv_object_get(attrs, "ospeed", NULL); 149 if (v) cfsetospeed(&t, (speed_t)ucv_to_unsigned(v)); 150 151 cc = ucv_object_get(attrs, "cc", NULL); 152 153 if (ucv_type(cc) == UC_ARRAY) { 154 n = ucv_array_length(cc); 155 156 for (i = 0; i < n && i < NCCS; i++) { 157 v = ucv_array_get(cc, i); 158 if (v) t.c_cc[i] = (cc_t)ucv_to_unsigned(v); 159 } 160 } 161 162 act = (ucv_type(when) == UC_INTEGER) ? (int)ucv_int64_get(when) : TCSANOW; 163 164 if (tcsetattr(fd, act, &t) != 0) 165 err_return(errno); 166 167 return ucv_boolean_new(true); 168 } 169 170 static uc_value_t * 171 uc_serial_setspeed(uc_vm_t *vm, size_t nargs) 172 { 173 uc_value_t *speed = uc_fn_arg(1); 174 uc_value_t *when = uc_fn_arg(2); 175 struct termios t; 176 speed_t spd; 177 int fd, act; 178 179 fd = get_fd(vm, uc_fn_arg(0)); 180 181 if (fd < 0) 182 err_return(EBADF); 183 184 if (ucv_type(speed) != UC_INTEGER) 185 err_return(EINVAL); 186 187 spd = (speed_t)ucv_to_unsigned(speed); 188 189 if (tcgetattr(fd, &t) != 0) 190 err_return(errno); 191 192 if (cfsetispeed(&t, spd) != 0 || cfsetospeed(&t, spd) != 0) 193 err_return(errno); 194 195 act = (ucv_type(when) == UC_INTEGER) ? (int)ucv_int64_get(when) : TCSANOW; 196 197 if (tcsetattr(fd, act, &t) != 0) 198 err_return(errno); 199 200 return ucv_boolean_new(true); 201 } 202 203 static uc_value_t * 204 uc_serial_setraw(uc_vm_t *vm, size_t nargs) 205 { 206 uc_value_t *when = uc_fn_arg(1); 207 struct termios t; 208 int fd, act; 209 210 fd = get_fd(vm, uc_fn_arg(0)); 211 212 if (fd < 0) 213 err_return(EBADF); 214 215 if (tcgetattr(fd, &t) != 0) 216 err_return(errno); 217 218 cfmakeraw(&t); 219 220 act = (ucv_type(when) == UC_INTEGER) ? (int)ucv_int64_get(when) : TCSANOW; 221 222 if (tcsetattr(fd, act, &t) != 0) 223 err_return(errno); 224 225 return ucv_boolean_new(true); 226 } 227 228 static uc_value_t * 229 uc_serial_setblocking(uc_vm_t *vm, size_t nargs) 230 { 231 uc_value_t *vmin = uc_fn_arg(1); 232 uc_value_t *vtime = uc_fn_arg(2); 233 uc_value_t *when = uc_fn_arg(3); 234 struct termios t; 235 int fd, act; 236 237 fd = get_fd(vm, uc_fn_arg(0)); 238 239 if (fd < 0) 240 err_return(EBADF); 241 242 if (ucv_type(vmin) != UC_INTEGER || ucv_type(vtime) != UC_INTEGER) 243 err_return(EINVAL); 244 245 if (tcgetattr(fd, &t) != 0) 246 err_return(errno); 247 248 t.c_cc[VMIN] = (cc_t)ucv_to_unsigned(vmin); 249 t.c_cc[VTIME] = (cc_t)ucv_to_unsigned(vtime); 250 251 act = (ucv_type(when) == UC_INTEGER) ? (int)ucv_int64_get(when) : TCSANOW; 252 253 if (tcsetattr(fd, act, &t) != 0) 254 err_return(errno); 255 256 return ucv_boolean_new(true); 257 } 258 259 static uc_value_t * 260 uc_serial_mget(uc_vm_t *vm, size_t nargs) 261 { 262 int fd, bits; 263 264 fd = get_fd(vm, uc_fn_arg(0)); 265 266 if (fd < 0) 267 err_return(EBADF); 268 269 if (ioctl(fd, TIOCMGET, &bits) != 0) 270 err_return(errno); 271 272 return ucv_int64_new(bits); 273 } 274 275 static uc_value_t * 276 uc_serial_mset(uc_vm_t *vm, size_t nargs) 277 { 278 uc_value_t *b = uc_fn_arg(1); 279 int fd, bits; 280 281 fd = get_fd(vm, uc_fn_arg(0)); 282 283 if (fd < 0) 284 err_return(EBADF); 285 286 if (ucv_type(b) != UC_INTEGER) 287 err_return(EINVAL); 288 289 bits = (int)ucv_int64_get(b); 290 291 if (ioctl(fd, TIOCMSET, &bits) != 0) 292 err_return(errno); 293 294 return ucv_boolean_new(true); 295 } 296 297 static uc_value_t * 298 serial_modem_change(uc_vm_t *vm, size_t nargs, unsigned long req) 299 { 300 uc_value_t *b = uc_fn_arg(1); 301 int fd, bits; 302 303 fd = get_fd(vm, uc_fn_arg(0)); 304 305 if (fd < 0) 306 err_return(EBADF); 307 308 if (ucv_type(b) != UC_INTEGER) 309 err_return(EINVAL); 310 311 bits = (int)ucv_int64_get(b); 312 313 if (ioctl(fd, req, &bits) != 0) 314 err_return(errno); 315 316 return ucv_boolean_new(true); 317 } 318 319 static uc_value_t * 320 uc_serial_mbis(uc_vm_t *vm, size_t nargs) 321 { 322 return serial_modem_change(vm, nargs, TIOCMBIS); 323 } 324 325 static uc_value_t * 326 uc_serial_mbic(uc_vm_t *vm, size_t nargs) 327 { 328 return serial_modem_change(vm, nargs, TIOCMBIC); 329 } 330 331 static uc_value_t * 332 serial_modem_line(uc_vm_t *vm, size_t nargs, int bit) 333 { 334 uc_value_t *on = uc_fn_arg(1); 335 int fd; 336 337 fd = get_fd(vm, uc_fn_arg(0)); 338 339 if (fd < 0) 340 err_return(EBADF); 341 342 if (ioctl(fd, ucv_is_truish(on) ? TIOCMBIS : TIOCMBIC, &bit) != 0) 343 err_return(errno); 344 345 return ucv_boolean_new(true); 346 } 347 348 static uc_value_t * 349 uc_serial_dtr(uc_vm_t *vm, size_t nargs) 350 { 351 return serial_modem_line(vm, nargs, TIOCM_DTR); 352 } 353 354 static uc_value_t * 355 uc_serial_rts(uc_vm_t *vm, size_t nargs) 356 { 357 return serial_modem_line(vm, nargs, TIOCM_RTS); 358 } 359 360 static uc_value_t * 361 uc_serial_sendbreak(uc_vm_t *vm, size_t nargs) 362 { 363 uc_value_t *dur = uc_fn_arg(1); 364 int fd, d; 365 366 fd = get_fd(vm, uc_fn_arg(0)); 367 368 if (fd < 0) 369 err_return(EBADF); 370 371 d = (ucv_type(dur) == UC_INTEGER) ? (int)ucv_int64_get(dur) : 0; 372 373 if (tcsendbreak(fd, d) != 0) 374 err_return(errno); 375 376 return ucv_boolean_new(true); 377 } 378 379 static uc_value_t * 380 uc_serial_drain(uc_vm_t *vm, size_t nargs) 381 { 382 int fd = get_fd(vm, uc_fn_arg(0)); 383 384 if (fd < 0) 385 err_return(EBADF); 386 387 if (tcdrain(fd) != 0) 388 err_return(errno); 389 390 return ucv_boolean_new(true); 391 } 392 393 static uc_value_t * 394 uc_serial_flush(uc_vm_t *vm, size_t nargs) 395 { 396 uc_value_t *q = uc_fn_arg(1); 397 int fd, queue; 398 399 fd = get_fd(vm, uc_fn_arg(0)); 400 401 if (fd < 0) 402 err_return(EBADF); 403 404 queue = (ucv_type(q) == UC_INTEGER) ? (int)ucv_int64_get(q) : TCIOFLUSH; 405 406 if (tcflush(fd, queue) != 0) 407 err_return(errno); 408 409 return ucv_boolean_new(true); 410 } 411 412 static uc_value_t * 413 serial_queue_count(uc_vm_t *vm, size_t nargs, unsigned long req) 414 { 415 int fd, n = 0; 416 417 fd = get_fd(vm, uc_fn_arg(0)); 418 419 if (fd < 0) 420 err_return(EBADF); 421 422 if (ioctl(fd, req, &n) != 0) 423 err_return(errno); 424 425 return ucv_int64_new(n); 426 } 427 428 static uc_value_t * 429 uc_serial_input_waiting(uc_vm_t *vm, size_t nargs) 430 { 431 return serial_queue_count(vm, nargs, TIOCINQ); 432 } 433 434 static uc_value_t * 435 uc_serial_output_waiting(uc_vm_t *vm, size_t nargs) 436 { 437 return serial_queue_count(vm, nargs, TIOCOUTQ); 438 } 439 440 #ifdef __linux__ 441 static uc_value_t * 442 uc_serial_getinfo(uc_vm_t *vm, size_t nargs) 443 { 444 struct serial_struct ss; 445 uc_value_t *rv; 446 int fd; 447 448 fd = get_fd(vm, uc_fn_arg(0)); 449 450 if (fd < 0) 451 err_return(EBADF); 452 453 if (ioctl(fd, TIOCGSERIAL, &ss) != 0) 454 err_return(errno); 455 456 rv = ucv_object_new(vm); 457 458 ucv_object_add(rv, "type", ucv_int64_new(ss.type)); 459 ucv_object_add(rv, "line", ucv_int64_new(ss.line)); 460 ucv_object_add(rv, "port", ucv_uint64_new(ss.port)); 461 ucv_object_add(rv, "irq", ucv_int64_new(ss.irq)); 462 ucv_object_add(rv, "flags", ucv_int64_new(ss.flags)); 463 ucv_object_add(rv, "xmit_fifo_size", ucv_int64_new(ss.xmit_fifo_size)); 464 ucv_object_add(rv, "custom_divisor", ucv_int64_new(ss.custom_divisor)); 465 ucv_object_add(rv, "baud_base", ucv_int64_new(ss.baud_base)); 466 ucv_object_add(rv, "close_delay", ucv_int64_new(ss.close_delay)); 467 ucv_object_add(rv, "closing_wait", ucv_int64_new(ss.closing_wait)); 468 ucv_object_add(rv, "hub6", ucv_int64_new(ss.hub6)); 469 ucv_object_add(rv, "io_type", ucv_int64_new(ss.io_type)); 470 ucv_object_add(rv, "port_high", ucv_uint64_new(ss.port_high)); 471 ucv_object_add(rv, "iomem_reg_shift", ucv_int64_new(ss.iomem_reg_shift)); 472 473 return rv; 474 } 475 476 static uc_value_t * 477 uc_serial_setinfo(uc_vm_t *vm, size_t nargs) 478 { 479 uc_value_t *opts = uc_fn_arg(1); 480 uc_value_t *v; 481 struct serial_struct ss; 482 int fd; 483 484 fd = get_fd(vm, uc_fn_arg(0)); 485 486 if (fd < 0) 487 err_return(EBADF); 488 489 if (ucv_type(opts) != UC_OBJECT) 490 err_return(EINVAL); 491 492 if (ioctl(fd, TIOCGSERIAL, &ss) != 0) 493 err_return(errno); 494 495 v = ucv_object_get(opts, "type", NULL); 496 if (v) ss.type = (int)ucv_int64_get(v); 497 498 v = ucv_object_get(opts, "port", NULL); 499 if (v) ss.port = (unsigned int)ucv_to_unsigned(v); 500 501 v = ucv_object_get(opts, "irq", NULL); 502 if (v) ss.irq = (int)ucv_int64_get(v); 503 504 v = ucv_object_get(opts, "flags", NULL); 505 if (v) ss.flags = (int)ucv_int64_get(v); 506 507 v = ucv_object_get(opts, "xmit_fifo_size", NULL); 508 if (v) ss.xmit_fifo_size = (int)ucv_int64_get(v); 509 510 v = ucv_object_get(opts, "custom_divisor", NULL); 511 if (v) ss.custom_divisor = (int)ucv_int64_get(v); 512 513 v = ucv_object_get(opts, "baud_base", NULL); 514 if (v) ss.baud_base = (int)ucv_int64_get(v); 515 516 v = ucv_object_get(opts, "close_delay", NULL); 517 if (v) ss.close_delay = (unsigned short)ucv_to_unsigned(v); 518 519 v = ucv_object_get(opts, "closing_wait", NULL); 520 if (v) ss.closing_wait = (unsigned short)ucv_to_unsigned(v); 521 522 v = ucv_object_get(opts, "hub6", NULL); 523 if (v) ss.hub6 = (int)ucv_int64_get(v); 524 525 v = ucv_object_get(opts, "port_high", NULL); 526 if (v) ss.port_high = (unsigned int)ucv_to_unsigned(v); 527 528 v = ucv_object_get(opts, "iomem_reg_shift", NULL); 529 if (v) ss.iomem_reg_shift = (unsigned short)ucv_to_unsigned(v); 530 531 if (ioctl(fd, TIOCSSERIAL, &ss) != 0) 532 err_return(errno); 533 534 return ucv_boolean_new(true); 535 } 536 537 static uc_value_t * 538 uc_serial_lowlatency(uc_vm_t *vm, size_t nargs) 539 { 540 uc_value_t *on = uc_fn_arg(1); 541 struct serial_struct ss; 542 int fd; 543 544 fd = get_fd(vm, uc_fn_arg(0)); 545 546 if (fd < 0) 547 err_return(EBADF); 548 549 if (ioctl(fd, TIOCGSERIAL, &ss) != 0) 550 err_return(errno); 551 552 if (ucv_is_truish(on)) 553 ss.flags |= ASYNC_LOW_LATENCY; 554 else 555 ss.flags &= ~ASYNC_LOW_LATENCY; 556 557 if (ioctl(fd, TIOCSSERIAL, &ss) != 0) 558 err_return(errno); 559 560 return ucv_boolean_new(true); 561 } 562 #endif 563 564 static const uc_function_list_t global_fns[] = { 565 { "error", uc_serial_error }, 566 { "isatty", uc_serial_isatty }, 567 { "attr", uc_serial_attr }, 568 { "setattr", uc_serial_setattr }, 569 { "setspeed", uc_serial_setspeed }, 570 { "setraw", uc_serial_setraw }, 571 { "setblocking", uc_serial_setblocking }, 572 { "mget", uc_serial_mget }, 573 { "mset", uc_serial_mset }, 574 { "mbis", uc_serial_mbis }, 575 { "mbic", uc_serial_mbic }, 576 { "dtr", uc_serial_dtr }, 577 { "rts", uc_serial_rts }, 578 { "sendbreak", uc_serial_sendbreak }, 579 { "drain", uc_serial_drain }, 580 { "flush", uc_serial_flush }, 581 { "input_waiting", uc_serial_input_waiting }, 582 { "output_waiting", uc_serial_output_waiting }, 583 #ifdef __linux__ 584 { "getinfo", uc_serial_getinfo }, 585 { "setinfo", uc_serial_setinfo }, 586 { "lowlatency", uc_serial_lowlatency }, 587 #endif 588 }; 589 590 void uc_module_init(uc_vm_t *vm, uc_value_t *scope) 591 { 592 uc_function_list_register(scope, global_fns); 593 594 #define ADD_CONST(x) ucv_object_add(scope, #x, ucv_int64_new(x)) 595 596 #ifdef TCSANOW 597 ADD_CONST(TCSANOW); 598 #endif 599 #ifdef TCSADRAIN 600 ADD_CONST(TCSADRAIN); 601 #endif 602 #ifdef TCSAFLUSH 603 ADD_CONST(TCSAFLUSH); 604 #endif 605 606 #ifdef TCIFLUSH 607 ADD_CONST(TCIFLUSH); 608 #endif 609 #ifdef TCOFLUSH 610 ADD_CONST(TCOFLUSH); 611 #endif 612 #ifdef TCIOFLUSH 613 ADD_CONST(TCIOFLUSH); 614 #endif 615 616 #ifdef CSIZE 617 ADD_CONST(CSIZE); 618 #endif 619 #ifdef CS5 620 ADD_CONST(CS5); 621 #endif 622 #ifdef CS6 623 ADD_CONST(CS6); 624 #endif 625 #ifdef CS7 626 ADD_CONST(CS7); 627 #endif 628 #ifdef CS8 629 ADD_CONST(CS8); 630 #endif 631 #ifdef CSTOPB 632 ADD_CONST(CSTOPB); 633 #endif 634 #ifdef CREAD 635 ADD_CONST(CREAD); 636 #endif 637 #ifdef PARENB 638 ADD_CONST(PARENB); 639 #endif 640 #ifdef PARODD 641 ADD_CONST(PARODD); 642 #endif 643 #ifdef HUPCL 644 ADD_CONST(HUPCL); 645 #endif 646 #ifdef CLOCAL 647 ADD_CONST(CLOCAL); 648 #endif 649 #ifdef CRTSCTS 650 ADD_CONST(CRTSCTS); 651 #endif 652 #ifdef CMSPAR 653 ADD_CONST(CMSPAR); 654 #endif 655 #ifdef CBAUD 656 ADD_CONST(CBAUD); 657 #endif 658 #ifdef CBAUDEX 659 ADD_CONST(CBAUDEX); 660 #endif 661 662 #ifdef IGNBRK 663 ADD_CONST(IGNBRK); 664 #endif 665 #ifdef BRKINT 666 ADD_CONST(BRKINT); 667 #endif 668 #ifdef IGNPAR 669 ADD_CONST(IGNPAR); 670 #endif 671 #ifdef PARMRK 672 ADD_CONST(PARMRK); 673 #endif 674 #ifdef INPCK 675 ADD_CONST(INPCK); 676 #endif 677 #ifdef ISTRIP 678 ADD_CONST(ISTRIP); 679 #endif 680 #ifdef INLCR 681 ADD_CONST(INLCR); 682 #endif 683 #ifdef IGNCR 684 ADD_CONST(IGNCR); 685 #endif 686 #ifdef ICRNL 687 ADD_CONST(ICRNL); 688 #endif 689 #ifdef IUCLC 690 ADD_CONST(IUCLC); 691 #endif 692 #ifdef IXON 693 ADD_CONST(IXON); 694 #endif 695 #ifdef IXANY 696 ADD_CONST(IXANY); 697 #endif 698 #ifdef IXOFF 699 ADD_CONST(IXOFF); 700 #endif 701 #ifdef IMAXBEL 702 ADD_CONST(IMAXBEL); 703 #endif 704 #ifdef IUTF8 705 ADD_CONST(IUTF8); 706 #endif 707 708 #ifdef OPOST 709 ADD_CONST(OPOST); 710 #endif 711 #ifdef OLCUC 712 ADD_CONST(OLCUC); 713 #endif 714 #ifdef ONLCR 715 ADD_CONST(ONLCR); 716 #endif 717 #ifdef OCRNL 718 ADD_CONST(OCRNL); 719 #endif 720 #ifdef ONOCR 721 ADD_CONST(ONOCR); 722 #endif 723 #ifdef ONLRET 724 ADD_CONST(ONLRET); 725 #endif 726 #ifdef OFILL 727 ADD_CONST(OFILL); 728 #endif 729 #ifdef OFDEL 730 ADD_CONST(OFDEL); 731 #endif 732 733 #ifdef ISIG 734 ADD_CONST(ISIG); 735 #endif 736 #ifdef ICANON 737 ADD_CONST(ICANON); 738 #endif 739 #ifdef ECHO 740 ADD_CONST(ECHO); 741 #endif 742 #ifdef ECHOE 743 ADD_CONST(ECHOE); 744 #endif 745 #ifdef ECHOK 746 ADD_CONST(ECHOK); 747 #endif 748 #ifdef ECHONL 749 ADD_CONST(ECHONL); 750 #endif 751 #ifdef ECHOCTL 752 ADD_CONST(ECHOCTL); 753 #endif 754 #ifdef ECHOKE 755 ADD_CONST(ECHOKE); 756 #endif 757 #ifdef NOFLSH 758 ADD_CONST(NOFLSH); 759 #endif 760 #ifdef TOSTOP 761 ADD_CONST(TOSTOP); 762 #endif 763 #ifdef IEXTEN 764 ADD_CONST(IEXTEN); 765 #endif 766 767 #ifdef VINTR 768 ADD_CONST(VINTR); 769 #endif 770 #ifdef VQUIT 771 ADD_CONST(VQUIT); 772 #endif 773 #ifdef VERASE 774 ADD_CONST(VERASE); 775 #endif 776 #ifdef VKILL 777 ADD_CONST(VKILL); 778 #endif 779 #ifdef VEOF 780 ADD_CONST(VEOF); 781 #endif 782 #ifdef VTIME 783 ADD_CONST(VTIME); 784 #endif 785 #ifdef VMIN 786 ADD_CONST(VMIN); 787 #endif 788 #ifdef VSWTC 789 ADD_CONST(VSWTC); 790 #endif 791 #ifdef VSTART 792 ADD_CONST(VSTART); 793 #endif 794 #ifdef VSTOP 795 ADD_CONST(VSTOP); 796 #endif 797 #ifdef VSUSP 798 ADD_CONST(VSUSP); 799 #endif 800 #ifdef VEOL 801 ADD_CONST(VEOL); 802 #endif 803 #ifdef VREPRINT 804 ADD_CONST(VREPRINT); 805 #endif 806 #ifdef VDISCARD 807 ADD_CONST(VDISCARD); 808 #endif 809 #ifdef VWERASE 810 ADD_CONST(VWERASE); 811 #endif 812 #ifdef VLNEXT 813 ADD_CONST(VLNEXT); 814 #endif 815 #ifdef VEOL2 816 ADD_CONST(VEOL2); 817 #endif 818 #ifdef NCCS 819 ADD_CONST(NCCS); 820 #endif 821 822 #ifdef B0 823 ADD_CONST(B0); 824 #endif 825 #ifdef B50 826 ADD_CONST(B50); 827 #endif 828 #ifdef B75 829 ADD_CONST(B75); 830 #endif 831 #ifdef B110 832 ADD_CONST(B110); 833 #endif 834 #ifdef B134 835 ADD_CONST(B134); 836 #endif 837 #ifdef B150 838 ADD_CONST(B150); 839 #endif 840 #ifdef B200 841 ADD_CONST(B200); 842 #endif 843 #ifdef B300 844 ADD_CONST(B300); 845 #endif 846 #ifdef B600 847 ADD_CONST(B600); 848 #endif 849 #ifdef B1200 850 ADD_CONST(B1200); 851 #endif 852 #ifdef B1800 853 ADD_CONST(B1800); 854 #endif 855 #ifdef B2400 856 ADD_CONST(B2400); 857 #endif 858 #ifdef B4800 859 ADD_CONST(B4800); 860 #endif 861 #ifdef B9600 862 ADD_CONST(B9600); 863 #endif 864 #ifdef B19200 865 ADD_CONST(B19200); 866 #endif 867 #ifdef B38400 868 ADD_CONST(B38400); 869 #endif 870 #ifdef B57600 871 ADD_CONST(B57600); 872 #endif 873 #ifdef B115200 874 ADD_CONST(B115200); 875 #endif 876 #ifdef B230400 877 ADD_CONST(B230400); 878 #endif 879 #ifdef B460800 880 ADD_CONST(B460800); 881 #endif 882 #ifdef B500000 883 ADD_CONST(B500000); 884 #endif 885 #ifdef B576000 886 ADD_CONST(B576000); 887 #endif 888 #ifdef B921600 889 ADD_CONST(B921600); 890 #endif 891 #ifdef B1000000 892 ADD_CONST(B1000000); 893 #endif 894 #ifdef B1152000 895 ADD_CONST(B1152000); 896 #endif 897 #ifdef B1500000 898 ADD_CONST(B1500000); 899 #endif 900 #ifdef B2000000 901 ADD_CONST(B2000000); 902 #endif 903 #ifdef B2500000 904 ADD_CONST(B2500000); 905 #endif 906 #ifdef B3000000 907 ADD_CONST(B3000000); 908 #endif 909 #ifdef B3500000 910 ADD_CONST(B3500000); 911 #endif 912 #ifdef B4000000 913 ADD_CONST(B4000000); 914 #endif 915 916 #ifdef TIOCM_LE 917 ADD_CONST(TIOCM_LE); 918 #endif 919 #ifdef TIOCM_DTR 920 ADD_CONST(TIOCM_DTR); 921 #endif 922 #ifdef TIOCM_RTS 923 ADD_CONST(TIOCM_RTS); 924 #endif 925 #ifdef TIOCM_ST 926 ADD_CONST(TIOCM_ST); 927 #endif 928 #ifdef TIOCM_SR 929 ADD_CONST(TIOCM_SR); 930 #endif 931 #ifdef TIOCM_CTS 932 ADD_CONST(TIOCM_CTS); 933 #endif 934 #ifdef TIOCM_CAR 935 ADD_CONST(TIOCM_CAR); 936 #endif 937 #ifdef TIOCM_CD 938 ADD_CONST(TIOCM_CD); 939 #endif 940 #ifdef TIOCM_RNG 941 ADD_CONST(TIOCM_RNG); 942 #endif 943 #ifdef TIOCM_RI 944 ADD_CONST(TIOCM_RI); 945 #endif 946 #ifdef TIOCM_DSR 947 ADD_CONST(TIOCM_DSR); 948 #endif 949 950 #ifdef __linux__ 951 #ifdef ASYNC_HUP_NOTIFY 952 ADD_CONST(ASYNC_HUP_NOTIFY); 953 #endif 954 #ifdef ASYNC_FOURPORT 955 ADD_CONST(ASYNC_FOURPORT); 956 #endif 957 #ifdef ASYNC_SAK 958 ADD_CONST(ASYNC_SAK); 959 #endif 960 #ifdef ASYNC_SPD_HI 961 ADD_CONST(ASYNC_SPD_HI); 962 #endif 963 #ifdef ASYNC_SPD_VHI 964 ADD_CONST(ASYNC_SPD_VHI); 965 #endif 966 #ifdef ASYNC_SPD_SHI 967 ADD_CONST(ASYNC_SPD_SHI); 968 #endif 969 #ifdef ASYNC_SPD_CUST 970 ADD_CONST(ASYNC_SPD_CUST); 971 #endif 972 #ifdef ASYNC_SPD_WARP 973 ADD_CONST(ASYNC_SPD_WARP); 974 #endif 975 #ifdef ASYNC_SPD_MASK 976 ADD_CONST(ASYNC_SPD_MASK); 977 #endif 978 #ifdef ASYNC_SKIP_TEST 979 ADD_CONST(ASYNC_SKIP_TEST); 980 #endif 981 #ifdef ASYNC_AUTO_IRQ 982 ADD_CONST(ASYNC_AUTO_IRQ); 983 #endif 984 #ifdef ASYNC_CALLOUT_NOHUP 985 ADD_CONST(ASYNC_CALLOUT_NOHUP); 986 #endif 987 #ifdef ASYNC_LOW_LATENCY 988 ADD_CONST(ASYNC_LOW_LATENCY); 989 #endif 990 #ifdef ASYNC_BUGGY_UART 991 ADD_CONST(ASYNC_BUGGY_UART); 992 #endif 993 #ifdef ASYNC_CLOSING_WAIT_INF 994 ADD_CONST(ASYNC_CLOSING_WAIT_INF); 995 #endif 996 #ifdef ASYNC_CLOSING_WAIT_NONE 997 ADD_CONST(ASYNC_CLOSING_WAIT_NONE); 998 #endif 999 1000 #ifdef PORT_UNKNOWN 1001 ADD_CONST(PORT_UNKNOWN); 1002 #endif 1003 #ifdef PORT_8250 1004 ADD_CONST(PORT_8250); 1005 #endif 1006 #ifdef PORT_16450 1007 ADD_CONST(PORT_16450); 1008 #endif 1009 #ifdef PORT_16550 1010 ADD_CONST(PORT_16550); 1011 #endif 1012 #ifdef PORT_16550A 1013 ADD_CONST(PORT_16550A); 1014 #endif 1015 #ifdef PORT_16650 1016 ADD_CONST(PORT_16650); 1017 #endif 1018 #ifdef PORT_16650V2 1019 ADD_CONST(PORT_16650V2); 1020 #endif 1021 #ifdef PORT_16750 1022 ADD_CONST(PORT_16750); 1023 #endif 1024 #endif 1025 1026 #undef ADD_CONST 1027 } 1028
This page was automatically generated by LXR 0.3.1. • OpenWrt