[prev in list] [next in list] [prev in thread] [next in thread] 

List:       monetdb-checkins
Subject:    MonetDB: default - No need for GDK function if used in only one ...
From:       Sjoerd Mullender <commits+sjoerd=acm.org () monetdb ! org>
Date:       2016-08-29 13:34:43
Message-ID: hg.dca8646cb993.1472477683.6315528441665844383 () monetdb2 ! cwi-incubator ! nl
[Download RAW message or body]

Changeset: dca8646cb993 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dca8646cb993
Modified Files:
	gdk/gdk.h
	gdk/gdk_storage.c
	monetdb5/mal/mal_linker.c
Branch: default
Log Message:

No need for GDK function if used in only one place.


diffs (83 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1494,7 +1494,6 @@ gdk_export size_t BATmemsize(BAT *b, int
 
 #define NOFARM (-1) /* indicate to GDKfilepath to create relative path */
 
-gdk_export int GDKfileexists(const char *path);
 gdk_export char *GDKfilepath(int farmid, const char *dir, const char *nme, const \
char *ext);  gdk_export gdk_return GDKcreatedir(const char *nme);
 
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -87,16 +87,6 @@ GDKfilepath(int farmid, const char *dir,
 	return path;
 }
 
-/*
- * returns 1 if the file exists
- */
-int 
-GDKfileexists(const char *path) {
-	struct stat st;
-	int ret = stat(path, &st);
-	return (ret == 0);
-}
-
 /* make sure the parent directory of DIR exists (the argument itself
  * is usually a file that is to be created) */
 gdk_return
diff --git a/monetdb5/mal/mal_linker.c b/monetdb5/mal/mal_linker.c
--- a/monetdb5/mal/mal_linker.c
+++ b/monetdb5/mal/mal_linker.c
@@ -44,6 +44,21 @@ static FileRecord filesLoaded[MAXMODULES
 static int maxfiles = MAXMODULES;
 static int lastfile = 0;
 
+/*
+ * returns 1 if the file exists
+ */
+#ifndef F_OK
+#define F_OK 0
+#endif
+#ifdef _MSC_VER
+#define access(f, m)	_access(f, m)
+#endif
+static inline int
+fileexists(const char *path)
+{
+	return access(path, F_OK) == 0;
+}
+
 /* Search for occurrence of the function in the library identified by the filename.  \
*/  MALfcn
 getAddress(stream *out, str modname, str fcnname, int silent)
@@ -178,7 +193,7 @@ loadLibrary(str filename, int flag)
 				 mod_path, DIR_SEP, SO_PREFIX, s, SO_EXT);
 #endif
 		handle = dlopen(nme, mode);
-		if (handle == NULL && GDKfileexists(nme)) {
+		if (handle == NULL && fileexists(nme)) {
 			throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR " failed to open library %s (from \
within file '%s'): %s", s, nme, dlerror());  }
 		if (handle == NULL && strcmp(SO_EXT, ".so") != 0) {
@@ -187,7 +202,7 @@ loadLibrary(str filename, int flag)
 					 (int) (p - mod_path),
 					 mod_path, DIR_SEP, SO_PREFIX, s);
 			handle = dlopen(nme, mode);
-			if (handle == NULL && GDKfileexists(nme)) {
+			if (handle == NULL && fileexists(nme)) {
 				throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR " failed to open library %s \
(from within file '%s'): %s", s, nme, dlerror());  }
 		}
@@ -198,7 +213,7 @@ loadLibrary(str filename, int flag)
 					 (int) (p - mod_path),
 					 mod_path, DIR_SEP, SO_PREFIX, s);
 			handle = dlopen(nme, mode);
-			if (handle == NULL && GDKfileexists(nme)) {
+			if (handle == NULL && fileexists(nme)) {
 				throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR " failed to open library %s \
(from within file '%s'): %s", s, nme, dlerror());  }
 		}
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic