Changeset: 665b5f7028cb for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=665b5f7028cb
Added Files:
        gdk/gdk_atomic.h
Modified Files:
        MonetDB.spec
        configure.ag
        gdk/Makefile.ag
        gdk/gdk_bbp.c
        gdk/gdk_system.h
        gdk/gdk_utils.c
        monetdb5/mal/mal.c
        monetdb5/mal/mal_resource.c
Branch: default
Log Message:

Merge with Feb2013 branch.


diffs (truncated from 633 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -33,8 +33,8 @@ BuildRequires: bison
 BuildRequires: bzip2-devel
 # BuildRequires: cfitsio-devel
 BuildRequires: flex
-%if %{?centos:0}%{!?centos:1}
-# no geos library on CentOS
+%if %{?rhel:0}%{!?rhel:1}
+# no geos library on RedHat Enterprise Linux and derivatives
 BuildRequires: geos-devel >= 2.2.0
 %endif
 BuildRequires: libcurl-devel
@@ -44,12 +44,14 @@ BuildRequires: openssl-devel
 BuildRequires: pcre-devel >= 4.5
 BuildRequires: perl
 BuildRequires: python-devel
+%if %{?rhel:0}%{!?rhel:1}
 BuildRequires: python3-devel
+%endif
 # BuildRequires: raptor-devel >= 1.4.16
 BuildRequires: readline-devel
 BuildRequires: ruby
 BuildRequires: rubygems
-%if %{?centos:0}%{!?centos:1}
+%if %{?rhel:0}%{!?rhel:1}
 BuildRequires: rubygems-devel
 %endif
 BuildRequires: unixODBC-devel
@@ -335,7 +337,7 @@ developer.
 %{_bindir}/sqlsample.php
 %{_bindir}/sqlsample.pl
 
-%if %{?centos:0}%{!?centos:1}
+%if %{?rhel:0}%{!?rhel:1}
 %package geom-MonetDB5
 Summary: MonetDB5 SQL GIS support module
 Group: Applications/Databases
@@ -429,7 +431,7 @@ fi
 %{_libdir}/libmonetdb5.so.*
 %dir %{_libdir}/monetdb5
 %dir %{_libdir}/monetdb5/autoload
-%if %{?centos:0}%{!?centos:1}
+%if %{?rhel:0}%{!?rhel:1}
 %exclude %{_libdir}/monetdb5/geom.mal
 %endif
 # %exclude %{_libdir}/monetdb5/rdf.mal
@@ -442,7 +444,7 @@ fi
 %{_libdir}/monetdb5/autoload/*_opt_sql_append.mal
 %{_libdir}/monetdb5/autoload/*_udf.mal
 %{_libdir}/monetdb5/autoload/*_vault.mal
-%if %{?centos:0}%{!?centos:1}
+%if %{?rhel:0}%{!?rhel:1}
 %exclude %{_libdir}/monetdb5/lib_geom.so
 %endif
 # %exclude %{_libdir}/monetdb5/lib_rdf.so
@@ -505,7 +507,7 @@ systemd-tmpfiles --create %{_sysconfdir}
 %{_libdir}/monetdb5/lib_sql.so
 %{_libdir}/monetdb5/*.sql
 %dir %{_libdir}/monetdb5/createdb
-%if %{?centos:0}%{!?centos:1}
+%if %{?rhel:0}%{!?rhel:1}
 %exclude %{_libdir}/monetdb5/createdb/*_geom.sql
 %endif
 # %exclude %{_libdir}/monetdb5/createdb/*_rdf.sql
@@ -539,6 +541,7 @@ program.
 %{python_sitelib}/python_monetdb-*.egg-info
 %doc clients/python2/README.rst
 
+%if %{?rhel:0}%{!?rhel:1}
 %package -n python3-monetdb
 Summary: Native MonetDB client Python3 API
 Group: Applications/Databases
@@ -560,6 +563,7 @@ program.
 %{python3_sitelib}/monetdb/*
 %{python3_sitelib}/python_monetdb-*.egg-info
 %doc clients/python3/README.rst
+%endif
 
 %package testing
 Summary: MonetDB - Monet Database Management System
@@ -626,7 +630,7 @@ developer, but if you do want to test, t
        --enable-developer=no \
        --enable-fits=no \
        --enable-gdk=yes \
-       --enable-geom=%{?centos:no}%{!?centos:yes} \
+       --enable-geom=%{?rhel:no}%{!?rhel:yes} \
        --enable-instrument=no \
        --enable-jaql=yes \
        --enable-jdbc=no \
@@ -642,14 +646,14 @@ developer, but if you do want to test, t
        --enable-testing=yes \
        --with-ant=no \
        --with-bz2=yes \
-       --with-geos=%{?centos:no}%{!?centos:yes} \
+       --with-geos=%{?rhel:no}%{!?rhel:yes} \
        --with-hwcounters=no \
        --with-java=no \
        --with-mseed=no \
        --with-perl=yes \
        --with-pthread=yes \
        --with-python2=yes \
-       --with-python3=yes \
+       --with-python3=%{?rhel:no}%{!?rhel:yes} \
        --with-readline=yes \
        --with-rubygem=yes \
        --with-rubygem-dir="%{gem_dir}" \
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -430,7 +430,7 @@ case "$host_os" in
                        | sed 's|^.*\(Red\) \(Hat\).* Linux *\([[A-Z]]*\) 
release \([[0-9]][[^ \n]]*\)\( .*\)*$|\1\2:\4\3|' \
                        | sed 's|^Red Hat Enterprise Linux \([[AW]]S\) release 
\([[0-9]][[^ \n]]*\)\( .*\)*$|RHEL:\2\1|' \
                        | sed 's|^\(CentOS\).* release \([[0-9]][[^ \n]]*\)\( 
.*\)*$|\1:\2|' \
-                       | sed 's|^\(Scientific\) Linux SL release \([[0-9]][[^ 
\n]]*\)\( .*\)*$|\1:\2|'`" 
+                       | sed 's|^\(Scientific\) Linux.* release \([[0-9]][[^ 
\n]]*\)\( .*\)*$|\1:\2|'`" 
        elif test -s /etc/SuSE-release ; then
                LINUX_DIST="`cat /etc/SuSE-release   | head -n1 \
                        | sed 's|^.*\(S[[Uu]]SE\) LINUX Enterprise 
\([[SD]]\)[[ervsktop]]* \([[0-9]][[^ \n]]*\)\( .*\)*$|\1:\3E\2|' \
diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -23,7 +23,7 @@ lib_gdk = {
        VERSION = $(GDK_VERSION)
        NAME = bat
        SOURCES = \
-               gdk.h gdk_batop.c gdk_select.c \
+               gdk.h gdk_atomic.h gdk_batop.c gdk_select.c \
                gdk_search.c gdk_search.h gdk_tm.c \
                gdk_align.c gdk_bbp.c gdk_bbp.h \
                gdk_heap.c gdk_setop.mx gdk_utils.c gdk_utils.h \
diff --git a/gdk/gdk_atomic.h b/gdk/gdk_atomic.h
new file mode 100644
--- /dev/null
+++ b/gdk/gdk_atomic.h
@@ -0,0 +1,102 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2013 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+#ifndef _GDK_ATOMIC_H_
+#define _GDK_ATOMIC_H_
+
+#if defined(__GNUC__)
+#if SIZEOF_SSIZE_T == SIZEOF_LONG_LONG
+#define ATOMIC_TYPE            long long
+#else
+#define ATOMIC_TYPE            long
+#endif
+#define ATOMIC_ADD(var, val)   __sync_fetch_and_add(&var, (ATOMIC_TYPE) (val))
+#define ATOMIC_INC(var)                __sync_add_and_fetch(&var, 
(ATOMIC_TYPE) 1)
+#define ATOMIC_SUB(var, val)   __sync_fetch_and_sub(&var, (ATOMIC_TYPE) (val))
+#define ATOMIC_DEC(var)                __sync_sub_and_fetch(&var, 
(ATOMIC_TYPE) 1)
+#define ATOMIC_START(lock, func)
+#define ATOMIC_END(lock, func)
+#define ATOMIC_INIT(lock, func)
+#define ATOMIC_COMP_SWAP(var, old, new, lock, func)    \
+       __sync_val_compare_and_swap(&var, old, new)
+#define ATOMIC_GET(var, lock, func)    var
+#elif defined(_MSC_VER)
+#include <intrin.h>
+#if SIZEOF_SSIZE_T == SIZEOF___INT64
+#define ATOMIC_TYPE            __int64
+#define ATOMIC_ADD(var, val)   _InterlockedExchangeAdd64(&var, (__int64) (val))
+#define ATOMIC_INC(var)                _InterlockedIncrement64(&var)
+#define ATOMIC_SUB(var, val)   _InterlockedExchangeAdd64(&var, -(__int64) 
(val))
+#define ATOMIC_DEC(var)                _InterlockedDecrement64(&var)
+#pragma intrinsic(_InterlockedExchangeAdd64)
+#pragma intrinsic(_InterlockedIncrement64)
+#pragma intrinsic(_InterlockedDecrement64)
+#else
+#define ATOMIC_TYPE            long
+#define ATOMIC_ADD(var, val)   _InterlockedExchangeAdd(&var, (long) (val))
+#define ATOMIC_INC(var)                _InterlockedIncrement(&var)
+#define ATOMIC_SUB(var, val)   _InterlockedExchangeAdd(&var, -(long) (val))
+#define ATOMIC_DEC(var)                _InterlockedDecrement(&var)
+#pragma intrinsic(_InterlockedExchangeAdd)
+#pragma intrinsic(_InterlockedIncrement)
+#pragma intrinsic(_InterlockedDecrement)
+#endif
+#define ATOMIC_START(lock, func)
+#define ATOMIC_END(lock, func)
+#define ATOMIC_INIT(lock, func)
+#define ATOMIC_COMP_SWAP(var, old, new, lock, func)    \
+       _InterlockedCompareExchange(&var, new, old)
+#pragma intrinsic(_InterlockedCompareExchange)
+#define ATOMIC_GET(var, lock, func)    var
+#else
+#define ATOMIC_LOCK            PTHREAD_MUTEX_INITIALIZER /* must use locks */
+#define ATOMIC_TYPE            ssize_t
+#define ATOMIC_ADD(var, val)   var += (ssize_t) (val)
+#define ATOMIC_INC(var)                var++
+#define ATOMIC_SUB(var, val)   var -= (ssize_t) (val)
+#define ATOMIC_DEC(var)                var--
+#define ATOMIC_START(lock, func)       MT_lock_set(&lock, func)
+#define ATOMIC_END(lock, func) MT_lock_unset(&lock, func)
+#define ATOMIC_INIT(lock, func)        MT_lock_init(&lock, func)
+static inline int
+atomic_comp_swap(volatile int *var, int old, int new, MT_Lock *lock, const 
char *func)
+{
+       int orig;
+       MT_lock_set(lock, func);
+       orig = *var;
+       if (*var == old)
+               *var = new;
+       MT_lock_unset(lock, func);
+       return orig;
+}
+#define ATOMIC_COMP_SWAP(var, old, new, lock, func)    \
+       atomic_comp_swap(&var, old, new, &lock, func)
+static inline int
+atomic_get(volatile int *var, MT_Lock *lock, const char *func)
+{
+       int orig;
+       MT_lock_set(lock, func);
+       orig = *var;
+       MT_lock_unset(lock, func);
+       return orig;
+}
+#define ATOMIC_GET(var, lock, func)    atomic_get(&var, &lock, func)
+#endif
+
+#endif /* _GDK_ATOMIC_H_ */
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -100,7 +100,7 @@ BBPrec *BBP[N_BBPINIT];             /* fixed base V
 bat BBPlimit = 0;              /* current committed VM BBP array */
 bat BBPsize = 0;               /* current used size of BBP array */
 
-#define KITTENNAP 2 * GDKnr_threads    /* used to suspend processing */
+#define KITTENNAP 4    /* used to suspend processing */
 #define BBPNONAME "."          /* filler for no name in BBP.dir */
 /*
  * The hash index uses a bucket index (int array) of size mask that is
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -46,7 +46,10 @@
 /* Linux gprof messes up on multithreaded programs */
 #ifdef PROFILE
 /* Linux gprof messes up on multithreaded programs */
-gdk_export int gprof_pthread_create(pthread_t * __restrict, __const 
pthread_attr_t * __restrict, void *(*fcn) (void *), void *__restrict);
+gdk_export int gprof_pthread_create(pthread_t * __restrict,
+                                   __const pthread_attr_t * __restrict,
+                                   void *(*fcn) (void *),
+                                   void *__restrict);
 #define pthread_create gprof_pthread_create
 #endif
 #endif
@@ -57,7 +60,7 @@ gdk_export int gprof_pthread_create(pthr
 #endif
 
 #ifdef HAVE_SYS_PARAM_H
-# include <sys/param.h>  /* prerequisite of sys/sysctl on OpenBSD */
+# include <sys/param.h>           /* prerequisite of sys/sysctl on OpenBSD */
 #endif
 #ifdef HAVE_SYS_SYSCTL_H
 # include <sys/sysctl.h>
@@ -84,18 +87,17 @@ gdk_export unsigned long long MT_locktra
 gdk_export char *MT_locktrace_nme[65536];
 gdk_export unsigned long long MT_clock(void);
 
-#define MT_locktrace_hash(_id)  ((int) (((lng) ((size_t) _id))^(((lng) 
((size_t) _id))>>16))&65535)
+#define MT_locktrace_hash(_id) ((int) (((lng) ((size_t) (_id))) ^ (((lng) 
((size_t) (_id))) >> 16)) & 65535)
 #define MT_log_trace(_impl, _object, _action, _caller, _fp, _pat)      \
        do {                                                            \
                unsigned long long _c=0;                                \
                if (MT_locktrace)                                       \
-                       _c=(MT_getpid() == MT_locktrace)?MT_clock():0;  \
+                       _c = MT_getpid() == MT_locktrace ? MT_clock() : 0; \
                MT_log(_impl, _object, _action, _caller, _fp);          \
-               if (_c) {                                               \
+               if (_c)                                         \
                        MT_locktrace_cnt[MT_locktrace_hash(_pat)] += MT_clock() 
- _c; \
-               }                                                       \
        } while(0)
-#define MT_locktrace_set(s,n)\
+#define MT_locktrace_set(s, n)                                         \
        do {                                                            \
                int _i = MT_locktrace_hash(s);                          \
                if (MT_locktrace_nme[_i] && MT_locktrace_nme[_i] != (n)) { \
@@ -106,10 +108,18 @@ gdk_export unsigned long long MT_clock(v
        } while (0)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to