tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / graphics / gfxassociate.c
blobb73bc5ced6e15ea39d5c79e2ea288a18250ec35f
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <exec/types.h>
10 #include <exec/memory.h>
11 #include <graphics/gfxbase.h>
12 #include <graphics/monitor.h>
13 #include <graphics/view.h>
14 #include <graphics/gfxnodes.h>
15 #include <proto/exec.h>
16 #include <proto/graphics.h>
17 #include "graphics_intern.h"
19 /*****************************************************************************
21 NAME */
23 AROS_LH2( void , GfxAssociate,
25 /* SYNOPSIS */
27 AROS_LHA( void *, pointer, A0),
28 AROS_LHA( struct ExtendedNode *, node, A1),
30 /* LOCATION */
32 struct GfxBase *, GfxBase, 112, Graphics)
34 /* FUNCTION
35 Associate a special graphics extended data structure with another
36 structure via the other structure's pointer. Later, when you call
37 GfxLookUp() with the other structure's pointer you may receive
38 the pointer to this special graphics extended data structure, if it
39 is available
41 INPUTS
42 pointer = a pointer to a data structure
43 node = an ExtendedNode structure to associate with the pointer
45 RESULT
46 an association is created between the pointer and the node such
47 that given the pointer the node can be retrieved via GfxLookUp().
49 NOTES
50 Never associate one special graphics extended data structure to
51 several pointers. Only one pointer is allowed!
53 EXAMPLE
55 BUGS
57 SEE ALSO
58 graphics/gfxnodes.h, GfxFree(), GfxNew(), GfxLookUp()
60 INTERNALS
62 HISTORY
64 ******************************************************************************/
66 AROS_LIBFUNC_INIT
68 IPTR *Hash = GfxBase -> hash_table;
69 ULONG Index = CalcHashIndex((IPTR)pointer, GFXASSOCIATE_HASHSIZE);
71 /* Whatever structure we get as node we put the pointer in the space
72 following immediately after the ExtendedNode structure.
73 ViewExtra -> View is equal to
74 ViewPortExtra -> ViewPort
77 ((struct ViewExtra *)node) -> View = pointer;
78 ObtainSemaphore(GfxBase->HashTableSemaphore);
80 /* Insert the structure into a hash_list which is to be found
81 in the gfxlibrary */
82 if (0 != Hash[Index])
83 ((struct ExtendedNode *)Hash[Index]) -> xln_Pred = (struct Node *)node;
84 node -> xln_Succ = (struct Node *)Hash[Index];
85 node -> xln_Pred = (struct Node *)&Hash[Index];
86 Hash[Index] = (IPTR)node;
88 ReleaseSemaphore(GfxBase->HashTableSemaphore);
90 AROS_LIBFUNC_EXIT
91 } /* GfxAssociate */