X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvalue.h;h=4554a36617eb589153dc7244f19b3edf74c0bbd7;hb=9a04fda196e392d456f034e1fc2ad744a20d22b4;hp=e3e3f0de4ce9fab2267f535cd919bfdbdc73ba1f;hpb=b5f633cb2139ad17ce66cb4433b3a96276ccb1a9;p=pspp-builds.git diff --git a/src/data/value.h b/src/data/value.h index e3e3f0de..4554a366 100644 --- a/src/data/value.h +++ b/src/data/value.h @@ -1,42 +1,32 @@ -/* PSPP - computes sample statistics. - Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. +/* PSPP - a program for statistical analysis. + Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program. If not, see . */ -#if !value_h -#define value_h 1 +#ifndef DATA_VALUE_H +#define DATA_VALUE_H 1 -#include #include +#include +#include #include "minmax.h" -#include - -/* Values. */ /* "Short" strings, which are generally those no more than 8 characters wide, can participate in more operations than longer strings. */ #define MAX_SHORT_STRING (MAX (ROUND_UP (SIZEOF_DOUBLE, 2), 8)) #define MIN_LONG_STRING (MAX_SHORT_STRING + 1) -#define MAX_STRING 32767 - -/* Special values. */ -#define SYSMIS (-DBL_MAX) -#define LOWEST second_lowest_value -#define HIGHEST DBL_MAX /* A numeric or short string value. Multiple consecutive values represent a long string. */ @@ -47,10 +37,27 @@ union value }; union value *value_dup (const union value *, int width); +union value *value_create (int width); + int compare_values (const union value *, const union value *, int width); -unsigned hash_value (const union value *, int width); +unsigned hash_value (const union value *, int width); +int compare_ptr_values (const union value **, const union value **, int width); +unsigned hash_ptr_value (const union value **, int width); + + +static inline size_t value_cnt_from_width (int width); void value_copy (union value *, const union value *, int width); void value_set_missing (union value *, int width); - -#endif /* !value.h */ +bool value_is_resizable (const union value *, int old_width, int new_width); +void value_resize (union value *, int old_width, int new_width); + +/* Number of "union value"s required for a variable of the given + WIDTH. */ +static inline size_t +value_cnt_from_width (int width) +{ + return width == 0 ? 1 : DIV_RND_UP (width, MAX_SHORT_STRING); +} + +#endif /* data/value.h */