win-pvdrivers

view liblfds.6/src/single_dir_for_windows_kernel/slist_delete.c @ 1025:aa2e51f67f7c

Fix hibernate under Win8. Change debugprints.
author James Harper <james.harper@bendigoit.com.au>
date Tue Feb 19 15:14:53 2013 +1100 (2013-02-19)
parents 6300617040e0
children
line source
1 #include "slist_internal.h"
7 /****************************************************************************/
8 void slist_delete( struct slist_state *ss )
9 {
10 slist_delete_all_elements( ss );
12 abstraction_aligned_free( ss );
14 return;
15 }
21 /****************************************************************************/
22 void slist_delete_element( struct slist_state *ss, struct slist_element *se )
23 {
24 ALIGN(ALIGN_DOUBLE_POINTER) void
25 *volatile user_data_and_flags[2],
26 *volatile new_user_data_and_flags[2];
28 unsigned char
29 cas_rv = 0;
31 assert( ss != NULL );
32 assert( se != NULL );
34 user_data_and_flags[SLIST_USER_DATA] = se->user_data_and_flags[SLIST_USER_DATA];
35 user_data_and_flags[SLIST_FLAGS] = se->user_data_and_flags[SLIST_FLAGS];
37 do
38 {
39 new_user_data_and_flags[SLIST_USER_DATA] = user_data_and_flags[SLIST_USER_DATA];
40 new_user_data_and_flags[SLIST_FLAGS] = (void *) ((atom_t) user_data_and_flags[SLIST_FLAGS] | SLIST_FLAG_DELETED);
41 }
42 while( !((atom_t) user_data_and_flags[SLIST_FLAGS] & SLIST_FLAG_DELETED) and 0 == (cas_rv = abstraction_dcas((volatile atom_t *) se->user_data_and_flags, (atom_t *) new_user_data_and_flags, (atom_t *) user_data_and_flags)) );
44 if( cas_rv == 1 )
45 if( ss->user_data_delete_function != NULL )
46 ss->user_data_delete_function( (void *) user_data_and_flags[SLIST_USER_DATA], ss->user_state );
48 return;
49 }
55 /****************************************************************************/
56 void slist_delete_all_elements( struct slist_state *ss )
57 {
58 struct slist_element
59 *volatile se,
60 *volatile se_temp;
62 se = ss->head;
64 while( se != NULL )
65 {
66 // TRD : if a non-deleted element and there is a delete function, call the delete function
67 if( ss->user_data_delete_function != NULL )
68 ss->user_data_delete_function( (void *) se->user_data_and_flags[SLIST_USER_DATA], ss->user_state );
70 se_temp = se;
71 se = se->next;
72 abstraction_aligned_free( (void *) se_temp );
73 }
75 slist_internal_init_slist( ss, ss->user_data_delete_function, ss->user_state );
77 return;
78 }