OSSP CVS Repository

ossp - Check-in [151]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 151
Date: 2000-Aug-19 16:46:26 (local)
2000-Aug-19 14:46:26 (UTC)
User:rse
Branch:
Comment: *** empty log message ***
Tickets:
Inspections:
Files:
ossp-pkg/act/Makefile.in      1.4 -> 1.5     2 inserted, 2 deleted
ossp-pkg/act/act_grid.c      added-> 1.1
ossp-pkg/act/act_grid.h      added-> 1.1
ossp-pkg/act/act_hash.c      1.4 -> 1.5     1 inserted, 1 deleted
ossp-pkg/act/act_mem.c      1.7 -> 1.8     16 inserted, 0 deleted
ossp-pkg/act/act_mem.h      1.4 -> 1.5     2 inserted, 0 deleted

ossp-pkg/act/Makefile.in 1.4 -> 1.5

--- Makefile.in  2000/08/20 13:57:52     1.4
+++ Makefile.in  2000/08/20 14:46:26     1.5
@@ -13,8 +13,8 @@
 
 PRE     = act_p.h
 LIB     = libact.a
-SRC     = act_mem.c act_ctx.c act_str.c act_lib.c act_hash.c act_hash_fct.c act_hash_oh.c act_hash_lh.c 
-OBJ     = act_mem.o act_ctx.o act_str.o act_lib.o act_hash.o act_hash_fct.o act_hash_oh.o act_hash_lh.o 
+SRC     = act_mem.c act_ctx.c act_str.c act_grid.c act_lib.c act_hash.c act_hash_fct.c act_hash_oh.c act_hash_lh.c 
+OBJ     = act_mem.o act_ctx.o act_str.o act_grid.o act_lib.o act_hash.o act_hash_fct.o act_hash_oh.o act_hash_lh.o 
 TST     = act_test
 
 _VERSION_FILE = \


ossp-pkg/act/act_grid.c -> 1.1

*** /dev/null    Sat Nov 23 01:23:29 2024
--- -    Sat Nov 23 01:23:37 2024
***************
*** 0 ****
--- 1,114 ----
+ /* 
+ **  Act - Abstract Container Type Library
+ **  Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ **
+ **  This file is part of Act, a library for dealing with Abstract 
+ **  Container Types which can be found at http://www.ossp.org/pkg/act/.
+ **
+ **  Permission to use, copy, modify, and distribute this software for
+ **  any purpose with or without fee is hereby granted, provided that
+ **  the above copyright notice and this permission notice appear in all
+ **  copies.
+ **
+ **  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ **  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ **  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ **  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ **  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ **  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ **  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ **  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ **  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ **  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ **  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ **  SUCH DAMAGE.
+ **
+ **  act_grid.c: memory grid (implementation)
+ */
+ 
+ #include "act_p.h"
+ 
+ /* the top-level structure of a grid */
+ struct act_grid_st {
+     act_ctx_t *g_ctx;
+     void      *g_seg_block;
+     void      *g_seg_free;
+     size_t     g_seg_num;
+     size_t     g_seg_size;
+ };
+ 
+ act_grid_t *act_grid_create(act_ctx_t *ctx, size_t segnum, size_t segsize)
+ {
+     act_grid_t *grid = NULL;
+     void *block;
+     void *seg;
+     int i;
+ 
+     /* consistency checks */
+     insist(ctx != NULL, NULL);
+     insist(segnum >= 1, NULL);
+     insist(segsize >= sizeof(void *), NULL);
+     
+     /* align segment size */
+     segsize = act_mem_align(segsize);
+ 
+     /* allocate memory chunks */
+     if ((grid = (act_grid_t *)act_mem_alloc_ctx(ctx, sizeof(act_grid_t))) == NULL)
+         return NULL;
+     if ((block = act_mem_alloc_ctx(ctx, segnum * segsize)) == NULL) {
+         act_mem_free_ctx(ctx, grid);
+         return NULL;
+     }
+ 
+     /* initialize top-level structure */
+     grid->g_ctx       = act_ctx_dup(ctx, NULL);
+     grid->g_seg_block = block;
+     grid->g_seg_free  = block;
+     grid->g_seg_num   = segnum;
+     grid->g_seg_size  = segsize;
+ 
+     /* initialize segment block */
+     seg = grid->g_seg_free;
+     for (i = 0; i < segnum-1; i++) {
+         *((void **)seg) = (char *)seg+segsize;
+         seg = (char *)seg+segsize;
+     }
+     *((void **)seg) = NULL;
+ 
+     return grid;
+ }
+ 
+ int act_grid_destroy(act_grid_t *grid)
+ {
+     act_ctx_t *ctx;
+ 
+     insist(grid != NULL, FALSE);
+ 
+     ctx = grid->g_ctx;
+     act_mem_free_ctx(ctx, grid->g_seg_block);
+     act_mem_free_ctx(ctx, grid);
+ 
+     return TRUE;
+ }
+ 
+ void *act_grid_alloc(act_grid_t *grid)
+ {
+     void *chunk = NULL;
+ 
+     insist(grid != NULL, NULL);
+ 
+     /* XXX */
+ 
+     return chunk;
+ }
+ 
+ int act_grid_free(act_grid_t *grid, void *segptr)
+ {
+     insist(grid != NULL, FALSE);
+     insist(segptr != NULL, FALSE);
+ 
+     /* XXX */
+ 
+     return TRUE;
+ }
+ 


ossp-pkg/act/act_grid.h -> 1.1

*** /dev/null    Sat Nov 23 01:23:29 2024
--- -    Sat Nov 23 01:23:37 2024
***************
*** 0 ****
--- 1,41 ----
+ /* 
+ **  Act - Abstract Container Type Library
+ **  Copyright (c) 1999-2000 Ralf S. Engelschall <rse@engelschall.com>
+ **
+ **  This file is part of Act, a library for dealing with Abstract 
+ **  Container Types which can be found at http://www.ossp.org/pkg/act/.
+ **
+ **  Permission to use, copy, modify, and distribute this software for
+ **  any purpose with or without fee is hereby granted, provided that
+ **  the above copyright notice and this permission notice appear in all
+ **  copies.
+ **
+ **  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ **  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ **  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ **  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ **  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ **  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ **  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ **  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ **  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ **  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ **  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ **  SUCH DAMAGE.
+ **
+ **  act_grid.h: memory grid (declaration)
+ */
+ 
+ #ifndef _ACT_GRID_H_
+ #define _ACT_GRID_H_
+ 
+ struct act_grid_st;
+ typedef struct act_grid_st act_grid_t;
+ 
+ extern act_grid_t *act_grid_create   (act_ctx_t *ctx, size_t segnum, size_t segsize);
+ extern void       *act_grid_alloc    (act_grid_t *grid);
+ extern int         act_grid_free     (act_grid_t *grid, void *segptr);
+ extern int         act_grid_destroy  (act_grid_t *grid);
+ 
+ #endif /* _ACT_GRID_H_ */
+ 


ossp-pkg/act/act_hash.c 1.4 -> 1.5

--- act_hash.c   2000/08/20 13:57:53     1.4
+++ act_hash.c   2000/08/20 14:46:26     1.5
@@ -74,7 +74,7 @@
     insist(data != NULL, NULL);
 
     /* allocate a top-level data structure */
-    if ((h = (act_hash_t *)act_mem_alloc(sizeof(act_hash_t))) == NULL) {
+    if ((h = (act_hash_t *)act_mem_alloc_ctx(ctx, sizeof(act_hash_t))) == NULL) {
         method->m_free(ctx, data);
         return NULL;
     }


ossp-pkg/act/act_mem.c 1.7 -> 1.8

--- act_mem.c    2000/08/18 15:58:09     1.7
+++ act_mem.c    2000/08/20 14:46:26     1.8
@@ -42,6 +42,22 @@
 void *(*act_mem_char)(const void *, unsigned char, size_t)       = _act_mem_char;
 int   (*act_mem_cmp)(const void *, const void *, size_t)         = _act_mem_cmp;
 
+/* 
+ * Align a size to the next larger or equal size which is likely to have the
+ * longest *relevant* CPU-specific memory word alignment restrictions.
+ */
+size_t act_mem_align(size_t size)
+{
+    union mem_word {
+        void  *mw_vp;
+        void (*mw_fp)(void);
+        char  *mw_cp;
+        long   mw_l;
+        double mw_d;
+    };
+    return ((1+((size-1) / sizeof(union mem_word))) * sizeof(union mem_word));
+}
+
 /* the initialization function for the memory part */
 intern int act_mem_init(void)
 {


ossp-pkg/act/act_mem.h 1.4 -> 1.5

--- act_mem.h    2000/08/18 15:58:09     1.4
+++ act_mem.h    2000/08/20 14:46:26     1.5
@@ -29,6 +29,8 @@
 #ifndef _ACT_MEM_H_
 #define _ACT_MEM_H_
 
+extern size_t  act_mem_align(size_t);
+
 extern void *(*act_mem_alloc)(size_t);
 extern void *(*act_mem_realloc)(void *, size_t);
 extern void  (*act_mem_free)(void *);

CVSTrac 2.0.1