Browse Source

Test starpu_f*lock return codes internally, as we don't bother doing it when calling them

Samuel Thibault 9 years ago
parent
commit
5d15ae25bc
2 changed files with 23 additions and 18 deletions
  1. 10 10
      socl/src/debug.h
  2. 13 8
      src/common/utils.c

+ 10 - 10
socl/src/debug.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010,2011, 2015 University of Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -22,26 +22,26 @@
 #ifdef STARPU_VERBOSE
 #define DEBUG
 #include <stdio.h>
-  #define DEBUG_MSG(...) do { if (!getenv("STARPU_SILENT")) { fprintf(stderr, "[SOCL] [%s] ", __starpu_func__); fprintf(stderr, __VA_ARGS__);}} while (0);
+  #define DEBUG_MSG(...) do { if (!getenv("STARPU_SILENT")) { fprintf(stderr, "[SOCL] [%s] ", __starpu_func__); fprintf(stderr, __VA_ARGS__);}} while (0)
   #define DEBUG_MSG_NOHEAD(...) do { if (!getenv("STARPU_SILENT")) { fprintf(stderr, __VA_ARGS__);}} while (0);
-  #define DEBUG_ERROR(...) do { if (!getenv("STARPU_SILENT")) { fprintf(stderr, "[SOCL] ERROR: "__VA_ARGS__); } exit(1); } while (0);
+  #define DEBUG_ERROR(...) do { if (!getenv("STARPU_SILENT")) { fprintf(stderr, "[SOCL] ERROR: "__VA_ARGS__); } exit(1); } while (0)
 #else
-   #define DEBUG_MSG(...) while(0);
-   #define DEBUG_MSG_NOHEAD(...) while(0);
-   #define DEBUG_ERROR(...) while(0);
+   #define DEBUG_MSG(...) while(0)
+   #define DEBUG_MSG_NOHEAD(...) while(0)
+   #define DEBUG_ERROR(...) while(0)
 #endif
 
 
-#define ERROR_MSG(...) do { fprintf(stderr, "[SOCL] [%s] ERROR: ", __starpu_func__); fprintf(stderr, __VA_ARGS__); } while (0);
+#define ERROR_MSG(...) do { fprintf(stderr, "[SOCL] [%s] ERROR: ", __starpu_func__); fprintf(stderr, __VA_ARGS__); } while (0)
 #define ERROR_MSG_NOHEAD(...) fprintf(stderr, __VA_ARGS__)
-#define ERROR_STOP(...) do { ERROR_MSG(__VA_ARGS__); exit(1); } while(0);
+#define ERROR_STOP(...) do { ERROR_MSG(__VA_ARGS__); exit(1); } while(0)
 
 void ERROR_CL(char *s, cl_int err);
 
 #ifdef STARPU_VERBOSE
-   #define DEBUG_CL(args...) ERROR_CL(args) 
+   #define DEBUG_CL(args...) ERROR_CL(args)
 #else
-   #define DEBUG_CL(...) while(0);
+   #define DEBUG_CL(...) while(0)
 #endif
 
 #ifdef DEBUG

+ 13 - 8
src/common/utils.c

@@ -143,14 +143,13 @@ int _starpu_ftruncate(FILE *file)
 
 int _starpu_frdlock(FILE *file)
 {
-#if defined(_WIN32) && !defined(__CYGWIN__)
 	int ret;
+#if defined(_WIN32) && !defined(__CYGWIN__)
 	do
 	{
 		ret = _locking(fileno(file), _LK_RLCK, 10);
 	}
 	while (ret == EDEADLOCK);
-	return ret;
 #else
 	struct flock lock =
 	{
@@ -159,17 +158,20 @@ int _starpu_frdlock(FILE *file)
 		.l_start = 0,
 		.l_len = 0
 	};
-	return fcntl(fileno(file), F_SETLKW, &lock);
+	ret = fcntl(fileno(file), F_SETLKW, &lock);
 #endif
+	STARPU_ASSERT(ret == 0);
+	return ret;
 }
 
 int _starpu_frdunlock(FILE *file)
 {
+	int ret;
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #  ifndef _LK_UNLCK
 #    define _LK_UNLCK _LK_UNLOCK
 #  endif
-	return _locking(fileno(file), _LK_UNLCK, 10);
+	ret = _locking(fileno(file), _LK_UNLCK, 10);
 #else
 	struct flock lock =
 	{
@@ -178,20 +180,21 @@ int _starpu_frdunlock(FILE *file)
 		.l_start = 0,
 		.l_len = 0
 	};
-	return fcntl(fileno(file), F_SETLKW, &lock);
+	ret = fcntl(fileno(file), F_SETLKW, &lock);
 #endif
+	STARPU_ASSERT(ret == 0);
+	return ret;
 }
 
 int _starpu_fwrlock(FILE *file)
 {
-#if defined(_WIN32) && !defined(__CYGWIN__)
 	int ret;
+#if defined(_WIN32) && !defined(__CYGWIN__)
 	do
 	{
 		ret = _locking(fileno(file), _LK_LOCK, 10);
 	}
 	while (ret == EDEADLOCK);
-	return ret;
 #else
 	struct flock lock =
 	{
@@ -200,8 +203,10 @@ int _starpu_fwrlock(FILE *file)
 		.l_start = 0,
 		.l_len = 0
 	};
-	return fcntl(fileno(file), F_SETLKW, &lock);
+	ret = fcntl(fileno(file), F_SETLKW, &lock);
 #endif
+	STARPU_ASSERT(ret == 0);
+	return ret;
 }
 
 int _starpu_fwrunlock(FILE *file)