Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc

Issue 1679643002: nacl_io: Add SOCK_DGRAM support to socketpair() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit test failure Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "nacl_io/kernel_proxy.h" 5 #include "nacl_io/kernel_proxy.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <limits.h> 10 #include <limits.h>
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 if (AF_INET == domain || AF_INET6 == domain) { 1817 if (AF_INET == domain || AF_INET6 == domain) {
1818 errno = EOPNOTSUPP; 1818 errno = EOPNOTSUPP;
1819 return -1; 1819 return -1;
1820 } 1820 }
1821 1821
1822 if (AF_UNIX != domain) { 1822 if (AF_UNIX != domain) {
1823 errno = EAFNOSUPPORT; 1823 errno = EAFNOSUPPORT;
1824 return -1; 1824 return -1;
1825 } 1825 }
1826 1826
1827 if (SOCK_STREAM != type) { 1827 // TODO(cernekee): mask this off with SOCK_TYPE_MASK first.
1828 if (SOCK_STREAM != type && SOCK_DGRAM != type) {
1828 errno = EPROTOTYPE; 1829 errno = EPROTOTYPE;
1829 return -1; 1830 return -1;
1830 } 1831 }
1831 1832
1832 int open_flags = O_RDWR; 1833 int open_flags = O_RDWR;
1833 1834
1834 #if defined(SOCK_CLOEXEC) 1835 #if defined(SOCK_CLOEXEC)
1835 if (type & SOCK_CLOEXEC) { 1836 if (type & SOCK_CLOEXEC) {
1836 #if defined(O_CLOEXEC) 1837 #if defined(O_CLOEXEC)
1837 // The NaCl newlib version of fcntl.h doesn't currently define 1838 // The NaCl newlib version of fcntl.h doesn't currently define
1838 // O_CLOEXEC. 1839 // O_CLOEXEC.
1839 // TODO(sbc): remove this guard once it gets added. 1840 // TODO(sbc): remove this guard once it gets added.
1840 open_flags |= O_CLOEXEC; 1841 open_flags |= O_CLOEXEC;
1841 #endif 1842 #endif
1842 type &= ~SOCK_CLOEXEC; 1843 type &= ~SOCK_CLOEXEC;
1843 } 1844 }
1844 #endif 1845 #endif
1845 1846
1846 #if defined(SOCK_NONBLOCK) 1847 #if defined(SOCK_NONBLOCK)
1847 if (type & SOCK_NONBLOCK) { 1848 if (type & SOCK_NONBLOCK) {
1848 open_flags |= O_NONBLOCK; 1849 open_flags |= O_NONBLOCK;
1849 type &= ~SOCK_NONBLOCK; 1850 type &= ~SOCK_NONBLOCK;
1850 } 1851 }
1851 #endif 1852 #endif
1852 1853
1853 UnixNode* socket = new UnixNode(stream_fs_.get()); 1854 UnixNode* socket = new UnixNode(stream_fs_.get(), type);
1854 Error rtn = socket->Init(O_RDWR); 1855 Error rtn = socket->Init(O_RDWR);
1855 if (rtn != 0) { 1856 if (rtn != 0) {
1856 errno = rtn; 1857 errno = rtn;
1857 return -1; 1858 return -1;
1858 } 1859 }
1859 ScopedNode node0(socket); 1860 ScopedNode node0(socket);
1860 socket = new UnixNode(stream_fs_.get(), *socket); 1861 socket = new UnixNode(stream_fs_.get(), *socket);
1861 rtn = socket->Init(O_RDWR); 1862 rtn = socket->Init(O_RDWR);
1862 if (rtn != 0) { 1863 if (rtn != 0) {
1863 errno = rtn; 1864 errno = rtn;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 errno = ENOTSOCK; 1896 errno = ENOTSOCK;
1896 return -1; 1897 return -1;
1897 } 1898 }
1898 1899
1899 return 0; 1900 return 0;
1900 } 1901 }
1901 1902
1902 #endif // PROVIDES_SOCKET_API 1903 #endif // PROVIDES_SOCKET_API
1903 1904
1904 } // namespace_nacl_io 1905 } // namespace_nacl_io
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698