Logo ROOT  
Reference Guide
keys.c
Go to the documentation of this file.
1/* @(#)root/clib:$Id$ */
2/* Author: */
3
4/* Access for application keys in mmap'd malloc managed region.
5 Copyright 1992 Free Software Foundation, Inc.
6
7 Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com
8
9This file is part of the GNU C Library.
10
11The GNU C Library is free software; you can redistribute it and/or
12modify it under the terms of the GNU Library General Public License as
13published by the Free Software Foundation; either version 2 of the
14License, or (at your option) any later version.
15
16The GNU C Library is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19Library General Public License for more details.
20
21You should have received a copy of the GNU Library General Public
22License along with the GNU C Library; see the file COPYING.LIB. If
23not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24Boston, MA 02111-1307, USA. */
25
26/* This module provides access to some keys that the application can use to
27 provide persistent access to locations in the mapped memory section.
28 The intent is that these keys are to be used sparingly as sort of
29 persistent global variables which the application can use to reinitialize
30 access to data in the mapped region.
31
32 For the moment, these keys are simply stored in the malloc descriptor
33 itself, in an array of fixed length. This should be fixed so that there
34 can be an unlimited number of keys, possibly using a multilevel access
35 scheme of some sort. */
36
37#ifndef WIN32
38# include <sys/types.h>
39# include <sys/mman.h>
40#endif /* WIN32 */
41
42#include "mmprivate.h"
43
44int mmalloc_setkey(PTR md, int keynum, PTR key)
45{
46 struct mdesc *mdp = (struct mdesc *) md;
47 int result = 0;
48
49 if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS))
50 {
51 mdp -> keys [keynum] = key;
52#ifndef WIN32
53#ifndef VMS
54#ifndef R__LYNXOS
55#ifndef R__HURD
56 /* We should really test for _POSIX_SYNCRONIZED_IO here */
57 msync((void *)mdp, sizeof(struct mdesc), MS_ASYNC);
58#endif
59#endif
60#endif
61#endif
62 result++;
63 }
64 return (result);
65}
66
67PTR mmalloc_getkey(PTR md, int keynum)
68{
69 struct mdesc *mdp = (struct mdesc *) md;
70 PTR keyval = NULL;
71
72 if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS))
73 {
74 keyval = (PTR)((long)mdp -> keys [keynum] + mdp->offset);
75 }
76 return (keyval);
77}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
#define NULL
Definition ZInflate.c:15
int mmalloc_setkey(PTR md, int keynum, PTR key)
Definition keys.c:44
PTR mmalloc_getkey(PTR md, int keynum)
Definition keys.c:67
#define PTR
Definition mmalloc.h:29
#define MMALLOC_KEYS
Definition mmprivate.h:71
PTR keys[MMALLOC_KEYS]
Definition mmprivate.h:315
long offset
Definition mmprivate.h:299