summaryrefslogtreecommitdiffstats
path: root/db/mork/src/morkConfig.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-11-03 00:17:46 -0400
committerMatt A. Tobin <email@mattatobin.com>2019-11-03 00:17:46 -0400
commit302bf1b523012e11b60425d6eee1221ebc2724eb (patch)
treeb191a895f8716efcbe42f454f37597a545a6f421 /db/mork/src/morkConfig.cpp
parent21b3f6247403c06f85e1f45d219f87549862198f (diff)
downloadUXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.gz
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.lz
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.xz
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.zip
Issue #1258 - Part 1: Import mailnews, ldap, and mork from comm-esr52.9.1
Diffstat (limited to 'db/mork/src/morkConfig.cpp')
-rw-r--r--db/mork/src/morkConfig.cpp201
1 files changed, 201 insertions, 0 deletions
diff --git a/db/mork/src/morkConfig.cpp b/db/mork/src/morkConfig.cpp
new file mode 100644
index 000000000..b58cd03c8
--- /dev/null
+++ b/db/mork/src/morkConfig.cpp
@@ -0,0 +1,201 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef _MDB_
+#include "mdb.h"
+#endif
+
+#ifndef _MORK_
+#include "mork.h"
+#endif
+
+#ifndef _MORKCONFIG_
+#include "morkConfig.h"
+#endif
+
+//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
+
+void mork_assertion_signal(const char* inMessage)
+{
+#if defined(MORK_WIN) || defined(MORK_MAC)
+ // asm { int 3 }
+ NS_ERROR(inMessage);
+#endif /*MORK_WIN*/
+}
+
+#ifdef MORK_PROVIDE_STDLIB
+
+MORK_LIB_IMPL(mork_i4)
+mork_memcmp(const void* inOne, const void* inTwo, mork_size inSize)
+{
+ const mork_u1* t = (const mork_u1*) inTwo;
+ const mork_u1* s = (const mork_u1*) inOne;
+ const mork_u1* end = s + inSize;
+ mork_i4 delta;
+
+ while ( s < end )
+ {
+ delta = ((mork_i4) *s) - ((mork_i4) *t);
+ if ( delta )
+ return delta;
+ else
+ {
+ ++t;
+ ++s;
+ }
+ }
+ return 0;
+}
+
+MORK_LIB_IMPL(void)
+mork_memcpy(void* outDst, const void* inSrc, mork_size inSize)
+{
+ mork_u1* d = (mork_u1*) outDst;
+ mork_u1* end = d + inSize;
+ const mork_u1* s = ((const mork_u1*) inSrc);
+
+ while ( inSize >= 8 )
+ {
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+
+ inSize -= 8;
+ }
+
+ while ( d < end )
+ *d++ = *s++;
+}
+
+MORK_LIB_IMPL(void)
+mork_memmove(void* outDst, const void* inSrc, mork_size inSize)
+{
+ mork_u1* d = (mork_u1*) outDst;
+ const mork_u1* s = (const mork_u1*) inSrc;
+ if ( d != s && inSize ) // copy is necessary?
+ {
+ const mork_u1* srcEnd = s + inSize; // one past last source byte
+
+ if ( d > s && d < srcEnd ) // overlap? need to copy backwards?
+ {
+ s = srcEnd; // start one past last source byte
+ d += inSize; // start one past last dest byte
+ mork_u1* dstBegin = d; // last byte to write is first in dest range
+ while ( d - dstBegin >= 8 )
+ {
+ *--d = *--s;
+ *--d = *--s;
+ *--d = *--s;
+ *--d = *--s;
+
+ *--d = *--s;
+ *--d = *--s;
+ *--d = *--s;
+ *--d = *--s;
+ }
+ while ( d > dstBegin )
+ *--d = *--s;
+ }
+ else // can copy forwards without any overlap
+ {
+ mork_u1* dstEnd = d + inSize;
+ while ( dstEnd - d >= 8 )
+ {
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+ }
+ while ( d < dstEnd )
+ *d++ = *s++;
+ }
+ }
+}
+
+MORK_LIB_IMPL(void)
+mork_memset(void* outDst, int inByte, mork_size inSize)
+{
+ mork_u1* d = (mork_u1*) outDst;
+ mork_u1* end = d + inSize;
+ while ( d < end )
+ *d++ = (mork_u1) inByte;
+}
+
+MORK_LIB_IMPL(void)
+mork_strcpy(void* outDst, const void* inSrc)
+{
+ // back up one first to support preincrement
+ mork_u1* d = ((mork_u1*) outDst) - 1;
+ const mork_u1* s = ((const mork_u1*) inSrc) - 1;
+ while ( ( *++d = *++s ) != 0 )
+ /* empty */;
+}
+
+MORK_LIB_IMPL(mork_i4)
+mork_strcmp(const void* inOne, const void* inTwo)
+{
+ const mork_u1* t = (const mork_u1*) inTwo;
+ const mork_u1* s = ((const mork_u1*) inOne);
+ mork_i4 a;
+ mork_i4 b;
+ mork_i4 delta;
+
+ do
+ {
+ a = (mork_i4) *s++;
+ b = (mork_i4) *t++;
+ delta = a - b;
+ }
+ while ( !delta && a && b );
+
+ return delta;
+}
+
+MORK_LIB_IMPL(mork_i4)
+mork_strncmp(const void* inOne, const void* inTwo, mork_size inSize)
+{
+ const mork_u1* t = (const mork_u1*) inTwo;
+ const mork_u1* s = (const mork_u1*) inOne;
+ const mork_u1* end = s + inSize;
+ mork_i4 delta;
+ mork_i4 a;
+ mork_i4 b;
+
+ while ( s < end )
+ {
+ a = (mork_i4) *s++;
+ b = (mork_i4) *t++;
+ delta = a - b;
+ if ( delta || !a || !b )
+ return delta;
+ }
+ return 0;
+}
+
+MORK_LIB_IMPL(mork_size)
+mork_strlen(const void* inString)
+{
+ // back up one first to support preincrement
+ const mork_u1* s = ((const mork_u1*) inString) - 1;
+ while ( *++s ) // preincrement is cheapest
+ /* empty */;
+
+ return s - ((const mork_u1*) inString); // distance from original address
+}
+
+#endif /*MORK_PROVIDE_STDLIB*/
+
+//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789