Changeset: 3522ab3481c1 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3522ab3481c1 Added Files: gdk/gdk_atoms.c gdk/gdk_atoms.h Removed Files: gdk/gdk_atoms.mx Modified Files: gdk/Makefile.ag monetdb5/tests/gdkTests/Tests/casts.stable.out monetdb5/tests/gdkTests/Tests/casts.stable.out.SunOS5.10 monetdb5/tests/gdkTests/Tests/casts.stable.out.SunOS5.10.oid64 monetdb5/tests/gdkTests/Tests/casts.stable.out.Windows monetdb5/tests/gdkTests/Tests/casts.stable.out.Windows.64bit.oid64 monetdb5/tests/gdkTests/Tests/casts.stable.out.oid64 Branch: default Log Message:
Merge heads. diffs (truncated from 2295 to 300 lines): diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag --- a/gdk/Makefile.ag +++ b/gdk/Makefile.ag @@ -36,7 +36,7 @@ lib_gdk = { gdk_scanselect_defs_var.mx \ gdk_scanselect.mx gdk.h gdk_batop.mx \ gdk_search.mx gdk_tm.c gdk_align.c gdk_bbp.mx \ - gdk_heap.c gdk_setop.mx gdk_utils.c gdk_utils.h gdk_atoms.mx \ + gdk_heap.c gdk_setop.mx gdk_utils.c gdk_utils.h gdk_atoms.c gdk_atoms.h \ gdk_qsort.mx gdk_ssort.mx gdk_storage.c gdk_bat.c gdk_bat.h \ gdk_delta.c gdk_relop.mx gdk_system.c gdk_value.c \ gdk_rangejoin.mx \ diff --git a/gdk/gdk_atoms.mx b/gdk/gdk_atoms.c rename from gdk/gdk_atoms.mx rename to gdk/gdk_atoms.c --- a/gdk/gdk_atoms.mx +++ b/gdk/gdk_atoms.c @@ -1,25 +1,22 @@ -@/ -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 +/* + * 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-2012 MonetDB B.V. + * All Rights Reserved. + */ -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-2012 MonetDB B.V. -All Rights Reserved. -@ - -@f gdk_atoms - -@c /* * @a M. L. Kersten, P. Boncz * @* Atomic types @@ -29,100 +26,7 @@ All Rights Reserved. * both built-in and user-defined atomic types. * New types, such as point and polygons, can be readily added to this * collection. - * @- */ -@h -#ifndef _GDK_ATOMS_H_ -#define _GDK_ATOMS_H_ - -#define MAXATOMS 128 - -/* - * @- comparison macro's - * In order to get maximum performance, we extensively use out-factoring - * of typechecks using Mx macros. To catch diverging code in one Mx macro - * we use the following #defines for comparing atoms: - */ -#define simple_CMP(x,y,tpe) (simple_LT(x,y,tpe)?-1:simple_GT(x,y,tpe)) -#define simple_EQ(x,y,tpe) ((*(const tpe*) (x)) == (*(const tpe*) (y))) -#define simple_NE(x,y,tpe,nl) ((*(const tpe*)(y)) != nl && (*(const tpe*) (x)) != (*(const tpe*) (y))) -#define simple_LT(x,y,tpe) ((*(const tpe*) (x)) < (*(const tpe*) (y))) -#define simple_GT(x,y,tpe) ((*(const tpe*) (x)) > (*(const tpe*) (y))) -#define simple_LE(x,y,tpe) ((*(const tpe*) (x)) <= (*(const tpe*) (y))) -#define simple_GE(x,y,tpe) ((*(const tpe*) (x)) >= (*(const tpe*) (y))) -#define atom_CMP(x,y,id) (*BATatoms[id].atomCmp)(x,y) -#define atom_EQ(x,y,id) ((*BATatoms[id].atomCmp)(x,y) == 0) -#define atom_NE(x,y,id,nl) ((*BATatoms[id].atomCmp)(y,BATatoms[id].atomNull) != 0 && (*BATatoms[id].atomCmp)(x,y) != 0) -#define atom_LT(x,y,id) ((*BATatoms[id].atomCmp)(x,y) < 0) -#define atom_GT(x,y,id) ((*BATatoms[id].atomCmp)(x,y) > 0) -#define atom_LE(x,y,id) ((*BATatoms[id].atomCmp)(x,y) <= 0) -#define atom_GE(x,y,id) ((*BATatoms[id].atomCmp)(x,y) >= 0) -#define simple_HASH(v,tpe,dst) ((dst) *(const tpe *) (v)) -#define atom_HASH(v,id,dst) ((dst) (*BATatoms[id].atomHash)(v)) - -/* - * @- maximum atomic string lengths - */ -#define bitStrlen 8 -#define bteStrlen 8 -#define shtStrlen 12 -#define intStrlen 24 -#if SIZEOF_OID == SIZEOF_INT -#define oidStrlen 24 -#else -#define oidStrlen 48 -#endif -#if SIZEOF_WRD == SIZEOF_INT -#define wrdStrlen 24 -#else -#define wrdStrlen 48 -#endif -#if SIZEOF_PTR == SIZEOF_INT -#define ptrStrlen 24 -#else -#define ptrStrlen 48 -#endif -#define lngStrlen 48 -#define fltStrlen 48 -#define dblStrlen 96 - -/* - * @- - * The system comes with the traditional atomic types: int (4 bytes), bool(1 - * byte) and str (variable). In addition, we support the notion of an OID - * type, which ensures uniqueness of its members. - * This leads to the following type descriptor table. - */ - -gdk_export int lngFromStr(const char *src, int *len, lng **dst); -gdk_export int lngToStr(str *dst, int *len, const lng *src); -gdk_export int intFromStr(const char *src, int *len, int **dst); -gdk_export int intToStr(str *dst, int *len, const int *src); -gdk_export int batFromStr(const char *src, int *len, bat **dst); -gdk_export int batToStr(str *dst, int *len, const bat *src); -gdk_export int ptrFromStr(const char *src, int *len, ptr **dst); -gdk_export int ptrToStr(str *dst, int *len, const ptr *src); -gdk_export int bitFromStr(const char *src, int *len, bit **dst); -gdk_export int bitToStr(str *dst, int *len, const bit *src); -gdk_export int OIDfromStr(const char *src, int *len, oid **dst); -gdk_export int OIDtoStr(str *dst, int *len, const oid *src); -gdk_export int shtFromStr(const char *src, int *len, sht **dst); -gdk_export int shtToStr(str *dst, int *len, const sht *src); -gdk_export int bteFromStr(const char *src, int *len, bte **dst); -gdk_export int bteToStr(str *dst, int *len, const bte *src); -gdk_export int fltFromStr(const char *src, int *len, flt **dst); -gdk_export int fltToStr(str *dst, int *len, const flt *src); -gdk_export int dblFromStr(const char *src, int *len, dbl **dst); -gdk_export int dblToStr(str *dst, int *len, const dbl *src); -gdk_export ssize_t GDKstrFromStr(unsigned char *dst, const unsigned char *src, ssize_t len); -gdk_export int strFromStr(const char *src, int *len, str *dst); -gdk_export int strToStr(str *dst, int *len, const char *src); -gdk_export BUN strHash(const char *s); -gdk_export int strLen(const char *s); -gdk_export int strNil(const char *s); -gdk_export int escapedStrlen(const char *src); -gdk_export int escapedStr(char *dst, const char *src, int dstlen); -@c /* * @- inline comparison routines * Return 0 on l==r, < 0 iff l < r, >0 iff l > r @@ -263,7 +167,7 @@ batUnfix(const bat *b) * * The routines cmp and eq are comparison routines used to build access * structures. The null returns a reference to a null value representation. - * @- + * * The incremental atom construction uses hardwired properties. * This should be improved later on. */ @@ -427,60 +331,6 @@ ATOMisdescendant(int tpe, int parent) } -@h -/* - * @- nil values - * All types have a single value designated as a NIL value. It designates - * a missing value and it is ignored (forbidden) in several primitives. - * The current policy is to use the smallest value in any ordered domain. - * The routine atomnil returns a pointer to the nil value representation. - */ -#define GDK_bit_max ((bit) 1) -#define GDK_bit_min ((bit) 0) -#define GDK_bte_max ((bte) SCHAR_MAX) -#define GDK_bte_min ((bte) SCHAR_MIN) -#define GDK_sht_max ((sht) SHRT_MAX) -#define GDK_sht_min ((sht) SHRT_MIN) -#define GDK_int_max INT_MAX -#define GDK_int_min INT_MIN -#define GDK_flt_max ((flt) FLT_MAX) -#define GDK_flt_min (-GDK_flt_max) -#define GDK_lng_max ((lng) LLONG_MAX) -#define GDK_lng_min ((lng) LLONG_MIN) -#define GDK_dbl_max ((dbl) DBL_MAX) -#define GDK_dbl_min (-GDK_dbl_max) -/* GDK_oid_max see below */ -#define GDK_oid_min ((oid) 0) -/* representation of the nil */ -gdk_export const bte bte_nil; -gdk_export const sht sht_nil; -gdk_export const int int_nil; -gdk_export const flt flt_nil; -gdk_export const dbl dbl_nil; -gdk_export const lng lng_nil; -gdk_export const oid oid_nil; -gdk_export const wrd wrd_nil; -gdk_export const char str_nil[2]; -gdk_export const ptr ptr_nil; - -/* derived NIL values - OIDDEPEND */ -#define bit_nil ((bit) bte_nil) -#define bat_nil ((bat) int_nil) -#if SIZEOF_WRD == SIZEOF_INT -#define GDK_wrd_max ((wrd) GDK_int_max) -#define GDK_wrd_min ((wrd) GDK_int_min) -#else -#define GDK_wrd_max ((wrd) GDK_lng_max) -#define GDK_wrd_min ((wrd) GDK_lng_min) -#endif -#if SIZEOF_OID == SIZEOF_INT -#define GDK_oid_max ((oid) GDK_int_max) -#else -#define GDK_oid_max ((oid) GDK_lng_max) -#endif - -#define void_nil oid_nil -@c const bte bte_nil = GDK_bte_min; const sht sht_nil = GDK_sht_min; const int int_nil = GDK_int_min; @@ -504,162 +354,6 @@ ATOMnil(int t) return dst; } -@h -/* - * @- Derived types - * In all algorithms across GDK, you will find switches on the types - * ( bte, sht, int, wrd, flt, dbl, lng, str). They respectively represent - * an octet, a 16-bit int, a 32-bit int, a 32-bit float, a 64-bit double, - * a 64-bit int, and a pointer-sized location of a char-buffer (ended by - * a zero char). - * - * In contrast, the types (bit, ptr, bat, oid) are derived types. They - * do not occur in the switches. The ATOMstorage macro maps them respectively - * onto a @code{ bte}, @code{ int} (pointers are 32-bit), @code{ int}, and - * @code{ int}. OIDs are 32-bit. - * - * This approach makes it tractable to switch to 64-bits OIDs, - * or to a fully 64-bits OS easily. One only has to map the @code{ oid} - * and @code{ ptr} types to @code{ lng} instead of @code{ int}. - * - * Derived types mimic their fathers in many ways. They inherit the @code{ size}, - * @code{ varsized}, @code{ linear}, @code{ null} and @code{ align} properties of their - * father. The same goes for the ADT functions HASH, CMP, PUT, NULL, - * DEL, LEN, and HEAP. So, a derived type differs in only two ways - * from its father: - * @table @code - * @item [string representation] - * the only two ADT operations specific for a derived type are FROMSTR - * and TOSTR. - * @item [identity] - * (a @code{ bit} is really of a different type than @code{ bte}). The set of - * operations on derived type values or BATs of such types may differ - * from the sets of operations on the father type. - * @end table - */ -/* use "do ... while(0)" so that lhs can safely be used in if statements */ -#define ATOMstorage(t) BATatoms[t].storage -#define ATOMsize(t) BATatoms[t].size -#define ATOMalign(t) BATatoms[t].align -#define ATOMfromstr(t,s,l,src) BATatoms[t].atomFromStr(src,l,s) -#define ATOMnilptr(t) BATatoms[t].atomNull -#define ATOMhash(t,src) BATatoms[t].atomHash(src) -#define ATOMdel(t,hp,src) do if (BATatoms[t].atomDel) BATatoms[t].atomDel(hp,src); while (0) -#define ATOMvarsized(t) ((t != TYPE_void) && BATatoms[t].varsized) -#define ATOMlinear(t) BATatoms[t].linear -#define ATOMtype(t) ((t == TYPE_void)?TYPE_oid:t) -#define ATOMfix(t,v) do if (BATatoms[t].atomFix) BATatoms[t].atomFix(v); while (0) -#define ATOMunfix(t,v) do if (BATatoms[t].atomUnfix) BATatoms[t].atomUnfix(v); while (0) -#define ATOMconvert(t,v,d) do if (BATatoms[t].atomConvert) BATatoms[t].atomConvert(v,d); while (0) -#define ATOMheapConvert(t,hp,d) do if (BATatoms[t].atomHeapConvert) BATatoms[t].atomHeapConvert(hp,d); while (0) - -#define CONV_HTON 1 -#define CONV_NTOH 0 - -/* - * @- - * In case that atoms are added to a bat, their logical reference count - * should be incremented (and decremented if deleted). Notice that BATs - * with atomic types that have logical references (e.g. BATs of BATs but - * also BATs of ODMG odSet) can never be persistent, as this would make - * the commit tremendously complicated. - */ -#define ATOMput(type, heap, dst, src) \ - do { \ - int t_ = (type); \ - ptr d_ = (ptr) (dst); \ _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list