Commit b9010214 authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

Added better missing function emulation.

parent b3ec4b91
......@@ -513,11 +513,21 @@ AC_FUNC_ALLOCA()
AC_CHECK_FUNCS(\
_lwp_create \
clone \
getnetbyaddr \
getnetbyname \
getpagesize \
getprotobyname \
getprotobynumber \
getservbyport \
getsockopt \
inet_network \
memmove \
rfork \
select \
sendmsg \
settimeofday \
sigaltstack \
statfs \
strcasecmp \
strerror \
strncasecmp \
......
......@@ -41,6 +41,7 @@
#include "heap.h"
#include "msdos.h"
#include "options.h"
#include "wine/port.h"
#include "task.h"
#include "debugtools.h"
......
......@@ -151,21 +151,51 @@
/* Define if you have the gethostbyname function. */
#undef HAVE_GETHOSTBYNAME
/* Define if you have the getnetbyaddr function. */
#undef HAVE_GETNETBYADDR
/* Define if you have the getnetbyname function. */
#undef HAVE_GETNETBYNAME
/* Define if you have the getpagesize function. */
#undef HAVE_GETPAGESIZE
/* Define if you have the getprotobyname function. */
#undef HAVE_GETPROTOBYNAME
/* Define if you have the getprotobynumber function. */
#undef HAVE_GETPROTOBYNUMBER
/* Define if you have the getservbyport function. */
#undef HAVE_GETSERVBYPORT
/* Define if you have the getsockopt function. */
#undef HAVE_GETSOCKOPT
/* Define if you have the inet_network function. */
#undef HAVE_INET_NETWORK
/* Define if you have the memmove function. */
#undef HAVE_MEMMOVE
/* Define if you have the rfork function. */
#undef HAVE_RFORK
/* Define if you have the select function. */
#undef HAVE_SELECT
/* Define if you have the sendmsg function. */
#undef HAVE_SENDMSG
/* Define if you have the settimeofday function. */
#undef HAVE_SETTIMEOFDAY
/* Define if you have the sigaltstack function. */
#undef HAVE_SIGALTSTACK
/* Define if you have the statfs function. */
#undef HAVE_STATFS
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
......
/*
* Wine porting definitions
*
*/
#ifndef __WINE_WINE_PORT_H
#define __WINE_WINE_PORT_H
#include "config.h"
#include <sys/types.h>
#include <sys/time.h>
/* Types */
#if !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME)
struct netent {
char *n_name;
char **n_aliases;
int n_addrtype;
unsigned long n_net;
};
#endif /* !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME) */
#if !defined(HAVE_GETPROTOBYNAME) && !defined(HAVE_GETPROTOBYNUMBER)
struct protoent {
char *p_name;
char **p_aliases;
int p_proto;
};
#endif /* !defined(HAVE_GETPROTOBYNAME) && !defined(HAVE_GETPROTOBYNUMBER) */
#ifndef HAVE_STATFS
# ifdef __BEOS__
# define STATFS_HAS_BFREE
struct statfs {
long f_bsize; /* block_size */
long f_blocks; /* total_blocks */
long f_bfree; /* free_blocks */
};
# else /* defined(__BEOS__) */
struct statfs;
# endif /* defined(__BEOS__) */
#endif /* !defined(HAVE_STATFS) */
/* Functions */
#if !defined(HAVE_CLONE) && defined(linux)
int clone(int (*fn)(void *arg), void *stack, int flags, void *arg);
#endif /* !defined(HAVE_CLONE) && defined(linux) */
#ifndef HAVE_GETNETBYADDR
struct netent *getnetbyaddr(unsigned long net, int type);
#endif /* defined(HAVE_GETNETBYNAME) */
#ifndef HAVE_GETNETBYNAME
struct netent *getnetbyname(const char *name);
#endif /* defined(HAVE_GETNETBYNAME) */
#ifndef HAVE_GETPROTOBYNAME
struct protoent *getprotobyname(const char *name);
#endif /* !defined(HAVE_GETPROTOBYNAME) */
#ifndef HAVE_GETPROTOBYNUMBER
struct protoent *getprotobynumber(int proto);
#endif /* !defined(HAVE_GETPROTOBYNUMBER) */
#ifndef HAVE_GETSERVBYPORT
struct servent *getservbyport(int port, const char *proto);
#endif /* !defined(HAVE_GETSERVBYPORT) */
#ifndef HAVE_GETSOCKOPT
int getsockopt(int socket, int level, int option_name, void *option_value, size_t *option_len);
#endif /* !defined(HAVE_GETSOCKOPT) */
#ifndef HAVE_MEMMOVE
void *memmove(void *dest, const void *src, unsigned int len);
#endif /* !defined(HAVE_MEMMOVE) */
#ifndef HAVE_INET_NETWORK
unsigned long inet_network(const char *cp);
#endif /* !defined(HAVE_INET_NETWORK) */
#ifndef HAVE_SETTIMEOFDAY
int settimeofday(struct timeval *tp, void *reserved);
#endif /* !defined(HAVE_SETTIMEOFDAY) */
#ifndef HAVE_STATFS
int statfs(const char *name, struct statfs *info);
#endif /* !defined(HAVE_STATFS) */
#ifndef HAVE_STRNCASECMP
int strncasecmp(const char *str1, const char *str2, size_t n);
#endif /* !defined(HAVE_STRNCASECMP) */
#ifndef HAVE_STRERROR
const char *strerror(int err);
#endif /* !defined(HAVE_STRERROR) */
#ifndef HAVE_STRCASECMP
int strcasecmp(const char *str1, const char *str2);
#endif /* !defined(HAVE_STRCASECMP) */
#ifndef HAVE_USLEEP
int usleep (unsigned int useconds);
#endif /* !defined(HAVE_USLEEP) */
#endif /* !defined(__WINE_WINE_PORT_H) */
......@@ -4,8 +4,14 @@
* Copyright 1996 Alexandre Julliard
*/
#include "config.h"
#include "wine/port.h"
#ifdef __BEOS__
#include <be/kernel/fs_info.h>
#include <be/kernel/OS.h>
#endif
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
......@@ -20,13 +26,22 @@
#ifdef HAVE_LIBIO_H
# include <libio.h>
#endif
#ifdef HAVE_SYSCALL_H
# include <syscall.h>
#endif
/***********************************************************************
* usleep
*/
#ifndef HAVE_USLEEP
#ifdef __EMX__
unsigned int usleep (unsigned int useconds) { DosSleep(useconds); }
#else
unsigned int usleep (unsigned int useconds)
{
#if defined(__EMX__)
DosSleep(useconds);
return 0;
#elif defined(__BEOS__)
return snooze(useconds);
#elif defined(HAVE_SELECT)
struct timeval delay;
delay.tv_sec = 0;
......@@ -34,10 +49,16 @@ unsigned int usleep (unsigned int useconds)
select( 0, 0, 0, 0, &delay );
return 0;
#else /* defined(__EMX__) || defined(__BEOS__) || defined(HAVE_SELECT) */
errno = ENOSYS;
return -1;
#endif /* defined(__EMX__) || defined(__BEOS__) || defined(HAVE_SELECT) */
}
#endif
#endif /* HAVE_USLEEP */
/***********************************************************************
* memmove
*/
#ifndef HAVE_MEMMOVE
void *memmove( void *dest, const void *src, unsigned int len )
{
......@@ -63,6 +84,9 @@ void *memmove( void *dest, const void *src, unsigned int len )
}
#endif /* HAVE_MEMMOVE */
/***********************************************************************
* strerror
*/
#ifndef HAVE_STRERROR
const char *strerror( int err )
{
......@@ -71,12 +95,10 @@ const char *strerror( int err )
}
#endif /* HAVE_STRERROR */
/***********************************************************************
* clone
*/
#if !defined(HAVE_CLONE) && defined(__linux__)
#include <assert.h>
#include <errno.h>
#ifdef HAVE_SYSCALL_H
# include <syscall.h>
#endif
int clone( int (*fn)(void *), void *stack, int flags, void *arg )
{
#ifdef __i386__
......@@ -106,7 +128,9 @@ int clone( int (*fn)(void *), void *stack, int flags, void *arg )
}
#endif /* !HAVE_CLONE && __linux__ */
/***********************************************************************
* strcasecmp
*/
#ifndef HAVE_STRCASECMP
int strcasecmp( const char *str1, const char *str2 )
{
......@@ -115,6 +139,9 @@ int strcasecmp( const char *str1, const char *str2 )
}
#endif /* HAVE_STRCASECMP */
/***********************************************************************
* strncasecmp
*/
#ifndef HAVE_STRNCASECMP
int strncasecmp( const char *str1, const char *str2, size_t n )
{
......@@ -126,13 +153,16 @@ int strncasecmp( const char *str1, const char *str2, size_t n )
}
#endif /* HAVE_STRNCASECMP */
/**
* It looks like the openpty that comes with glibc in RedHat 5.0
* is buggy (second call returns what looks like a dup of 0 and 1
* instead of a new pty), this is a generic replacement.
/***********************************************************************
* wine_openpty
* NOTE
* It looks like the openpty that comes with glibc in RedHat 5.0
* is buggy (second call returns what looks like a dup of 0 and 1
* instead of a new pty), this is a generic replacement.
*
* FIXME
* We should have a autoconf check for this.
*/
/** We will have an autoconf check for this soon... */
int wine_openpty(int *master, int *slave, char *name,
struct termios *term, struct winsize *winsize)
{
......@@ -170,3 +200,131 @@ int wine_openpty(int *master, int *slave, char *name,
return -1;
}
/***********************************************************************
* getnetbyaddr
*/
#ifndef HAVE_GETNETBYADDR
struct netent *getnetbyaddr(unsigned long net, int type)
{
errno = ENOSYS;
return NULL;
}
#endif /* defined(HAVE_GETNETBYNAME) */
/***********************************************************************
* getnetbyname
*/
#ifndef HAVE_GETNETBYNAME
struct netent *getnetbyname(const char *name)
{
errno = ENOSYS;
return NULL;
}
#endif /* defined(HAVE_GETNETBYNAME) */
/***********************************************************************
* getprotobyname
*/
#ifndef HAVE_GETPROTOBYNAME
struct protoent *getprotobyname(const char *name)
{
errno = ENOSYS;
return NULL;
}
#endif /* !defined(HAVE_GETPROTOBYNAME) */
/***********************************************************************
* getprotobynumber
*/
#ifndef HAVE_GETPROTOBYNUMBER
struct protoent *getprotobynumber(int proto)
{
errno = ENOSYS;
return NULL;
}
#endif /* !defined(HAVE_GETPROTOBYNUMBER) */
/***********************************************************************
* getservbyport
*/
#ifndef HAVE_GETSERVBYPORT
struct servent *getservbyport(int port, const char *proto)
{
errno = ENOSYS;
return NULL;
}
#endif /* !defined(HAVE_GETSERVBYPORT) */
/***********************************************************************
* getsockopt
*/
#ifndef HAVE_GETSOCKOPT
int getsockopt(int socket, int level, int option_name,
void *option_value, size_t *option_len)
{
errno = ENOSYS;
return -1;
}
#endif /* !defined(HAVE_GETSOCKOPT) */
/***********************************************************************
* inet_network
*/
#ifndef HAVE_INET_NETWORK
unsigned long inet_network(const char *cp)
{
errno = ENOSYS;
return 0;
}
#endif /* defined(HAVE_INET_NETWORK) */
/***********************************************************************
* settimeofday
*/
#ifndef HAVE_SETTIMEOFDAY
int settimeofday(struct timeval *tp, void *reserved)
{
tp->tv_sec = 0;
tp->tv_usec = 0;
errno = ENOSYS;
return -1;
}
#endif /* HAVE_SETTIMEOFDAY */
/***********************************************************************
* statfs
*/
#ifndef HAVE_STATFS
int statfs(const char *name, struct statfs *info)
{
#ifdef __BEOS__
dev_t mydev;
fs_info fsinfo;
if(!info) {
errno = ENOSYS;
return -1;
}
if ((mydev = dev_for_path(name)) < 0) {
errno = ENOSYS;
return -1;
}
if (fs_stat_dev(mydev,&fsinfo) < 0) {
errno = ENOSYS;
return -1;
}
info->f_bsize = fsinfo.block_size;
info->f_blocks = fsinfo.total_blocks;
info->f_bfree = fsinfo.free_blocks;
return 0;
#else /* defined(__BEOS__) */
errno = ENOSYS;
return -1;
#endif /* defined(__BEOS__) */
}
#endif /* !defined(HAVE_STATFS) */
......@@ -77,6 +77,7 @@
#include "task.h"
#include "message.h"
#include "miscemu.h"
#include "wine/port.h"
#include "services.h"
#include "server.h"
#include "debugtools.h"
......
......@@ -83,6 +83,7 @@
#include "task.h"
#include "message.h"
#include "miscemu.h"
#include "wine/port.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(winsock)
......
......@@ -25,6 +25,7 @@ static int *ph_errno = &h_errno;
#ifdef HAVE_UCONTEXT_H
# include <ucontext.h>
#endif
#include "wine/port.h"
#include "thread.h"
#include "server.h"
#include "winbase.h"
......@@ -33,14 +34,10 @@ static int *ph_errno = &h_errno;
DEFAULT_DEBUG_CHANNEL(thread)
#ifdef linux
#define HAVE_CLONE_SYSCALL
#endif
/* Xlib critical section (FIXME: does not belong here) */
CRITICAL_SECTION X11DRV_CritSection = { 0, };
#ifdef HAVE_CLONE_SYSCALL
#ifdef linux
# ifdef HAVE_SCHED_H
# include <sched.h>
# endif
......@@ -50,10 +47,8 @@ CRITICAL_SECTION X11DRV_CritSection = { 0, };
# define CLONE_FILES 0x00000400
# define CLONE_SIGHAND 0x00000800
# define CLONE_PID 0x00001000
/* If we didn't get the flags, we probably didn't get the prototype either */
extern int clone( int (*fn)(void *arg), void *stack, int flags, void *arg );
# endif /* CLONE_VM */
#endif /* HAVE_CLONE_SYSCALL */
#endif /* linux */
static int init_done;
......@@ -155,7 +150,7 @@ int SYSDEPS_SpawnThread( TEB *teb )
{
#ifndef NO_REENTRANT_LIBC
#ifdef HAVE_CLONE_SYSCALL
#ifdef linux
if (clone( (int (*)(void *))SYSDEPS_StartThread, teb->stack_top,
CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, teb ) < 0)
return -1;
......
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