dxx-rebirth/common/misc/vg-wrap-physfs.h
Kp 8ccf0e5301 Add PHYSFS_read wrapper support
- Add wrappers for PHYSFS_read and its convenience functions.  Poison
  the memory before calling PHYSFS, so that any uninitialized bytes
  (likely caused by a short read) are reported if the caller tries to
  access the value anyway.
- Add SConstruct options to enable wrapping, so that users do not need
  to enumerate the wrapped functions manually.
- Fix link failure when using LTO+wrappers.
2017-07-26 03:15:58 +00:00

63 lines
1.8 KiB
C

#include "dxxsconf.h"
#ifndef DXX_ENABLE_wrap_PHYSFS_read
#define DXX_ENABLE_wrap_PHYSFS_read DXX_HAVE_POISON_VALGRIND
#endif
#ifndef DXX_ENABLE_wrap_PHYSFS_write
#define DXX_ENABLE_wrap_PHYSFS_write DXX_HAVE_POISON_VALGRIND
#endif
#if DXX_ENABLE_wrap_PHYSFS_read || DXX_ENABLE_wrap_PHYSFS_write
#include <physfs.h>
#ifdef DXX_VG_DECLARE_EXTERN_C
extern "C" {
#if DXX_ENABLE_wrap_PHYSFS_read
DXX_VG_DECLARE_EXTERN_C(PHYSFS_read);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_readSBE16);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_readSBE32);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_readSLE16);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_readSLE32);
#endif
#if DXX_ENABLE_wrap_PHYSFS_write
DXX_VG_DECLARE_EXTERN_C(PHYSFS_write);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_writeSBE16);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_writeSBE32);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_writeSLE16);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_writeSLE32);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_writeULE16);
DXX_VG_DECLARE_EXTERN_C(PHYSFS_writeULE32);
#endif
}
#endif
#if DXX_ENABLE_wrap_PHYSFS_read
#ifdef DXX_VG_DECLARE_READ_HELPER
DXX_VG_DECLARE_READ_HELPER;
#endif
#ifdef DXX_VG_DEFINE_READ
DXX_VG_DEFINE_READ(PHYSFS_readSBE16, PHYSFS_sint16);
DXX_VG_DEFINE_READ(PHYSFS_readSBE32, PHYSFS_sint32);
DXX_VG_DEFINE_READ(PHYSFS_readSLE16, PHYSFS_sint16);
DXX_VG_DEFINE_READ(PHYSFS_readSLE32, PHYSFS_sint32);
#endif
#endif
#if DXX_ENABLE_wrap_PHYSFS_write
#ifdef DXX_VG_DECLARE_WRITE_HELPER
DXX_VG_DECLARE_WRITE_HELPER;
#endif
#ifdef DXX_VG_DEFINE_WRITE
DXX_VG_DEFINE_WRITE(PHYSFS_writeSBE16, PHYSFS_sint16);
DXX_VG_DEFINE_WRITE(PHYSFS_writeSBE32, PHYSFS_sint32);
DXX_VG_DEFINE_WRITE(PHYSFS_writeSLE16, PHYSFS_sint16);
DXX_VG_DEFINE_WRITE(PHYSFS_writeSLE32, PHYSFS_sint32);
DXX_VG_DEFINE_WRITE(PHYSFS_writeULE16, PHYSFS_uint16);
DXX_VG_DEFINE_WRITE(PHYSFS_writeULE32, PHYSFS_uint32);
#endif
#endif
#endif