From 758b28c9f8db9aec8cf5b090daf93e950da79abb Mon Sep 17 00:00:00 2001 From: Christophe Bothamy Date: Tue, 6 May 2003 20:28:13 +0000 Subject: [PATCH] - add mkstemp replacement function and S_I???? defines when not present --- bochs/osdep.cc | 14 +++++++++++++- bochs/osdep.h | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/bochs/osdep.cc b/bochs/osdep.cc index 973c12e23..b85294664 100644 --- a/bochs/osdep.cc +++ b/bochs/osdep.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: osdep.cc,v 1.13 2003-03-11 17:30:20 vruppert Exp $ +// $Id: osdep.cc,v 1.14 2003-05-06 20:28:12 cbothamy Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -235,6 +235,18 @@ char *bx_strrev(char *str) } #endif /* !BX_HAVE_STRREV */ +#if !BX_HAVE_MKSTEMP +int bx_mkstemp(char *tpl) +{ + mktemp(tpl); + return ::open(tpl, O_RDWR | O_CREAT | O_TRUNC +# ifdef O_BINARY + | O_BINARY +# endif + , S_IWUSR | S_IRUSR | S_IRGRP | S_IWGRP); +} +#endif // !BX_HAVE_MKSTEMP + ////////////////////////////////////////////////////////////////////// // Missing library functions, implemented for MacOS only ////////////////////////////////////////////////////////////////////// diff --git a/bochs/osdep.h b/bochs/osdep.h index 5e1a192ef..05697efc1 100644 --- a/bochs/osdep.h +++ b/bochs/osdep.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: osdep.h,v 1.15 2003-01-10 22:32:46 cbothamy Exp $ +// $Id: osdep.h,v 1.16 2003-05-06 20:28:13 cbothamy Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -62,8 +62,19 @@ extern "C" { // win32 has snprintf though with different name. #define snprintf _snprintf #endif /* ifnndef __MINGW32__ */ + #endif /* WIN32 */ +// Missing defines for open +#ifndef S_IRUSR +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#define S_IRGRP 0040 +#define S_IWGRP 0020 +#define S_IROTH 0004 +#define S_IWOTH 0002 +#endif /* S_IRUSR */ + ////////////////////////////////////////////////////////////////////// // Missing library functions. // These should work on any platform that needs them. @@ -107,6 +118,11 @@ extern "C" { typedef int socklen_t; #endif +#if !BX_HAVE_MKSTEMP +#define mkstemp bx_mkstemp + extern int bx_mkstemp(char *tpl); +#endif + ////////////////////////////////////////////////////////////////////// // Missing library functions, implemented for MacOS only //////////////////////////////////////////////////////////////////////