- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Osi-0.98.1/DyLP/src/Dylp/glplib.h

Go to the documentation of this file.

    00001 /* glplib.h */
    00002
    00003 /*----------------------------------------------------------------------
    00004 -- Copyright (C) 2000, 2001, 2002 Andrew Makhorin <mao@mai2.rcnet.ru>,
    00005 --               Department for Applied Informatics, Moscow Aviation
    00006 --               Institute, Moscow, Russia. All rights reserved.
    00007 --
    00008 -- This file is a part of GLPK (GNU Linear Programming Kit).
    00009 --
    00010 -- Licensed under the Common Public License (CPL) by permission of the
    00011 -- author for inclusion in the DyLP LP distribution.
    00012 ----------------------------------------------------------------------*/
    00013 /*
    00014   @(#)glplib.h  1.1     10/18/02
    00015   svn/cvs: $Id: glplib.h 158 2007-07-06 01:25:14Z lou $
    00016 */
    00017
    00018 #ifndef _GLPLIB_H
    00019 #define _GLPLIB_H
    00020
    00021 #define save_pointer          dy_glp_save_pointer
    00022 #define read_pointer          dy_glp_read_pointer
    00023
    00024 #define init_lib_env          dy_glp_init_lib_env
    00025 #define get_env_ptr           dy_glp_get_env_ptr
    00026 #define free_lib_env          dy_glp_free_lib_env
    00027
    00028 #define print                 dy_glp_print
    00029 #define fault                 dy_glp_fault
    00030 #define _insist               dy_glp_insist
    00031 #define watch                 dy_glp_watch
    00032
    00033 #define umalloc               dy_glp_umalloc
    00034 #define ucalloc               dy_glp_ucalloc
    00035 #define ufree                 dy_glp_ufree
    00036
    00037 #define create_pool           dy_glp_create_pool
    00038 #define get_atom              dy_glp_get_atom
    00039 #define free_atom             dy_glp_free_atom
    00040 #define get_atomv             dy_glp_get_atomv
    00041 #define clear_pool            dy_glp_clear_pool
    00042 #define delete_pool           dy_glp_delete_pool
    00043
    00044 extern void save_pointer(void *ptr);
    00045 /* save a pointer */
    00046
    00047 extern void *read_pointer(void);
    00048 /* obtain a pointer */
    00049
    00050 typedef struct ENV ENV;
    00051 typedef struct MEM MEM;
    00052
    00053 struct ENV
    00054 {     /* library environmental block */
    00055       MEM *mem_ptr;
    00056       /* pointer to the linked list of allocated memory blocks */
    00057       int mem_limit;
    00058       /* maximal amount of memory (in bytes) available for dynamic
    00059          allocation */
    00060       int mem_total;
    00061       /* total amount of currently allocated memory (in bytes; is the
    00062          sum of the size fields over all memory block descriptors) */
    00063       int mem_tpeak;
    00064       /* peak value of mem_total */
    00065       int mem_count;
    00066       /* total number of currently allocated memory blocks */
    00067       int mem_cpeak;
    00068       /* peak value of mem_count */
    00069 };
    00070
    00071 extern int init_lib_env(void);
    00072 /* initialize library environment */
    00073
    00074 extern ENV *get_env_ptr(void);
    00075 /* obtain a pointer to the environmental block */
    00076
    00077 extern int free_lib_env(void);
    00078 /* deinitialize library environment */
    00079
    00080 extern void print(const char *fmt, ...);
    00081 /* print informative message */
    00082
    00083 extern void fault(const char *fmt, ...);
    00084 /* print error message and terminate program execution */
    00085
    00086 #define insist(expr) \
    00087 ((void)((expr) || (_insist(#expr, __FILE__, __LINE__), 1)))
    00088
    00089 extern void _insist(const char *expr, const char *file, int line);
    00090 /* check for logical condition */
    00091
    00092 extern double watch(void);
    00093 /* take reading of stop-watch */
    00094
    00095 /* some processors need data to be properly aligned; the align_boundary
    00096    macro defines the boundary which should fit for all data types; the
    00097    align_datasize macro allows enlarging size of data item in order the
    00098    immediately following data of any type should be properly aligned */
    00099
    00100 #define align_boundary sizeof(double)
    00101
    00102 #define align_datasize(size) \
    00103 ((((size) + (align_boundary - 1)) / align_boundary) * align_boundary)
    00104
    00105 struct MEM
    00106 {     /* memory block descriptor */
    00107       int size;
    00108       /* size of block (in bytes, including descriptor) */
    00109       int flag;
    00110       /* descriptor flag */
    00111       MEM *prev;
    00112       /* pointer to descriptor of the previous block */
    00113       MEM *next;
    00114       /* pointer to descriptor of the next block */
    00115       /* actual data start here (there may be a "hole" between the next
    00116          field and actual data because of data alignment) */
    00117 };
    00118
    00119 extern void *umalloc(int size);
    00120 /* allocate memory block */
    00121
    00122 extern void *ucalloc(int nmemb, int size);
    00123 /* allocate memory block */
    00124
    00125 extern void ufree(void *ptr);
    00126 /* free memory block */
    00127
    00128 typedef struct POOL POOL;
    00129
    00130 struct POOL
    00131 {     /* memory pool (a set of atoms) */
    00132       int size;
    00133       /* size of each atom in bytes (1 <= size <= 256); if size = 0,
    00134          different atoms may have different sizes */
    00135       void *avail;
    00136       /* pointer to the linked list of free atoms */
    00137       void *link;
    00138       /* pointer to the linked list of allocated blocks (it points to
    00139          the last recently allocated block) */
    00140       int used;
    00141       /* number of bytes used in the last allocated block */
    00142       void *stock;
    00143       /* pointer to the linked list of free blocks */
    00144       int count;
    00145       /* total number of allocated atoms */
    00146 };
    00147
    00148 extern POOL *create_pool(int size);
    00149 /* create memory pool */
    00150
    00151 extern void *get_atom(POOL *pool);
    00152 /* allocate atom of fixed size */
    00153
    00154 extern void free_atom(POOL *pool, void *ptr);
    00155 /* free an atom */
    00156
    00157 extern void *get_atomv(POOL *pool, int size);
    00158 /* allocate atom of variable size */
    00159
    00160 extern void clear_pool(POOL *pool);
    00161 /* free all atoms */
    00162
    00163 extern void delete_pool(POOL *pool);
    00164 /* delete memory pool */
    00165
    00166 #endif
    00167
    00168 /* eof */