<commit_before>/*
 * host.go
 *
 * Copyright 2017 <NAME>
 */
/*
 * This file is part of Cgofuse.
 *
 * It is licensed under the MIT license. The full license text can be found
 * in the License.txt file at the root of this project.
 */

package fuse

/*
#cgo darwin CFLAGS: -DFUSE_USE_VERSION=28 -D_FILE_OFFSET_BITS=64 -I/usr/local/include/osxfuse/fuse
#cgo darwin LDFLAGS: -L/usr/local/lib -losxfuse
#cgo linux CFLAGS: -DFUSE_USE_VERSION=28 -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse
#cgo linux LDFLAGS: -lfuse
#cgo windows CFLAGS: -D_WIN32_WINNT=0x0600 -DFUSE_USE_VERSION=28

#if !(defined(__APPLE__) || defined(__linux__) || defined(_WIN32))
#error platform not supported
#endif

#include <stdlib.h>
#include <string.h>

#if defined(__APPLE__) || defined(__linux__)

#include <spawn.h>
#include <sys/mount.h>
#include <sys/wait.h>
#include <fuse.h>

#elif defined(_WIN32)

#include <windows.h>

static PVOID cgofuse_init_winfsp(VOID);
static PVOID cgofuse_init_fail();
static inline VOID cgofuse_init(VOID)
{
	static SRWLOCK Lock = SRWLOCK_INIT;
	static PVOID Module = 0;
	AcquireSRWLockExclusive(&Lock);
	if (0 == Module)
		Module = cgofuse_init_winfsp();
	ReleaseSRWLockExclusive(&Lock);
}

#define FSP_FUSE_API                    static
#define FSP_FUSE_API_NAME(api)          (* pfn_ ## api)
#define FSP_FUSE_API_CALL(api)          (cgofuse_init(), pfn_ ## api)
#define FSP_FUSE_SYM(proto, ...)        static inline proto { __VA_ARGS__ }
//#include <fuse_common.h>
#include <fuse.h>
//#include <fuse_opt.h>

static inline NTSTATUS FspLoad(PVOID *PModule)
{<commit_msg>host: improve cgofuse_init for windows<commit_after>/*
 * host.go
 *
 * Copyright 2017 <NAME>
 */
/*
 * This file is part of Cgofuse.
 *
 * It is licensed under the MIT license. The full license text can be found
 * in the License.txt file at the root of this project.
 */

package fuse

/*
#cgo darwin CFLAGS: -DFUSE_USE_VERSION=28 -D_FILE_OFFSET_BITS=64 -I/usr/local/include/osxfuse/fuse
#cgo darwin LDFLAGS: -L/usr/local/lib -losxfuse
#cgo linux CFLAGS: -DFUSE_USE_VERSION=28 -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse
#cgo linux LDFLAGS: -lfuse
#cgo windows CFLAGS: -D_WIN32_WINNT=0x0600 -DFUSE_USE_VERSION=28

#if !(defined(__APPLE__) || defined(__linux__) || defined(_WIN32))
#error platform not supported
#endif

#include <stdlib.h>
#include <string.h>

#if defined(__APPLE__) || defined(__linux__)

#include <spawn.h>
#include <sys/mount.h>
#include <sys/wait.h>
#include <fuse.h>

#elif defined(_WIN32)

#include <windows.h>

static PVOID cgofuse_init_winfsp(VOID);
static PVOID cgofuse_init_fail();
static inline VOID cgofuse_init(VOID)
{
	static SRWLOCK Lock = SRWLOCK_INIT;
	static PVOID _Module = 0;
	PVOID Module = _Module;
	MemoryBarrier();
	if (0 == Module)
	{
		AcquireSRWLockExclusive(&Lock);
		Module = _Module;
		if (0 == Module)
		{
			Module = cgofuse_init_winfsp();
			MemoryBarrier();
			_Module = Module;
		}
		ReleaseSRWLockExclusive(&Lock);
	}
}

#define FSP_FUSE_API                    static
#define FSP_FUSE_API_NAME(api)          (* pfn_ ## api)
#define FSP_FUSE_API_CALL(api)          (cgofuse_init(), pfn_ ## api)
#define FSP_FUSE_SYM(proto, ...)        static inline proto { __VA_ARGS__ }
#include <fuse_common.h>
#include <fuse.h>
#include <fuse_opt.h>

static NTSTATUS FspLoad(PVOID *PModule)
{
{'fraction_non_alphanumeric': 0.12556732223903178, 'fraction_numerical': 0.01664145234493192, 'mean_word_length': 4.2727272727272725, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6664259', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1271, 'n_words': 305}