Changeset: 8d49500b4900 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8d49500b4900
Modified Files:
        NT/monetdb_config.h.in
        clients/Tests/exports.stable.out
        configure.ag
        gdk/gdk.h
        gdk/gdk_calc.c
        gdk/gdk_select.c
Branch: Oct2014
Log Message:

Add restrict keyword in some places.


diffs (truncated from 539 to 300 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -987,6 +987,14 @@
 #endif
 #endif
 
+/* Define to `__restrict__' or `__restrict' if that's what the C compiler
+   calls it, or to nothing if 'restrict' is not supported under any name.  */
+#ifndef __cplusplus
+#ifndef restrict
+#define restrict __restrict
+#endif
+#endif
+
 /* Define to `long int' if <sys/types.h> does not define. */
 /* #undef off_t */
 
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -261,18 +261,18 @@ MT_Lock *volatile GDKlocklist;
 ATOMIC_FLAG volatile GDKlocklistlock;
 ATOMIC_TYPE volatile GDKlocksleepcnt;
 void GDKlockstatistics(int);
-void *GDKmalloc(size_t size);
+void *GDKmalloc(size_t size) __attribute__((__malloc__)) 
__attribute__((__warn_unused_result__));
 size_t GDKmem_cursize(void);
 void *GDKmmap(const char *path, int mode, size_t len);
 int GDKms(void);
 int GDKnr_threads;
 void GDKqsort(void *h, void *t, const void *base, size_t n, int hs, int ts, 
int tpe);
 void GDKqsort_rev(void *h, void *t, const void *base, size_t n, int hs, int 
ts, int tpe);
-void *GDKrealloc(void *pold, size_t size);
+void *GDKrealloc(void *pold, size_t size) 
__attribute__((__warn_unused_result__));
 void GDKsetenv(str name, str value);
 ssize_t GDKstrFromStr(unsigned char *dst, const unsigned char *src, ssize_t 
len);
-str GDKstrdup(const char *s);
-str GDKstrndup(const char *s, size_t n);
+str GDKstrdup(const char *s) __attribute__((__warn_unused_result__));
+str GDKstrndup(const char *s, size_t n) 
__attribute__((__warn_unused_result__));
 int GDKsyserror(_In_z_ _Printf_format_string_ const char *format, ...) 
__attribute__((__format__(__printf__, 1, 2)));
 ThreadRec GDKthreads[THREADS];
 int GDKupgradevarheap(COLrec *c, var_t v, int copyall, int mayshare);
@@ -280,7 +280,7 @@ lng GDKusec(void);
 BAT *GDKval;
 const char *GDKversion(void);
 size_t GDKvm_cursize(void);
-void *GDKzalloc(size_t size);
+void *GDKzalloc(size_t size) __attribute__((__malloc__)) 
__attribute__((__warn_unused_result__));
 void HASHdestroy(BAT *b);
 BUN HASHlist(Hash *h, BUN i);
 BUN HASHprobe(Hash *h, const void *v);
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2823,6 +2823,7 @@ dnl     checks for structures
 dnl     checks for compiler characteristics
 AC_C_CONST
 AC_C_INLINE
+AC_C_RESTRICT
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo(int * restrict p) { return *p; }])],
        AC_DEFINE(HAVE_RESTRICT, 1,
                [Define if the compiler supports the restrict keyword]),
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2232,12 +2232,19 @@ gdk_export int  GDK_vm_trim;            /* allow tr
 gdk_export size_t GDKmem_cursize(void);        /* RAM/swapmem that MonetDB has 
claimed from OS */
 gdk_export size_t GDKvm_cursize(void); /* current MonetDB VM address space 
usage */
 
-gdk_export void *GDKmalloc(size_t size);
-gdk_export void *GDKzalloc(size_t size);
-gdk_export void *GDKrealloc(void *pold, size_t size);
+gdk_export void *GDKmalloc(size_t size)
+       __attribute__((__malloc__))
+       __attribute__ ((__warn_unused_result__));
+gdk_export void *GDKzalloc(size_t size)
+       __attribute__((__malloc__))
+       __attribute__ ((__warn_unused_result__));
+gdk_export void *GDKrealloc(void *pold, size_t size)
+       __attribute__ ((__warn_unused_result__));
 gdk_export void GDKfree(void *blk);
-gdk_export str GDKstrdup(const char *s);
-gdk_export str GDKstrndup(const char *s, size_t n);
+gdk_export str GDKstrdup(const char *s)
+       __attribute__ ((__warn_unused_result__));
+gdk_export str GDKstrndup(const char *s, size_t n)
+       __attribute__ ((__warn_unused_result__));
 
 #if !defined(NDEBUG) && !defined(STATIC_CODE_ANALYSIS)
 /* In debugging mode, replace GDKmalloc and other functions with a
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -103,7 +103,7 @@ checkbats(BAT *b1, BAT *b2, const char *
 #define UNARY_2TYPE_FUNC(TYPE1, TYPE2, FUNC)                           \
        do {                                                            \
                const TYPE1 *src = (const TYPE1 *) Tloc(b, b->batFirst); \
-               TYPE2 *dst = (TYPE2 *) Tloc(bn, bn->batFirst);          \
+               TYPE2 * restrict dst = (TYPE2 *) Tloc(bn, bn->batFirst); \
                CANDLOOP(dst, i, TYPE2##_nil, 0, start);                \
                if (b->T->nonil && cand == NULL) {                      \
                        for (i = start; i < end; i++)                   \
@@ -784,7 +784,7 @@ BATcalcisnil(BAT *b, BAT *s)
        BAT *bn;
        BUN i, cnt, start, end;
        const oid *cand = NULL, *candend = NULL;
-       bit *dst;
+       bit * restrict dst;
        BUN nils = 0;
 
        BATcheck(b, "BATcalcisnil");
@@ -897,7 +897,7 @@ VARcalcisnotnil(ValPtr ret, const ValRec
 static BUN                                                             \
 add_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff,        \
                                int abort_on_error)                     \
@@ -927,7 +927,7 @@ add_##TYPE1##_##TYPE2##_##TYPE3(const TY
 static BUN                                                             \
 add_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff)        \
 {                                                                      \
@@ -1076,7 +1076,7 @@ ADD_3TYPE(dbl, dbl, dbl)
 static BUN
 add_typeswitchloop(const void *lft, int tp1, int incr1,
                   const void *rgt, int tp2, int incr2,
-                  void *dst, int tp, BUN cnt,
+                  void * restrict dst, int tp, BUN cnt,
                   BUN start, BUN end, const oid *cand,
                   const oid *candend, oid candoff,
                   int abort_on_error, const char *func)
@@ -2207,7 +2207,7 @@ VARcalcincr(ValPtr ret, const ValRecord 
 static BUN                                                             \
 sub_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff,        \
                                int abort_on_error)                     \
@@ -2237,7 +2237,7 @@ sub_##TYPE1##_##TYPE2##_##TYPE3(const TY
 static BUN                                                             \
 sub_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff)        \
 {                                                                      \
@@ -2386,7 +2386,7 @@ SUB_3TYPE(dbl, dbl, dbl)
 static BUN
 sub_typeswitchloop(const void *lft, int tp1, int incr1,
                   const void *rgt, int tp2, int incr2,
-                  void *dst, int tp, BUN cnt,
+                  void * restrict dst, int tp, BUN cnt,
                   BUN start, BUN end, const oid *cand,
                   const oid *candend, oid candoff,
                   int abort_on_error, const char *func)
@@ -3368,7 +3368,7 @@ VARcalcdecr(ValPtr ret, const ValRecord 
 static BUN                                                             \
 mul_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff,        \
                                int abort_on_error)                     \
@@ -3399,7 +3399,7 @@ mul_##TYPE1##_##TYPE2##_##TYPE3(const TY
 static BUN                                                             \
 mul_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff)        \
 {                                                                      \
@@ -3429,7 +3429,7 @@ mul_##TYPE1##_##TYPE2##_##TYPE3(const TY
 static BUN                                                             \
 mul_##TYPE1##_##TYPE2##_lng(const TYPE1 *lft, int incr1,               \
                            const TYPE2 *rgt, int incr2,                \
-                           lng *dst, BUN cnt, BUN start,               \
+                           lng * restrict dst, BUN cnt, BUN start,     \
                            BUN end, const oid *cand,                   \
                            const oid *candend, oid candoff,            \
                            int abort_on_error)                         \
@@ -3467,7 +3467,7 @@ mul_##TYPE1##_##TYPE2##_lng(const TYPE1 
 static BUN                                                             \
 mul_##TYPE1##_##TYPE2##_lng(const TYPE1 *lft, int incr1,               \
                            const TYPE2 *rgt, int incr2,                \
-                           lng *dst, BUN cnt, BUN start,               \
+                           lng * restrict dst, BUN cnt, BUN start,     \
                            BUN end, const oid *cand,                   \
                            const oid *candend, oid candoff,            \
                            int abort_on_error)                         \
@@ -3498,7 +3498,7 @@ mul_##TYPE1##_##TYPE2##_lng(const TYPE1 
 static BUN                                                             \
 mul_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff,        \
                                int abort_on_error)                     \
@@ -3685,7 +3685,7 @@ MUL_2TYPE_float(dbl, dbl, dbl)
 static BUN
 mul_typeswitchloop(const void *lft, int tp1, int incr1,
                   const void *rgt, int tp2, int incr2,
-                  void *dst, int tp, BUN cnt,
+                  void * restrict dst, int tp, BUN cnt,
                   BUN start, BUN end, const oid *cand,
                   const oid *candend, oid candoff,
                   int abort_on_error, const char *func)
@@ -4675,7 +4675,7 @@ VARcalcmul(ValPtr ret, const ValRecord *
 static BUN                                                             \
 div_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff,        \
                                int abort_on_error)                     \
@@ -4707,7 +4707,7 @@ div_##TYPE1##_##TYPE2##_##TYPE3(const TY
 static BUN                                                             \
 div_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff,        \
                                int abort_on_error)                     \
@@ -4870,7 +4870,7 @@ DIV_3TYPE_float(dbl, dbl, dbl)
 static BUN
 div_typeswitchloop(const void *lft, int tp1, int incr1,
                   const void *rgt, int tp2, int incr2,
-                  void *dst, int tp, BUN cnt,
+                  void * restrict dst, int tp, BUN cnt,
                   BUN start, BUN end, const oid *cand,
                   const oid *candend, oid candoff,
                   int abort_on_error, const char *func)
@@ -5909,7 +5909,7 @@ VARcalcdiv(ValPtr ret, const ValRecord *
 static BUN                                                             \
 mod_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff,        \
                                int abort_on_error)                     \
@@ -5941,7 +5941,7 @@ mod_##TYPE1##_##TYPE2##_##TYPE3(const TY
 static BUN                                                             \
 mod_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1,           \
                                const TYPE2 *rgt, int incr2,            \
-                               TYPE3 *dst, BUN cnt, BUN start,         \
+                               TYPE3 * restrict dst, BUN cnt, BUN start, \
                                BUN end, const oid *cand,               \
                                const oid *candend, oid candoff,        \
                                int abort_on_error)                     \
@@ -6075,7 +6075,7 @@ FMOD_3TYPE(dbl, dbl, dbl, fmod)
 static BUN
 mod_typeswitchloop(const void *lft, int tp1, int incr1,
                   const void *rgt, int tp2, int incr2,
-                  void *dst, int tp, BUN cnt,
+                  void * restrict dst, int tp, BUN cnt,
                   BUN start, BUN end, const oid *cand,
                   const oid *candend, oid candoff,
                   int abort_on_error, const char *func)
@@ -6918,7 +6918,7 @@ VARcalcmod(ValPtr ret, const ValRecord *
 static BUN
 xor_typeswitchloop(const void *lft, int incr1,
                   const void *rgt, int incr2,
-                  void *dst, int tp, BUN cnt,
+                  void * restrict dst, int tp, BUN cnt,
                   BUN start, BUN end, const oid *cand,
                   const oid *candend, oid candoff,
                   int nonil, const char *func)
@@ -7139,7 +7139,7 @@ VARcalcxor(ValPtr ret, const ValRecord *
 static BUN
 or_typeswitchloop(const void *lft, int incr1,
                  const void *rgt, int incr2,
-                 void *dst, int tp, BUN cnt,
+                 void * restrict dst, int tp, BUN cnt,
                  BUN start, BUN end, const oid *cand,
                  const oid *candend, oid candoff,
                  int nonil, const char *func)
@@ -7378,7 +7378,7 @@ VARcalcor(ValPtr ret, const ValRecord *l
 static BUN
 and_typeswitchloop(const void *lft, int incr1,
                   const void *rgt, int incr2,
-                  void *dst, int tp, BUN cnt,
+                  void * restrict dst, int tp, BUN cnt,
                   BUN start, BUN end, const oid *cand,
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to