当前位置: 首页>>代码示例>>C++>>正文


C++ do_write函数代码示例

本文整理汇总了C++中do_write函数的典型用法代码示例。如果您正苦于以下问题:C++ do_write函数的具体用法?C++ do_write怎么用?C++ do_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了do_write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cvm_mmc_interrupt

irqreturn_t cvm_mmc_interrupt(int irq, void *dev_id)
{
	struct cvm_mmc_host *host = dev_id;
	struct mmc_request *req;
	unsigned long flags = 0;
	u64 emm_int, rsp_sts;
	bool host_done;

	if (host->need_irq_handler_lock)
		spin_lock_irqsave(&host->irq_handler_lock, flags);
	else
		__acquire(&host->irq_handler_lock);

	/* Clear interrupt bits (write 1 clears ). */
	emm_int = readq(host->base + MIO_EMM_INT(host));
	writeq(emm_int, host->base + MIO_EMM_INT(host));

	if (emm_int & MIO_EMM_INT_SWITCH_ERR)
		check_switch_errors(host);

	req = host->current_req;
	if (!req)
		goto out;

	rsp_sts = readq(host->base + MIO_EMM_RSP_STS(host));
	/*
	 * dma_val set means DMA is still in progress. Don't touch
	 * the request and wait for the interrupt indicating that
	 * the DMA is finished.
	 */
	if ((rsp_sts & MIO_EMM_RSP_STS_DMA_VAL) && host->dma_active)
		goto out;

	if (!host->dma_active && req->data &&
	    (emm_int & MIO_EMM_INT_BUF_DONE)) {
		unsigned int type = (rsp_sts >> 7) & 3;

		if (type == 1)
			do_read(host, req, rsp_sts & MIO_EMM_RSP_STS_DBUF);
		else if (type == 2)
			do_write(req);
	}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:42,代码来源:cavium.c

示例2: ltpc_xmit

static int ltpc_xmit(struct sk_buff *skb, struct net_device *dev)
{
    /* in kernel 1.3.xx, on entry skb->data points to ddp header,
     * and skb->len is the length of the ddp data + ddp header
     */

    struct net_device_stats *stats = &((struct ltpc_private *)dev->priv)->stats;

    int i;
    struct lt_sendlap cbuf;
    unsigned char *hdr;

    cbuf.command = LT_SENDLAP;
    cbuf.dnode = skb->data[0];
    cbuf.laptype = skb->data[2];
    skb_pull(skb,3);    /* skip past LLAP header */
    cbuf.length = skb->len;    /* this is host order */
    skb_reset_transport_header(skb);

    if(debug & DEBUG_UPPER) {
        printk("command ");
        for(i=0;i<6;i++)
            printk("%02x ",((unsigned char *)&cbuf)[i]);
        printk("\n");
    }

    hdr = skb_transport_header(skb);
    do_write(dev, &cbuf, sizeof(cbuf), hdr, skb->len);

    if(debug & DEBUG_UPPER) {
        printk("sent %d ddp bytes\n",skb->len);
        for (i = 0; i < skb->len; i++)
            printk("%02x ", hdr[i]);
        printk("\n");
    }

    stats->tx_packets++;
    stats->tx_bytes+=skb->len;

    dev_kfree_skb(skb);
    return 0;
}
开发者ID:274914765,项目名称:C,代码行数:42,代码来源:ltpc.c

示例3: do_dump

static int do_dump(int cmd, char *name, char *buf)
{
	struct gfsc_header h, *rh;
	char *reply;
	int reply_len;
	int fd, rv;

	init_header(&h, cmd, name, 0);

	reply_len = sizeof(struct gfsc_header) + GFSC_DUMP_SIZE;
	reply = malloc(reply_len);
	if (!reply) {
		rv = -1;
		goto out;
	}
	memset(reply, 0, reply_len);

	fd = do_connect(GFSC_QUERY_SOCK_PATH);
	if (fd < 0) {
		rv = fd;
		goto out;
	}

	rv = do_write(fd, &h, sizeof(h));
	if (rv < 0)
		goto out_close;

	/* won't always get back the full reply_len */
	do_read(fd, reply, reply_len);

	rh = (struct gfsc_header *)reply;
	rv = rh->data;
	if (rv < 0)
		goto out_close;

	memcpy(buf, (char *)reply + sizeof(struct gfsc_header),
	       GFSC_DUMP_SIZE);
 out_close:
	close(fd);
 out:
	return rv;
}
开发者ID:smintz,项目名称:cluster,代码行数:42,代码来源:main.c

示例4: sysfs_write

static int sysfs_write(struct pci_dev *d, int pos, byte *buf, int len)
{
  int fd = sysfs_setup(d, 1);
  int res;

  if (fd < 0)
    return 0;
  res = do_write(d, fd, buf, len, pos);
  if (res < 0)
    {
      d->access->warning("sysfs_write: write failed: %s", strerror(errno));
      return 0;
    }
  else if (res != len)
    {
      d->access->warning("sysfs_write: tried to write %d bytes at %d, but only %d succeeded", len, pos, res);
      return 0;
    }
  return 1;
}
开发者ID:BackupTheBerlios,项目名称:sax-svn,代码行数:20,代码来源:sysfs.c

示例5: do_write

void chat_client::do_write()
{
	asio::async_write(socket_,
		asio::buffer(write_msgs_.front().data(),
		write_msgs_.front().length()),
		[this](std::error_code ec, std::size_t /*length*/)
	{
		if (!ec)
		{
			write_msgs_.pop_front();
			if (!write_msgs_.empty())
			{
				do_write();
			}
		} else
		{
			socket_.close();
		}
	});
}
开发者ID:piaoasd123,项目名称:ServerTest,代码行数:20,代码来源:ChatClient.cpp

示例6: do_flush

static void do_flush(device_extension* Vcb) {
    LIST_ENTRY rollback;
    
    InitializeListHead(&rollback);
    
    FsRtlEnterFileSystem();

    ExAcquireResourceExclusiveLite(&Vcb->tree_lock, TRUE);

    if (Vcb->need_write)
        do_write(Vcb, &rollback);
    
    free_trees(Vcb);
    
    clear_rollback(&rollback);

    ExReleaseResourceLite(&Vcb->tree_lock);

    FsRtlExitFileSystem();
}
开发者ID:mvardan,项目名称:reactos,代码行数:20,代码来源:flushthread.c

示例7: smsg

void CompressedInetStreamSocket::write(const ByteStream& msg, Stats* stats)
{
    size_t outLen = 0;
    uint32_t len = msg.length();

    if (useCompression && (len > 512))
    {
        ByteStream smsg(alg.maxCompressedSize(len));

        alg.compress((char*) msg.buf(), len, (char*) smsg.getInputPtr(), &outLen);
        smsg.advanceInputPtr(outLen);

        if (outLen < len)
            do_write(smsg, COMPRESSED_BYTESTREAM_MAGIC, stats);
        else
            InetStreamSocket::write(msg, stats);
    }
    else
        InetStreamSocket::write(msg, stats);
}
开发者ID:mariadb-corporation,项目名称:mariadb-columnstore-engine,代码行数:20,代码来源:compressed_iss.cpp

示例8: nand_dev_erase_file

static uint32_t nand_dev_erase_file(nand_dev *dev, uint64_t addr, uint32_t total_len)
{
    uint32_t len = total_len;
    size_t write_len = dev->erase_size;
    int ret;

    do_lseek(dev->fd, addr, SEEK_SET);
    memset(dev->data, 0xff, dev->erase_size);
    while(len > 0) {
        if(len < write_len)
            write_len = len;
        ret = do_write(dev->fd, dev->data, write_len);
        if(ret < write_len) {
            XLOG( "nand_dev_write_file, write failed: %s\n", strerror(errno));
            break;
        }
        len -= write_len;
    }
    return total_len - len;
}
开发者ID:0-14N,项目名称:NDroid,代码行数:20,代码来源:goldfish_nand.c

示例9: empty_buf

/* empty the circular buffer by issuing random sized remove_cbuf
   calls, then write the result to stdout */
void empty_buf(cbuf * thebuf)
{
    int want, got, j;
    char last = 0;
    buf_t destbuf[BSIZE];
    FILE *fptr;

    errlog(5,"Writer starting");
    fptr = stdout;
    got = 1;
    while (got) {
	want = (int)rnum(BSIZE);
	test_lookahead(thebuf);
	test_unget(thebuf);
	test_read(thebuf);
	got = remove_cbuf(thebuf, destbuf, want);
	do_write(destbuf, got);
    }

}
开发者ID:glocklueng,项目名称:WeatherStation,代码行数:22,代码来源:test_cbuf.c

示例10: connect_cb

static void connect_cb(uv_connect_t* req, int status) {
  int i;

  if (status) LOG(uv_strerror(uv_last_error()));
  ASSERT(status == 0);

  write_sockets++;
  req_free((uv_req_t*) req);

  maybe_connect_some();

  if (write_sockets == TARGET_CONNECTIONS) {
    start_stats_collection();

    /* Yay! start writing */
    for (i = 0; i < write_sockets; i++) {
      do_write(type == TCP ? (uv_stream_t*)&tcp_write_handles[i] : (uv_stream_t*)&pipe_write_handles[i]);
    }
  }
}
开发者ID:CrabDude,项目名称:node,代码行数:20,代码来源:benchmark-pump.c

示例11: chips_append

static int chips_append(int argc, char **argv)
{
	if(argc != 2)
	{
		fprintf(stderr, "Usage: %s <file>\n", argv[0]);
		return -1;
	}
	int fd = do_open(argv[1]);
	if(fd < 0)
	{
		if(!fs_create(argv[1], POTATOES_DATA_FILE))	
		{
			fprintf(stderr, "Failed to create %s\n", argv[1]);
			return 1;
		}
		if((fd = do_open(argv[1])) < 0)
		{
			fprintf(stderr, "Failed to open %s\n", argv[1]);
			return 1;
		}
	}

	potatoes_file_info_t info;
	get_file_info(fd, &info);

	if(info.mode != POTATOES_DATA_FILE)
	{
		fprintf(stderr, "Not a file: %s\n", argv[1]);
		return 1;
	}

	char buf[512];
	int count;
	int off = info.size;
	while((count = read(0, buf, 512)) > 0)
	{
		do_write(fd, buf, count, off);
		off += count;
	}
	return 0;
}
开发者ID:MatiasNAmendola,项目名称:potatoes,代码行数:41,代码来源:chips.c

示例12: g_socks4a_proxy_connect_async

static void
g_socks4a_proxy_connect_async (GProxy               *proxy,
			       GIOStream            *io_stream,
			       GProxyAddress        *proxy_address,
			       GCancellable         *cancellable,
			       GAsyncReadyCallback   callback,
			       gpointer              user_data)
{
  GError *error = NULL;
  GTask *task;
  ConnectAsyncData *data;
  const gchar *hostname;
  guint16 port;
  const gchar *username;

  data = g_slice_new0 (ConnectAsyncData);
  data->io_stream = g_object_ref (io_stream);

  task = g_task_new (proxy, cancellable, callback, user_data);
  g_task_set_task_data (task, data, (GDestroyNotify) free_connect_data);

  hostname = g_proxy_address_get_destination_hostname (proxy_address);
  port = g_proxy_address_get_destination_port (proxy_address);
  username = g_proxy_address_get_username (proxy_address); 

  data->buffer = g_malloc0 (SOCKS4_CONN_MSG_LEN);
  data->length = set_connect_msg (data->buffer,
				  hostname, port, username,
				  &error);
  data->offset = 0;

  if (data->length < 0)
    {
      g_task_return_error (task, error);
      g_object_unref (task);
    }
  else
    {
      do_write (connect_msg_write_cb, task, data);
    }
}
开发者ID:183amir,项目名称:glib,代码行数:41,代码来源:gsocks4aproxy.c

示例13: process_request

/*
 * Writes one request to disk
 */
static int process_request(tee_saved_request *sr)
{
	sr->time_dequeued = apr_time_now();
	set_filename(sr);
	if (!sr->filename)
		return 0;

	apr_file_t *file;
	apr_int32_t flags = APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_BUFFERED;
	apr_status_t rc = apr_file_open(&file, sr->filename, flags, APR_OS_DEFAULT, sr->pool);
	if (rc != APR_SUCCESS) {
		ap_log_error(APLOG_MARK, APLOG_ERR, 0, sr->server, "tee: Cannot create file %s: %s",
				sr->filename, tee_get_error_string(rc, sr->pool));
		return 0;
	}
	do_write(file, sr);
	sr->filesize = tee_get_file_pos(file);
	ap_log_error(APLOG_MARK, APLOG_INFO, 0, sr->server, "tee: File saved: %s (pid %d)", sr->filename, getpid());
	sr->time_written = apr_time_now();
	return 1;
}
开发者ID:despegar,项目名称:mod_tee,代码行数:24,代码来源:writer.c

示例14: do_write

    void do_write() {
        boost::asio::async_write(
            socket_,
            boost::asio::buffer(
                write_msgs_.front()->data(),
                write_msgs_.front()->length()),
            [this](boost::system::error_code ec, std::size_t) {
                if (ec) {
                    std::cout << ec.message() << "\n";
                    if (ec != boost::asio::error::operation_aborted) {
                        socket_.close();
                    }
                    return;
                }

                write_msgs_.pop_front();
                if (!write_msgs_.empty()) {
                    do_write();
                }
            });
    }
开发者ID:q191201771,项目名称:asio-tutorial,代码行数:21,代码来源:client.hpp

示例15: handle_events

static void handle_events( int _epollfd, struct epoll_event* _events, int _num, int _listenfd, char* _buf )
{
	int fd = 0;
	for( int i = 0; i < _num; ++i )
	{
		fd = _events[i].data.fd;
		//根据描述符的类型和事件类型进行处理
		if( (fd == _listenfd) && (_events[i].events & EPOLLIN) )
		{
			handle_accept( _epollfd, _listenfd );
		}
		else if( _events[i].events & EPOLLIN )
		{
			do_read( _epollfd, fd, _buf );
		}
		else if( _events[i].events & EPOLLOUT )
		{
			do_write( _epollfd, fd, _buf );
		}
	}
}
开发者ID:coolsofttonyjj,项目名称:workspace,代码行数:21,代码来源:epollServer.cpp


注:本文中的do_write函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。