_WIN32 ifdefs cleanup
This commit is contained in:
parent
5631554abd
commit
66bc94d1e8
10 changed files with 25 additions and 36 deletions
|
@ -47,6 +47,7 @@ typedef int ssize_t;
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#define ftruncate _chsize_s
|
#define ftruncate _chsize_s
|
||||||
|
#define chdir _chdir
|
||||||
#define PATH_MAX MAX_PATH
|
#define PATH_MAX MAX_PATH
|
||||||
#define MAXPATHLEN PATH_MAX
|
#define MAXPATHLEN PATH_MAX
|
||||||
#define R_OK 4
|
#define R_OK 4
|
||||||
|
|
|
@ -459,14 +459,10 @@ void RclConfig::initThrConf()
|
||||||
if (vq.size() > 0 && vq[0] == 0) {
|
if (vq.size() > 0 && vq[0] == 0) {
|
||||||
LOGDEB(("RclConfig::initThrConf: autoconf requested\n"));
|
LOGDEB(("RclConfig::initThrConf: autoconf requested\n"));
|
||||||
CpuConf cpus;
|
CpuConf cpus;
|
||||||
#ifdef _WIN32
|
|
||||||
cpus.ncpus = 1;
|
|
||||||
#else
|
|
||||||
if (!getCpuConf(cpus) || cpus.ncpus < 1) {
|
if (!getCpuConf(cpus) || cpus.ncpus < 1) {
|
||||||
LOGERR(("RclConfig::initThrConf: could not retrieve cpu conf\n"));
|
LOGERR(("RclConfig::initThrConf: could not retrieve cpu conf\n"));
|
||||||
cpus.ncpus = 1;
|
cpus.ncpus = 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
// Arbitrarily set threads config based on number of CPUS. This also
|
// Arbitrarily set threads config based on number of CPUS. This also
|
||||||
// depends on the IO setup actually, so we're bound to be wrong...
|
// depends on the IO setup actually, so we're bound to be wrong...
|
||||||
if (cpus.ncpus == 1) {
|
if (cpus.ncpus == 1) {
|
||||||
|
|
|
@ -31,9 +31,7 @@
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
#include "unac.h"
|
#include "unac.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
#ifndef _WIN32
|
|
||||||
#include "execmd.h"
|
#include "execmd.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static const int catchedSigs[] = {SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2};
|
static const int catchedSigs[] = {SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2};
|
||||||
|
|
|
@ -494,7 +494,7 @@ int main(int argc, char **argv)
|
||||||
if ((op_flags & OPT_E)) {
|
if ((op_flags & OPT_E)) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
#ifndef _WIN32
|
|
||||||
string rundir;
|
string rundir;
|
||||||
config->getConfParam("idxrundir", rundir);
|
config->getConfParam("idxrundir", rundir);
|
||||||
if (!rundir.compare("tmp")) {
|
if (!rundir.compare("tmp")) {
|
||||||
|
@ -512,7 +512,6 @@ int main(int argc, char **argv)
|
||||||
rundir.c_str(), errno));
|
rundir.c_str(), errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bool rezero((op_flags & OPT_z) != 0);
|
bool rezero((op_flags & OPT_z) != 0);
|
||||||
bool inPlaceReset((op_flags & OPT_Z) != 0);
|
bool inPlaceReset((op_flags & OPT_Z) != 0);
|
||||||
|
|
|
@ -62,7 +62,6 @@ bool getCpuConf(CpuConf& cpus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#else // TEST_CPUCONF
|
#else // TEST_CPUCONF
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -22,10 +22,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifndef _WIN32
|
#include <safefcntl.h> // in case O_APPEND is in there
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef INCLUDE_NEW_H
|
#ifdef INCLUDE_NEW_H
|
||||||
#include <new.h>
|
#include <new.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -250,6 +250,14 @@ bool maketmpdir(string& tdir, string& reason)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// There is a race condition between name computation and
|
||||||
|
// mkdir. try to make sure that we at least don't shoot ourselves
|
||||||
|
// in the foot
|
||||||
|
#if !defined(HAVE_MKDTEMP) || defined(_WIN32)
|
||||||
|
static PTMutexInit mlock;
|
||||||
|
PTMutexLocker lock(mlock);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!
|
if (!
|
||||||
#ifdef HAVE_MKDTEMP
|
#ifdef HAVE_MKDTEMP
|
||||||
mkdtemp(cp)
|
mkdtemp(cp)
|
||||||
|
@ -265,8 +273,6 @@ bool maketmpdir(string& tdir, string& reason)
|
||||||
}
|
}
|
||||||
tdir = cp;
|
tdir = cp;
|
||||||
free(cp);
|
free(cp);
|
||||||
// At this point the directory does not exist yet if mktemp was used
|
|
||||||
|
|
||||||
#else // _WIN32
|
#else // _WIN32
|
||||||
// There is a race condition between name computation and
|
// There is a race condition between name computation and
|
||||||
// mkdir. try to make sure that we at least don't shoot ourselves
|
// mkdir. try to make sure that we at least don't shoot ourselves
|
||||||
|
@ -276,6 +282,9 @@ bool maketmpdir(string& tdir, string& reason)
|
||||||
tdir = path_wingettempfilename(TEXT("rcltmp"));
|
tdir = path_wingettempfilename(TEXT("rcltmp"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// At this point the directory does not exist yet except if we used
|
||||||
|
// mkdtemp
|
||||||
|
|
||||||
#if !defined(HAVE_MKDTEMP) || defined(_WIN32)
|
#if !defined(HAVE_MKDTEMP) || defined(_WIN32)
|
||||||
if (mkdir(tdir.c_str(), 0700) < 0) {
|
if (mkdir(tdir.c_str(), 0700) < 0) {
|
||||||
reason = string("maketmpdir: mkdir ") + tdir + " failed";
|
reason = string("maketmpdir: mkdir ") + tdir + " failed";
|
||||||
|
@ -290,6 +299,13 @@ bool maketmpdir(string& tdir, string& reason)
|
||||||
TempFileInternal::TempFileInternal(const string& suffix)
|
TempFileInternal::TempFileInternal(const string& suffix)
|
||||||
: m_noremove(false)
|
: m_noremove(false)
|
||||||
{
|
{
|
||||||
|
// Because we need a specific suffix, can't use mkstemp
|
||||||
|
// well. There is a race condition between name computation and
|
||||||
|
// file creation. try to make sure that we at least don't shoot
|
||||||
|
// our own selves in the foot. maybe we'll use mkstemps one day.
|
||||||
|
static PTMutexInit mlock;
|
||||||
|
PTMutexLocker lock(mlock);
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
string filename = path_cat(tmplocation(), "rcltmpfXXXXXX");
|
string filename = path_cat(tmplocation(), "rcltmpfXXXXXX");
|
||||||
char *cp = strdup(filename.c_str());
|
char *cp = strdup(filename.c_str());
|
||||||
|
@ -298,8 +314,8 @@ TempFileInternal::TempFileInternal(const string& suffix)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yes using mkstemp this way is awful (bot the suffix adding and
|
// Using mkstemp this way is awful (bot the suffix adding and
|
||||||
// using mkstemp() just to avoid the warnings)
|
// using mkstemp() instead of mktemp just to avoid the warnings)
|
||||||
int fd;
|
int fd;
|
||||||
if ((fd = mkstemp(cp)) < 0) {
|
if ((fd = mkstemp(cp)) < 0) {
|
||||||
free(cp);
|
free(cp);
|
||||||
|
@ -311,11 +327,6 @@ TempFileInternal::TempFileInternal(const string& suffix)
|
||||||
filename = cp;
|
filename = cp;
|
||||||
free(cp);
|
free(cp);
|
||||||
#else
|
#else
|
||||||
// There is a race condition between name computation and
|
|
||||||
// mkdir. try to make sure that we at least don't shoot ourselves
|
|
||||||
// in the foot
|
|
||||||
static PTMutexInit mlock;
|
|
||||||
PTMutexLocker lock(mlock);
|
|
||||||
string filename = path_wingettempfilename(TEXT("recoll"));
|
string filename = path_wingettempfilename(TEXT("recoll"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -97,11 +97,6 @@ extern bool maketmpdir(std::string& tdir, std::string& reason);
|
||||||
/// mkdir -p
|
/// mkdir -p
|
||||||
extern bool makepath(const std::string& path);
|
extern bool makepath(const std::string& path);
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
/// Convert \ separators to /
|
|
||||||
extern void path_slashize(std::string& s);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Sub-directory for default recoll config (e.g: .recoll)
|
/// Sub-directory for default recoll config (e.g: .recoll)
|
||||||
extern std::string path_defaultrecollconfsubdir();
|
extern std::string path_defaultrecollconfsubdir();
|
||||||
/// Where we create the user data subdirs
|
/// Where we create the user data subdirs
|
||||||
|
|
|
@ -21,12 +21,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#include "safeunistd.h"
|
||||||
#include <windows.h>
|
|
||||||
static inline unsigned int sleep(unsigned int s) {Sleep(s * 1000); return 0;}
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "workqueue.h"
|
#include "workqueue.h"
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,7 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// MSVC #define-s open but also defines a function called open, so just undef
|
// MSVC #define-s open but also defines a function called open, so just undef
|
||||||
// the macro.
|
// the macro.
|
||||||
// Jf/recoll: don't do this, open() seems to be finally deprecated in vs 2015, we need _open(). Hopefully recoll has
|
# undef open
|
||||||
// no open() methods..
|
|
||||||
//# undef open
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
inline int fcntl_open_(const char *filename, int flags, mode_t mode) {
|
inline int fcntl_open_(const char *filename, int flags, mode_t mode) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue