Replaced mkstemp by mkstemps from libiberty.
Removed a couple of unnecessary portability functions.
This commit is contained in:
parent
bae5c76d0c
commit
2ee8b5bb13
|
@ -13078,8 +13078,6 @@ fi
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -13108,12 +13106,10 @@ for ac_func in \
|
|||
getprotobynumber \
|
||||
getpwuid \
|
||||
getservbyport \
|
||||
getsockopt \
|
||||
inet_network \
|
||||
lseek64 \
|
||||
lstat \
|
||||
memmove \
|
||||
mkstemp \
|
||||
mmap \
|
||||
pclose \
|
||||
popen \
|
||||
|
|
|
@ -931,12 +931,10 @@ AC_CHECK_FUNCS(\
|
|||
getprotobynumber \
|
||||
getpwuid \
|
||||
getservbyport \
|
||||
getsockopt \
|
||||
inet_network \
|
||||
lseek64 \
|
||||
lstat \
|
||||
memmove \
|
||||
mkstemp \
|
||||
mmap \
|
||||
pclose \
|
||||
popen \
|
||||
|
|
|
@ -562,8 +562,8 @@ static char *extract_icon( const char *path, int index)
|
|||
int fd, nodefault = 1;
|
||||
char *filename, tmpfn[25];
|
||||
|
||||
strcpy(tmpfn,"/tmp/icon.XXXXXX");
|
||||
fd = mkstemp( tmpfn );
|
||||
strcpy(tmpfn,"/tmp/icon.XXXXXX.xpm");
|
||||
fd = mkstemps( tmpfn, 4 );
|
||||
if (fd == -1)
|
||||
return NULL;
|
||||
filename = heap_strdup( tmpfn );
|
||||
|
|
|
@ -296,7 +296,11 @@ INT WINAPI EnumProtocolsW( LPINT lpiProtocols, LPVOID lpBuffer,
|
|||
*/
|
||||
UINT WINAPI WSOCK32_inet_network(const char *cp)
|
||||
{
|
||||
#ifdef HAVE_INET_NETWORK
|
||||
return inet_network(cp);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
|
@ -161,9 +161,6 @@
|
|||
/* Define to 1 if you have the `getservbyport' function. */
|
||||
#undef HAVE_GETSERVBYPORT
|
||||
|
||||
/* Define to 1 if you have the `getsockopt' function. */
|
||||
#undef HAVE_GETSOCKOPT
|
||||
|
||||
/* Define to 1 if you have the <gif_lib.h> header file. */
|
||||
#undef HAVE_GIF_LIB_H
|
||||
|
||||
|
@ -326,9 +323,6 @@
|
|||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `mkstemp' function. */
|
||||
#undef HAVE_MKSTEMP
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ struct statfs;
|
|||
* Function definitions (only when using libwine)
|
||||
*/
|
||||
|
||||
#ifndef NO_LIBWINE
|
||||
#ifndef NO_LIBWINE_PORT
|
||||
|
||||
#if !defined(HAVE_CLONE) && defined(linux)
|
||||
int clone(int (*fn)(void *arg), void *stack, int flags, void *arg);
|
||||
|
@ -199,22 +199,10 @@ extern int getopt_long_only (int ___argc, char *const *___argv,
|
|||
size_t getpagesize(void);
|
||||
#endif /* HAVE_GETPAGESIZE */
|
||||
|
||||
#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_INET_NETWORK
|
||||
unsigned long inet_network(const char *cp);
|
||||
#endif /* !defined(HAVE_INET_NETWORK) */
|
||||
|
||||
#ifndef HAVE_LSTAT
|
||||
int lstat(const char *file_name, struct stat *buf);
|
||||
#endif /* HAVE_LSTAT */
|
||||
|
||||
#ifndef HAVE_MKSTEMP
|
||||
int mkstemp(char *tmpfn);
|
||||
#endif /* HAVE_MKSTEMP */
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
void *memmove(void *dest, const void *src, size_t len);
|
||||
#endif /* !defined(HAVE_MEMMOVE) */
|
||||
|
@ -261,6 +249,8 @@ int usleep (unsigned int useconds);
|
|||
extern void *wine_memcpy_unaligned( void *dst, const void *src, size_t size );
|
||||
#endif /* __i386__ */
|
||||
|
||||
extern int mkstemps(char *template, int suffix_len);
|
||||
|
||||
/* Interlocked functions */
|
||||
|
||||
#if defined(__i386__) && defined(__GNUC__)
|
||||
|
@ -315,14 +305,12 @@ extern long interlocked_xchg_add( long *dest, long incr );
|
|||
|
||||
#endif /* __i386___ && __GNUC__ */
|
||||
|
||||
#else /* NO_LIBWINE */
|
||||
#else /* NO_LIBWINE_PORT */
|
||||
|
||||
#define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
|
||||
|
||||
#define clone __WINE_NOT_PORTABLE(clone)
|
||||
#define getpagesize __WINE_NOT_PORTABLE(getpagesize)
|
||||
#define getsockopt __WINE_NOT_PORTABLE(getsockopt)
|
||||
#define inet_network __WINE_NOT_PORTABLE(inet_network)
|
||||
#define lstat __WINE_NOT_PORTABLE(lstat)
|
||||
#define memmove __WINE_NOT_PORTABLE(memmove)
|
||||
#define pread __WINE_NOT_PORTABLE(pread)
|
||||
|
@ -333,6 +321,6 @@ extern long interlocked_xchg_add( long *dest, long incr );
|
|||
#define strncasecmp __WINE_NOT_PORTABLE(strncasecmp)
|
||||
#define usleep __WINE_NOT_PORTABLE(usleep)
|
||||
|
||||
#endif /* NO_LIBWINE */
|
||||
#endif /* NO_LIBWINE_PORT */
|
||||
|
||||
#endif /* !defined(__WINE_WINE_PORT_H) */
|
||||
|
|
|
@ -65,65 +65,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* clone
|
||||
*/
|
||||
#if !defined(HAVE_CLONE) && defined(__linux__)
|
||||
int clone( int (*fn)(void *), void *stack, int flags, void *arg )
|
||||
{
|
||||
#ifdef __i386__
|
||||
int ret;
|
||||
void **stack_ptr = (void **)stack;
|
||||
*--stack_ptr = arg; /* Push argument on stack */
|
||||
*--stack_ptr = fn; /* Push function pointer (popped into ebx) */
|
||||
__asm__ __volatile__( "pushl %%ebx\n\t"
|
||||
"movl %2,%%ebx\n\t"
|
||||
"int $0x80\n\t"
|
||||
"popl %%ebx\n\t" /* Contains fn in the child */
|
||||
"testl %%eax,%%eax\n\t"
|
||||
"jnz 0f\n\t"
|
||||
"xorl %ebp,%ebp\n\t" /* Terminate the stack frames */
|
||||
"call *%%ebx\n\t" /* Should never return */
|
||||
"xorl %%eax,%%eax\n\t" /* Just in case it does*/
|
||||
"0:"
|
||||
: "=a" (ret)
|
||||
: "0" (SYS_clone), "r" (flags), "c" (stack_ptr) );
|
||||
assert( ret ); /* If ret is 0, we returned from the child function */
|
||||
if (ret > 0) return ret;
|
||||
errno = -ret;
|
||||
return -1;
|
||||
#else
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
#endif /* __i386__ */
|
||||
}
|
||||
#endif /* !HAVE_CLONE && __linux__ */
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* 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) */
|
||||
|
||||
|
||||
#if defined(__svr4__) || defined(__NetBSD__)
|
||||
/***********************************************************************
|
||||
* try_mmap_fixed
|
||||
|
|
|
@ -11,7 +11,7 @@ C_SRCS = \
|
|||
getpagesize.c \
|
||||
lstat.c \
|
||||
memmove.c \
|
||||
mkstemp.c \
|
||||
mkstemps.c \
|
||||
pread.c \
|
||||
pwrite.c \
|
||||
statfs.c \
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* mkstemp function
|
||||
*
|
||||
* Copyright 1996 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
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKSTEMP
|
||||
int mkstemp(char *tmpfn)
|
||||
{
|
||||
int tries;
|
||||
char *xstart;
|
||||
|
||||
xstart = tmpfn+strlen(tmpfn)-1;
|
||||
while ((xstart > tmpfn) && (*xstart == 'X'))
|
||||
xstart--;
|
||||
tries = 10;
|
||||
while (tries--)
|
||||
{
|
||||
char *newfn = mktemp(tmpfn);
|
||||
int fd;
|
||||
if (!newfn) /* something else broke horribly */
|
||||
return -1;
|
||||
fd = open(newfn,O_CREAT|O_RDWR|O_EXCL,0600);
|
||||
if (fd!=-1)
|
||||
return fd;
|
||||
newfn = xstart;
|
||||
/* fill up with X and try again ... */
|
||||
while (*newfn) *newfn++ = 'X';
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif /* HAVE_MKSTEMP */
|
|
@ -0,0 +1,129 @@
|
|||
/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
|
||||
This file is derived from mkstemp.c from the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
/* We need to provide a type for gcc_uint64_t. */
|
||||
#ifdef __GNUC__
|
||||
__extension__ typedef unsigned long long gcc_uint64_t;
|
||||
#else
|
||||
typedef unsigned long gcc_uint64_t;
|
||||
#endif
|
||||
|
||||
#ifndef TMP_MAX
|
||||
#define TMP_MAX 16384
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len})
|
||||
|
||||
Generate a unique temporary file name from @var{template}.
|
||||
@var{template} has the form:
|
||||
|
||||
@example
|
||||
@var{path}/ccXXXXXX@var{suffix}
|
||||
@end example
|
||||
|
||||
@var{suffix_len} tells us how long @var{suffix} is (it can be zero
|
||||
length). The last six characters of @var{template} before @var{suffix}
|
||||
must be @samp{XXXXXX}; they are replaced with a string that makes the
|
||||
filename unique. Returns a file descriptor open on the file for
|
||||
reading and writing.
|
||||
|
||||
@end deftypefn
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
mkstemps (template, suffix_len)
|
||||
char *template;
|
||||
int suffix_len;
|
||||
{
|
||||
static const char letters[]
|
||||
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
static gcc_uint64_t value;
|
||||
struct timeval tv;
|
||||
char *XXXXXX;
|
||||
size_t len;
|
||||
int count;
|
||||
|
||||
len = strlen (template);
|
||||
|
||||
if ((int) len < 6 + suffix_len
|
||||
|| strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
XXXXXX = &template[len - 6 - suffix_len];
|
||||
|
||||
/* Get some more or less random data. */
|
||||
gettimeofday (&tv, NULL);
|
||||
value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
|
||||
|
||||
for (count = 0; count < TMP_MAX; ++count)
|
||||
{
|
||||
gcc_uint64_t v = value;
|
||||
int fd;
|
||||
|
||||
/* Fill in the random bits. */
|
||||
XXXXXX[0] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[1] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[2] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[3] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[4] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[5] = letters[v % 62];
|
||||
|
||||
#ifdef VMS
|
||||
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600, "fop=tmd");
|
||||
#else
|
||||
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
|
||||
#endif
|
||||
if (fd >= 0)
|
||||
/* The file does not exist. */
|
||||
return fd;
|
||||
|
||||
/* This is a random value. It is only necessary that the next
|
||||
TMP_MAX values generated by adding 7777 to VALUE are different
|
||||
with (module 2^32). */
|
||||
value += 7777;
|
||||
}
|
||||
|
||||
/* We return the null string if we can't find a unique file name. */
|
||||
template[0] = '\0';
|
||||
return -1;
|
||||
}
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
@ -1981,7 +1982,7 @@ static BOOL gdb_startup(struct gdb_context* gdbctx, DEBUG_EVENT* de, unsigned fl
|
|||
|
||||
if (!(gdb_path = getenv("WINE_GDB"))) gdb_path = "gdb";
|
||||
strcpy(buf,"/tmp/winegdb.XXXXXX");
|
||||
fd = mkstemp(buf);
|
||||
fd = mkstemps(buf,0);
|
||||
if (fd == -1) return FALSE;
|
||||
if ((f = fdopen(fd, "w+")) == NULL) return FALSE;
|
||||
fprintf(f, "file %s\n", wine_path);
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
#ifdef HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#ifdef HAVE_SCHED_H
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#include "thread.h"
|
||||
#include "wine/server.h"
|
||||
#include "winbase.h"
|
||||
|
@ -51,19 +55,6 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(thread);
|
||||
|
||||
#if defined(linux) || defined(HAVE_CLONE)
|
||||
# ifdef HAVE_SCHED_H
|
||||
# include <sched.h>
|
||||
# endif
|
||||
# ifndef CLONE_VM
|
||||
# define CLONE_VM 0x00000100
|
||||
# define CLONE_FS 0x00000200
|
||||
# define CLONE_FILES 0x00000400
|
||||
# define CLONE_SIGHAND 0x00000800
|
||||
# define CLONE_PID 0x00001000
|
||||
# endif /* CLONE_VM */
|
||||
#endif /* linux || HAVE_CLONE */
|
||||
|
||||
struct thread_cleanup_info
|
||||
{
|
||||
void *stack_base;
|
||||
|
@ -185,18 +176,12 @@ static void SYSDEPS_StartThread( TEB *teb )
|
|||
*/
|
||||
int SYSDEPS_SpawnThread( TEB *teb )
|
||||
{
|
||||
#ifdef ERRNO_LOCATION
|
||||
|
||||
#if defined(linux) || defined(HAVE_CLONE)
|
||||
const int flags = CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD;
|
||||
if (clone( (int (*)(void *))SYSDEPS_StartThread, teb->stack_top, flags, teb ) < 0)
|
||||
#ifdef HAVE_CLONE
|
||||
if (clone( (int (*)(void *))SYSDEPS_StartThread, teb->stack_top,
|
||||
CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, teb ) < 0)
|
||||
return -1;
|
||||
if (!(flags & CLONE_FILES)) close( teb->request_fd ); /* close the child socket in the parent */
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RFORK
|
||||
const int flags = RFPROC | RFMEM; /*|RFFDG*/
|
||||
#elif defined(HAVE_RFORK)
|
||||
void **sp = (void **)teb->stack_top;
|
||||
*--sp = teb;
|
||||
*--sp = 0;
|
||||
|
@ -212,13 +197,10 @@ int SYSDEPS_SpawnThread( TEB *teb )
|
|||
"ret;\n"
|
||||
"1:\n\t" /* parent -> caller thread */
|
||||
"addl $8,%%esp" :
|
||||
: "r" (sp), "g" (SYS_rfork), "g" (flags)
|
||||
: "r" (sp), "g" (SYS_rfork), "g" (RFPROC | RFMEM)
|
||||
: "eax", "edx");
|
||||
if (flags & RFFDG) close( teb->request_fd ); /* close the child socket in the parent */
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__LWP_CREATE
|
||||
#elif defined(HAVE__LWP_CREATE)
|
||||
ucontext_t context;
|
||||
_lwp_makecontext( &context, (void(*)(void *))SYSDEPS_StartThread, teb,
|
||||
NULL, teb->stack_base, (char *)teb->stack_top - (char *)teb->stack_base );
|
||||
|
@ -227,10 +209,8 @@ int SYSDEPS_SpawnThread( TEB *teb )
|
|||
return 0;
|
||||
#endif
|
||||
|
||||
#endif /* ERRNO_LOCATION */
|
||||
|
||||
FIXME("CreateThread: stub\n" );
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ struct file *create_temp_file( int access )
|
|||
int fd;
|
||||
|
||||
sprintf( tmpfn, "anonmap.XXXXXX" ); /* create it in the server directory */
|
||||
fd = mkstemp(tmpfn);
|
||||
fd = mkstemps( tmpfn, 0 );
|
||||
if (fd == -1)
|
||||
{
|
||||
file_set_error();
|
||||
|
|
|
@ -616,13 +616,13 @@ static const char *ldcombine_files( char **argv )
|
|||
|
||||
if (output_file_name && output_file_name[0])
|
||||
{
|
||||
ld_tmp_file = xmalloc( strlen(output_file_name) + 8 );
|
||||
ld_tmp_file = xmalloc( strlen(output_file_name) + 10 );
|
||||
strcpy( ld_tmp_file, output_file_name );
|
||||
strcat( ld_tmp_file, ".XXXXXX" );
|
||||
strcat( ld_tmp_file, ".XXXXXX.o" );
|
||||
}
|
||||
else ld_tmp_file = xstrdup( "/tmp/winebuild.tmp.XXXXXX" );
|
||||
else ld_tmp_file = xstrdup( "/tmp/winebuild.tmp.XXXXXX.o" );
|
||||
|
||||
if ((fd = mkstemp( ld_tmp_file ) == -1)) fatal_error( "could not generate a temp file\n" );
|
||||
if ((fd = mkstemps( ld_tmp_file, 2 ) == -1)) fatal_error( "could not generate a temp file\n" );
|
||||
close( fd );
|
||||
atexit( remove_ld_tmp_file );
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ int wpp_parse_temp( const char *input, const char *output_base, char **output_na
|
|||
strcpy( temp_name, output_base );
|
||||
strcat( temp_name, ".XXXXXX" );
|
||||
|
||||
if((fd = mkstemp( temp_name )) == -1)
|
||||
if((fd = mkstemps( temp_name, 0 )) == -1)
|
||||
{
|
||||
fprintf(stderr, "Could not generate a temp name from %s\n", temp_name);
|
||||
exit(2);
|
||||
|
|
Loading…
Reference in New Issue