Commit 1bb94039 authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

ANSI C fixes.

parent 3f284324
......@@ -438,6 +438,7 @@ fi
dnl **** Check for functions ****
AC_FUNC_ALLOCA()
AC_CHECK_FUNCS(\
_lwp_create \
clone \
......
......@@ -11,6 +11,8 @@
* please read EDIT.TODO (and update it when you change things)
*/
#include "config.h"
#include <string.h>
#include "winnt.h"
#include "win.h"
......@@ -113,8 +115,9 @@ typedef struct
#define ORDER_UINT(x,y) do { if ((UINT)(y) < (UINT)(x)) SWAP_UINT32((x),(y)); } while(0)
#define DPRINTF_EDIT_NOTIFY(hwnd, str) \
({TRACE_(edit)("notification " str " sent to hwnd=%08x\n", \
(UINT)(hwnd));})
do {TRACE_(edit)("notification " str " sent to hwnd=%08x\n", \
(UINT)(hwnd));} while(0)
/* used for disabled or read-only edit control */
#define EDIT_SEND_CTLCOLORSTATIC(wnd,hdc) \
(SendMessageA((wnd)->parent->hwndSelf, WM_CTLCOLORSTATIC, \
......@@ -123,10 +126,10 @@ typedef struct
(SendMessageA((wnd)->parent->hwndSelf, WM_CTLCOLOREDIT, \
(WPARAM)(hdc), (LPARAM)(wnd)->hwndSelf))
#define EDIT_NOTIFY_PARENT(wnd, wNotifyCode, str) \
(DPRINTF_EDIT_NOTIFY((wnd)->parent->hwndSelf, str), \
do {DPRINTF_EDIT_NOTIFY((wnd)->parent->hwndSelf, str); \
SendMessageA((wnd)->parent->hwndSelf, WM_COMMAND, \
MAKEWPARAM((wnd)->wIDmenu, wNotifyCode), \
(LPARAM)(wnd)->hwndSelf))
MAKEWPARAM((wnd)->wIDmenu, wNotifyCode), \
(LPARAM)(wnd)->hwndSelf);} while(0)
#define DPRINTF_EDIT_MSG16(str) \
TRACE_(edit)(\
"16 bit : " str ": hwnd=%08x, wParam=%08x, lParam=%08x\n", \
......@@ -145,12 +148,12 @@ typedef struct
/*
* These functions have trivial implementations
* We still like to call them internally
* "static __inline__" makes them more like macro's
* "static inline" makes them more like macro's
*/
static __inline__ BOOL EDIT_EM_CanUndo(WND *wnd, EDITSTATE *es);
static __inline__ void EDIT_EM_EmptyUndoBuffer(WND *wnd, EDITSTATE *es);
static __inline__ void EDIT_WM_Clear(WND *wnd, EDITSTATE *es);
static __inline__ void EDIT_WM_Cut(WND *wnd, EDITSTATE *es);
static inline BOOL EDIT_EM_CanUndo(WND *wnd, EDITSTATE *es);
static inline void EDIT_EM_EmptyUndoBuffer(WND *wnd, EDITSTATE *es);
static inline void EDIT_WM_Clear(WND *wnd, EDITSTATE *es);
static inline void EDIT_WM_Cut(WND *wnd, EDITSTATE *es);
/*
* This is the only exported function
*/
......@@ -252,7 +255,7 @@ static LRESULT EDIT_WM_VScroll(WND *wnd, EDITSTATE *es, INT action, INT pos, HWN
* EM_CANUNDO
*
*/
static __inline__ BOOL EDIT_EM_CanUndo(WND *wnd, EDITSTATE *es)
static inline BOOL EDIT_EM_CanUndo(WND *wnd, EDITSTATE *es)
{
return (es->undo_insert_count || lstrlenA(es->undo_text));
}
......@@ -263,7 +266,7 @@ static __inline__ BOOL EDIT_EM_CanUndo(WND *wnd, EDITSTATE *es)
* EM_EMPTYUNDOBUFFER
*
*/
static __inline__ void EDIT_EM_EmptyUndoBuffer(WND *wnd, EDITSTATE *es)
static inline void EDIT_EM_EmptyUndoBuffer(WND *wnd, EDITSTATE *es)
{
es->undo_insert_count = 0;
*es->undo_text = '\0';
......@@ -275,7 +278,7 @@ static __inline__ void EDIT_EM_EmptyUndoBuffer(WND *wnd, EDITSTATE *es)
* WM_CLEAR
*
*/
static __inline__ void EDIT_WM_Clear(WND *wnd, EDITSTATE *es)
static inline void EDIT_WM_Clear(WND *wnd, EDITSTATE *es)
{
EDIT_EM_ReplaceSel(wnd, es, TRUE, "");
}
......@@ -286,7 +289,7 @@ static __inline__ void EDIT_WM_Clear(WND *wnd, EDITSTATE *es)
* WM_CUT
*
*/
static __inline__ void EDIT_WM_Cut(WND *wnd, EDITSTATE *es)
static inline void EDIT_WM_Cut(WND *wnd, EDITSTATE *es)
{
EDIT_WM_Copy(wnd, es);
EDIT_WM_Clear(wnd, es);
......
......@@ -756,7 +756,7 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner,
BITMAP bm;
HBITMAP resBmp = 0;
// Check if there is a magic menu item associated with this item
/* Check if there is a magic menu item associated with this item */
if((LOWORD((int)lpitem->text))<12)
{
resBmp = MENU_LoadMagicItem((int)lpitem->text, (lpitem->fType & MF_HILITE),
......@@ -1149,8 +1149,10 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
HDC hdcMem = CreateCompatibleDC( hdc );
// Check if there is a magic menu item associated with this item
// and load the appropriate bitmap
/*
* Check if there is a magic menu item associated with this item
* and load the appropriate bitmap
*/
if((LOWORD((int)lpitem->text)) < 12)
{
resBmp = MENU_LoadMagicItem((int)lpitem->text, (lpitem->fState & MF_HILITE),
......
......@@ -6,12 +6,17 @@
* Copyright 1995 Morten Welinder
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include "winbase.h"
#include "class.h"
......
......@@ -2637,9 +2637,9 @@ BOOL X11DRV_GetTextExtentPoint( DC *dc, LPCSTR str, INT count,
TRACE(font, "x = %f y = %f\n", x, y);
x *= pfo->lpX11Trans->pixelsize / 1000.0;
y *= pfo->lpX11Trans->pixelsize / 1000.0;
size->cx = fabsf((x + dc->w.breakRem + count * dc->w.charExtra) *
size->cx = fabs((x + dc->w.breakRem + count * dc->w.charExtra) *
dc->wndExtX / dc->vportExtX);
size->cy = fabsf(y * dc->wndExtY / dc->vportExtY);
size->cy = fabs(y * dc->wndExtY / dc->vportExtY);
}
return TRUE;
}
......
......@@ -265,19 +265,19 @@ void WINAPI SNOOP16_Entry(CONTEXT *context) {
max = fun->nrofargs;
if (max>16) max=16;
for (i=max;i--;)
DPRINTF("%04x%s",*(WORD*)(PTR_SEG_OFF_TO_LIN(SS_reg(context),SP_reg(context))+8+sizeof(WORD)*i),i?",":"");
DPRINTF("%04x%s",*(WORD*)((char *) PTR_SEG_OFF_TO_LIN(SS_reg(context),SP_reg(context))+8+sizeof(WORD)*i),i?",":"");
if (max!=fun->nrofargs)
DPRINTF(" ...");
} else if (fun->nrofargs<0) {
DPRINTF("<unknown, check return>");
ret->args = HeapAlloc(SystemHeap,0,16*sizeof(WORD));
memcpy(ret->args,(LPBYTE)(PTR_SEG_OFF_TO_LIN(SS_reg(context),SP_reg(context))+8),sizeof(WORD)*16);
memcpy(ret->args,(LPBYTE)((char *) PTR_SEG_OFF_TO_LIN(SS_reg(context),SP_reg(context))+8),sizeof(WORD)*16);
}
DPRINTF(") ret=%04x:%04x\n",HIWORD(ret->origreturn),LOWORD(ret->origreturn));
}
void WINAPI SNOOP16_Return(CONTEXT *context) {
SNOOP16_RETURNENTRY *ret = (SNOOP16_RETURNENTRY*)(PTR_SEG_OFF_TO_LIN(CS_reg(context),IP_reg(context))-5);
SNOOP16_RETURNENTRY *ret = (SNOOP16_RETURNENTRY*)((char *) PTR_SEG_OFF_TO_LIN(CS_reg(context),IP_reg(context))-5);
/* We haven't found out the nrofargs yet. If we called a cdecl
* function it is too late anyway and we can just set '0' (which
......
/* include/config.h.in. Generated automatically from configure.in by autoheader. */
/* Define if using alloca.c. */
#undef C_ALLOCA
/* Define to empty if the keyword does not work. */
#undef const
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
#undef CRAY_STACKSEG_END
/* Define if you have alloca, as a function or macro. */
#undef HAVE_ALLOCA
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
#undef HAVE_ALLOCA_H
/* Define as __inline if that's what the C compiler calls it. */
#undef inline
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
#undef STACK_DIRECTION
/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
#undef STAT_MACROS_BROKEN
......
......@@ -501,12 +501,14 @@ struct create_pipe_reply
/* Allocate a console for the current process */
struct alloc_console_request
{
int dummy;
};
/* Free the console of the current process */
struct free_console_request
{
int dummy;
};
......@@ -597,6 +599,7 @@ struct read_console_input_request
};
struct read_console_input_reply
{
int dummy;
/* INPUT_RECORD records[0]; */ /* input records */
};
......
......@@ -79,10 +79,10 @@ typedef void *VA_LIST16;
(thdb)->cur_stack += (size))
/* Push a DWORD on the 32-bit stack */
#define STACK32_PUSH(context,val) (*--((DWORD *)ESP_reg(context)) = (val))
#define STACK32_PUSH(context,val) (*--(*(DWORD **)&ESP_reg(context)) = (val))
/* Pop a DWORD from the 32-bit stack */
#define STACK32_POP(context) (*((DWORD *)ESP_reg(context))++)
#define STACK32_POP(context) (*(*(DWORD **)&ESP_reg(context))++)
/* Win32 register functions */
#define REGS_ENTRYPOINT(name) void WINAPI __regs_##name( CONTEXT *context )
......
......@@ -35,11 +35,10 @@
#include "bit_array.h"
#ifdef HAS_BITOPS
#define inline __inline__ /* So we can compile with -ansi */
#include <asm/bitops.h>
#else
static __inline__ int clear_bit(int bit, int *mem);
static __inline__ int set_bit(int bit, int *mem);
static inline int clear_bit(int bit, int *mem);
static inline int set_bit(int bit, int *mem);
#endif /* HAS_BITOPS */
......@@ -81,7 +80,7 @@ static void initialize_arrays()
** Find first zero bit in the integer.
** Assume there is at least one zero.
*/
static __inline__ int find_zbit_in_integer(unsigned int integer)
static inline int find_zbit_in_integer(unsigned int integer)
{
int i;
......@@ -98,7 +97,7 @@ static __inline__ int find_zbit_in_integer(unsigned int integer)
}
/* return -1 on failure */
static __inline__ int find_first_zero_bit(unsigned *array, int bits)
static inline int find_first_zero_bit(unsigned *array, int bits)
{
unsigned int integer;
int i;
......@@ -120,7 +119,7 @@ static __inline__ int find_first_zero_bit(unsigned *array, int bits)
return -1;
}
static __inline__ int test_bit(int pos, unsigned *array)
static inline int test_bit(int pos, unsigned *array)
{
unsigned int integer;
int bit = BIT_IN_INT(pos);
......@@ -139,7 +138,7 @@ static __inline__ int test_bit(int pos, unsigned *array)
/* inputs: bit number and memory address (32 bit) */
/* output: Value of the bit before modification */
static __inline__ int clear_bit(int bit, int *mem)
static inline int clear_bit(int bit, int *mem)
{
int ret;
......@@ -151,7 +150,7 @@ static __inline__ int clear_bit(int bit, int *mem)
return (ret);
}
static __inline__ int set_bit(int bit, int *mem)
static inline int set_bit(int bit, int *mem)
{
int ret;
__asm__("xor %1,%1\n"
......
......@@ -382,7 +382,7 @@ INT WINAPI wvsnprintfA( LPSTR buffer, UINT maxlen, LPCSTR spec,
LPSTR p = buffer;
UINT i, len;
CHAR number[20];
WPRINTF_DATA argData = (WPRINTF_DATA)0;
WPRINTF_DATA argData;
while (*spec && (maxlen > 1))
{
......
......@@ -23,7 +23,11 @@ DECLARE_DEBUG_CHANNEL(io)
(IS_V86(context) ? FALSE : IS_SELECTOR_32BIT(seg))
#define STACK_sig(context) \
(IS_SEL_32(context,SS_sig(context)) ? ESP_sig(context) : SP_sig(context))
(IS_SEL_32(context,SS_sig(context)) ? ESP_sig(context) : (DWORD)SP_sig(context))
#define ADD_STACK_sig(context,offset) \
do { if (IS_SEL_32(context,SS_sig(context))) ESP_sig(context) += (offset); \
else SP_sig(context) += (offset); } while(0)
#define MAKE_PTR(seg,off) \
(IS_SELECTOR_SYSTEM(seg) ? (void *)(off) : PTR_SEG_OFF_TO_LIN(seg,off))
......@@ -408,7 +412,7 @@ BOOL INSTR_EmulateInstruction( SIGCONTEXT *context )
case 0x17: SS_sig(context) = seg; break;
case 0x1f: DS_sig(context) = seg; break;
}
STACK_sig(context) += long_op ? 4 : 2;
ADD_STACK_sig(context, long_op ? 4 : 2);
EIP_sig(context) += prefixlen + 1;
return TRUE;
}
......@@ -465,7 +469,7 @@ BOOL INSTR_EmulateInstruction( SIGCONTEXT *context )
if (INSTR_ReplaceSelector( context, &seg ))
{
FS_sig(context) = seg;
STACK_sig(context) += long_op ? 4 : 2;
ADD_STACK_sig(context, long_op ? 4 : 2);
EIP_sig(context) += prefixlen + 2;
return TRUE;
}
......@@ -480,7 +484,7 @@ BOOL INSTR_EmulateInstruction( SIGCONTEXT *context )
if (INSTR_ReplaceSelector( context, &seg ))
{
GS_sig(context) = seg;
STACK_sig(context) += long_op ? 4 : 2;
ADD_STACK_sig(context, long_op ? 4 : 2);
EIP_sig(context) += prefixlen + 2;
return TRUE;
}
......@@ -667,7 +671,7 @@ BOOL INSTR_EmulateInstruction( SIGCONTEXT *context )
*(--stack) = FL_sig(context);
*(--stack) = CS_sig(context);
*(--stack) = IP_sig(context) + prefixlen + 2;
STACK_sig(context) -= 3 * sizeof(WORD);
ADD_STACK_sig(context, -3 * sizeof(WORD));
/* Jump to the interrupt handler */
CS_sig(context) = HIWORD(addr);
EIP_sig(context) = LOWORD(addr);
......@@ -681,7 +685,7 @@ BOOL INSTR_EmulateInstruction( SIGCONTEXT *context )
EIP_sig(context) = *stack++;
CS_sig(context) = *stack++;
EFL_sig(context) = *stack;
STACK_sig(context) += 3*sizeof(DWORD); /* Pop the return address and flags */
ADD_STACK_sig(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
}
else
{
......@@ -689,7 +693,7 @@ BOOL INSTR_EmulateInstruction( SIGCONTEXT *context )
EIP_sig(context) = *stack++;
CS_sig(context) = *stack++;
FL_sig(context) = *stack;
STACK_sig(context) += 3*sizeof(WORD); /* Pop the return address and flags */
ADD_STACK_sig(context, 3*sizeof(WORD)); /* Pop the return address and flags */
}
return TRUE;
......@@ -803,7 +807,7 @@ BOOL INSTR_EmulateInstruction( SIGCONTEXT *context )
WORD *stack = (WORD *)STACK_PTR( context );
*--stack = CS_sig(context);
*--stack = EIP_sig(context);
STACK_sig(context) -= 2*sizeof(WORD);
ADD_STACK_sig(context, -2*sizeof(WORD));
CS_sig(context) = SELECTOROF( gpHandler );
EIP_sig(context) = OFFSETOF( gpHandler );
......
......@@ -184,38 +184,38 @@ static void do_IO_port_init_read_or_write(char* temp, char rw)
}
}
static __inline__ BYTE inb( WORD port )
static inline BYTE inb( WORD port )
{
BYTE b;
__asm__ __volatile__( "inb %w1,%0" : "=a" (b) : "d" (port) );
return b;
}
static __inline__ WORD inw( WORD port )
static inline WORD inw( WORD port )
{
WORD w;
__asm__ __volatile__( "inw %w1,%0" : "=a" (w) : "d" (port) );
return w;
}
static __inline__ DWORD inl( WORD port )
static inline DWORD inl( WORD port )
{
DWORD dw;
__asm__ __volatile__( "inl %w1,%0" : "=a" (dw) : "d" (port) );
return dw;
}
static __inline__ void outb( BYTE value, WORD port )
static inline void outb( BYTE value, WORD port )
{
__asm__ __volatile__( "outb %b0,%w1" : : "a" (value), "d" (port) );
}
static __inline__ void outw( WORD value, WORD port )
static inline void outw( WORD value, WORD port )
{
__asm__ __volatile__( "outw %w0,%w1" : : "a" (value), "d" (port) );
}
static __inline__ void outl( DWORD value, WORD port )
static inline void outl( DWORD value, WORD port )
{
__asm__ __volatile__( "outl %0,%w1" : : "a" (value), "d" (port) );
}
......
......@@ -114,11 +114,11 @@ typedef struct DataCache DataCache;
* by this object.
*/
#define _ICOM_THIS_From_IDataObject(class,name) class* this = (class*)name;
#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((void*)name)-sizeof(void*));
#define _ICOM_THIS_From_IPersistStorage(class, name) class* this = (class*)(((void*)name)-2*sizeof(void*));
#define _ICOM_THIS_From_IViewObject2(class, name) class* this = (class*)(((void*)name)-3*sizeof(void*));
#define _ICOM_THIS_From_IOleCache2(class, name) class* this = (class*)(((void*)name)-4*sizeof(void*));
#define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((void*)name)-5*sizeof(void*));
#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
#define _ICOM_THIS_From_IPersistStorage(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
#define _ICOM_THIS_From_IViewObject2(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
#define _ICOM_THIS_From_IOleCache2(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*));
#define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*));
/*
* Prototypes for the methods of the DataCache class.
......
......@@ -107,9 +107,9 @@ typedef struct DefaultHandler DefaultHandler;
* by this object.
*/
#define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name;
#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((void*)name)-sizeof(void*));
#define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((void*)name)-2*sizeof(void*));
#define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((void*)name)-3*sizeof(void*));
#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
#define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
#define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
/*
* Prototypes for the methods of the DefaultHandler class.
......
......@@ -426,7 +426,7 @@ HRESULT WINAPI HGLOBALStreamImpl_Read(
*/
supportBuffer = GlobalLock(This->supportHandle);
memcpy(pv, supportBuffer+This->currentPosition.LowPart, bytesToReadFromBuffer);
memcpy(pv, (char *) supportBuffer+This->currentPosition.LowPart, bytesToReadFromBuffer);
/*
* Move the current position to the new position
......@@ -510,7 +510,7 @@ HRESULT WINAPI HGLOBALStreamImpl_Write(
*/
supportBuffer = GlobalLock(This->supportHandle);
memcpy(supportBuffer+This->currentPosition.LowPart, pv, cb);
memcpy((char *) supportBuffer+This->currentPosition.LowPart, pv, cb);
/*
* Move the current position to the new position
......
......@@ -380,7 +380,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl_ReadAt(
supportBuffer = GlobalLock(This->supportHandle);
memcpy(pv,
supportBuffer + ulOffset.LowPart,
(char *) supportBuffer + ulOffset.LowPart,
bytesToReadFromBuffer);
/*
......@@ -458,7 +458,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl_WriteAt(
*/
supportBuffer = GlobalLock(This->supportHandle);
memcpy(supportBuffer + ulOffset.LowPart, pv, cb);
memcpy((char *) supportBuffer + ulOffset.LowPart, pv, cb);
/*
* Return the number of bytes written.
......
......@@ -64,9 +64,9 @@ static void CLIENT_SendRequest_v( enum request req, int pass_fd,
{
THDB *thdb = THREAD_Current();
#ifndef HAVE_MSGHDR_ACCRIGHTS
struct cmsg_fd cmsg = { sizeof(cmsg), SOL_SOCKET, SCM_RIGHTS, pass_fd };
struct cmsg_fd cmsg;
#endif
struct msghdr msghdr = { NULL, 0, vec, veclen, };
struct msghdr msghdr;
struct header head;
int i, ret, len;
......@@ -80,16 +80,39 @@ static void CLIENT_SendRequest_v( enum request req, int pass_fd,
head.len = len;
head.seq = thdb->seq++;
msghdr.msg_name = NULL;
msghdr.msg_namelen = 0;
msghdr.msg_iov = vec;
msghdr.msg_iovlen = veclen;
#ifdef HAVE_MSGHDR_ACCRIGHTS
if (pass_fd != -1) /* we have an fd to send */
{
#ifdef HAVE_MSGHDR_ACCRIGHTS
msghdr.msg_accrights = (void *)&pass_fd;
msghdr.msg_accrights = (void *)&pass_fd;
msghdr.msg_accrightslen = sizeof(pass_fd);
#else
}
else
{
msghdr.msg_accrights = NULL;
msghdr.msg_accrightslen = 0;
}
#else /* HAVE_MSGHDR_ACCRIGHTS */
if (pass_fd != -1) /* we have an fd to send */
{
cmsg.len = sizeof(cmsg);
cmsg.level = SOL_SOCKET;
cmsg.type = SCM_RIGHTS;
cmsg.fd = pass_fd;
msghdr.msg_control = &cmsg;
msghdr.msg_controllen = sizeof(cmsg);
#endif
}
else
{
msghdr.msg_control = NULL;
msghdr.msg_controllen = 0;
}
msghdr.msg_flags = 0;
#endif /* HAVE_MSGHDR_ACCRIGHTS */
if ((ret = sendmsg( thdb->socket, &msghdr, 0 )) < len)
{
......@@ -122,7 +145,7 @@ void CLIENT_SendRequest( enum request req, int pass_fd,
vec[i].iov_len = va_arg( args, int );
}
va_end( args );
return CLIENT_SendRequest_v( req, pass_fd, vec, n );
CLIENT_SendRequest_v( req, pass_fd, vec, n );
}
......@@ -137,15 +160,32 @@ static unsigned int CLIENT_WaitReply_v( int *len, int *passed_fd,
{
THDB *thdb = THREAD_Current();
int pass_fd = -1;
#ifdef HAVE_MSGHDR_ACCRIGHTS
struct msghdr msghdr = { NULL, 0, vec, veclen, (void*)&pass_fd, sizeof(int) };
#else
struct cmsg_fd cmsg = { sizeof(cmsg), SOL_SOCKET, SCM_RIGHTS, -1 };
struct msghdr msghdr = { NULL, 0, vec, veclen, &cmsg, sizeof(cmsg), 0 };
#endif
struct header head;
int ret, remaining;
#ifdef HAVE_MSGHDR_ACCRIGHTS
struct msghdr msghdr;
msghdr.msg_accrights = (void *)&pass_fd;
msghdr.msg_accrightslen = sizeof(int);
#else /* HAVE_MSGHDR_ACCRIGHTS */
struct msghdr msghdr;
struct cmsg_fd cmsg;
cmsg.len = sizeof(cmsg);
cmsg.level = SOL_SOCKET;
cmsg.type = SCM_RIGHTS;
cmsg.fd = -1;
msghdr.msg_control = &cmsg;
msghdr.msg_controllen = sizeof(cmsg);
msghdr.msg_flags = 0;
#endif /* HAVE_MSGHDR_ACCRIGHTS */
msghdr.msg_name = NULL;
msghdr.msg_namelen = 0;
msghdr.msg_iov = vec;
msghdr.msg_iovlen = veclen;
assert( veclen > 0 );
vec[0].iov_base = &head;
vec[0].iov_len = sizeof(head);
......
......@@ -158,7 +158,7 @@ int SYSDEPS_SpawnThread( THDB *thread )
#ifdef HAVE__LWP_CREATE
ucontext_t context;
_lwp_makecontext( &context, (void(*)(void *))SYSDEPS_StartThread, thread,
NULL, thread->stack_base, thread->teb.stack_top - thread->stack_base );
NULL, thread->stack_base, (char *) thread->teb.stack_top - (char *) thread->stack_base );
if ( _lwp_create( &context, 0, NULL ) )
return -1;
return 0;
......
......@@ -70,10 +70,9 @@ static void do_write( struct client *client, int client_fd )
{
struct iovec vec[2];
#ifndef HAVE_MSGHDR_ACCRIGHTS
struct cmsg_fd cmsg = { sizeof(cmsg), SOL_SOCKET, SCM_RIGHTS,
client->pass_fd };
struct cmsg_fd cmsg;
#endif
struct msghdr msghdr = { NULL, 0, vec, 2, };
struct msghdr msghdr;
int ret;
/* make sure we have something to send */
......@@ -81,12 +80,17 @@ static void do_write( struct client *client, int client_fd )
/* make sure the client is listening */
assert( client->state == READING );
msghdr.msg_name = NULL;
msghdr.msg_namelen = 0;
msghdr.msg_iov = vec;
if (client->count < sizeof(client->head))
{
vec[0].iov_base = (char *)&client->head + client->count;
vec[0].iov_len = sizeof(client->head) - client->count;
vec[1].iov_base = client->data;
vec[1].iov_len = client->head.len - sizeof(client->head);
msghdr.msg_iovlen = 2;
}
else
{
......@@ -94,16 +98,36 @@ static void do_write( struct client *client, int client_fd )
vec[0].iov_len = client->head.len - client->count;
msghdr.msg_iovlen = 1;
}
#ifdef HAVE_MSGHDR_ACCRIGHTS
if (client->pass_fd != -1) /* we have an fd to send */
{
#ifdef HAVE_MSGHDR_ACCRIGHTS
msghdr.msg_accrights = (void *)&client->pass_fd;
msghdr.msg_accrightslen = sizeof(client->pass_fd);
#else
}
else
{
msghdr.msg_accrights = NULL;
msghdr.msg_accrightslen = 0;
}
#else /* HAVE_MSGHDR_ACCRIGHTS */
if (client->pass_fd != -1) /* we have an fd to send */
{
cmsg.len = sizeof(cmsg);
cmsg.level = SOL_SOCKET;
cmsg.type = SCM_RIGHTS;
cmsg.fd = client->pass_fd;
msghdr.msg_control = &cmsg;
msghdr.msg_controllen = sizeof(cmsg);
#endif
}
else
{
msghdr.msg_control = NULL;
msghdr.msg_controllen = 0;
}
msghdr.msg_flags = 0;
#endif /* HAVE_MSGHDR_ACCRIGHTS */
ret = sendmsg( client_fd, &msghdr, 0 );
if (ret == -1)
{
......@@ -133,14 +157,31 @@ static void do_read( struct client *client, int client_fd )
{
struct iovec vec;
int pass_fd = -1;
#ifdef HAVE_MSGHDR_ACCRIGHTS
struct msghdr msghdr = { NULL, 0, &vec, 1, (void*)&pass_fd, sizeof(int) };
#else
struct cmsg_fd cmsg = { sizeof(cmsg), SOL_SOCKET, SCM_RIGHTS, -1 };
struct msghdr msghdr = { NULL, 0, &vec, 1, &cmsg, sizeof(cmsg), 0 };
#endif
int ret;
#ifdef HAVE_MSGHDR_ACCRIGHTS
struct msghdr msghdr;
msghdr.msg_accrights = (void *)&pass_fd;
msghdr.msg_accrightslen = sizeof(int);
#else /* HAVE_MSGHDR_ACCRIGHTS */
struct msghdr msghdr;
struct cmsg_fd cmsg;
cmsg.len = sizeof(cmsg);
cmsg.level = SOL_SOCKET;
cmsg.type = SCM_RIGHTS;
cmsg.fd = -1;
msghdr.msg_control = &cmsg;
msghdr.msg_controllen = sizeof(cmsg);
msghdr.msg_flags = 0;
#endif /* HAVE_MSGHDR_ACCRIGHTS */
msghdr.msg_name = NULL;
msghdr.msg_namelen = 0;
msghdr.msg_iov = &vec;
msghdr.msg_iovlen = 1;
if (client->count < sizeof(client->head))
{
vec.iov_base = (char *)&client->head + client->count;
......
......@@ -453,11 +453,13 @@ static int dump_create_pipe_reply( struct create_pipe_reply *req, int len )
static int dump_alloc_console_request( struct alloc_console_request *req, int len )
{
fprintf( stderr, " dummy=%d", req->dummy );
return (int)sizeof(*req);
}
static int dump_free_console_request( struct free_console_request *req, int len )
{
fprintf( stderr, " dummy=%d", req->dummy );
return (int)sizeof(*req);
}
......@@ -548,6 +550,7 @@ static int dump_read_console_input_request( struct read_console_input_request *r
static int dump_read_console_input_reply( struct read_console_input_reply *req, int len )
{
fprintf( stderr, " dummy=%d", req->dummy );
return (int)sizeof(*req);
}
......
......@@ -1007,6 +1007,9 @@ static int BuildSpec32File( char * specfile, FILE *outfile )
/* Output code for all register functions */
fprintf( outfile, "#ifdef __i386__\n" );
fprintf( outfile, "#ifndef __GNUC__\n" );
fprintf( outfile, "static void __asm__dummy() {\n" );
fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" );
for (i = Base, odp = OrdinalDefinitions + Base; i <= Limit; i++, odp++)
{
if (odp->type != TYPE_REGISTER) continue;
......@@ -1021,7 +1024,10 @@ static int BuildSpec32File( char * specfile, FILE *outfile )
odp->u.func.link_name, odp->u.func.link_name,
odp->u.func.link_name, odp->u.func.link_name );
}
fprintf( outfile, "#endif\n" );
fprintf( outfile, "#ifndef __GNUC__\n" );
fprintf( outfile, "}\n" );
fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" );
fprintf( outfile, "#endif /* defined(__i386__) */\n" );
/* Output the DLL functions prototypes */
......
......@@ -85,14 +85,18 @@
* - Corrected syntax problems with an old yacc (;)
* - Added extra comment about grammar
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <string.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <config.h>
#include "wrc.h"
#include "utils.h"
#include "newstruc.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment