reactos/reactos/include/wine/list.h

166 lines
4.6 KiB
C
Raw Normal View History

Sync to Wine-20050111: Michael Stefaniuc <mstefani@redhat.de> - Do not check for non NULL pointer before HeapFree'ing it. It's redundant. Eric Pouech <pouech-eric@wanadoo.fr> - Fixed some errors in function prototypes. - ReadFile and WriteFile must be passed a parameter for the number of handled bytes when no overlapped operation is done. - Removed excessive statement (break after return or goto, not useful break, not needed vars...) Robert Shearman <rob@codeweavers.com> - Remove unnecessary WNDPROC casts. - Document how thread-safety is ensured for each member of the stub_manager and ifstub structs. - Make stub_manager ref counted to ensure it doesn't get freed whilst it is still being used. - ifstubs are now freed only when the controlling stub_manager is freed. - Rename stub_manager_ref/unref to stub_manager_ext_addref/release respectively and make then take an unsigned long to prevent malicious callers from passing in a negative value and corrupting the ref count. - Rename iid in wine_marshal_id to ipid and use IPIDs instead of IIDs in the stub manager. - The channel buffer can be NULL if the proxy is disconnected, so check for this before releasing it. - Make the ClassFactory proxy support aggregation. - Document how thread-safety is ensured for each member of the stub_manager and ifstub structs. - Make stub_manager ref counted to ensure it doesn't get freed whilst it is still being used. - ifstubs are now freed only when the controlling stub_manager is freed. - Rename stub_manager_ref/unref to stub_manager_ext_addref/release respectively and make then take an unsigned long to prevent malicious callers from passing in a negative value and corrupting the ref count. - The current architecture cannot handle pipes changing address, so use a static array. Fixes memory corruption that sometimes occurs when using multiple pipes. - Fix race on apartment creation. - Display errors in decimal to make searching for the meaning in winerror.h easier. - Move named pipe macros into rpc.c. - Remove unneeded function. - Implement COM local servers using table marshaling to avoid doing the marshaling in a child thread where COM has not been initialized. - Remove unneeded includes and the unused COMPOBJ_hInstance32 variable. - Make the wine_marshal_id structure more like the DCOM OBJREF structure, by replacing the process id field by apartment id (OXID), changing the users of the process id field to use the new field and renaming the objectid field to oid. - Fix StdMarshalImpl_UnmarshalInterface to invalidate and release its stub when doing a same apartment marshal. - Fixed incorrect unsigned test. - Add tracing for proxy ref count functions. - Release the channel on proxy destruction. - Implement proxy manager. - Add documentation to several functions. - Coding style changes according to the style Mike and I have agreed upon for COM related files. - Use OBJREF on the wire for generic marshaling functions. - Add some function declarations to objbase.h. - Add stubs for server ref counting. - Implement HRESULT marshaling. - Make struct oletls ref counted so that it is only detached from the apartment on the final CoUninitialize. - Decrease the size of the crit sec on destroying an apartment - it is only needed for touching the apartment list. - Small cleanups. Mike Hearn <mh@codeweavers.com> - Implement the COM stub manager, refactor the current stub code. - Begin implementing interface stubs. - Make apartment access thread-safe by introducing refcounting and wider usage of the apartment lock. - Rework OLE TLS management to eliminate uninitialised apartments and parent chaining. - Comment out an assert, as we don't yet implement IRemUnknown. - Propagate apartments through the intermediate threads, make listener thread apartment scoped. - Rename the STUBMGR thread to more accurately reflect its purpose. - Add a DCOM todo list. Mike McCormack <mike@codeweavers.com> - Test and fix a few problems with OLE storage streams. - Allow COM to start services containing COM servers. - Tests and fixes for StgOpenStorage. - Test and fix StgCreateDocFile grfModes. Paul Vriens <Paul.Vriens@xs4all.nl> - use Interlocked* functions in AddRef and Release. - store the result of the Interlocked functions and use only this. Francois Gouget <fgouget@free.fr> - Assorted spelling fixes. Alexandre Julliard <julliard@winehq.org> - Janitorial: C booleans must not be compared against TRUE. Bill Medland <billmedland@mercuryspeed.com> - Corrected testing for multithreaded (based upon observations by Paul Vriens, Christian Costa and Robert Shearman). - Added TRACE for investigating OXID errors. svn path=/trunk/; revision=12952
2005-01-12 10:23:25 +00:00
/*
* Linked lists support
*
* Copyright (C) 2002 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_SERVER_LIST_H
#define __WINE_SERVER_LIST_H
struct list
{
struct list *next;
struct list *prev;
};
/* Define a list like so:
*
* struct gadget
* {
* struct list entry; <-- doesn't have to be the first item in the struct
* int a, b;
* };
*
* static struct list global_gadgets = LIST_INIT( global_gadgets );
*
* or
*
* struct some_global_thing
* {
* struct list gadgets;
* };
*
* list_init( &some_global_thing->gadgets );
*
* Manipulate it like this:
*
* list_add_head( &global_gadgets, &new_gadget->entry );
* list_remove( &new_gadget->entry );
* list_add_after( &some_random_gadget->entry, &new_gadget->entry );
*
* And to iterate over it:
*
* struct list *cursor;
* LIST_FOR_EACH( cursor, &global_gadgets )
* {
* struct gadget *gadget = LIST_ENTRY( cursor, struct gadget, entry );
* }
*
*/
/* add an element after the specified one */
inline static void list_add_after( struct list *elem, struct list *to_add )
{
to_add->next = elem->next;
to_add->prev = elem;
elem->next->prev = to_add;
elem->next = to_add;
}
/* add an element before the specified one */
inline static void list_add_before( struct list *elem, struct list *to_add )
{
to_add->next = elem;
to_add->prev = elem->prev;
elem->prev->next = to_add;
elem->prev = to_add;
}
/* add element at the head of the list */
inline static void list_add_head( struct list *list, struct list *elem )
{
list_add_after( list, elem );
}
/* add element at the tail of the list */
inline static void list_add_tail( struct list *list, struct list *elem )
{
list_add_before( list, elem );
}
/* remove an element from its list */
inline static void list_remove( struct list *elem )
{
elem->next->prev = elem->prev;
elem->prev->next = elem->next;
}
/* get the next element */
inline static struct list *list_next( struct list *list, struct list *elem )
{
struct list *ret = elem->next;
if (elem->next == list) ret = NULL;
return ret;
}
/* get the previous element */
inline static struct list *list_prev( struct list *list, struct list *elem )
{
struct list *ret = elem->prev;
if (elem->prev == list) ret = NULL;
return ret;
}
/* get the first element */
inline static struct list *list_head( struct list *list )
{
return list_next( list, list );
}
/* get the last element */
inline static struct list *list_tail( struct list *list )
{
return list_prev( list, list );
}
/* check if a list is empty */
inline static int list_empty( struct list *list )
{
return list->next == list;
}
/* initialize a list */
inline static void list_init( struct list *list )
{
list->next = list->prev = list;
}
/* iterate through the list */
#define LIST_FOR_EACH(cursor,list) \
for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next)
Sync to Wine-20050211 Robert Shearman <rob@codeweavers.com> - Add documentation for most Co* functions. - Move several functions into different files to group them with similar functions. - Implement CoDisconnectObject. - Change CoLockObjectExternal so that it does the correct action now and eliminate a fair few lines of now redundant code. - Rename OLE32_Dll{Register,Unregister}Server to Dll{Register,Unregister}Server. - Move OLE automation interface registration to oleaut32. - Add IRemUnknown to list of interfaces to register. - Make proxy manager use IMultiQI instead of IInternalUnknown as tests show that IInternalUnknown isn't exposed. - Implement IMultiQI on top of IRemUnknown calls. - Silence some fixmes that occur during tests and don't give us any useful information. - Fix typo in class factory proxy that caused us to use the wrong offset into the CFProxy structure, causing us to not call the outer_unknown properly. - Use InterlockedIncrement for the ipid counter instead of a critical section (suggested by Mike Hearn). - Remove a line added by a bad merge. - Implement RemUnkStub_Disconnect. - Remove all of the RPC disconnect code. - Implement IRemUnknown. - Use IRemUnknown for life-cycle management instead of the current hacks. - Generate machine-local IPIDs. - Make pipes be uniquely identified only by their IPID. - Implement table marshaling. - The apartment reference should be held while the stub manager reference is held. - Fix same apartment-unmarshal detection. - Proxies/stubs for IRemUnknown methods, based on code written by Ove Ksven. - Initialize ppv pointer in ClientIdentity_QueryInterface to NULL as apps depend on this. - Don't release IRpcProxyBuffer on ifproxy destruction - the caller will do this for us. - Make find_proxy_manager add a reference to the proxy manager and make proxy_manager_construct return an object with a valid ref-count. - Remove stray not operator to fix a memory leak / crash in proxy_manager_destroy. - More debug messages, especially on errors. - Fix ref-count leak in the Class Factory proxy. - Add a test case for IClassFactory_CreateInstance. - Split up apartment creation so that the long code paths that don't need locking no longer have locking. - Add special cases for the threads that join apartments but can't increase the refcount of the apartment. - Free TLS storage on thread destruction (including releasing the apartment the thread is in, if any, and so making another test pass). - More tests. - Change return code of CoGetPSClsid to match test result. - Do a slight hack to make IRemUnknown proxies be added after the proxy that uses them to stop them being used after they are destroyed. - Fix multiple local server connections. - The apartment reference should be held while the stub manager reference is held. - Fix same apartment-unmarshal detection. - Don't use the pipe caching code because it doesn't work correctly at the moment. - Always write disconnect reply packet, even in failure cases. - Move object-to-stub-manager mapping rule to register_ifstub. - Pass the original IID to IMarshal_UnmarshalInterface and query for the requested interface. - Unmarshaling IID_NULL means use the IID the interface was originally marshaled with. - Add code for destroying the thread-local storage data, but don't use it yet. - Don't release apartment on changing modes because we didn't add a reference anywhere. - Quieten the RPC_E_DISCONNECTED error message as it is an expected return code. - Treat IID_NULL the same as IID_IUnknown. - Make tests compile on Win95 again. - Fix copy+paste error where the test failure should be from the CoUnmarshalInterface function. - Give IUnknown its own ifstub to fix ref-counting and ipid storage issues. - Add a new flag SORFP_NOLIFETIMEMGMT to tell the proxy manager not to call any IRemUnknown functions. - Move the low-level unmarshaling code into a new function, unmarshal_object, so that it can be easily reused for unmarshaling IRemUnknown. - Consolidate more stub creation details into register_ifstub. - Replace the current wine_marshal_id structure with STDOBJREF for the on-the-wire format. - Initialize clsid member to the marshaler clsid to fix custom marshaling. - Make proxy shutdown test succeed by releasing the channel on disconnect. - Remove wine_marshal_data: it is unneeded and there is no equivalent in STDOBJREF. - Remove obsolete structs, rearrange things to group the structs together and to group similar functions. - Document thread-safety of members of structs. - Document CoSetState & CoGetState. - Rewrite them to only retrieve TLS info once. - Remove trailing whitespace in COM_CurrentInfo. - Release the client security objects when no longer needed (reported by Mike McCormack). - Implement CoSetProxyBlanket, CoQueryProxyBlanket and CoCopyProxy. - Update todo list. - Destroy stubs on apartment shutdown. - Make MTA dynamically allocated so that proxies and other resources are freed at the proper time. - Changed/removed some incorrect comments regarding apartments. Mike Hearn <mh@codeweavers.com> - Various formatting/style changes. - Force context switch on chanbuf disconnect to avoid a race in the test suite. Mike Hearn <mh@codeweavers.com> Robert Shearman <rob@codeweavers.com> - Rework RPC dispatch layer to be simpler and not get confused by server/client duality. - Make threads shut down at the right time and not access freed memory after apartment destruction. - Rename stub_dispatch_thread to client_dispatch_thread. - Add some more tracing - Check return value of WaitNamedPipe. - Change named pipe timeouts to 0.5s, which should be enough for even the slowest machines. Christian Costa <titan.costa@wanadoo.fr> - CoInitialize(Ex) should return S_FALSE when COM is already initialized for the current thread. svn path=/trunk/; revision=13532
2005-02-13 20:52:16 +00:00
/* iterate through the list, with safety against removal */
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list) \
for ((cursor) = (list)->next, (cursor2) = (cursor)->next; \
(cursor) != (list); \
(cursor) = (cursor2), (cursor2) = (cursor)->next)
/* iterate through the list using a list entry */
#define LIST_FOR_EACH_ENTRY(elem, list, type, field) \
for ((elem) = LIST_ENTRY((list)->next, type, field); \
&(elem)->field != (list); \
(elem) = LIST_ENTRY((elem)->field.next, type, field))
Sync to Wine-20050111: Michael Stefaniuc <mstefani@redhat.de> - Do not check for non NULL pointer before HeapFree'ing it. It's redundant. Eric Pouech <pouech-eric@wanadoo.fr> - Fixed some errors in function prototypes. - ReadFile and WriteFile must be passed a parameter for the number of handled bytes when no overlapped operation is done. - Removed excessive statement (break after return or goto, not useful break, not needed vars...) Robert Shearman <rob@codeweavers.com> - Remove unnecessary WNDPROC casts. - Document how thread-safety is ensured for each member of the stub_manager and ifstub structs. - Make stub_manager ref counted to ensure it doesn't get freed whilst it is still being used. - ifstubs are now freed only when the controlling stub_manager is freed. - Rename stub_manager_ref/unref to stub_manager_ext_addref/release respectively and make then take an unsigned long to prevent malicious callers from passing in a negative value and corrupting the ref count. - Rename iid in wine_marshal_id to ipid and use IPIDs instead of IIDs in the stub manager. - The channel buffer can be NULL if the proxy is disconnected, so check for this before releasing it. - Make the ClassFactory proxy support aggregation. - Document how thread-safety is ensured for each member of the stub_manager and ifstub structs. - Make stub_manager ref counted to ensure it doesn't get freed whilst it is still being used. - ifstubs are now freed only when the controlling stub_manager is freed. - Rename stub_manager_ref/unref to stub_manager_ext_addref/release respectively and make then take an unsigned long to prevent malicious callers from passing in a negative value and corrupting the ref count. - The current architecture cannot handle pipes changing address, so use a static array. Fixes memory corruption that sometimes occurs when using multiple pipes. - Fix race on apartment creation. - Display errors in decimal to make searching for the meaning in winerror.h easier. - Move named pipe macros into rpc.c. - Remove unneeded function. - Implement COM local servers using table marshaling to avoid doing the marshaling in a child thread where COM has not been initialized. - Remove unneeded includes and the unused COMPOBJ_hInstance32 variable. - Make the wine_marshal_id structure more like the DCOM OBJREF structure, by replacing the process id field by apartment id (OXID), changing the users of the process id field to use the new field and renaming the objectid field to oid. - Fix StdMarshalImpl_UnmarshalInterface to invalidate and release its stub when doing a same apartment marshal. - Fixed incorrect unsigned test. - Add tracing for proxy ref count functions. - Release the channel on proxy destruction. - Implement proxy manager. - Add documentation to several functions. - Coding style changes according to the style Mike and I have agreed upon for COM related files. - Use OBJREF on the wire for generic marshaling functions. - Add some function declarations to objbase.h. - Add stubs for server ref counting. - Implement HRESULT marshaling. - Make struct oletls ref counted so that it is only detached from the apartment on the final CoUninitialize. - Decrease the size of the crit sec on destroying an apartment - it is only needed for touching the apartment list. - Small cleanups. Mike Hearn <mh@codeweavers.com> - Implement the COM stub manager, refactor the current stub code. - Begin implementing interface stubs. - Make apartment access thread-safe by introducing refcounting and wider usage of the apartment lock. - Rework OLE TLS management to eliminate uninitialised apartments and parent chaining. - Comment out an assert, as we don't yet implement IRemUnknown. - Propagate apartments through the intermediate threads, make listener thread apartment scoped. - Rename the STUBMGR thread to more accurately reflect its purpose. - Add a DCOM todo list. Mike McCormack <mike@codeweavers.com> - Test and fix a few problems with OLE storage streams. - Allow COM to start services containing COM servers. - Tests and fixes for StgOpenStorage. - Test and fix StgCreateDocFile grfModes. Paul Vriens <Paul.Vriens@xs4all.nl> - use Interlocked* functions in AddRef and Release. - store the result of the Interlocked functions and use only this. Francois Gouget <fgouget@free.fr> - Assorted spelling fixes. Alexandre Julliard <julliard@winehq.org> - Janitorial: C booleans must not be compared against TRUE. Bill Medland <billmedland@mercuryspeed.com> - Corrected testing for multithreaded (based upon observations by Paul Vriens, Christian Costa and Robert Shearman). - Added TRACE for investigating OXID errors. svn path=/trunk/; revision=12952
2005-01-12 10:23:25 +00:00
/* macros for statically initialized lists */
#define LIST_INIT(list) { &(list), &(list) }
/* get pointer to object containing list element */
#define LIST_ENTRY(elem, type, field) \
((type *)((char *)(elem) - (unsigned int)(&((type *)0)->field)))
#endif /* __WINE_SERVER_LIST_H */