Merge branch 'master' of https://github.com/cnlohr/colorchord
This commit is contained in:
commit
8830b99454
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
colorchord2/windows/colorchord.def
|
||||
colorchord2/colorchord.def
|
|
@ -9,7 +9,6 @@
|
|||
#include "hidapi.h"
|
||||
#include "color.h"
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct HIDAPIOutDriver
|
||||
{
|
||||
|
@ -58,7 +57,7 @@ static void * LEDOutThread( void * v )
|
|||
}
|
||||
led->readyFlag = 0;
|
||||
}
|
||||
usleep(100);
|
||||
OGUSleep(100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -86,7 +85,7 @@ static void LEDUpdate(void * id, struct NoteFinder*nf)
|
|||
int leds_this_round = 0;
|
||||
int ledbid = 0;
|
||||
|
||||
while( led->readyFlag ) usleep(100);
|
||||
while( led->readyFlag ) OGUSleep(100);
|
||||
|
||||
int lastledplace = 1;
|
||||
led->last_leds[0] = 0;
|
||||
|
|
|
@ -9,10 +9,12 @@
|
|||
#include <string.h>
|
||||
#include "color.h"
|
||||
#include "DrawFunctions.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) || defined(WINDOWS)
|
||||
#include <windows.h>
|
||||
#ifdef TCC
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#define MSG_NOSIGNAL 0
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "color.h"
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern float DeltaFrameTime;
|
||||
extern double Now;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "color.h"
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct LEDOutDriver
|
||||
{
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "color.h"
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct ProminentDriver
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ play = 0
|
|||
rec = 1
|
||||
channels = 2
|
||||
samplerate = 44100
|
||||
wininput = 0
|
||||
wininput = 1
|
||||
|
||||
#Compiled version will default this.
|
||||
#sound_source = ALSA
|
||||
|
|
|
@ -420,7 +420,9 @@ uint16_t Sdatspace[FIXBINS*4]; //(advances,places,isses,icses)
|
|||
static uint8_t Sdo_this_octave[BINCYCLE];
|
||||
static int16_t Saccum_octavebins[OCTAVES];
|
||||
static uint8_t Swhichoctaveplace;
|
||||
#ifndef INCLUDING_EMBEDDED
|
||||
uint16_t embeddedbins[FIXBINS]; //This is updated every time the DFT hits the octavecount, or 1/32 updates.
|
||||
#endif
|
||||
|
||||
//From: http://stackoverflow.com/questions/1100090/looking-for-an-efficient-integer-square-root-algorithm-for-arm-thumb2
|
||||
/**
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
#include "parameters.h"
|
||||
#include "hook.h"
|
||||
#include "configs.h"
|
||||
#include <winsock2.h>
|
||||
|
||||
struct SoundDriver * sd;
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) || defined(USE_WINDOWS)
|
||||
#include <windows.h>
|
||||
|
||||
#define ESCAPE_KEY 0x1B
|
||||
|
@ -41,8 +42,8 @@ double Now = 0;
|
|||
|
||||
int lastfps;
|
||||
short screenx, screeny;
|
||||
struct DriverInstances * outdriver[MAX_OUT_DRIVERS];
|
||||
|
||||
struct DriverInstances * outdriver[MAX_OUT_DRIVERS];
|
||||
|
||||
int headless = 0; REGISTER_PARAM( headless, PAINT );
|
||||
int set_screenx = 640; REGISTER_PARAM( set_screenx, PAINT );
|
||||
|
@ -159,18 +160,19 @@ void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct Soun
|
|||
*samplesp = samplesr;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef TCC
|
||||
ManuallyRegisterDevices();
|
||||
#endif
|
||||
|
||||
printf( "Output Drivers:\n" );
|
||||
for( i = 0; i < MAX_OUT_DRIVERS; i++ )
|
||||
{
|
||||
if( ODList[i].Name ) printf( "\t%s\n", ODList[i].Name );
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) || defined(USE_WINDOWS)
|
||||
WSADATA wsaData;
|
||||
|
||||
WSAStartup(0x202, &wsaData);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "os_generic.h"
|
||||
|
||||
|
||||
#ifdef USE_WINDOWS
|
||||
|
||||
#include <windows.h>
|
||||
|
@ -49,15 +48,16 @@ double OGGetFileTime( const char * file )
|
|||
}
|
||||
|
||||
|
||||
og_thread_t OGCreateThread( void * (function)( void * ), void * parameter )
|
||||
og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter )
|
||||
{
|
||||
return (og_thread_t)CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)function, parameter, 0, 0 );
|
||||
return (og_thread_t)CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)routine, parameter, 0, 0 );
|
||||
}
|
||||
|
||||
void * OGJoinThread( og_thread_t ot )
|
||||
{
|
||||
WaitForSingleObject( ot, INFINITE );
|
||||
CloseHandle( ot );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OGCancelThread( og_thread_t ot )
|
||||
|
@ -93,28 +93,23 @@ og_sema_t OGCreateSema()
|
|||
return (og_sema_t)sem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef LONG NTSTATUS;
|
||||
|
||||
typedef NTSTATUS (NTAPI *_NtQuerySemaphore)(
|
||||
HANDLE SemaphoreHandle,
|
||||
DWORD SemaphoreInformationClass, /* Would be SEMAPHORE_INFORMATION_CLASS */
|
||||
PVOID SemaphoreInformation, /* but this is to much to dump here */
|
||||
ULONG SemaphoreInformationLength,
|
||||
PULONG ReturnLength OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
typedef struct _SEMAPHORE_BASIC_INFORMATION {
|
||||
ULONG CurrentCount;
|
||||
ULONG MaximumCount;
|
||||
} SEMAPHORE_BASIC_INFORMATION;
|
||||
|
||||
|
||||
int OGGetSema( og_sema_t os )
|
||||
{
|
||||
typedef LONG NTSTATUS;
|
||||
HANDLE sem = (HANDLE)os;
|
||||
typedef NTSTATUS (NTAPI *_NtQuerySemaphore)(
|
||||
HANDLE SemaphoreHandle,
|
||||
DWORD SemaphoreInformationClass, /* Would be SEMAPHORE_INFORMATION_CLASS */
|
||||
PVOID SemaphoreInformation, /* but this is to much to dump here */
|
||||
ULONG SemaphoreInformationLength,
|
||||
PULONG ReturnLength OPTIONAL
|
||||
);
|
||||
|
||||
typedef struct _SEMAPHORE_BASIC_INFORMATION {
|
||||
ULONG CurrentCount;
|
||||
ULONG MaximumCount;
|
||||
} SEMAPHORE_BASIC_INFORMATION;
|
||||
|
||||
|
||||
static _NtQuerySemaphore NtQuerySemaphore;
|
||||
SEMAPHORE_BASIC_INFORMATION BasicInfo;
|
||||
|
@ -158,9 +153,8 @@ void OGDeleteSema( og_sema_t os )
|
|||
|
||||
#else
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
//Copyright 2015 <>< Charles Lohr under the NewBSD or MIT/x11 License.
|
||||
|
||||
#ifndef _OS_GENERIC_H
|
||||
#define _OS_GENERIC_H
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined( WIN32 ) || defined (WINDOWS) || defined( _WIN32)
|
||||
#define USE_WINDOWS
|
||||
#endif
|
||||
|
||||
|
@ -12,12 +11,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define EXECUTE_AT_BOOT( x, y ) \
|
||||
\
|
||||
void fn##x() __attribute__((constructor)); \
|
||||
void fn##x() \
|
||||
{ y; } \
|
||||
|
||||
|
||||
//Things that shouldn't be macro'd
|
||||
double OGGetAbsoluteTime();
|
||||
void OGSleep( int is );
|
||||
|
@ -55,7 +49,7 @@ void OGDeleteSema( og_sema_t os );
|
|||
#endif
|
||||
|
||||
|
||||
//Date Stamp: 2014-06-12
|
||||
//Date Stamp: 2012-02-15
|
||||
|
||||
/*
|
||||
NOTE: Portions (namely the top section) are part of headers from other
|
||||
|
|
|
@ -41,6 +41,6 @@ struct DriverInstances * SetupOutDriver( );
|
|||
void RegOutDriver( const char * ron, struct DriverInstances * (*Init)( ) );
|
||||
|
||||
#define REGISTER_OUT_DRIVER( name ) \
|
||||
EXECUTE_AT_BOOT( r##name, RegOutDriver( #name, name ) );
|
||||
void REGISTER##name() __attribute__((constructor)) { RegOutDriver( #name, name ); }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -58,8 +58,7 @@ void SetParametersFromString( const char * string );
|
|||
void AddCallback( const char * name, ParamCallbackT t, void * v );
|
||||
|
||||
#define REGISTER_PARAM( parameter_name, type ) \
|
||||
void Register##parameter_name() __attribute__((constructor)); \
|
||||
void Register##parameter_name() { RegisterValue( #parameter_name, type, ¶meter_name, sizeof( parameter_name ) ); }
|
||||
void REGISTER##parameter_name() __attribute__((constructor)) { RegisterValue( #parameter_name, type, ¶meter_name, sizeof( parameter_name ) ); }
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -55,7 +55,6 @@ struct SoundDriver * InitSound( const char * driver_name, SoundCBType cb )
|
|||
{
|
||||
int i;
|
||||
struct SoundDriver * ret = 0;
|
||||
|
||||
if( driver_name == 0 || strlen( driver_name ) == 0 )
|
||||
{
|
||||
//Search for a driver.
|
||||
|
@ -74,6 +73,7 @@ struct SoundDriver * InitSound( const char * driver_name, SoundCBType cb )
|
|||
}
|
||||
else
|
||||
{
|
||||
printf( "Initializing sound. Recommended driver: %s\n", driver_name );
|
||||
for( i = 0; i < MAX_SOUND_DRIVERS; i++ )
|
||||
{
|
||||
if( SoundDrivers[i] == 0 )
|
||||
|
|
|
@ -34,5 +34,8 @@ void CloseSound( struct SoundDriver * soundobject );
|
|||
//Called by various sound drivers. Notice priority must be greater than 0. Priority of 0 or less will not register.
|
||||
void RegSound( int priority, const char * name, SoundInitFn * fn );
|
||||
|
||||
#define REGISTER_SOUND( sounddriver, priority, name, function ) \
|
||||
void REGISTER##sounddriver() __attribute__((constructor)) { RegSound( priority, name, function ); }
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -337,5 +337,5 @@ void * InitSoundAlsa( SoundCBType cb )
|
|||
return InitASound(r);
|
||||
}
|
||||
|
||||
EXECUTE_AT_BOOT( AlsaSoundReg, RegSound( 10, "ALSA", InitSoundAlsa ) );
|
||||
REGISTER_SOUND( AlsaSound, 10, "ALSA", InitSoundAlsa );
|
||||
|
||||
|
|
|
@ -41,6 +41,5 @@ void * InitSoundNull( SoundCBType cb )
|
|||
}
|
||||
|
||||
|
||||
|
||||
EXECUTE_AT_BOOT( NullSoundReg, RegSound( 1, "NULL", InitSoundNull ) );
|
||||
REGISTER_SOUND( NullSound, 1, "NULL", InitSoundNull );
|
||||
|
||||
|
|
|
@ -374,6 +374,6 @@ fail:
|
|||
|
||||
|
||||
|
||||
EXECUTE_AT_BOOT( PulseSoundReg, RegSound( 11, "PULSE", InitSoundPulse ) );
|
||||
REGISTER_SOUND( PulseSound, 11, "PULSE", InitSoundPulse );
|
||||
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include "parameters.h"
|
||||
#include "sound.h"
|
||||
#include "os_generic.h"
|
||||
#include <mmsystem.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
#if defined(WIN32)
|
||||
#pragma comment(lib,"winmm.lib")
|
||||
|
@ -106,7 +106,8 @@ static struct SoundDriverWin * InitWinSound( struct SoundDriverWin * r )
|
|||
{
|
||||
int i;
|
||||
WAVEFORMATEX wfmt;
|
||||
|
||||
memset( &wfmt, 0, sizeof(wfmt) );
|
||||
printf ("WFMT Size (debugging temp for TCC): %d\n", sizeof(wfmt) );
|
||||
if( GetParameterI( "play", 0 ) )
|
||||
{
|
||||
fprintf( stderr, "Error: This Windows Sound Driver does not support playback.\n" );
|
||||
|
@ -136,7 +137,7 @@ static struct SoundDriverWin * InitWinSound( struct SoundDriverWin * r )
|
|||
|
||||
int p = waveInOpen(&r->hMyWave, dwdevice, &wfmt,(DWORD)(void*)(&HANDLEMIC) , 0, CALLBACK_FUNCTION);
|
||||
|
||||
printf( "WIO: %d\n", p ); //On real windows, returns 11
|
||||
printf( "WIO: %d\n", p );
|
||||
|
||||
for ( i=0;i<BUFFS;i++)
|
||||
{
|
||||
|
@ -150,7 +151,7 @@ static struct SoundDriverWin * InitWinSound( struct SoundDriverWin * r )
|
|||
|
||||
p = waveInStart(r->hMyWave);
|
||||
|
||||
printf( "WIS: %d\n", p ); //On real windows returns 5.
|
||||
printf( "WIS: %d\n", p );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -159,7 +160,7 @@ static struct SoundDriverWin * InitWinSound( struct SoundDriverWin * r )
|
|||
|
||||
void * InitSoundWin( SoundCBType cb )
|
||||
{
|
||||
struct SoundDriverWin * r = malloc( sizeof( struct SoundDriverWin ) );
|
||||
struct SoundDriverWin * r = (struct SoundDriverWin *)malloc( sizeof( struct SoundDriverWin ) );
|
||||
|
||||
r->CloseFn = CloseSoundWin;
|
||||
r->SoundStateFn = SoundStateWin;
|
||||
|
@ -177,5 +178,5 @@ void * InitSoundWin( SoundCBType cb )
|
|||
return InitWinSound(r);
|
||||
}
|
||||
|
||||
EXECUTE_AT_BOOT( WinSoundReg, RegSound( 10, "WIN", InitSoundWin ) );
|
||||
REGISTER_SOUND( SoundWin, 10, "WIN", InitSoundWin );
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
//This file may be used in whole or part in any way for any purpose by anyone
|
||||
//without restriction.
|
||||
|
||||
#include "util.h"
|
||||
#include <math.h>
|
||||
#include "util.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
//Take the absolute distance between two points on a torus.
|
||||
|
|
BIN
colorchord2/windows/32/WS2_32.Lib
Normal file
BIN
colorchord2/windows/32/WS2_32.Lib
Normal file
Binary file not shown.
BIN
colorchord2/windows/32/WinMM.Lib
Normal file
BIN
colorchord2/windows/32/WinMM.Lib
Normal file
Binary file not shown.
BIN
colorchord2/windows/64/WS2_32.Lib
Normal file
BIN
colorchord2/windows/64/WS2_32.Lib
Normal file
Binary file not shown.
BIN
colorchord2/windows/64/WinMM.Lib
Normal file
BIN
colorchord2/windows/64/WinMM.Lib
Normal file
Binary file not shown.
8
colorchord2/windows/compile.bat
Normal file
8
colorchord2/windows/compile.bat
Normal file
|
@ -0,0 +1,8 @@
|
|||
@echo off
|
||||
echo Unzip https://download.savannah.gnu.org/releases/tinycc/tcc-0.9.26-win64-bin.zip to C:\tcc
|
||||
set CFLAGS=-v -DHIDAPI -DWINDOWS -DWIN32 -DTCC -DRUNTIME_SYMNUM -Os -Itccinc -DINCLUDING_EMBEDDED -I.. -I. -I../../embeddedcommon -rdynamic -g
|
||||
set LDFLAGS=-lkernel32 -lgdi32 -luser32 -lsetupapi -ldbghelp -ltcc1 -lwinmm -lws2_32
|
||||
set SOURCES=..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.c ..\DisplayNetwork.c ..\DisplayArray.c ..\DisplayHIDAPI.c ..\DisplayOUTDriver.c ..\DisplayPie.c ..\DrawFunctions.c ..\filter.c ..\hidapi.c ..\hook.c ..\main.c ..\os_generic.c ..\outdrivers.c ..\OutputCells.c ..\OutputLinear.c ..\OutputProminent.c ..\OutputVoronoi.c ..\parameters.c ..\sound.c ..\sound_win.c ..\sound_null.c ..\util.c ..\WinDriver.c ..\notefinder.c ..\..\embeddedcommon\DFT32.c tcc_stubs.c symbol_enumerator.c
|
||||
set ARCH_SPECIFIC=-L32
|
||||
@echo on
|
||||
C:\tcc\tcc %CFLAGS% %ARCH_SPECIFIC% %SOURCES% %LDFLAGS% -o ..\colorchord.exe
|
926
colorchord2/windows/math.h
Normal file
926
colorchord2/windows/math.h
Normal file
|
@ -0,0 +1,926 @@
|
|||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
#ifndef _MATH_H_
|
||||
#define _MATH_H_
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <_mingw.h>
|
||||
|
||||
struct exception;
|
||||
|
||||
#pragma pack(push,_CRT_PACKING)
|
||||
|
||||
#define _DOMAIN 1
|
||||
#define _SING 2
|
||||
#define _OVERFLOW 3
|
||||
#define _UNDERFLOW 4
|
||||
#define _TLOSS 5
|
||||
#define _PLOSS 6
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#ifndef NO_OLDNAMES
|
||||
#define DOMAIN _DOMAIN
|
||||
#define SING _SING
|
||||
#define OVERFLOW _OVERFLOW
|
||||
#define UNDERFLOW _UNDERFLOW
|
||||
#define TLOSS _TLOSS
|
||||
#define PLOSS _PLOSS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#define M_E 2.71828182845904523536
|
||||
#define M_LOG2E 1.44269504088896340736
|
||||
#define M_LOG10E 0.434294481903251827651
|
||||
#define M_LN2 0.693147180559945309417
|
||||
#define M_LN10 2.30258509299404568402
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#define M_PI_4 0.785398163397448309616
|
||||
#define M_1_PI 0.318309886183790671538
|
||||
#define M_2_PI 0.636619772367581343076
|
||||
#define M_2_SQRTPI 1.12837916709551257390
|
||||
#define M_SQRT2 1.41421356237309504880
|
||||
#define M_SQRT1_2 0.707106781186547524401
|
||||
#endif
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
/* See also float.h */
|
||||
#ifndef __MINGW_FPCLASS_DEFINED
|
||||
#define __MINGW_FPCLASS_DEFINED 1
|
||||
#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
|
||||
#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
|
||||
#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
|
||||
#define _FPCLASS_NN 0x0008 /* Negative Normal */
|
||||
#define _FPCLASS_ND 0x0010 /* Negative Denormal */
|
||||
#define _FPCLASS_NZ 0x0020 /* Negative Zero */
|
||||
#define _FPCLASS_PZ 0x0040 /* Positive Zero */
|
||||
#define _FPCLASS_PD 0x0080 /* Positive Denormal */
|
||||
#define _FPCLASS_PN 0x0100 /* Positive Normal */
|
||||
#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _EXCEPTION_DEFINED
|
||||
#define _EXCEPTION_DEFINED
|
||||
struct _exception {
|
||||
int type;
|
||||
char *name;
|
||||
double arg1;
|
||||
double arg2;
|
||||
double retval;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef _COMPLEX_DEFINED
|
||||
#define _COMPLEX_DEFINED
|
||||
struct _complex {
|
||||
double x,y;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define EDOM 33
|
||||
#define ERANGE 34
|
||||
|
||||
#ifndef _HUGE
|
||||
#ifdef _MSVCRT_
|
||||
extern double *_HUGE;
|
||||
#else
|
||||
extern double *_imp___HUGE;
|
||||
#define _HUGE (*_imp___HUGE)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define HUGE_VAL _HUGE
|
||||
|
||||
#ifndef _CRT_ABS_DEFINED
|
||||
#define _CRT_ABS_DEFINED
|
||||
int __cdecl abs(int _X);
|
||||
long __cdecl labs(long _X);
|
||||
#endif
|
||||
double __cdecl acos(double _X);
|
||||
double __cdecl asin(double _X);
|
||||
double __cdecl atan(double _X);
|
||||
double __cdecl atan2(double _Y,double _X);
|
||||
#ifndef _SIGN_DEFINED
|
||||
#define _SIGN_DEFINED
|
||||
_CRTIMP double __cdecl _copysign (double _Number,double _Sign);
|
||||
_CRTIMP double __cdecl _chgsign (double _X);
|
||||
#endif
|
||||
double __cdecl cos(double _X);
|
||||
double __cdecl cosh(double _X);
|
||||
double __cdecl exp(double _X);
|
||||
double __cdecl expm1(double _X);
|
||||
double __cdecl fabs(double _X);
|
||||
double __cdecl fmod(double _X,double _Y);
|
||||
double __cdecl log(double _X);
|
||||
double __cdecl log10(double _X);
|
||||
double __cdecl pow(double _X,double _Y);
|
||||
double __cdecl sin(double _X);
|
||||
double __cdecl sinh(double _X);
|
||||
double __cdecl tan(double _X);
|
||||
double __cdecl tanh(double _X);
|
||||
double __cdecl sqrt(double _X);
|
||||
#ifndef _CRT_ATOF_DEFINED
|
||||
#define _CRT_ATOF_DEFINED
|
||||
double __cdecl atof(const char *_String);
|
||||
double __cdecl _atof_l(const char *_String,_locale_t _Locale);
|
||||
#endif
|
||||
|
||||
_CRTIMP double __cdecl _cabs(struct _complex _ComplexA);
|
||||
double __cdecl ceil(double _X);
|
||||
double __cdecl floor(double _X);
|
||||
double __cdecl frexp(double _X,int *_Y);
|
||||
double __cdecl _hypot(double _X,double _Y);
|
||||
_CRTIMP double __cdecl _j0(double _X);
|
||||
_CRTIMP double __cdecl _j1(double _X);
|
||||
_CRTIMP double __cdecl _jn(int _X,double _Y);
|
||||
double __cdecl ldexp(double _X,int _Y);
|
||||
#ifndef _CRT_MATHERR_DEFINED
|
||||
#define _CRT_MATHERR_DEFINED
|
||||
int __cdecl _matherr(struct _exception *_Except);
|
||||
#endif
|
||||
double __cdecl modf(double _X,double *_Y);
|
||||
_CRTIMP double __cdecl _y0(double _X);
|
||||
_CRTIMP double __cdecl _y1(double _X);
|
||||
_CRTIMP double __cdecl _yn(int _X,double _Y);
|
||||
|
||||
#if(defined(_X86_) && !defined(__x86_64))
|
||||
_CRTIMP int __cdecl _set_SSE2_enable(int _Flag);
|
||||
/* from libmingwex */
|
||||
float __cdecl _hypotf(float _X,float _Y);
|
||||
#endif
|
||||
|
||||
float frexpf(float _X,int *_Y);
|
||||
float __cdecl ldexpf(float _X,int _Y);
|
||||
long double __cdecl ldexpl(long double _X,int _Y);
|
||||
float __cdecl acosf(float _X);
|
||||
float __cdecl asinf(float _X);
|
||||
float __cdecl atanf(float _X);
|
||||
float __cdecl atan2f(float _X,float _Y);
|
||||
float __cdecl cosf(float _X);
|
||||
float __cdecl sinf(float _X);
|
||||
float __cdecl tanf(float _X);
|
||||
float __cdecl coshf(float _X);
|
||||
float __cdecl sinhf(float _X);
|
||||
float __cdecl tanhf(float _X);
|
||||
float __cdecl expf(float _X);
|
||||
float __cdecl expm1f(float _X);
|
||||
float __cdecl logf(float _X);
|
||||
float __cdecl log10f(float _X);
|
||||
float __cdecl modff(float _X,float *_Y);
|
||||
float __cdecl powf(float _X,float _Y);
|
||||
float __cdecl sqrtf(float _X);
|
||||
float __cdecl ceilf(float _X);
|
||||
float __cdecl floorf(float _X);
|
||||
float __cdecl fmodf(float _X,float _Y);
|
||||
float __cdecl _hypotf(float _X,float _Y);
|
||||
float __cdecl fabsf(float _X);
|
||||
#if !defined(__ia64__)
|
||||
/* from libmingwex */
|
||||
float __cdecl _copysignf (float _Number,float _Sign);
|
||||
float __cdecl _chgsignf (float _X);
|
||||
float __cdecl _logbf(float _X);
|
||||
float __cdecl _nextafterf(float _X,float _Y);
|
||||
int __cdecl _finitef(float _X);
|
||||
int __cdecl _isnanf(float _X);
|
||||
int __cdecl _fpclassf(float _X);
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
__CRT_INLINE long double __cdecl fabsl (long double x)
|
||||
{
|
||||
long double res;
|
||||
__asm__ ("fabs;" : "=t" (res) : "0" (x));
|
||||
return res;
|
||||
}
|
||||
#define _hypotl(x,y) ((long double)_hypot((double)(x),(double)(y)))
|
||||
#define _matherrl _matherr
|
||||
__CRT_INLINE long double _chgsignl(long double _Number) { return _chgsign((double)(_Number)); }
|
||||
__CRT_INLINE long double _copysignl(long double _Number,long double _Sign) { return _copysign((double)(_Number),(double)(_Sign)); }
|
||||
__CRT_INLINE float frexpf(float _X,int *_Y) { return ((float)frexp((double)_X,_Y)); }
|
||||
|
||||
#if !defined (__ia64__)
|
||||
__CRT_INLINE float __cdecl fabsf (float x)
|
||||
{
|
||||
return fabs(x);
|
||||
}
|
||||
|
||||
__CRT_INLINE float __cdecl ldexpf (float x, int expn) { return (float) ldexp (x, expn); }
|
||||
#endif
|
||||
#else
|
||||
// cplusplus
|
||||
__CRT_INLINE long double __cdecl fabsl (long double x)
|
||||
{
|
||||
long double res;
|
||||
__asm__ ("fabs;" : "=t" (res) : "0" (x));
|
||||
return res;
|
||||
}
|
||||
__CRT_INLINE long double modfl(long double _X,long double *_Y) {
|
||||
double _Di,_Df = modf((double)_X,&_Di);
|
||||
*_Y = (long double)_Di;
|
||||
return (_Df);
|
||||
}
|
||||
__CRT_INLINE long double _chgsignl(long double _Number) { return _chgsign(static_cast<double>(_Number)); }
|
||||
__CRT_INLINE long double _copysignl(long double _Number,long double _Sign) { return _copysign(static_cast<double>(_Number),static_cast<double>(_Sign)); }
|
||||
__CRT_INLINE float frexpf(float _X,int *_Y) { return ((float)frexp((double)_X,_Y)); }
|
||||
#ifndef __ia64__
|
||||
__CRT_INLINE float __cdecl fabsf (float x)
|
||||
{
|
||||
float res;
|
||||
__asm__ ("fabs;" : "=t" (res) : "0" (x));
|
||||
return res;
|
||||
}
|
||||
__CRT_INLINE float __cdecl ldexpf (float x, int expn) { return (float) ldexp (x, expn); }
|
||||
#ifndef __x86_64
|
||||
__CRT_INLINE float acosf(float _X) { return ((float)acos((double)_X)); }
|
||||
__CRT_INLINE float asinf(float _X) { return ((float)asin((double)_X)); }
|
||||
__CRT_INLINE float atanf(float _X) { return ((float)atan((double)_X)); }
|
||||
__CRT_INLINE float atan2f(float _X,float _Y) { return ((float)atan2((double)_X,(double)_Y)); }
|
||||
__CRT_INLINE float ceilf(float _X) { return ((float)ceil((double)_X)); }
|
||||
__CRT_INLINE float cosf(float _X) { return ((float)cos((double)_X)); }
|
||||
__CRT_INLINE float coshf(float _X) { return ((float)cosh((double)_X)); }
|
||||
__CRT_INLINE float expf(float _X) { return ((float)exp((double)_X)); }
|
||||
__CRT_INLINE float floorf(float _X) { return ((float)floor((double)_X)); }
|
||||
__CRT_INLINE float fmodf(float _X,float _Y) { return ((float)fmod((double)_X,(double)_Y)); }
|
||||
__CRT_INLINE float logf(float _X) { return ((float)log((double)_X)); }
|
||||
__CRT_INLINE float log10f(float _X) { return ((float)log10((double)_X)); }
|
||||
__CRT_INLINE float modff(float _X,float *_Y) {
|
||||
double _Di,_Df = modf((double)_X,&_Di);
|
||||
*_Y = (float)_Di;
|
||||
return ((float)_Df);
|
||||
}
|
||||
__CRT_INLINE float powf(float _X,float _Y) { return ((float)pow((double)_X,(double)_Y)); }
|
||||
__CRT_INLINE float sinf(float _X) { return ((float)sin((double)_X)); }
|
||||
__CRT_INLINE float sinhf(float _X) { return ((float)sinh((double)_X)); }
|
||||
__CRT_INLINE float sqrtf(float _X) { return ((float)sqrt((double)_X)); }
|
||||
__CRT_INLINE float tanf(float _X) { return ((float)tan((double)_X)); }
|
||||
__CRT_INLINE float tanhf(float _X) { return ((float)tanh((double)_X)); }
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NO_OLDNAMES
|
||||
#define matherr _matherr
|
||||
|
||||
#define HUGE _HUGE
|
||||
/* double __cdecl cabs(struct _complex _X); */
|
||||
double __cdecl hypot(double _X,double _Y);
|
||||
_CRTIMP double __cdecl j0(double _X);
|
||||
_CRTIMP double __cdecl j1(double _X);
|
||||
_CRTIMP double __cdecl jn(int _X,double _Y);
|
||||
_CRTIMP double __cdecl y0(double _X);
|
||||
_CRTIMP double __cdecl y1(double _X);
|
||||
_CRTIMP double __cdecl yn(int _X,double _Y);
|
||||
#endif
|
||||
|
||||
#ifndef __NO_ISOCEXT
|
||||
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
|
||||
|| !defined __STRICT_ANSI__ || defined __GLIBCPP__
|
||||
|
||||
#define NAN (0.0F/0.0F)
|
||||
#define HUGE_VALF (1.0F/0.0F)
|
||||
#define HUGE_VALL (1.0L/0.0L)
|
||||
#define INFINITY (1.0F/0.0F)
|
||||
|
||||
|
||||
#define FP_NAN 0x0100
|
||||
#define FP_NORMAL 0x0400
|
||||
#define FP_INFINITE (FP_NAN | FP_NORMAL)
|
||||
#define FP_ZERO 0x4000
|
||||
#define FP_SUBNORMAL (FP_NORMAL | FP_ZERO)
|
||||
/* 0x0200 is signbit mask */
|
||||
|
||||
|
||||
/*
|
||||
We can't __CRT_INLINE float or double, because we want to ensure truncation
|
||||
to semantic type before classification.
|
||||
(A normal long double value might become subnormal when
|
||||
converted to double, and zero when converted to float.)
|
||||
*/
|
||||
|
||||
extern int __cdecl __fpclassifyf (float);
|
||||
extern int __cdecl __fpclassify (double);
|
||||
extern int __cdecl __fpclassifyl (long double);
|
||||
|
||||
/* Implemented at tcc/tcc_libm.h */
|
||||
#define fpclassify(x) (sizeof (x) == sizeof (float) ? __fpclassifyf (x) \
|
||||
: sizeof (x) == sizeof (double) ? __fpclassify (x) \
|
||||
: __fpclassifyl (x))
|
||||
|
||||
/* 7.12.3.2 */
|
||||
#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
|
||||
|
||||
/* 7.12.3.3 */
|
||||
#define isinf(x) (fpclassify(x) == FP_INFINITE)
|
||||
|
||||
/* 7.12.3.4 */
|
||||
/* We don't need to worry about trucation here:
|
||||
A NaN stays a NaN. */
|
||||
#define isnan(x) (fpclassify(x) == FP_NAN)
|
||||
|
||||
/* 7.12.3.5 */
|
||||
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
|
||||
|
||||
/* 7.12.3.6 The signbit macro */
|
||||
|
||||
extern int __cdecl __signbitf (float);
|
||||
extern int __cdecl __signbit (double);
|
||||
extern int __cdecl __signbitl (long double);
|
||||
|
||||
/* Implemented at tcc/tcc_libm.h */
|
||||
#define signbit(x) (sizeof (x) == sizeof (float) ? __signbitf (x) \
|
||||
: sizeof (x) == sizeof (double) ? __signbit (x) \
|
||||
: __signbitl (x))
|
||||
|
||||
extern double __cdecl exp2(double);
|
||||
extern float __cdecl exp2f(float);
|
||||
extern long double __cdecl exp2l(long double);
|
||||
|
||||
#define FP_ILOGB0 ((int)0x80000000)
|
||||
#define FP_ILOGBNAN ((int)0x80000000)
|
||||
extern int __cdecl ilogb (double);
|
||||
extern int __cdecl ilogbf (float);
|
||||
extern int __cdecl ilogbl (long double);
|
||||
|
||||
extern double __cdecl log1p(double);
|
||||
extern float __cdecl log1pf(float);
|
||||
extern long double __cdecl log1pl(long double);
|
||||
|
||||
extern double __cdecl log2 (double);
|
||||
extern float __cdecl log2f (float);
|
||||
extern long double __cdecl log2l (long double);
|
||||
|
||||
extern double __cdecl logb (double);
|
||||
extern float __cdecl logbf (float);
|
||||
extern long double __cdecl logbl (long double);
|
||||
|
||||
__CRT_INLINE double __cdecl logb (double x)
|
||||
{
|
||||
double res;
|
||||
__asm__ ("fxtract\n\t"
|
||||
"fstp %%st" : "=t" (res) : "0" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
__CRT_INLINE float __cdecl logbf (float x)
|
||||
{
|
||||
float res;
|
||||
__asm__ ("fxtract\n\t"
|
||||
"fstp %%st" : "=t" (res) : "0" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
__CRT_INLINE long double __cdecl logbl (long double x)
|
||||
{
|
||||
long double res;
|
||||
__asm__ ("fxtract\n\t"
|
||||
"fstp %%st" : "=t" (res) : "0" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
extern long double __cdecl modfl (long double, long double*);
|
||||
|
||||
/* 7.12.6.13 */
|
||||
extern double __cdecl scalbn (double, int);
|
||||
extern float __cdecl scalbnf (float, int);
|
||||
extern long double __cdecl scalbnl (long double, int);
|
||||
|
||||
extern double __cdecl scalbln (double, long);
|
||||
extern float __cdecl scalblnf (float, long);
|
||||
extern long double __cdecl scalblnl (long double, long);
|
||||
|
||||
/* 7.12.7.1 */
|
||||
/* Implementations adapted from Cephes versions */
|
||||
extern double __cdecl cbrt (double);
|
||||
extern float __cdecl cbrtf (float);
|
||||
extern long double __cdecl cbrtl (long double);
|
||||
|
||||
__CRT_INLINE float __cdecl hypotf (float x, float y)
|
||||
{ return (float) hypot (x, y);}
|
||||
extern long double __cdecl hypotl (long double, long double);
|
||||
|
||||
extern long double __cdecl powl (long double, long double);
|
||||
extern long double __cdecl expl(long double);
|
||||
extern long double __cdecl expm1l(long double);
|
||||
extern long double __cdecl coshl(long double);
|
||||
extern long double __cdecl fabsl (long double);
|
||||
extern long double __cdecl acosl(long double);
|
||||
extern long double __cdecl asinl(long double);
|
||||
extern long double __cdecl atanl(long double);
|
||||
extern long double __cdecl atan2l(long double,long double);
|
||||
extern long double __cdecl sinhl(long double);
|
||||
extern long double __cdecl tanhl(long double);
|
||||
|
||||
/* 7.12.8.1 The erf functions */
|
||||
extern double __cdecl erf (double);
|
||||
extern float __cdecl erff (float);
|
||||
/* TODO
|
||||
extern long double __cdecl erfl (long double);
|
||||
*/
|
||||
|
||||
/* 7.12.8.2 The erfc functions */
|
||||
extern double __cdecl erfc (double);
|
||||
extern float __cdecl erfcf (float);
|
||||
/* TODO
|
||||
extern long double __cdecl erfcl (long double);
|
||||
*/
|
||||
|
||||
/* 7.12.8.3 The lgamma functions */
|
||||
extern double __cdecl lgamma (double);
|
||||
extern float __cdecl lgammaf (float);
|
||||
extern long double __cdecl lgammal (long double);
|
||||
|
||||
/* 7.12.8.4 The tgamma functions */
|
||||
extern double __cdecl tgamma (double);
|
||||
extern float __cdecl tgammaf (float);
|
||||
extern long double __cdecl tgammal (long double);
|
||||
|
||||
extern long double __cdecl ceill (long double);
|
||||
extern long double __cdecl floorl (long double);
|
||||
extern long double __cdecl frexpl(long double,int *);
|
||||
extern long double __cdecl log10l(long double);
|
||||
extern long double __cdecl logl(long double);
|
||||
extern long double __cdecl cosl(long double);
|
||||
extern long double __cdecl sinl(long double);
|
||||
extern long double __cdecl tanl(long double);
|
||||
extern long double sqrtl(long double);
|
||||
|
||||
/* 7.12.9.3 */
|
||||
extern double __cdecl nearbyint ( double);
|
||||
extern float __cdecl nearbyintf (float);
|
||||
extern long double __cdecl nearbyintl (long double);
|
||||
|
||||
/* 7.12.9.4 */
|
||||
/* round, using fpu control word settings */
|
||||
__CRT_INLINE double __cdecl rint (double x)
|
||||
{
|
||||
double retval;
|
||||
__asm__ (
|
||||
"fldl %1\n"
|
||||
"frndint \n"
|
||||
"fstl %0\n" : "=m" (retval) : "m" (x));
|
||||
return retval;
|
||||
}
|
||||
|
||||
__CRT_INLINE float __cdecl rintf (float x)
|
||||
{
|
||||
float retval;
|
||||
__asm__ (
|
||||
"flds %1\n"
|
||||
"frndint \n"
|
||||
"fsts %0\n" : "=m" (retval) : "m" (x));
|
||||
return retval;
|
||||
}
|
||||
|
||||
__CRT_INLINE long double __cdecl rintl (long double x)
|
||||
{
|
||||
long double retval;
|
||||
__asm__ (
|
||||
"fldt %1\n"
|
||||
"frndint \n"
|
||||
"fstt %0\n" : "=m" (retval) : "m" (x));
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* 7.12.9.5 */
|
||||
__CRT_INLINE long __cdecl lrint (double x)
|
||||
{
|
||||
long retval;
|
||||
__asm__ __volatile__ \
|
||||
("fldl %1\n" \
|
||||
"fistpl %0" : "=m" (retval) : "m" (x)); \
|
||||
return retval;
|
||||
}
|
||||
|
||||
__CRT_INLINE long __cdecl lrintf (float x)
|
||||
{
|
||||
long retval;
|
||||
__asm__ __volatile__ \
|
||||
("flds %1\n" \
|
||||
"fistpl %0" : "=m" (retval) : "m" (x)); \
|
||||
return retval;
|
||||
}
|
||||
|
||||
__CRT_INLINE long __cdecl lrintl (long double x)
|
||||
{
|
||||
long retval;
|
||||
__asm__ __volatile__ \
|
||||
("fldt %1\n" \
|
||||
"fistpl %0" : "=m" (retval) : "m" (x)); \
|
||||
return retval;
|
||||
}
|
||||
|
||||
__CRT_INLINE long long __cdecl llrint (double x)
|
||||
{
|
||||
long long retval;
|
||||
__asm__ __volatile__ \
|
||||
("fldl %1\n" \
|
||||
"fistpll %0" : "=m" (retval) : "m" (x)); \
|
||||
return retval;
|
||||
}
|
||||
|
||||
__CRT_INLINE long long __cdecl llrintf (float x)
|
||||
{
|
||||
long long retval;
|
||||
__asm__ __volatile__ \
|
||||
("flds %1\n" \
|
||||
"fistpll %0" : "=m" (retval) : "m" (x)); \
|
||||
return retval;
|
||||
}
|
||||
|
||||
__CRT_INLINE long long __cdecl llrintl (long double x)
|
||||
{
|
||||
long long retval;
|
||||
__asm__ __volatile__ \
|
||||
("fldt %1\n" \
|
||||
"fistpll %0" : "=m" (retval) : "m" (x)); \
|
||||
return retval;
|
||||
}
|
||||
|
||||
#define FE_TONEAREST 0x0000
|
||||
#define FE_DOWNWARD 0x0400
|
||||
#define FE_UPWARD 0x0800
|
||||
#define FE_TOWARDZERO 0x0c00
|
||||
|
||||
__CRT_INLINE double trunc (double _x)
|
||||
{
|
||||
double retval;
|
||||
unsigned short saved_cw;
|
||||
unsigned short tmp_cw;
|
||||
__asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */
|
||||
tmp_cw = (saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO))
|
||||
| FE_TOWARDZERO;
|
||||
__asm__ ("fldcw %0;" : : "m" (tmp_cw));
|
||||
__asm__ ("fldl %1;"
|
||||
"frndint;"
|
||||
"fstl %0;" : "=m" (retval) : "m" (_x)); /* round towards zero */
|
||||
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* 7.12.9.6 */
|
||||
/* round away from zero, regardless of fpu control word settings */
|
||||
extern double __cdecl round (double);
|
||||
extern float __cdecl roundf (float);
|
||||
extern long double __cdecl roundl (long double);
|
||||
|
||||
/* 7.12.9.7 */
|
||||
extern long __cdecl lround (double);
|
||||
extern long __cdecl lroundf (float);
|
||||
extern long __cdecl lroundl (long double);
|
||||
|
||||
extern long long __cdecl llround (double);
|
||||
extern long long __cdecl llroundf (float);
|
||||
extern long long __cdecl llroundl (long double);
|
||||
|
||||
/* 7.12.9.8 */
|
||||
/* round towards zero, regardless of fpu control word settings */
|
||||
extern double __cdecl trunc (double);
|
||||
extern float __cdecl truncf (float);
|
||||
extern long double __cdecl truncl (long double);
|
||||
|
||||
extern long double __cdecl fmodl (long double, long double);
|
||||
|
||||
/* 7.12.10.2 */
|
||||
extern double __cdecl remainder (double, double);
|
||||
extern float __cdecl remainderf (float, float);
|
||||
extern long double __cdecl remainderl (long double, long double);
|
||||
|
||||
/* 7.12.10.3 */
|
||||
extern double __cdecl remquo(double, double, int *);
|
||||
extern float __cdecl remquof(float, float, int *);
|
||||
extern long double __cdecl remquol(long double, long double, int *);
|
||||
|
||||
/* 7.12.11.1 */
|
||||
extern double __cdecl copysign (double, double); /* in libmoldname.a */
|
||||
extern float __cdecl copysignf (float, float);
|
||||
extern long double __cdecl copysignl (long double, long double);
|
||||
|
||||
/* 7.12.11.2 Return a NaN */
|
||||
extern double __cdecl nan(const char *tagp);
|
||||
extern float __cdecl nanf(const char *tagp);
|
||||
extern long double __cdecl nanl(const char *tagp);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#define _nan() nan("")
|
||||
#define _nanf() nanf("")
|
||||
#define _nanl() nanl("")
|
||||
#endif
|
||||
|
||||
/* 7.12.11.3 */
|
||||
extern double __cdecl nextafter (double, double); /* in libmoldname.a */
|
||||
extern float __cdecl nextafterf (float, float);
|
||||
extern long double __cdecl nextafterl (long double, long double);
|
||||
|
||||
/* 7.12.11.4 The nexttoward functions: TODO */
|
||||
|
||||
/* 7.12.12.1 */
|
||||
/* x > y ? (x - y) : 0.0 */
|
||||
extern double __cdecl fdim (double x, double y);
|
||||
extern float __cdecl fdimf (float x, float y);
|
||||
extern long double __cdecl fdiml (long double x, long double y);
|
||||
|
||||
/* fmax and fmin.
|
||||
NaN arguments are treated as missing data: if one argument is a NaN
|
||||
and the other numeric, then these functions choose the numeric
|
||||
value. */
|
||||
|
||||
/* 7.12.12.2 */
|
||||
extern double __cdecl fmax (double, double);
|
||||
extern float __cdecl fmaxf (float, float);
|
||||
extern long double __cdecl fmaxl (long double, long double);
|
||||
|
||||
/* 7.12.12.3 */
|
||||
extern double __cdecl fmin (double, double);
|
||||
extern float __cdecl fminf (float, float);
|
||||
extern long double __cdecl fminl (long double, long double);
|
||||
|
||||
/* 7.12.13.1 */
|
||||
/* return x * y + z as a ternary op */
|
||||
extern double __cdecl fma (double, double, double);
|
||||
extern float __cdecl fmaf (float, float, float);
|
||||
extern long double __cdecl fmal (long double, long double, long double);
|
||||
|
||||
|
||||
#if 0 // gr: duplicate, see below
|
||||
/* 7.12.14 */
|
||||
/*
|
||||
* With these functions, comparisons involving quiet NaNs set the FP
|
||||
* condition code to "unordered". The IEEE floating-point spec
|
||||
* dictates that the result of floating-point comparisons should be
|
||||
* false whenever a NaN is involved, with the exception of the != op,
|
||||
* which always returns true: yes, (NaN != NaN) is true).
|
||||
*/
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
|
||||
#define isgreater(x, y) __builtin_isgreater(x, y)
|
||||
#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
|
||||
#define isless(x, y) __builtin_isless(x, y)
|
||||
#define islessequal(x, y) __builtin_islessequal(x, y)
|
||||
#define islessgreater(x, y) __builtin_islessgreater(x, y)
|
||||
#define isunordered(x, y) __builtin_isunordered(x, y)
|
||||
|
||||
#else
|
||||
/* helper */
|
||||
__CRT_INLINE int __cdecl
|
||||
__fp_unordered_compare (long double x, long double y){
|
||||
unsigned short retval;
|
||||
__asm__ ("fucom %%st(1);"
|
||||
"fnstsw;": "=a" (retval) : "t" (x), "u" (y));
|
||||
return retval;
|
||||
}
|
||||
|
||||
#define isgreater(x, y) ((__fp_unordered_compare(x, y) \
|
||||
& 0x4500) == 0)
|
||||
#define isless(x, y) ((__fp_unordered_compare (y, x) \
|
||||
& 0x4500) == 0)
|
||||
#define isgreaterequal(x, y) ((__fp_unordered_compare (x, y) \
|
||||
& FP_INFINITE) == 0)
|
||||
#define islessequal(x, y) ((__fp_unordered_compare(y, x) \
|
||||
& FP_INFINITE) == 0)
|
||||
#define islessgreater(x, y) ((__fp_unordered_compare(x, y) \
|
||||
& FP_SUBNORMAL) == 0)
|
||||
#define isunordered(x, y) ((__fp_unordered_compare(x, y) \
|
||||
& 0x4500) == 0x4500)
|
||||
|
||||
#endif
|
||||
#endif //0
|
||||
|
||||
|
||||
#endif /* __STDC_VERSION__ >= 199901L */
|
||||
#endif /* __NO_ISOCEXT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
extern "C++" {
|
||||
template<class _Ty> inline _Ty _Pow_int(_Ty _X,int _Y) {
|
||||
unsigned int _N;
|
||||
if(_Y >= 0) _N = (unsigned int)_Y;
|
||||
else _N = (unsigned int)(-_Y);
|
||||
for(_Ty _Z = _Ty(1);;_X *= _X) {
|
||||
if((_N & 1)!=0) _Z *= _X;
|
||||
if((_N >>= 1)==0) return (_Y < 0 ? _Ty(1) / _Z : _Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
/* 7.12.14 */
|
||||
/*
|
||||
* With these functions, comparisons involving quiet NaNs set the FP
|
||||
* condition code to "unordered". The IEEE floating-point spec
|
||||
* dictates that the result of floating-point comparisons should be
|
||||
* false whenever a NaN is involved, with the exception of the != op,
|
||||
* which always returns true: yes, (NaN != NaN) is true).
|
||||
*/
|
||||
|
||||
/* Mini libm (inline __fpclassify*, __signbit* and variants) */
|
||||
|
||||
/* TCC uses 8 bytes for double and long double, so effectively the l variants
|
||||
* are never used. For now, they just run the normal (double) variant.
|
||||
*/
|
||||
|
||||
/*
|
||||
* most of the code in this file is taken from MUSL rs-1.0 (MIT license)
|
||||
* - musl-libc: http://git.musl-libc.org/cgit/musl/tree/src/math?h=rs-1.0
|
||||
* - License: http://git.musl-libc.org/cgit/musl/tree/COPYRIGHT?h=rs-1.0
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
Start of code based on MUSL
|
||||
*******************************************************************************/
|
||||
/*
|
||||
musl as a whole is licensed under the following standard MIT license:
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Copyright © 2005-2014 Rich Felker, et al.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* fpclassify */
|
||||
|
||||
__CRT_INLINE int __cdecl __fpclassify (double x) {
|
||||
union {double f; uint64_t i;} u = {x};
|
||||
int e = u.i>>52 & 0x7ff;
|
||||
if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
|
||||
if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE;
|
||||
return FP_NORMAL;
|
||||
}
|
||||
|
||||
__CRT_INLINE int __cdecl __fpclassifyf (float x) {
|
||||
union {float f; uint32_t i;} u = {x};
|
||||
int e = u.i>>23 & 0xff;
|
||||
if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
|
||||
if (e==0xff) return u.i<<9 ? FP_NAN : FP_INFINITE;
|
||||
return FP_NORMAL;
|
||||
}
|
||||
|
||||
__CRT_INLINE int __cdecl __fpclassifyl (long double x) {
|
||||
return __fpclassify(x);
|
||||
}
|
||||
|
||||
|
||||
/* signbit */
|
||||
|
||||
__CRT_INLINE int __cdecl __signbit (double x) {
|
||||
union {double d; uint64_t i;} y = { x };
|
||||
return y.i>>63;
|
||||
}
|
||||
|
||||
__CRT_INLINE int __cdecl __signbitf (float x) {
|
||||
union {float f; uint32_t i; } y = { x };
|
||||
return y.i>>31;
|
||||
}
|
||||
|
||||
__CRT_INLINE int __cdecl __signbitl (long double x) {
|
||||
return __signbit(x);
|
||||
}
|
||||
|
||||
|
||||
/* fmin*, fmax* */
|
||||
|
||||
#define TCCFP_FMIN_EVAL (isnan(x) ? y : \
|
||||
isnan(y) ? x : \
|
||||
(signbit(x) != signbit(y)) ? (signbit(x) ? x : y) : \
|
||||
x < y ? x : y)
|
||||
|
||||
__CRT_INLINE double __cdecl fmin (double x, double y) {
|
||||
return TCCFP_FMIN_EVAL;
|
||||
}
|
||||
|
||||
__CRT_INLINE float __cdecl fminf (float x, float y) {
|
||||
return TCCFP_FMIN_EVAL;
|
||||
}
|
||||
|
||||
__CRT_INLINE long double __cdecl fminl (long double x, long double y) {
|
||||
return TCCFP_FMIN_EVAL;
|
||||
}
|
||||
|
||||
#define TCCFP_FMAX_EVAL (isnan(x) ? y : \
|
||||
isnan(y) ? x : \
|
||||
(signbit(x) != signbit(y)) ? (signbit(x) ? y : x) : \
|
||||
x < y ? y : x)
|
||||
|
||||
__CRT_INLINE double __cdecl fmax (double x, double y) {
|
||||
return TCCFP_FMAX_EVAL;
|
||||
}
|
||||
|
||||
__CRT_INLINE float __cdecl fmaxf (float x, float y) {
|
||||
return TCCFP_FMAX_EVAL;
|
||||
}
|
||||
|
||||
__CRT_INLINE long double __cdecl fmaxl (long double x, long double y) {
|
||||
return TCCFP_FMAX_EVAL;
|
||||
}
|
||||
|
||||
|
||||
/* *round* */
|
||||
|
||||
#define TCCFP_FORCE_EVAL(x) do { \
|
||||
if (sizeof(x) == sizeof(float)) { \
|
||||
volatile float __x; \
|
||||
__x = (x); \
|
||||
} else if (sizeof(x) == sizeof(double)) { \
|
||||
volatile double __x; \
|
||||
__x = (x); \
|
||||
} else { \
|
||||
volatile long double __x; \
|
||||
__x = (x); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
__CRT_INLINE double __cdecl round (double x) {
|
||||
union {double f; uint64_t i;} u = {x};
|
||||
int e = u.i >> 52 & 0x7ff;
|
||||
double y;
|
||||
|
||||
if (e >= 0x3ff+52)
|
||||
return x;
|
||||
if (u.i >> 63)
|
||||
x = -x;
|
||||
if (e < 0x3ff-1) {
|
||||
/* raise inexact if x!=0 */
|
||||
TCCFP_FORCE_EVAL(x + 0x1p52);
|
||||
return 0*u.f;
|
||||
}
|
||||
y = (double)(x + 0x1p52) - 0x1p52 - x;
|
||||
if (y > 0.5)
|
||||
y = y + x - 1;
|
||||
else if (y <= -0.5)
|
||||
y = y + x + 1;
|
||||
else
|
||||
y = y + x;
|
||||
if (u.i >> 63)
|
||||
y = -y;
|
||||
return y;
|
||||
}
|
||||
|
||||
__CRT_INLINE long __cdecl lround (double x) {
|
||||
return round(x);
|
||||
}
|
||||
|
||||
__CRT_INLINE long long __cdecl llround (double x) {
|
||||
return round(x);
|
||||
}
|
||||
|
||||
__CRT_INLINE float __cdecl roundf (float x) {
|
||||
return round(x);
|
||||
}
|
||||
|
||||
__CRT_INLINE long __cdecl lroundf (float x) {
|
||||
return round(x);
|
||||
}
|
||||
|
||||
__CRT_INLINE long long __cdecl llroundf (float x) {
|
||||
return round(x);
|
||||
}
|
||||
|
||||
__CRT_INLINE long double __cdecl roundl (long double x) {
|
||||
return round(x);
|
||||
}
|
||||
|
||||
__CRT_INLINE long __cdecl lroundl (long double x) {
|
||||
return round(x);
|
||||
}
|
||||
|
||||
__CRT_INLINE long long __cdecl llroundl (long double x) {
|
||||
return round(x);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* End _MATH_H_ */
|
||||
|
1950
colorchord2/windows/mmsystem.h
Normal file
1950
colorchord2/windows/mmsystem.h
Normal file
File diff suppressed because it is too large
Load diff
245
colorchord2/windows/symbol_enumerator.c
Normal file
245
colorchord2/windows/symbol_enumerator.c
Normal file
|
@ -0,0 +1,245 @@
|
|||
#include <stdio.h>
|
||||
#include "symbol_enumerator.h"
|
||||
|
||||
#if defined( WIN32 ) || defined( WINDOWS ) || defined( USE_WINDOWS ) || defined( _WIN32 )
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct _SYMBOL_INFO {
|
||||
ULONG SizeOfStruct;
|
||||
ULONG TypeIndex;
|
||||
ULONG64 Reserved[2];
|
||||
ULONG Index;
|
||||
ULONG Size;
|
||||
ULONG64 ModBase;
|
||||
ULONG Flags;
|
||||
ULONG64 Value;
|
||||
ULONG64 Address;
|
||||
ULONG Register;
|
||||
ULONG Scope;
|
||||
ULONG Tag;
|
||||
ULONG NameLen;
|
||||
ULONG MaxNameLen;
|
||||
TCHAR Name[1];
|
||||
} SYMBOL_INFO, *PSYMBOL_INFO;
|
||||
typedef struct _IMAGEHLP_STACK_FRAME {
|
||||
ULONG64 InstructionOffset;
|
||||
ULONG64 ReturnOffset;
|
||||
ULONG64 FrameOffset;
|
||||
ULONG64 StackOffset;
|
||||
ULONG64 BackingStoreOffset;
|
||||
ULONG64 FuncTableEntry;
|
||||
ULONG64 Params[4];
|
||||
ULONG64 Reserved[5];
|
||||
BOOL Virtual;
|
||||
ULONG Reserved2;
|
||||
} IMAGEHLP_STACK_FRAME, *PIMAGEHLP_STACK_FRAME;
|
||||
|
||||
|
||||
typedef BOOL (*PSYM_ENUMERATESYMBOLS_CALLBACK)(
|
||||
PSYMBOL_INFO pSymInfo,
|
||||
ULONG SymbolSize,
|
||||
PVOID UserContext
|
||||
);
|
||||
|
||||
BOOL WINAPI SymEnumSymbols(
|
||||
HANDLE hProcess,
|
||||
ULONG64 BaseOfDll,
|
||||
PCTSTR Mask,
|
||||
PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
|
||||
const PVOID UserContext
|
||||
);
|
||||
|
||||
BOOL WINAPI SymInitialize(
|
||||
HANDLE hProcess,
|
||||
PCTSTR UserSearchPath,
|
||||
BOOL fInvadeProcess
|
||||
);
|
||||
|
||||
BOOL WINAPI SymCleanup(
|
||||
HANDLE hProcess
|
||||
);
|
||||
|
||||
BOOL CALLBACK __cdecl mycb(
|
||||
PSYMBOL_INFO pSymInfo,
|
||||
ULONG SymbolSize,
|
||||
PVOID UserContext
|
||||
){
|
||||
SymEnumeratorCallback cb = (SymEnumeratorCallback)UserContext;
|
||||
return !cb( "", &pSymInfo->Name[0], (void*)pSymInfo->Address, (long) pSymInfo->Size );
|
||||
}
|
||||
|
||||
int EnumerateSymbols( SymEnumeratorCallback cb )
|
||||
{
|
||||
HANDLE proc = GetCurrentProcess();
|
||||
if( !SymInitialize( proc, 0, 1 ) ) return -1;
|
||||
if( !SymEnumSymbols( proc, 0, "*!*", &mycb, (void*)cb ) )
|
||||
{
|
||||
SymCleanup(proc);
|
||||
return -2;
|
||||
}
|
||||
SymCleanup(proc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __int128_t long long long
|
||||
#endif
|
||||
|
||||
#include <link.h>
|
||||
#include <elf.h>
|
||||
|
||||
#define UINTS_PER_WORD (__WORDSIZE / (CHAR_BIT * sizeof (unsigned int)))
|
||||
|
||||
|
||||
struct dl_phdr_info {
|
||||
ElfW(Addr) dlpi_addr; /* Base address of object */
|
||||
const char *dlpi_name; /* (Null-terminated) name of
|
||||
object */
|
||||
const ElfW(Phdr) *dlpi_phdr; /* Pointer to array of
|
||||
ELF program headers
|
||||
for this object */
|
||||
ElfW(Half) dlpi_phnum; /* # of items in dlpi_phdr */
|
||||
};
|
||||
|
||||
|
||||
|
||||
void dl_iterate_phdr( void*, void*);
|
||||
|
||||
|
||||
static ElfW(Word) gnu_hashtab_symbol_count(const unsigned int *const table)
|
||||
{
|
||||
const unsigned int *const bucket = table + 4 + table[2] * (unsigned int)(UINTS_PER_WORD);
|
||||
unsigned int b = table[0];
|
||||
unsigned int max = 0U;
|
||||
|
||||
while (b-->0U)
|
||||
if (bucket[b] > max)
|
||||
max = bucket[b];
|
||||
|
||||
return (ElfW(Word))max;
|
||||
}
|
||||
|
||||
static static void *dynamic_pointer(const ElfW(Addr) addr,
|
||||
const ElfW(Addr) base, const ElfW(Phdr) *const header, const ElfW(Half) headers)
|
||||
{
|
||||
if (addr) {
|
||||
ElfW(Half) h;
|
||||
|
||||
for (h = 0; h < headers; h++)
|
||||
if (header[h].p_type == PT_LOAD)
|
||||
if (addr >= base + header[h].p_vaddr &&
|
||||
addr < base + header[h].p_vaddr + header[h].p_memsz)
|
||||
return (void *)addr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Mostly based off of http://stackoverflow.com/questions/29903049/get-names-and-addresses-of-exported-functions-from-in-linux
|
||||
static int callback(struct dl_phdr_info *info,
|
||||
size_t size, void *data)
|
||||
{
|
||||
SymEnumeratorCallback cb = (SymEnumeratorCallback)data;
|
||||
const ElfW(Addr) base = info->dlpi_addr;
|
||||
const ElfW(Phdr) *const header = info->dlpi_phdr;
|
||||
const ElfW(Half) headers = info->dlpi_phnum;
|
||||
const char *libpath, *libname;
|
||||
ElfW(Half) h;
|
||||
|
||||
if (info->dlpi_name && info->dlpi_name[0])
|
||||
libpath = info->dlpi_name;
|
||||
else
|
||||
libpath = "";
|
||||
|
||||
libname = strrchr(libpath, '/');
|
||||
|
||||
if (libname && libname[0] == '/' && libname[1])
|
||||
libname++;
|
||||
else
|
||||
libname = libpath;
|
||||
|
||||
for (h = 0; h < headers; h++)
|
||||
{
|
||||
if (header[h].p_type == PT_DYNAMIC)
|
||||
{
|
||||
const ElfW(Dyn) *entry = (const ElfW(Dyn) *)(base + header[h].p_vaddr);
|
||||
const ElfW(Word) *hashtab;
|
||||
const ElfW(Sym) *symtab = NULL;
|
||||
const char *strtab = NULL;
|
||||
ElfW(Word) symbol_count = 0;
|
||||
|
||||
for (; entry->d_tag != DT_NULL; entry++)
|
||||
{
|
||||
switch (entry->d_tag)
|
||||
{
|
||||
case DT_HASH:
|
||||
hashtab = dynamic_pointer(entry->d_un.d_ptr, base, header, headers);
|
||||
if (hashtab)
|
||||
symbol_count = hashtab[1];
|
||||
break;
|
||||
case DT_GNU_HASH:
|
||||
hashtab = dynamic_pointer(entry->d_un.d_ptr, base, header, headers);
|
||||
if (hashtab)
|
||||
{
|
||||
ElfW(Word) count = gnu_hashtab_symbol_count(hashtab);
|
||||
if (count > symbol_count)
|
||||
symbol_count = count;
|
||||
}
|
||||
break;
|
||||
case DT_STRTAB:
|
||||
strtab = dynamic_pointer(entry->d_un.d_ptr, base, header, headers);
|
||||
break;
|
||||
case DT_SYMTAB:
|
||||
symtab = dynamic_pointer(entry->d_un.d_ptr, base, header, headers);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (symtab && strtab && symbol_count > 0) {
|
||||
ElfW(Word) s;
|
||||
|
||||
for (s = 0; s < symbol_count; s++) {
|
||||
const char *name;
|
||||
void *const ptr = dynamic_pointer(base + symtab[s].st_value, base, header, headers);
|
||||
int result;
|
||||
|
||||
if (!ptr)
|
||||
continue;
|
||||
|
||||
if (symtab[s].st_name)
|
||||
name = strtab + symtab[s].st_name;
|
||||
else
|
||||
name = "";
|
||||
|
||||
result = cb( libpath, name, ptr, symtab[s].st_size );
|
||||
if( result ) return result; //Bail early.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int EnumerateSymbols( SymEnumeratorCallback cb )
|
||||
{
|
||||
dl_iterate_phdr( callback, cb );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
12
colorchord2/windows/symbol_enumerator.h
Normal file
12
colorchord2/windows/symbol_enumerator.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef _SYMBOL_ENUMERATOR_H
|
||||
#define _SYMBOL_ENUMERATOR_H
|
||||
|
||||
//Enumerates all symbols in the currently loaded excutable.
|
||||
//Don't forget to compile with -rdynamic!
|
||||
|
||||
//Return 0 to continue search. 1 to stop.
|
||||
typedef int (*SymEnumeratorCallback)( const char * path, const char * name, void * location, long size );
|
||||
|
||||
int EnumerateSymbols( SymEnumeratorCallback cb );
|
||||
|
||||
#endif
|
80
colorchord2/windows/tcc_stubs.c
Normal file
80
colorchord2/windows/tcc_stubs.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
|
||||
#include <_mingw.h>
|
||||
|
||||
#define REMATH(x) double __cdecl x( double f ); float x##f(float v) { return x(v); }
|
||||
|
||||
int SymnumCheck( const char * path, const char * name, void * location, long size )
|
||||
{
|
||||
if( strncmp( name, "REGISTER", 8 ) == 0 )
|
||||
{
|
||||
typedef void (*sf)();
|
||||
sf fn = (sf)location;
|
||||
fn();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ManuallyRegisterDevices()
|
||||
{
|
||||
EnumerateSymbols( SymnumCheck );
|
||||
}
|
||||
|
||||
REMATH( acos );
|
||||
REMATH( cos );
|
||||
REMATH( sin );
|
||||
REMATH( sqrt );
|
||||
REMATH( asin );
|
||||
REMATH( exp );
|
||||
REMATH( fmod );
|
||||
REMATH( pow );
|
||||
|
||||
double __cdecl strtod (const char* str, char** endptr);
|
||||
float strtof( const char* str, char** endptr)
|
||||
{
|
||||
return strtod( str, endptr );
|
||||
}
|
||||
|
||||
double __cdecl atan2(double a, double b);
|
||||
float atan2f(float a, float b)
|
||||
{
|
||||
return atan2( a, b );
|
||||
}
|
||||
|
||||
//From http://stackoverflow.com/questions/40159892/using-asprintf-on-windows
|
||||
int __cdecl vsprintf_s(
|
||||
char *buffer,
|
||||
size_t numberOfElements,
|
||||
const char *format,
|
||||
va_list argptr
|
||||
);
|
||||
|
||||
int asprintf(char **strp, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int r = vasprintf(strp, fmt, ap);
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
int vasprintf(char **strp, const char *fmt, va_list ap) {
|
||||
// _vscprintf tells you how big the buffer needs to be
|
||||
int len = _vscprintf(fmt, ap);
|
||||
if (len == -1) {
|
||||
return -1;
|
||||
}
|
||||
size_t size = (size_t)len + 1;
|
||||
char *str = (char*)malloc(size);
|
||||
if (!str) {
|
||||
return -1;
|
||||
}
|
||||
// _vsprintf_s is the "secure" version of vsprintf
|
||||
int r = vsprintf_s(str, len + 1, fmt, ap);
|
||||
if (r == -1) {
|
||||
free(str);
|
||||
return -1;
|
||||
}
|
||||
*strp = str;
|
||||
return r;
|
||||
}
|
1303
colorchord2/windows/winsock2.h
Normal file
1303
colorchord2/windows/winsock2.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue