lib/ringbuffer/frontend_api.h: Include linux/prefetch.h.
[lttng-modules.git] / lib / ringbuffer / frontend_api.h
index d55eb33e31601658e15ca83865422be136b00fcb..c36ec3dc2e3f0e3e8436a54ebee50b0be26d77a4 100644 (file)
@@ -1,24 +1,37 @@
-#ifndef _LINUX_RING_BUFFER_FRONTEND_API_H
-#define _LINUX_RING_BUFFER_FRONTEND_API_H
+#ifndef _LIB_RING_BUFFER_FRONTEND_API_H
+#define _LIB_RING_BUFFER_FRONTEND_API_H
 
 /*
- * linux/ringbuffer/frontend_api.h
- *
- * (C) Copyright 2005-2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * lib/ringbuffer/frontend_api.h
  *
  * Ring Buffer Library Synchronization Header (buffer write API).
  *
+ * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  * Author:
  *     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * See ring_buffer_frontend.c for more information on wait-free algorithms.
  * See linux/ringbuffer/frontend.h for channel allocation and read-side API.
- *
- * Dual LGPL v2.1/GPL v2 license.
  */
 
 #include "../../wrapper/ringbuffer/frontend.h"
 #include <linux/errno.h>
+#include <linux/prefetch.h>
 
 /**
  * lib_ring_buffer_get_cpu - Precedes ring buffer reserve/commit.
@@ -82,6 +95,8 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
        *o_old = *o_begin;
 
        ctx->tsc = lib_ring_buffer_clock_read(chan);
+       if ((int64_t) ctx->tsc == -EIO)
+               return 1;
 
        /*
         * Prefetch cacheline for read because we have to read the previous
@@ -91,14 +106,13 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
        prefetch(&buf->commit_hot[subbuf_index(*o_begin, chan)]);
 
        if (last_tsc_overflow(config, buf, ctx->tsc))
-               ctx->rflags = RING_BUFFER_RFLAG_FULL_TSC;
+               ctx->rflags |= RING_BUFFER_RFLAG_FULL_TSC;
 
        if (unlikely(subbuf_offset(*o_begin, chan) == 0))
                return 1;
 
        ctx->slot_size = record_header_size(config, chan, *o_begin,
-                                           ctx->data_size, before_hdr_pad,
-                                           ctx->rflags, ctx);
+                                           before_hdr_pad, ctx);
        ctx->slot_size +=
                lib_ring_buffer_align(*o_begin + ctx->slot_size,
                                      ctx->largest_align) + ctx->data_size;
@@ -130,8 +144,12 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
  * Atomic wait-free slot reservation. The reserved space starts at the context
  * "pre_offset". Its length is "slot_size". The associated time-stamp is "tsc".
  *
- * Return : -ENOSPC if not enough space, -EAGAIN if channel is disabled.
- *          Returns 0 on success.
+ * Return :
+ *  0 on success.
+ * -EAGAIN if channel is disabled.
+ * -ENOSPC if event size is too large for packet.
+ * -ENOBUFS if there is currently not enough space in buffer for the event.
+ * -EIO if data cannot be written into the buffer for any other reason.
  */
 
 static inline
@@ -350,4 +368,4 @@ void lib_ring_buffer_record_enable(const struct lib_ring_buffer_config *config,
        atomic_dec(&buf->record_disabled);
 }
 
-#endif /* _LINUX_RING_BUFFER_FRONTEND_API_H */
+#endif /* _LIB_RING_BUFFER_FRONTEND_API_H */
This page took 0.023555 seconds and 4 git commands to generate.