zoukankan      html  css  js  c++  java
  • buildroot 编译udev 173 出错 'SOCK_NONBLOCK' undeclared

    root@james-desktop:/mnt/buildroot-2011.11# make
    >>> udev 173 Building
    PATH="/mnt/buildroot-2011.11/output/host/bin:/mnt/buildroot-2011.11/output/host/usr/bin:/mnt/buildroot-2011.11/output/host/usr/sbin/:/opt/QtSDK/Desktop/Qt/474/gcc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/ct-ng-1.13.2/bin/" PERLLIB="/mnt/buildroot-2011.11/output/host/usr/lib/perl"  /usr/bin/make -j2  -C /mnt/buildroot-2011.11/output/build/udev-173/
    make[1]: 正在进入目录 `/mnt/buildroot-2011.11/output/build/udev-173'
    /usr/bin/make --no-print-directory all-recursive
    Making all in .
      CC     libudev/libudev-monitor.lo
      CC     libudev/libudev-queue.lo
    libudev/libudev-monitor.c: In function 'udev_monitor_new_from_socket':
    libudev/libudev-monitor.c:153: error: 'SOCK_NONBLOCK' undeclared (first use in this function)
    libudev/libudev-monitor.c:153: error: (Each undeclared identifier is reported only once
    libudev/libudev-monitor.c:153: error: for each function it appears in.)
    libudev/libudev-monitor.c:153: error: 'SOCK_CLOEXEC' undeclared (first use in this function)
    libudev/libudev-monitor.c: In function 'udev_monitor_new_from_netlink_fd':
    libudev/libudev-monitor.c:186: error: 'SOCK_CLOEXEC' undeclared (first use in this function)
    libudev/libudev-monitor.c:186: error: 'SOCK_NONBLOCK' undeclared (first use in this function)

    http://blog.csdn.net/zjnig711/article/details/6148562

    #if defined(SOCK_NONBLOCK)
    return ::socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP);
    /* If they have O_NONBLOCK, use the Posix way to do it */
    #elif defined(O_NONBLOCK)
    /* Fixme: O_NONBLOCK is defined but broken on SunOS 4.1.x and AIX 3.2.5. */
    int sock = socket(PF_INET, SOCK_STREAM, 0);
    int flags;
    if (-1 == (flags = fcntl(sock, F_GETFL, 0)))
    flags = 0;
    fcntl(sock, F_SETFL, flags | O_NONBLOCK);
    return sock;
    #else
    int sock = socket(PF_INET, SOCK_STREAM, 0);
    /* Otherwise, use the old way of doing it */
    int flags = 1;
    ioctl(sock, FIOBIO, &flags);
    return sock;
    #endif

    http://kernel.org/doc/man-pages/online/pages/man2/socket.2.html

    int socket(int domain, int type, int protocol);

    Since Linux 2.6.27, the type argument serves a second purpose: in addition to specifying a socket type, it may include the bitwise OR of any of the following values, to modify the behavior of socket(): SOCK_NONBLOCK Set the O_NONBLOCK file status flag on the new open file description. Using this flag saves extra calls to fcntl(2) to achieve the same result. SOCK_CLOEXEC Set the close-on-exec (FD_CLOEXEC) flag on the new file descriptor. See the description of the O_CLOEXEC flag in open(2) for reasons why this may be useful.

    2.6.27才有SOCK_NONBLOCK ,我们用的内核是Linux 2.6.22

  • 相关阅读:
    unordered_set
    树的所有实现
    各类算法模板
    单链表全部实现(绝对史上最完整 附例题)
    求最长回文子串
    无重复的最长子串
    秋叶集
    1451. 重新排列句子中的单词
    152. 乘积最大子数组
    JVM总结的部分内容
  • 原文地址:https://www.cnblogs.com/cute/p/2314156.html
Copyright © 2011-2022 走看看