Searched defs:fcntl (Results 1 - 9 of 9) sorted by relevance

/external/webkit/Tools/Scripts/webkitpy/common/system/
H A Dfile_lock.py47 import fcntl namespace
48 fcntl.flock(self._lock_file_descriptor, fcntl.LOCK_EX | fcntl.LOCK_NB)
55 import fcntl namespace
56 fcntl.flock(self._lock_file_descriptor, fcntl.LOCK_UN)
/external/bison/lib/
H A Dfcntl.c23 #include <fcntl.h>
31 # define rpl_fcntl fcntl
33 #undef fcntl macro
152 native fcntl. An unrecognized ACTION returns -1 with errno set to
194 int flags = fcntl (fd, F_GETFD);
200 result = fcntl (fd, action, target);
201 if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
235 result = fcntl (fd, action, target);
256 int flags = fcntl (result, F_GETFD);
257 if (flags < 0 || fcntl (resul
[all...]
H A Derror.c88 # include <fcntl.h>
99 /* The gnulib override of fcntl is not needed in this file. */
100 # undef fcntl macro
130 There is no fcntl, and the gnulib replacement fcntl does not support
135 # error Please port fcntl to your platform
137 return 0 <= fcntl (fd, F_GETFL);
/external/webkit/Tools/Scripts/webkitpy/layout_tests/port/
H A Dserver_process.py40 import fcntl namespace
81 fl = fcntl.fcntl(fd, fcntl.F_GETFL)
82 fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
84 fl = fcntl.fcntl(fd, fcntl
[all...]
/external/bison/darwin-lib/
H A Dfcntl.h2 /* Like <fcntl.h>, but with non-working flags defined to 0.
33 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
34 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
41 #include_next <fcntl.h>
52 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
53 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
61 #include_next <fcntl.h>
400 # undef fcntl
401 # define fcntl rpl_fcntl
403 _GL_FUNCDECL_RPL (fcntl, in
411 _GL_CXXALIASWARN (fcntl); variable
413 # undef fcntl macro
[all...]
/external/bison/linux-lib/
H A Dfcntl.h2 /* Like <fcntl.h>, but with non-working flags defined to 0.
33 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
34 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
41 #include_next <fcntl.h>
52 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
53 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
61 #include_next <fcntl.h>
400 # undef fcntl macro
401 # define fcntl rpl_fcntl macro
403 _GL_FUNCDECL_RPL (fcntl, in
411 _GL_CXXALIASWARN (fcntl); variable
413 # undef fcntl macro
[all...]
/external/chromium/third_party/libjingle/source/talk/base/
H A Dphysicalsocketserver.cc37 #include <fcntl.h>
648 if (fcntl(afd_[0], F_SETFL, O_NONBLOCK) < 0) {
649 LOG_ERR(LS_WARNING) << "fcntl #1 failed";
651 if (fcntl(afd_[1], F_SETFL, O_NONBLOCK) < 0) {
652 LOG_ERR(LS_WARNING) << "fcntl #2 failed";
784 fcntl(s_, F_SETFL, fcntl(s_, F_GETFL, 0) | O_NONBLOCK);
886 fcntl(fd_, F_SETFL, fcntl(fd_, F_GETFL, 0) | O_NONBLOCK);
598 ASSERT(signum < ARRAY_SIZE(received_signal_)); if (signum < ARRAY_SIZE(received_signal_)) { return received_signal_[signum]; } else { return false; } } void ClearSignal(int signum) { ASSERT(signum < ARRAY_SIZE(received_signal_)); if (signum < ARRAY_SIZE(received_signal_)) { received_signal_[signum] = false; } } int GetDescriptor() const { return afd_[0]; } void OnPosixSignalReceived(int signum) { if (signum >= ARRAY_SIZE(received_signal_)) { return; } received_signal_[signum] = true; const uint8 b[1] = { 0 }; if (-1 == write(afd_[1], b, sizeof(b))) { return; } } private: PosixSignalHandler() { if (pipe(afd_) < 0) { LOG_ERR(LS_ERROR) << Ó; return; } if (fcntl(afd_[0], F_SETFL, O_NONBLOCK) < 0) { LOG_ERR(LS_WARNING) << Ó; } if (fcntl(afd_[1], F_SETFL, O_NONBLOCK) < 0) { LOG_ERR(LS_WARNING) << Ó; } memset(const_cast<void *>(static_cast<volatile void *>(received_signal_)), 0, sizeof(received_signal_)); } ~PosixSignalHandler() { int fd1 = afd_[0]; int fd2 = afd_[1]; afd_[0] = -1; afd_[1] = -1; close(fd1); close(fd2); } static PosixSignalHandler instance_; int afd_[2]; volatile uint8 received_signal_[kNumPosixSignals]; }; PosixSignalHandler PosixSignalHandler::instance_; class PosixSignalDispatcher : public Dispatcher { public: PosixSignalDispatcher(PhysicalSocketServer *owner) : owner_(owner) { owner_->Add(this); } virtual ~PosixSignalDispatcher() { owner_->Remove(this); } virtual uint32 GetRequestedEvents() { return DE_READ; } virtual void OnPreEvent(uint32 ff) { uint8 b[16]; ssize_t ret = read(GetDescriptor(), b, sizeof(b)); if (ret < 0) { LOG_ERR(LS_WARNING) << Ó; } else if (ret == 0) { LOG(LS_WARNING) << Ó; } } virtual void OnEvent(uint32 ff, int err) { for (int signum = 0; signum < PosixSignalHandler::kNumPosixSignals; ++signum) { if (PosixSignalHandler::Instance()->IsSignalSet(signum)) { PosixSignalHandler::Instance()->ClearSignal(signum); HandlerMap::iterator i = handlers_.find(signum); if (i == handlers_.end()) { LOG(LS_INFO) << Ó << signum; } else { (*i->second)(signum); } } } } virtual int GetDescriptor() { return PosixSignalHandler::Instance()->GetDescriptor(); } virtual bool IsDescriptorClosed() { return false; } void SetHandler(int signum, void (*handler)(int)) { handlers_[signum] = handler; } void ClearHandler(int signum) { handlers_.erase(signum); } bool HasHandlers() { return !handlers_.empty(); } private: typedef std::map<int, void (*)(int)> HandlerMap; HandlerMap handlers_; PhysicalSocketServer *owner_; }; class SocketDispatcher : public Dispatcher, public PhysicalSocket { public: explicit SocketDispatcher(PhysicalSocketServer *ss) : PhysicalSocket(ss) { } SocketDispatcher(SOCKET s, PhysicalSocketServer *ss) : PhysicalSocket(ss, s) { } virtual ~SocketDispatcher() { Close(); } bool Initialize() { ss_->Add(this); fcntl(s_, F_SETFL, fcntl(s_, F_GETFL, 0) | O_NONBLOCK); return true; } virtual bool Create(int type) { if (!PhysicalSocket::Create(type)) return false; return Initialize(); } virtual int GetDescriptor() { return s_; } virtual bool IsDescriptorClosed() { char ch; ssize_t res = ::recv(s_, &ch, 1, MSG_PEEK); if (res > 0) { return false; } else if (res == 0) { return true; } else { switch (errno) { case EBADF: case ECONNRESET: return true; default: LOG_ERR(LS_WARNING) << Ó; return false; } } } virtual uint32 GetRequestedEvents() { return enabled_events_; } virtual void OnPreEvent(uint32 ff) { if ((ff & DE_CONNECT) != 0) state_ = CS_CONNECTED; if ((ff & DE_CLOSE) != 0) state_ = CS_CLOSED; } virtual void OnEvent(uint32 ff, int err) { if ((ff & DE_READ) != 0) { enabled_events_ &= ~DE_READ; SignalReadEvent(this); } if ((ff & DE_WRITE) != 0) { enabled_events_ &= ~DE_WRITE; SignalWriteEvent(this); } if ((ff & DE_CONNECT) != 0) { enabled_events_ &= ~DE_CONNECT; SignalConnectEvent(this); } if ((ff & DE_ACCEPT) != 0) { enabled_events_ &= ~DE_ACCEPT; SignalReadEvent(this); } if ((ff & DE_CLOSE) != 0) { enabled_events_ = 0; SignalCloseEvent(this, err); } } virtual int Close() { if (s_ == INVALID_SOCKET) return 0; ss_->Remove(this); return PhysicalSocket::Close(); } }; class FileDispatcher: public Dispatcher, public AsyncFile { public: FileDispatcher(int fd, PhysicalSocketServer *ss) : ss_(ss), fd_(fd) { set_readable(true); ss_->Add(this); fcntl(fd_, F_SETFL, fcntl(fd_, F_GETFL, 0) | O_NONBLOCK); } virtual ~FileDispatcher() { ss_->Remove(this); } SocketServer* socketserver() { return ss_; } virtual int GetDescriptor() { return fd_; } virtual bool IsDescriptorClosed() { return false; } virtual uint32 GetRequestedEvents() { return flags_; } virtual void OnPreEvent(uint32 ff) { } virtual void OnEvent(uint32 ff, int err) { if ((ff & DE_READ) != 0) SignalReadEvent(this); if ((ff & DE_WRITE) != 0) SignalWriteEvent(this); if ((ff & DE_CLOSE) != 0) SignalCloseEvent(this, err); } virtual bool readable() { return (flags_ & DE_READ) != 0; } virtual void set_readable(bool value) { flags_ = value ? (flags_ | DE_READ) : (flags_ & ~DE_READ); } virtual bool writable() { return (flags_ & DE_WRITE) != 0; } virtual void set_writable(bool value) { flags_ = value ? (flags_ | DE_WRITE) : (flags_ & ~DE_WRITE); } private: PhysicalSocketServer* ss_; int fd_; int flags_; }; AsyncFile* PhysicalSocketServer::CreateFile(int fd) { return new FileDispatcher(fd, this); } static uint32 FlagsToEvents(uint32 events) { uint32 ffFD = FD_CLOSE; if (events & DE_READ) ffFD |= FD_READ; if (events & DE_WRITE) ffFD |= FD_WRITE; if (events & DE_CONNECT) ffFD |= FD_CONNECT; if (events & DE_ACCEPT) ffFD |= FD_ACCEPT; return ffFD; } class EventDispatcher : public Dispatcher { public: EventDispatcher(PhysicalSocketServer *ss) : ss_(ss) { hev_ = WSACreateEvent(); if (hev_) { ss_->Add(this); } } ~EventDispatcher() { if (hev_ != NULL) { ss_->Remove(this); WSACloseEvent(hev_); hev_ = NULL; } } virtual void Signal() { if (hev_ != NULL) WSASetEvent(hev_); } virtual uint32 GetRequestedEvents() { return 0; } virtual void OnPreEvent(uint32 ff) { WSAResetEvent(hev_); } virtual void OnEvent(uint32 ff, int err) { } virtual WSAEVENT GetWSAEvent() { return hev_; } virtual SOCKET GetSocket() { return INVALID_SOCKET; } virtual bool CheckSignalClose() { return false; } private: PhysicalSocketServer* ss_; WSAEVENT hev_; }; class SocketDispatcher : public Dispatcher, public PhysicalSocket { public: static int next_id_; int id_; bool signal_close_; int signal_err_; SocketDispatcher(PhysicalSocketServer* ss) : PhysicalSocket(ss), id_(0), signal_close_(false) { } SocketDispatcher(SOCKET s, PhysicalSocketServer* ss) : PhysicalSocket(ss, s), id_(0), signal_close_(false) { } virtual ~SocketDispatcher() { Close(); } bool Initialize() { ASSERT(s_ != INVALID_SOCKET); u_long argp = 1; ioctlsocket(s_, FIONBIO, &argp); ss_->Add(this); return true; } virtual bool Create(int type) { if (!PhysicalSocket::Create(type)) return false; if (!Initialize()) return false; do { id_ = ++next_id_; } while (id_ == 0); return true; } virtual int Close() { if (s_ == INVALID_SOCKET) return 0; id_ = 0; signal_close_ = false; ss_->Remove(this); return PhysicalSocket::Close(); } virtual uint32 GetRequestedEvents() { return enabled_events_; } virtual void OnPreEvent(uint32 ff) { if ((ff & DE_CONNECT) != 0) state_ = CS_CONNECTED; } virtual void OnEvent(uint32 ff, int err) { int cache_id = id_; if ((ff & DE_READ) != 0) { enabled_events_ &= ~DE_READ; SignalReadEvent(this); } if (((ff & DE_WRITE) != 0) && (id_ == cache_id)) { enabled_events_ &= ~DE_WRITE; SignalWriteEvent(this); } if (((ff & DE_CONNECT) != 0) && (id_ == cache_id)) { if (ff != DE_CONNECT) LOG(LS_VERBOSE) << Ó << ff; enabled_events_ &= ~DE_CONNECT; dbg_addr_ = Ó; dbg_addr_.append(GetRemoteAddress().ToString()); SignalConnectEvent(this); } if (((ff & DE_ACCEPT) != 0) && (id_ == cache_id)) { enabled_events_ &= ~DE_ACCEPT; SignalReadEvent(this); } if (((ff & DE_CLOSE) != 0) && (id_ == cache_id)) { signal_close_ = true; signal_err_ = err; } } virtual WSAEVENT GetWSAEvent() { return WSA_INVALID_EVENT; } virtual SOCKET GetSocket() { return s_; } virtual bool CheckSignalClose() { if (!signal_close_) return false; char ch; if (recv(s_, &ch, 1, MSG_PEEK) > 0) return false; state_ = CS_CLOSED; signal_close_ = false; SignalCloseEvent(this, signal_err_); return true; } }; int SocketDispatcher::next_id_ = 0; class Signaler : public EventDispatcher { public: Signaler(PhysicalSocketServer* ss, bool* pf) : EventDispatcher(ss), pf_(pf) { } virtual ~Signaler() { } void OnEvent(uint32 ff, int err) { if (pf_) *pf_ = false; } private: bool *pf_; }; PhysicalSocketServer::PhysicalSocketServer() : fWait_(false), last_tick_tracked_(0), last_tick_dispatch_count_(0) { signal_wakeup_ = new Signaler(this, &fWait_); socket_ev_ = WSACreateEvent(); } PhysicalSocketServer::~PhysicalSocketServer() { WSACloseEvent(socket_ev_); signal_dispatcher_.reset(); delete signal_wakeup_; ASSERT(dispatchers_.empty()); } void PhysicalSocketServer::WakeUp() { signal_wakeup_->Signal(); } Socket* PhysicalSocketServer::CreateSocket(int type) { PhysicalSocket* socket = new PhysicalSocket(this); if (socket->Create(type)) { return socket; } else { delete socket; return 0; } } AsyncSocket* PhysicalSocketServer::CreateAsyncSocket(int type) { SocketDispatcher* dispatcher = new SocketDispatcher(this); if (dispatcher->Create(type)) { return dispatcher; } else { delete dispatcher; return 0; } } AsyncSocket* PhysicalSocketServer::WrapSocket(SOCKET s) { SocketDispatcher* dispatcher = new SocketDispatcher(s, this); if (dispatcher->Initialize()) { return dispatcher; } else { delete dispatcher; return 0; } } void PhysicalSocketServer::Add(Dispatcher *pdispatcher) { CritScope cs(&crit_); DispatcherList::iterator pos = std::find(dispatchers_.begin(), dispatchers_.end(), pdispatcher); if (pos != dispatchers_.end()) return; dispatchers_.push_back(pdispatcher); } void PhysicalSocketServer::Remove(Dispatcher *pdispatcher) { CritScope cs(&crit_); DispatcherList::iterator pos = std::find(dispatchers_.begin(), dispatchers_.end(), pdispatcher); ASSERT(pos != dispatchers_.end()); size_t index = pos - dispatchers_.begin(); dispatchers_.erase(pos); for (IteratorList::iterator it = iterators_.begin(); it != iterators_.end(); ++it) { if (index < **it) { --**it; } } } bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { struct timeval *ptvWait = NULL; struct timeval tvWait; struct timeval tvStop; if (cmsWait != kForever) { tvWait.tv_sec = cmsWait / 1000; tvWait.tv_usec = (cmsWait % 1000) * 1000; ptvWait = &tvWait; gettimeofday(&tvStop, NULL); tvStop.tv_sec += tvWait.tv_sec; tvStop.tv_usec += tvWait.tv_usec; if (tvStop.tv_usec >= 1000000) { tvStop.tv_usec -= 1000000; tvStop.tv_sec += 1; } } fd_set fdsRead; FD_ZERO(&fdsRead); fd_set fdsWrite; FD_ZERO(&fdsWrite); fWait_ = true; while (fWait_) { int fdmax = -1; { CritScope cr(&crit_); for (size_t i = 0; i < dispatchers_.size(); ++i) { Dispatcher *pdispatcher = dispatchers_[i]; ASSERT(pdispatcher); if (!process_io && (pdispatcher != signal_wakeup_)) continue; int fd = pdispatcher->GetDescriptor(); if (fd > fdmax) fdmax = fd; uint32 ff = pdispatcher->GetRequestedEvents(); if (ff & (DE_READ | DE_ACCEPT)) FD_SET(fd, &fdsRead); if (ff & (DE_WRITE | DE_CONNECT)) FD_SET(fd, &fdsWrite); } } int n = select(fdmax + 1, &fdsRead, &fdsWrite, NULL, ptvWait); if (n < 0) { if (errno != EINTR) { LOG_E(LS_ERROR, EN, errno) << Ó; return false; } } else if (n == 0) { return true; } else { CritScope cr(&crit_); for (size_t i = 0; i < dispatchers_.size(); ++i) { Dispatcher *pdispatcher = dispatchers_[i]; int fd = pdispatcher->GetDescriptor(); uint32 ff = 0; int errcode = 0; if (FD_ISSET(fd, &fdsRead) || FD_ISSET(fd, &fdsWrite)) { socklen_t len = sizeof(errcode); ::getsockopt(fd, SOL_SOCKET, SO_ERROR, &errcode, &len); } if (FD_ISSET(fd, &fdsRead)) { FD_CLR(fd, &fdsRead); if (pdispatcher->GetRequestedEvents() & DE_ACCEPT) { ff |= DE_ACCEPT; } else if (errcode || pdispatcher->IsDescriptorClosed()) { ff |= DE_CLOSE; } else { ff |= DE_READ; } } if (FD_ISSET(fd, &fdsWrite)) { FD_CLR(fd, &fdsWrite); if (pdispatcher->GetRequestedEvents() & DE_CONNECT) { if (!errcode) { ff |= DE_CONNECT; } else { ff |= DE_CLOSE; } } else { ff |= DE_WRITE; } } if (ff != 0) { pdispatcher->OnPreEvent(ff); pdispatcher->OnEvent(ff, errcode); } } } if (cmsWait != kForever) { ptvWait->tv_sec = 0; ptvWait->tv_usec = 0; struct timeval tvT; gettimeofday(&tvT, NULL); if ((tvStop.tv_sec > tvT.tv_sec) || ((tvStop.tv_sec == tvT.tv_sec) && (tvStop.tv_usec > tvT.tv_usec) argument
/external/chromium-trace/trace-viewer/third_party/python_gflags/
H A Dgflags.py399 import fcntl namespace
401 fcntl = None variable
534 if (not sys.stdout.isatty()) or (termios is None) or (fcntl is None):
537 data = fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, '1234')
/external/valgrind/main/coregrind/
H A Dm_libcfile.c66 newfd = VG_(fcntl)(oldfd, VKI_F_DUPFD, VG_(fd_hard_limit));
71 VG_(fcntl)(newfd, VKI_F_SETFD, VKI_FD_CLOEXEC);
93 if (0 == VG_(fcntl)(fd, VKI_F_GETPATH, (UWord)tmp)) {
368 Int VG_(fcntl) ( Int fd, Int cmd, Addr arg ) function

Completed in 3678 milliseconds