1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-16 14:50:01 +00:00
Aquaria/ExternalLibs/ttvfs/VFSInternal.h

71 lines
1.7 KiB
C
Raw Normal View History

// VFSInternal.h - misc things that are not required to be visible outside of the library.
// For conditions of distribution and use, see copyright notice in VFS.h
// !! this file is supposed to be included ONLY from VFS*.cpp files.
#ifndef VFS_INTERNAL_H
#define VFS_INTERNAL_H
// checks to enforce correct including
#ifdef TTVFS_VFS_H
2014-04-06 17:19:33 +00:00
#error Oops, TTVFS_VFS_H is defined, someone messed up and included ttvfs.h wrongly.
#endif
#include "VFSDefines.h"
2014-04-07 02:16:15 +00:00
#if defined(VFS_LARGEFILE_SUPPORT)
# define _LARGEFILE_SOURCE
# define _LARGEFILE64_SOURCE
# define _FILE_OFFSET_BITS 64
#endif
#if _MSC_VER
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# endif
2014-04-07 02:16:15 +00:00
# ifndef _CRT_SECURE_NO_DEPRECATE
# define _CRT_SECURE_NO_DEPRECATE
2014-04-07 02:16:15 +00:00
# endif
#endif
2014-04-07 02:16:15 +00:00
// These are used for small, temporary memory allocations that can remain on the stack.
// If alloca is available, this is the preferred way.
#include <stdlib.h>
#ifdef _WIN32
# include <malloc.h> // MSVC/MinGW still need this for alloca. Seems to be windows-specific failure
#endif
2014-04-07 02:16:15 +00:00
#define VFS_STACK_ALLOC(size) alloca(size)
#define VFS_STACK_FREE(ptr) /* no need to free anything here */
// Fail-safe:
//#define VFS_STACK_ALLOC(size) malloc(size)
//#define VFS_STACK_FREE(ptr) free(ptr)
#include <string.h>
#include <string>
#include <assert.h>
VFS_NAMESPACE_START
2014-04-06 17:19:33 +00:00
template <typename DST, typename SRC> inline DST safecast(SRC p)
{
#ifndef NDEBUG
assert(!p || static_cast<DST>(p) == dynamic_cast<DST>(p));
#endif
return static_cast<DST>(p);
}
template <typename DST, typename SRC> inline DST safecastNonNull(SRC p)
{
#ifndef NDEBUG
assert(p && static_cast<DST>(p) == dynamic_cast<DST>(p));
#endif
return static_cast<DST>(p);
}
2014-04-07 02:16:15 +00:00
VFS_NAMESPACE_END
#endif