UnQLite Users Forum

unqlite-kv-111 fails to build on Mac OS X

append delete Chris0

Hello,

Thank you for UnQLite.

I have been evaluating it on OSX and I have some feedback.
The file unqlite.c fails to link as SyStrncmp is undefined (KV 1.1.1 NOT DB 1.1.7).
I have included a patch below to fix this. It also fixes a couple of warnings when compiled with clang 3.9.0. (Also, peculiarly, unqlite.c in unqlite-kv-111 uses CRLF line endings and the execution flags are set on all the files.)
Additionally, I found it necessary to use

% c
extern "C" {
#include "unqlite.h"
}
%

when using it from C++ in order to avoid other link errors. Strangely the DB 1.1.7 version of unqlite.c contains `extern "C"` but the KV 1.1.1 does not and neither version of unqlite.h contains it - so I don’t understand how it is supposed to work.

Hope this info helps.

Keep up the good work.
Regards,

CHRIS

% c
--- unqlite.c 1.1.1 2016-12-07 02:39:00
+++ unqlite.c       2017-04-15 17:54:11
@@ -9690,7 +9690,7 @@
 /*
  * Local memory allocation stuff.
  */
-void * unqlite_malloc(unsigned int nByte)
+static void * unqlite_malloc(unsigned int nByte)
 {
 	SyMemBackend *pAlloc;
 	void *p;
@@ -9698,7 +9698,7 @@
 	p = SyMemBackendAlloc(pAlloc,nByte);
 	return p;
 }
-void unqlite_free(void *p)
+static void unqlite_free(void *p)
 {
 	SyMemBackend *pAlloc;
 	pAlloc = (SyMemBackend *)unqliteExportMemBackend();
@@ -10956,7 +10956,9 @@
     close(fd); /* silently leak if fail, in error */
     return UNQLITE_IOERR;
   }
-  if (0 == SyStrncmp("msdos", fsInfo.f_fstypename, 5)) {
+  if ((fsInfo.f_fstypename[0] | 32) == 'm' && (fsInfo.f_fstypename[1] | 32) == 's' &&
+      (fsInfo.f_fstypename[2] | 32) == 'd' && (fsInfo.f_fstypename[3] | 32) == 'o' &&
+      (fsInfo.f_fstypename[4] | 32) == 's' &&  fsInfo.f_fstypename[5] == 0) { /* == 'msdos' */
     ((unixFile*)pFile)->fsFlags |= UNQLITE_FSFLAGS_IS_MSDOS;
   }
 #endif
%

Reply RSS

Replies

append delete #1. chm

Thank you Chris, will fix that

Reply

(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Your friendly neighbourhood moderators: chm_at_symisc, devel_at_symisc