2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Build checksum for a library.
8 #include <exec/execbase.h>
9 #include <exec/alerts.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
17 AROS_LH1(void, SumLibrary
,
20 AROS_LHA(struct Library
*, library
,A1
),
23 struct ExecBase
*, SysBase
, 71, Exec
)
26 Builds the checksum over a given library's jumptable and either puts
27 it into the library->lib_Sum field (if the library is marked as changed)
28 or compares it with this field and Alert()s at mismatch.
31 library - Pointer to library structure.
42 AddLibrary(), RemLibrary(), MakeLibrary(), MakeFunctions(), InitStruct()
46 ******************************************************************************/
53 /* Arbitrate for library base */
57 If the library checksumming is already in progress or if the
58 checksum is unused skip this part
60 if(library
->lib_Flags
&LIBF_SUMUSED
&&!(library
->lib_Flags
&LIBF_SUMMING
))
62 /* As long as the library is marked as changed */
67 /* Memorize library flags */
68 oldflags
=library
->lib_Flags
;
70 /* Tell other tasks: Summing in progress */
71 library
->lib_Flags
|=LIBF_SUMMING
;
72 library
->lib_Flags
&=~LIBF_CHANGED
;
74 /* As long as the summing goes multitasking may be permitted. */
77 /* Build checksum. Note: library bases are LONG aligned */
79 /* Get start of jumptable */
80 lp
=(ULONG
*)((UBYTE
*)library
+library
->lib_NegSize
);
82 while(lp
<(ULONG
*)library
)
85 /* Summing complete. Arbitrate again. */
88 /* Remove summing flag */
89 library
->lib_Flags
&=~LIBF_SUMMING
;
91 /* Do it again if the library changed while summing. */
92 }while(library
->lib_Flags
&LIBF_CHANGED
);
95 Alert() if the library wasn't marked as changed and if the
98 if(!(oldflags
&LIBF_CHANGED
)&&library
->lib_Sum
!=sum
)
99 Alert(AT_DeadEnd
|AN_LibChkSum
);
101 /* Set new checksum */
102 library
->lib_Sum
=sum
;