Fix portability to Visual C++

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 13 years ago
parent 1abaf69612
commit 0987522073
  1. 6
      Changelog
  2. 6
      configure.ac
  3. 2
      src/Makefile.am
  4. 20
      src/common.h
  5. 5
      src/getopt.c
  6. 2
      src/main.c
  7. 2
      src/sound.h
  8. 8
      src/win32/unistd.h
  9. 48
      src/win32/usleep.c
  10. 20
      vc/xmp.sln
  11. 245
      vc/xmp.vcproj

@ -1,6 +1,12 @@
Stable versions
---------------
4.0.6 (20130519):
- Portability fixes to build with Visual C++
Changes by Jan Engelhardt:
- Do not error out when g++ is absent on non-BEOS
4.0.5 (20130512):
- Fix loop when skipping to first file and it's not playable

@ -1,4 +1,4 @@
AC_INIT([xmp], [4.0.5])
AC_INIT([xmp], [4.0.6])
AC_CONFIG_AUX_DIR([build-aux])
0>confdefs.h
@ -67,7 +67,7 @@ AC_DEFUN([AC_CHECK_DEFINED],[
AS_VAR_POPDEF([ac_var])dnl
])
AC_CHECK_HEADERS([getopt.h signal.h termios.h])
AC_CHECK_HEADERS([getopt.h signal.h termios.h sys/time.h sys/audioio.h])
case "$host_cpu" in
powerpc64)
@ -76,8 +76,6 @@ powerpc64)
;;
esac
AC_CHECK_HEADERS(sys/audioio.h)
AM_CONDITIONAL([SOUND_AHI], [false])
AM_CONDITIONAL([SOUND_AIX], [false])
AM_CONDITIONAL([SOUND_ALSA05], [false])

@ -89,7 +89,7 @@ man_MANS = xmp.1
pkgsysconfdir = ${sysconfdir}/${PACKAGE_NAME}
pkgsysconf_DATA = modules.conf xmp.conf
EXTRA_DIST = ${man_MANS} ${pkgsysconf_DATA}
EXTRA_DIST = ${man_MANS} ${pkgsysconf_DATA} win32/usleep.c win32/unistd.h
# unused sources
EXTRA_DIST += sound_dart.c

@ -1,5 +1,19 @@
#ifndef __COMMON_H
#define __COMMON_H
#ifndef XMP_COMMON_H
#define XMP_COMMON_H
#ifdef _MSC_VER
#define PATH_MAX 1024
#define inline __inline
#define open _open
#define close _close
#define write _write
#define lseek _lseek
#define strdup _strdup
#define strcasecmp _stricmp
#define snprintf _snprintf
#define kbhit _kbhit
#define getch _getch
#endif
#define MAX_DRV_PARM 20
@ -35,7 +49,7 @@ struct options {
};
struct control {
long time; /* Replay time in ms */
double time; /* Replay time in ms */
int skip; /* Skip to next module */
int loop; /* Module is looped */
int pause; /* Replay paused */

@ -218,7 +218,8 @@ static char *posixly_correct;
/* Avoid depending on library functions or files
whose names are inconsistent. */
char *getenv ();
/* char *getenv (); */
#include <stdlib.h>
static char *
my_index (str, chr)
@ -370,7 +371,7 @@ _getopt_initialize (argc, argv, optstring)
nextchar = NULL;
posixly_correct = getenv ("POSIXLY_CORRECT");
posixly_correct getenv ("POSIXLY_CORRECT");
/* Determine how to handle the ordering of options and nonoptions. */

@ -12,7 +12,9 @@
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <unistd.h>
#include <stdarg.h>

@ -25,7 +25,7 @@ struct sound_driver {
#define parm_end() } }
#define parm_error() do { \
fprintf(stderr, "xmp: incorrect parameters in -D %s\n", s); \
exit(-4); } while (0)
exit(4); } while (0)
#define chkparm0(x,y) { \
if (!strcmp(s, x)) { \
if (token != NULL) parm_error(); else { y; } } }

@ -0,0 +1,8 @@
#ifndef _XMP_WIN32_UNISTD_H
#define _XMP_WIN32_UNISTD_H
#include <io.h>
void usleep(long usec);
#endif

@ -0,0 +1,48 @@
#ifndef HAVE_USLEEP
#ifdef HAVE_SELECT
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#else
# include <sys/time.h>
# include <sys/types.h>
# include <unistd.h>
#endif
void usleep(long usec)
{
struct timeval tv;
tv.tv_sec = usec / 1000000;
tv.tv_usec = usec % 1000000;
select(0, NULL, NULL, NULL, &tv);
}
#elif defined WIN32
/* usleep implementation from FreeSCI */
#include <windows.h>
void usleep (long usec)
{
LARGE_INTEGER lFrequency;
LARGE_INTEGER lEndTime;
LARGE_INTEGER lCurTime;
QueryPerformanceFrequency (&lFrequency);
if (lFrequency.QuadPart) {
QueryPerformanceCounter (&lEndTime);
lEndTime.QuadPart += (LONGLONG) usec *
lFrequency.QuadPart / 1000000;
do {
QueryPerformanceCounter (&lCurTime);
Sleep(0);
} while (lCurTime.QuadPart < lEndTime.QuadPart);
}
}
#endif
#endif /* !HAVE_USLEEP */

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xmp", "xmp.vcproj", "{A25F83C3-6C57-4DD7-939E-3F4F44F22345}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A25F83C3-6C57-4DD7-939E-3F4F44F22345}.Debug|Win32.ActiveCfg = Debug|Win32
{A25F83C3-6C57-4DD7-939E-3F4F44F22345}.Debug|Win32.Build.0 = Debug|Win32
{A25F83C3-6C57-4DD7-939E-3F4F44F22345}.Release|Win32.ActiveCfg = Release|Win32
{A25F83C3-6C57-4DD7-939E-3F4F44F22345}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,245 @@
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="xmp"
ProjectGUID="{A25F83C3-6C57-4DD7-939E-3F4F44F22345}"
Keyword="Win32Proj"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;VERSION=\&quot;4.0.6\&quot;;SOUND_WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\src;..\src\win32"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;VERSION=\&quot;4.0.6\&quot;;SOUND_WIN32"
ExceptionHandling="0"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="false"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libxmp.lib Winmm.lib"
LinkIncremental="2"
GenerateDebugInformation="false"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\src\commands.c"
>
</File>
<File
RelativePath="..\src\getopt.c"
>
</File>
<File
RelativePath="..\src\getopt1.c"
>
</File>
<File
RelativePath="..\src\info.c"
>
</File>
<File
RelativePath="..\src\main.c"
>
</File>
<File
RelativePath="..\src\options.c"
>
</File>
<File
RelativePath="..\src\read_config.c"
>
</File>
<File
RelativePath="..\src\sound.c"
>
</File>
<File
RelativePath="..\src\sound_file.c"
>
</File>
<File
RelativePath="..\src\sound_null.c"
>
</File>
<File
RelativePath="..\src\sound_wav.c"
>
</File>
<File
RelativePath="..\src\sound_win32.c"
>
</File>
<File
RelativePath="..\src\terminal.c"
>
</File>
<File
RelativePath="..\src\win32\usleep.c"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
Loading…
Cancel
Save