Browse Source

Add a STARPU_WARN_UNUSED_RESULT macro.

This is just a wrapper around GCC's __attribute__((__warn_unused_result__)). It is applied to starpu_init(), starpu_task_submit() and starpu_task_wait().
Cyril Roelandt 13 years ago
parent
commit
25019b621d
3 changed files with 9 additions and 3 deletions
  1. 1 1
      include/starpu.h
  2. 2 2
      include/starpu_task.h
  3. 6 0
      include/starpu_util.h

+ 1 - 1
include/starpu.h

@@ -88,7 +88,7 @@ int starpu_conf_init(struct starpu_conf *conf);
 /* Initialization method: it must be called prior to any other StarPU call
  * Default configuration is used if NULL is passed as argument.
  */
-int starpu_init(struct starpu_conf *conf);
+int starpu_init(struct starpu_conf *conf) STARPU_WARN_UNUSED_RESULT;
 
 /* Shutdown method: note that statistics are only generated once StarPU is
  * shutdown */

+ 2 - 2
include/starpu_task.h

@@ -284,14 +284,14 @@ struct starpu_task *starpu_task_create(void);
  * structure (default behaviour). Calling this function on a statically
  * allocated task results in an undefined behaviour. */
 void starpu_task_destroy(struct starpu_task *task);
-int starpu_task_submit(struct starpu_task *task);
+int starpu_task_submit(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
 
 /* This function blocks until the task was executed. It is not possible to
  * synchronize with a task more than once. It is not possible to wait
  * synchronous or detached tasks.
  * Upon successful completion, this function returns 0. Otherwise, -EINVAL
  * indicates that the waited task was either synchronous or detached. */
-int starpu_task_wait(struct starpu_task *task);
+int starpu_task_wait(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
 
 /* This function waits until all the tasks that were already submitted have
  * been executed. */

+ 6 - 0
include/starpu_util.h

@@ -95,6 +95,12 @@ extern "C"
 #define STARPU_DEPRECATED
 #endif /* __GNUC__ */
 
+#if STARPU_GNUC_PREREQ(3,3)
+#define STARPU_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
+#else
+#define STARPU_WARN_UNUSED_RESULT
+#endif /* __GNUC__ */
+
 #if defined(__i386__) || defined(__x86_64__)
 
 static __inline unsigned starpu_cmpxchg(unsigned *ptr, unsigned old, unsigned next)